From cf50ed67cd5b211acf91c961c9f9befa827fd85d Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 13 Oct 2021 00:34:40 +0200 Subject: [PATCH] Use AS_VAR_IF and AS_IF as often as possible --- configure.ac | 31 +++++----- libgphoto2_port/configure.ac | 70 ++++++++++++----------- libgphoto2_port/gphoto-m4/gp-byteorder.m4 | 4 +- 3 files changed, 56 insertions(+), 49 deletions(-) diff --git a/configure.ac b/configure.ac index 3777c172d7..d97e53864c 100644 --- a/configure.ac +++ b/configure.ac @@ -203,10 +203,10 @@ dnl GP_CONDITIONAL_COMPILE_FLAGS([CFLAGS], [-Wno-stringop-truncation]) dnl --------------------------------------------------------------------------- dnl Turn on (almost) all warnings when using gcc dnl --------------------------------------------------------------------------- -if test "x$GCC" = "xyes"; then +AS_VAR_IF([GCC], [yes], [dnl AC_SUBST([NO_UNUSED_CFLAGS], [-Wno-unused]) -fi -AM_CONDITIONAL([HAVE_GCC], [test "x$GCC" = "xyes"]) +]) +AM_CONDITIONAL([HAVE_GCC], [test "x$GCC" = xyes]) # Activate internal code AM_CPPFLAGS="$AM_CPPFLAGS -D_GPHOTO2_INTERNAL_CODE" @@ -343,7 +343,7 @@ AC_SUBST([LIBWS232]) AC_ARG_WITH([ws232], [AS_HELP_STRING([--without-ws232], [Build without ws2_32 library (default: no)])]) -AS_IF([test "x$with_ws232" != "xno"], [dnl +AS_VAR_IF([with_ws232], [no], [], [dnl AC_CHECK_LIB([ws2_32], [WSAStartup], [dnl AC_CHECK_HEADER([winsock.h], [dnl AC_DEFINE([HAVE_LIBWS232], [1], @@ -483,9 +483,11 @@ dnl --------------------------------------------------------------------------- AC_SUBST([PACKAGE_TARNAME]) -if test "x${utilsdir}" = "x"; then utilsdir="\${libdir}/\${PACKAGE_TARNAME}"; fi -AC_ARG_VAR([utilsdir],[Directory where utilities like print-camera-list will be installed]) -AC_SUBST([utilsdir]) +AC_ARG_VAR([utilsdir], + [Directory where utilities like print-camera-list will be installed]) +AS_VAR_IF([utilsdir], [], [dnl + utilsdir="\${libdir}/\${PACKAGE_TARNAME}" +]) GP_UDEV([true]) @@ -605,8 +607,11 @@ GPKG_CHECK_LINUX()dnl Check whether to package for a linux system dnl -------------------------------------------------------------------- dnl guess directory to install *.pc into dnl -------------------------------------------------------------------- -pkgconfigdir='${libdir}/pkgconfig' -AC_SUBST([pkgconfigdir]) +AC_ARG_VAR([pkgconfigdir], + [where to install pkg-config *.pc files to]) +AS_VAR_IF([pkgconfigdir], [], [dnl + pkgconfigdir='${libdir}/pkgconfig' +]) dnl --------------------------------------------------------------------------- @@ -648,16 +653,16 @@ CPPFLAGS="$CPPFLAGS_save" dnl --------------------------------------------------------------------------- dnl Configure subprojects dnl --------------------------------------------------------------------------- -if test -d "$srcdir/libgphoto2_port"; then +AS_IF([test -d "$srcdir/libgphoto2_port"], [dnl AC_CONFIG_SUBDIRS([libgphoto2_port]) -else +], [dnl AC_MSG_ERROR([ ****************************************************** *** Hey, where have you hidden my libgphoto2_port? *** *** I needed that! *** ****************************************************** ]) -fi +]) # --------------------------------------------------------------------------- @@ -690,7 +695,7 @@ AC_CONFIG_FILES([ ]) AC_OUTPUT -AS_IF([test "x$CDPATH" != "x"], [dnl +AS_VAR_IF([CDPATH], [], [], [dnl AC_MSG_WARN([ #=========================================================# diff --git a/libgphoto2_port/configure.ac b/libgphoto2_port/configure.ac index d13aacc706..62f59b448a 100644 --- a/libgphoto2_port/configure.ac +++ b/libgphoto2_port/configure.ac @@ -147,9 +147,9 @@ AC_CHECK_FUNC([gettext], [gettext_without_libintl=true]) # we don't have to check for gettext in libintl. Otherwise # we may even require libintl. dnl AC_CHECK_LIB(intl, gettext, [LIBS="$LIBS -lintl"]) -if test "x$gettext_without_libintl" != xtrue && test "x$USE_NLS" = xyes; then +AS_IF([test "x$gettext_without_libintl" != xtrue && test "x$USE_NLS" = xyes], [dnl AC_CHECK_LIB([intl], [gettext], [INTLLIBS="$INTLLIBS -lintl"]) -fi +]) dnl --------------------------------------------------------------------------- @@ -292,35 +292,31 @@ try_ttylock=true try_lockdev=true try_resmgr=true -if test "$ac_cv_header_sgtty_h" = "no" -then +AS_VAR_IF([ac_cv_header_sgtty_h], [no], [dnl have_serial=false serial_msg=no -fi +]) AC_ARG_ENABLE([serial], [AS_HELP_STRING([--disable-serial], [do not compile in SERIAL support])], [dnl - if test x$enableval = xno; then + AS_VAR_IF([enableval], [no], [dnl have_serial=false serial_msg=no try_ttylock=false try_lockdev=false try_resmgr=false - fi + ]) ]) -if $have_serial; then +AS_IF([$have_serial], [dnl IOLIB_LIST="$IOLIB_LIST serial" AC_DEFINE([HAVE_SERIAL], [1], [Whether you have serial support enabled]) -fi +]) GP_CONFIG_MSG([Serial ports]) GP_CONFIG_MSG([Serial support],[$serial_msg]) -SERIAL_LIBS="" -if $have_serial; then - dnl ----------------------------------------- dnl Serial port locking: We try to use either dnl (1) ttylock.h @@ -332,16 +328,20 @@ AC_ARG_ENABLE([$1], [AS_HELP_STRING([--disable-][$1], [do not use ][$1][ library]) ], [dnl - if test x$enableval = xno; then - try_[$1]=false - fi + AS_VAR_IF([enableval], [no], [dnl + try_[$1]=false + ]) ]) ])dnl + +SERIAL_LIBS="" +AS_IF([$have_serial], [dnl + GP_SERLOCK([ttylock])dnl GP_SERLOCK([lockdev])dnl ttylock_msg=no -if $try_ttylock; then +AS_IF([$try_ttylock], [dnl AC_CHECK_HEADER([lockdev.h]) AC_CHECK_HEADER([ttylock.h], [dnl lockdev_result="no" @@ -375,11 +375,11 @@ if $try_ttylock; then # include #endif ]) -fi +]) GP_CONFIG_MSG([ttylock locking],[${ttylock_msg}]) lockdev_msg=no -if $try_lockdev; then +AS_IF([$try_lockdev], [dnl AC_CHECK_LIB([lockdev], [dev_lock], [dnl AC_CHECK_HEADER([lockdev.h], [dnl AC_DEFINE([HAVE_LOCKDEV], [1], @@ -388,10 +388,10 @@ if $try_lockdev; then SERIAL_LIBS=-llockdev ]) ]) -fi +]) GP_CONFIG_MSG([lockdev locking],[${lockdev_msg}]) -fi # have_serial +])dnl $have_serial AC_SUBST([SERIAL_LIBS]) @@ -442,18 +442,20 @@ GP_CHECK_LIBRARY([LIBUSB],[libusb],[>= 0.1.5], IOLIB_LIST="$IOLIB_LIST usb" ;; *-linux*) - if test "x$have_LIBUSB1" != xyes; then + AS_VAR_IF([have_LIBUSB1], [yes], [dnl + GP_CONFIG_MSG([libusb0 support], + [detected, but disabled (libusb1 support is enabled)]) + ], [dnl IOLIB_LIST="$IOLIB_LIST usb usbdiskdirect usbscsi" - else - GP_CONFIG_MSG([libusb0 support],[detected, but disabled (libusb1 support is enabled)]) - fi + ]) ;; *) - if test "x$have_LIBUSB1" != xyes; then + AS_VAR_IF([have_LIBUSB1], [yes], [dnl + GP_CONFIG_MSG([libusb0 support], + [detected, but disabled (libusb1 support is enabled)]) + ], [dnl IOLIB_LIST="$IOLIB_LIST usb" - else - GP_CONFIG_MSG([libusb0 support],[detected, but disabled (libusb1 support is enabled)]) - fi + ]) ;; esac ], [], @@ -471,9 +473,9 @@ AC_ARG_ENABLE([disk], [enable_disk=yes]) dnl disk port also works everywhere, but it's not really necessary -if test "x$enable_disk" = "xyes"; then +AS_VAR_IF([enable_disk], [yes], [dnl IOLIB_LIST="$IOLIB_LIST disk" -fi +]) AC_ARG_ENABLE([vusb], [AS_HELP_STRING([--enable-vusb], @@ -485,9 +487,9 @@ AC_ARG_ENABLE([vusb], ) dnl disk port also works everywhere, but it's not really necessary -if test "x$enable_vusb" = "xyes"; then +AS_VAR_IF([enable_vusb], [yes], [dnl IOLIB_LIST="$IOLIB_LIST vusb" -fi +]) AC_ARG_ENABLE([ptpip], [AS_HELP_STRING([--disable-ptpip], @@ -568,10 +570,10 @@ GP_BUILD_GTK_DOCS()dnl dnl --------------------------------------------------------------------------- dnl Turn on all warnings when using gcc dnl --------------------------------------------------------------------------- -if test "$GCC" = "yes"; then +AS_VAR_IF([GCC], [yes], [dnl CFLAGS="$CFLAGS -Wall" CFLAGS="$CFLAGS -Wmissing-declarations -Wmissing-prototypes" -fi +]) # Activate internal code AM_CPPFLAGS="$AM_CPPFLAGS -D_GPHOTO2_INTERNAL_CODE" diff --git a/libgphoto2_port/gphoto-m4/gp-byteorder.m4 b/libgphoto2_port/gphoto-m4/gp-byteorder.m4 index 95d7435bf3..8cd4bf5042 100644 --- a/libgphoto2_port/gphoto-m4/gp-byteorder.m4 +++ b/libgphoto2_port/gphoto-m4/gp-byteorder.m4 @@ -40,9 +40,9 @@ fi # We're only interested in the target CPU, but it's not always set effective_target="$target" -if test "x$effective_target" = xNONE || test "x$effective_target" = x ; then +AS_IF([test "x$effective_target" = xNONE || test "x$effective_target" = x], [dnl effective_target="$host" -fi +]) AC_SUBST(effective_target) cat > "$1" << EOF