diff options
Diffstat (limited to 'configure.ac')
| -rw-r--r-- | configure.ac | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index b29feb9..61b5df0 100644 --- a/configure.ac +++ b/configure.ac @@ -136,6 +136,15 @@ AC_ARG_ENABLE([vaapi-x11], AS_HELP_STRING([--disable-vaapi-x11], [Disable vaPutSurface() rendering])) +#checking if QR code support is wanted: showing one's own Pica Pica ID as a QR +#code, and adding a contact by pointing the camera at theirs. Autodetected +#like VAAPI; see the check further down. +AC_ARG_ENABLE([qrcode], + AS_HELP_STRING([--enable-qrcode], + [Enable showing and scanning Pica Pica IDs as QR codes, using ZXing-C++ (default: autodetect)]) + AS_HELP_STRING([--disable-qrcode], + [Disable QR code support])) + #at least one program must be enabled AS_IF([test "x$PICA_NODE_ENABLED" != "xyes" && test "x$PICA_CLIENT_ENABLED" != "xyes" ], AC_MSG_ERROR(["Either pica-node or pica-client must be enabled"]) @@ -390,11 +399,110 @@ AS_IF([test "x$TARGET_OS" = "xwindows" && test "x$enable_d3d12va" != "xno"], [ AS_IF([test "x$TARGET_OS" != "xwindows" && test "x$enable_d3d12va" = "xyes"], [AC_MSG_ERROR(["Direct3D 12 acceleration was requested but it only exists on Windows"])]) + +#check for ZXing-C++, which both draws the QR code the "Show My Pica Pica ID" +#dialog shows and reads the one the camera sees in the "Scan QR Code" dialog. +# +#2.2 is the floor because that is where ReaderOptions, which the scanner is +#written against, first appeared - and what Ubuntu 24.04 ships. Distributions +#with anything older cannot build pica-client anyway, for want of +#webrtc-audio-processing 1.x. +# +#The version alone does not say how a code is drawn, though. ZXing-C++ has two +#writer APIs, and which of them a given libZXing carries is a build option of +#its own: 2.x builds the old MultiFormatWriter by default, 3.x the new +#CreateBarcodeFromText() instead, and either can be built with both or with +#no writer at all. So the two are tried by linking against them, the new one +#first, and a ZXing with neither counts as not found - scanning alone would +#leave nothing to scan from. +AS_IF([test "x$enable_qrcode" != "xno"], [ + PKG_CHECK_MODULES([ZXING], [zxing >= 2.2], + [pica_zxing_found=yes], + [pica_zxing_found=no]) + + PICA_ZXING_WRITER= + AS_IF([test "x$pica_zxing_found" = "xyes"], [ + AC_LANG_PUSH([C++]) + pica_save_CPPFLAGS="$CPPFLAGS" + pica_save_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS $ZXING_CFLAGS" + LIBS="$ZXING_LIBS $LIBS" + + AC_MSG_CHECKING([whether ZXing-C++ can read QR codes]) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <ZXing/ReadBarcode.h>]], + [[unsigned char pixel = 0; + ZXing::ImageView image(&pixel, 1, 1, ZXing::ImageFormat::Lum); + ZXing::ReaderOptions options; + options.setFormats(ZXing::BarcodeFormat::QRCode); + return ZXing::ReadBarcode(image, options).text().size() > 0;]])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + pica_zxing_found=no + ]) + + AS_IF([test "x$pica_zxing_found" = "xyes"], [ + AC_MSG_CHECKING([for the ZXing-C++ CreateBarcodeFromText() writer]) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <ZXing/CreateBarcode.h>]], + [[ZXing::Barcode barcode = ZXing::CreateBarcodeFromText("pica", + ZXing::CreatorOptions(ZXing::BarcodeFormat::QRCode)); + return barcode.symbol().width();]])], + [ + AC_MSG_RESULT([yes]) + PICA_ZXING_WRITER=create_barcode + ], + [AC_MSG_RESULT([no])]) + ]) + + AS_IF([test "x$pica_zxing_found" = "xyes" && test "x$PICA_ZXING_WRITER" = "x"], [ + AC_MSG_CHECKING([for the ZXing-C++ MultiFormatWriter writer]) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <ZXing/MultiFormatWriter.h> + #include <ZXing/BitMatrix.h>]], + [[ZXing::BitMatrix matrix = + ZXing::MultiFormatWriter(ZXing::BarcodeFormat::QRCode).encode(std::string("pica"), 0, 0); + return matrix.width();]])], + [ + AC_MSG_RESULT([yes]) + PICA_ZXING_WRITER=multi_format_writer + ], + [AC_MSG_RESULT([no])]) + ]) + + AS_IF([test "x$pica_zxing_found" = "xyes" && test "x$PICA_ZXING_WRITER" = "x"], + [pica_zxing_found=no]) + + CPPFLAGS="$pica_save_CPPFLAGS" + LIBS="$pica_save_LIBS" + AC_LANG_POP([C++]) + ]) + + AS_IF([test "x$pica_zxing_found" = "xyes"], + [ + PICA_QRCODE_ENABLED=yes + AC_DEFINE([HAVE_QRCODE], [1], [Define to 1 if Pica Pica IDs can be shown and scanned as QR codes]) + AS_IF([test "x$PICA_ZXING_WRITER" = "xcreate_barcode"], + [AC_DEFINE([HAVE_ZXING_CREATE_BARCODE], [1], [Define to 1 if ZXing-C++ draws barcodes with CreateBarcodeFromText()])]) + AC_SUBST([ZXING_CFLAGS]) + AC_SUBST([ZXING_LIBS]) + ], + [ + AS_IF([test "x$enable_qrcode" = "xyes"], + [AC_MSG_ERROR(["QR code support was requested but ZXing-C++ 2.2 or newer, built with both a reader and a writer, was not found"])], + [AC_MSG_WARN(["ZXing-C++ 2.2 or newer, built with both a reader and a writer, not found - building without QR code support"])]) + ]) +]) ]) AM_CONDITIONAL([PICA_PULSE], [test "x$PICA_PULSE_ENABLED" = "xyes"]) AM_CONDITIONAL([PICA_VAAPI], [test "x$PICA_VAAPI_ENABLED" = "xyes"]) AM_CONDITIONAL([PICA_VAAPI_X11], [test "x$PICA_VAAPI_X11_ENABLED" = "xyes"]) +AM_CONDITIONAL([PICA_QRCODE], [test "x$PICA_QRCODE_ENABLED" = "xyes"]) AC_SUBST([PLATFORM_DEPS_CFLAGS]) AC_SUBST([PLATFORM_DEPS_LIBS]) |
