Skip to content

Commit

Permalink
Use AS_VAR_IF and AS_IF as often as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ndim committed Oct 31, 2021
1 parent f132d8a commit cf50ed6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 49 deletions.
31 changes: 18 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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 ---------------------------------------------------------------------------
Expand Down Expand Up @@ -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
])


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -690,7 +695,7 @@ AC_CONFIG_FILES([
])
AC_OUTPUT

AS_IF([test "x$CDPATH" != "x"], [dnl
AS_VAR_IF([CDPATH], [], [], [dnl
AC_MSG_WARN([
#=========================================================#
Expand Down
70 changes: 36 additions & 34 deletions libgphoto2_port/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -375,11 +375,11 @@ if $try_ttylock; then
# include <lockdev.h>
#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],
Expand All @@ -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])

Expand Down Expand Up @@ -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
], [],
Expand All @@ -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],
Expand All @@ -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],
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions libgphoto2_port/gphoto-m4/gp-byteorder.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cf50ed6

Please sign in to comment.