]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Use AS_IF in the configure script
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Sat, 13 Jun 2015 14:05:33 +0000 (16:05 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Sat, 13 Jun 2015 14:05:33 +0000 (16:05 +0200)
I just found out about that macro that is supposed to make the code more
portable.

The indentation of the AS_IF blocks was a bit changed to use tabs instead
of spaces.

configure.ac

index b4b29d71394ab7051b4cc75fc2880fb2e641519a..5888f2bd652f1e4fcbc0d08da4107d73c0dee893 100644 (file)
@@ -36,9 +36,7 @@ saved_CFLAGS="${CFLAGS}"
 CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter"
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_extra_warnings="yes"],[have_extra_warnings="no"])
 AC_MSG_RESULT($have_extra_warnings)
-if test "$have_extra_warnings" = "no" ; then
-    CFLAGS="${saved_CFLAGS}"
-fi
+AS_IF([test "$have_extra_warnings" = "no"],[CFLAGS="${saved_CFLAGS}"])
 
 # Don't compare signs as it is a mess
 CFLAGS="${CFLAGS} -Wno-sign-compare"
@@ -48,18 +46,14 @@ saved_CFLAGS="${CFLAGS}"
 CFLAGS="${CFLAGS} -Werror=implicit-function-declaration"
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_implicit_function_declaration="yes"],[have_implicit_function_declaration="no"])
 AC_MSG_RESULT($have_implicit_function_declaration)
-if test "$have_implicit_function_declaration" = "no" ; then
-    CFLAGS="${saved_CFLAGS}"
-fi
+AS_IF([test "$have_implicit_function_declaration" = "no"],[CFLAGS="${saved_CFLAGS}"])
 
 AC_MSG_CHECKING([for format error flag in $CC])
 saved_CFLAGS="${CFLAGS}"
 CFLAGS="${CFLAGS} -Werror=format"
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_error_format="yes"],[have_error_format="no"])
 AC_MSG_RESULT($have_error_format)
-if test "$have_error_format" = "no" ; then
-    CFLAGS="${saved_CFLAGS}"
-fi
+AS_IF([test "$have_error_format" = "no"],[CFLAGS="${saved_CFLAGS}"])
 
 case "$host" in
    *-solaris*)
@@ -82,101 +76,106 @@ AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h
                execinfo.h math.h libintl.h libgen.h stdbool.h getopt.h fcntl.h fnmatch.h \
                winsock.h)
 
-if test $ac_cv_header_getopt_h = "no" ; then
-   AC_MSG_ERROR("getopt.h is required to compile sarg")
-fi
+AS_IF([test $ac_cv_header_getopt_h = "no"],[AC_MSG_ERROR("getopt.h is required to compile sarg")])
 
 # Build with gd
 AC_ARG_WITH([gd],
 AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]),
 [],[with_gd=check])
-if ( test "x$with_gd" != "xno" ) ; then
+AS_IF([test "x$with_gd" != "xno"],
+[
        AC_CHECK_HEADERS(gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h)
-       if ( test "x$ac_cv_header_gd_h" = "xyes" ) ; then
+       AS_IF([test "x$ac_cv_header_gd_h" = "xyes"],
+       [
                AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="")
-               if ( test "x$HAVE_GD_LIB" != "xyes" ) ; then
+               AS_IF([test "x$HAVE_GD_LIB" != "xyes"],
+               [
                        AC_MSG_ERROR([libgd is required to compile sarg with gd])
-               fi
-       else
+               ])
+       ],[
                gd_status="not found"
-       fi
-else
+       ])
+],[
        gd_status="disabled"
-fi
+])
 
 # Build with LDAP
 AC_ARG_WITH([ldap],
 AS_HELP_STRING([--with-ldap],[Compile with LDAP support]),
 [],[with_ldap=check])
-if ( test "x$with_ldap" != "xno" ) ; then
+AS_IF([test "x$with_ldap" != "xno"],
+[
        AC_CHECK_HEADERS([ldap_cdefs.h] [ldap_features.h] [ldap.h],,break)
-       if ( test "x$ac_cv_header_ldap_h" = "xyes" ) ; then
+       AS_IF([test "x$ac_cv_header_ldap_h" = "xyes"],
+       [
                AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
-       else
+       ],[
                ldap_status="not found"
-       fi
-else
+       ])
+],[
        ldap_status="disabled"
-fi
+])
 
 # Build with iconv
 AC_ARG_WITH([iconv],
 AS_HELP_STRING([--with-iconv],[Compile with support for iconv]),
 [],[with_iconv=check])
-if ( test "x$with_iconv" != "xno" ) ; then
+AS_IF([test "x$with_iconv" != "xno"],
+[
        dnl Check for iconv
        AM_ICONV
-       if test -n "$LIBICONV" ; then
-         LIBS="$LIBS $LIBICONV"
-       fi
+       AS_IF([test -n "$LIBICONV"],[LIBS="$LIBS $LIBICONV"])
        AC_CHECK_HEADERS(iconv.h)
-else
+],[
        AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line])
-fi
+])
 
 # Build with pcre
 AC_ARG_WITH([pcre],
 AS_HELP_STRING([--with-pcre],[Compile with support for the Perl Compatible Regular Expressions library]),
 [],[with_pcre=check])
-if ( test "x$with_pcre" != "xno" ) ; then
+AS_IF([test "x$with_pcre" != "xno"],
+[
        AC_CHECK_HEADERS(pcre.h)
-       if ( test "x$ac_cv_header_pcre_h" = "xyes" ) ; then
+       AS_IF([test "x$ac_cv_header_pcre_h" = "xyes"],
+       [
                LIBS="$LIBS $(pcre-config --libs)"
                CFLAGS="$CFLAGS $(pcre-config --cflags)"
-       else
+       ],[
                pcre_status="not found"
-       fi
-else
+       ])
+],[
        pcre_status="disabled"
-fi
+])
 
 # Build with file globbing
 AC_ARG_WITH([glob],
 AS_HELP_STRING([--without-glob],[Ignore wildcards in file names]),
 [with_glob=no],[with_glob=yes])
-if ( test "x$with_glob" != "xno" ) ; then
+AS_IF([test "x$with_glob" != "xno"],
+[
        AC_CHECK_HEADERS(glob.h)
-else
+],[
        glob_status="disabled"
-fi
+])
 
 # Build with zlib
 AC_ARG_WITH([zlib],
 AS_HELP_STRING([--with-zlib],[Compile with support to decompress gz files]),
 [],[with_zlib=check])
-if ( test "x$with_zlib" != "xno" ) ; then
+AS_IF([test "x$with_zlib" != "xno" ],
+[
        AC_CHECK_HEADERS(zlib.h)
-       if ( test "x$ac_cv_header_zlib_h" = "xyes" ) ; then
+       AS_IF([test "x$ac_cv_header_zlib_h" = "xyes"],
+       [
                AC_CHECK_LIB(z, gzopen,LIBS="-lz ${LIBS}"; HAVE_ZLIB_LIB="yes", HAVE_ZLIB_LIB="")
-               if ( test "x$HAVE_ZLIB_LIB" != "xyes" ) ; then
-                       AC_MSG_ERROR([zlib was not found])
-               fi
-       else
+               AS_IF([test "x$HAVE_ZLIB_LIB" != "xyes"],[AC_MSG_ERROR([zlib was not found])])
+       ],[
                zlib_status="not found"
-       fi
-else
+       ])
+],[
        zlib_status="disabled"
-fi
+])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -210,14 +209,14 @@ bu_cv_have_fopen64=no)]))
  ])
  CFLAGS=$noerror_CFLAGS])
 AC_MSG_RESULT($bu_cv_have_fopen64)
-if test "$bu_cv_have_fopen64" != no; then
-  AC_DEFINE([HAVE_FOPEN64], 1,
-            [Is fopen64 available?])
-  if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then
-    AC_DEFINE([_LARGEFILE64_SOURCE], 1,
-              [Enable LFS])
-  fi
-fi
+AS_IF([test "$bu_cv_have_fopen64" != no],
+[
+       AC_DEFINE([HAVE_FOPEN64],1,[Is fopen64 available?])
+       AS_IF([test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"],
+       [
+               AC_DEFINE([_LARGEFILE64_SOURCE],1,[Enable LFS])
+       ])
+])
 
 dnl check for functions
 AC_CHECK_FUNCS(backtrace)
@@ -232,77 +231,79 @@ dnl check for structure members
 AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
 
 dnl windows require this library
-if test $ac_cv_header_winsock_h = "yes" ; then
+AS_IF([test $ac_cv_header_winsock_h = "yes"],
+[
 #   AC_CHECK_LIBS([ws2_32],[WSAGetLastError]) fails because of the __stdcall in the function prototype
-   LIBS="$LIBS -lws2_32"
-fi
+       LIBS="$LIBS -lws2_32"
+])
 
 dnl check for the rlim_t size
 AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
 ])
-if test $ac_cv_sizeof_rlim_t = "4"; then
-    AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
-elif test $ac_cv_sizeof_rlim_t = "8"; then
-    AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
-else
-    AC_MSG_WARN([can not detect the size of your system rlim_t type])
-fi
+AS_IF([test $ac_cv_sizeof_rlim_t = "4"],
+[
+       AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
+],[test $ac_cv_sizeof_rlim_t = "8"],
+[
+       AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
+],[
+       AC_MSG_WARN([can not detect the size of your system rlim_t type])
+])
 
 dnl check for the long long int max constant
 AC_CHECK_DECL(LLONG_MAX,HAVE_LLONG_MAX="yes",HAVE_LLONG_MAX="no",[[#include <limits.h>]])
-if ( test "x$ac_cv_have_decl_LLONG_MAX" != "xyes" ) ; then
+AS_IF([test "x$ac_cv_have_decl_LLONG_MAX" != "xyes"],
+[
        AC_MSG_ERROR([LLONG_MAX is not defined on your system.])
-fi
+])
 
 dnl Select sarg-php directory
 AC_ARG_ENABLE(sargphp,
 AS_HELP_STRING([--enable-sargphp=sargphpdir],
 [Select sargphpdir as the directory to install sarg-php into]),
 [
-    if test "$enableval" -a "x$enableval" != "xno" ; then
-        SARGPHPDIR=$enableval
-    fi
+       AS_IF([test "$enableval" -a "x$enableval" != "xno"],[SARGPHPDIR=$enableval])
 ],[SARGPHPDIR="/var/www/html"])
-if test "$SARGPHPDIR" ; then
-   AC_MSG_NOTICE([using $SARGPHPDIR as the directory to install sarg-php])
-   AC_SUBST(SARGPHPDIR)
-fi
+AS_IF([test "$SARGPHPDIR"],
+[
+       AC_MSG_NOTICE([using $SARGPHPDIR as the directory to install sarg-php])
+       AC_SUBST(SARGPHPDIR)
+])
 
 dnl Select fonts dir
 AC_ARG_ENABLE(fontdir,
 AS_HELP_STRING([--enable-fontdir=fontdir],
 [Select fontdir as the directory with the fonts to use in the reports]),
 [
-    if test "$enableval" -a "x$enableval" != "xno" ; then
-        FONTDIR=$enableval
-    fi
+       AS_IF([test "$enableval" -a "x$enableval" != "xno"],[FONTDIR=$enableval])
 ],[FONTDIR="${datarootdir}/sarg/fonts"])
-if test "$FONTDIR" ; then
-   if test "x$prefix" = "xNONE" ; then
-      tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
-   else
-      tempfullpath=`eval "echo $FONTDIR"`
-   fi
-   AC_MSG_NOTICE([using $tempfullpath as the directory of the fonts])
-   AC_SUBST(FONTDIR)
-fi
+AS_IF([test "$FONTDIR"],
+[
+       AS_IF([test "x$prefix" = "xNONE"],
+       [
+               tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
+       ],[
+               tempfullpath=`eval "echo $FONTDIR"`
+       ])
+       AC_MSG_NOTICE([using $tempfullpath as the directory of the fonts])
+       AC_SUBST(FONTDIR)
+])
 
 dnl Select images dir
 AC_ARG_ENABLE(imagedir,
 AS_HELP_STRING([--enable-imagedir=imagedir],
 [Select imagedir as the directory with the images to use in the reports]),
 [
-    if test "$enableval"; then
-        IMAGEDIR=$enableval
-    fi
+       AS_IF([test "$enableval"],[IMAGEDIR=$enableval])
 ],[IMAGEDIR="${datarootdir}/sarg/images"])
-if test "x$prefix" = "xNONE" ; then
-   tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
-else
-   tempfullpath=`eval "echo $IMAGEDIR"`
-fi
+AS_IF([test "x$prefix" = "xNONE"],
+[
+       tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
+],[
+       tempfullpath=`eval "echo $IMAGEDIR"`
+])
 AC_MSG_NOTICE([using $tempfullpath as the directory of the images])
 AC_SUBST(IMAGEDIR)
 
@@ -311,31 +312,26 @@ AC_ARG_ENABLE(extraprotection,
 AS_HELP_STRING([--enable-extraprotection],
 [Enable compile and runtime extra protections]),
 [
-    if test "$enableval"; then
-       # _FORTIFY_SOURCE may have been defined by the system. It must be undefined before it is changed to the value we want.
-       CFLAGS="${CFLAGS} -fstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
-       if test "x$werror_status" != "xfail" ; then
-          CFLAGS="${CFLAGS} -Werror"
-       fi
-
-       AC_MSG_CHECKING([for format security flag in $CC])
-       saved_CFLAGS="${CFLAGS}"
-       CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
-       AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
-       AC_MSG_RESULT($have_format_security)
-       if test "$have_format_security" = "no" ; then
-          CFLAGS="${saved_CFLAGS}"
-       fi
-
-       AC_MSG_CHECKING([for empty body flag in $CC])
-       saved_CFLAGS="${CFLAGS}"
-       CFLAGS="${CFLAGS} -Wempty-body"
-       AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
-       AC_MSG_RESULT($have_empty_body)
-       if test "$have_empty_body" = "no" ; then
-          CFLAGS="${saved_CFLAGS}"
-       fi
-    fi
+       AS_IF([test "$enableval"],
+       [
+               # _FORTIFY_SOURCE may have been defined by the system. It must be undefined before it is changed to the value we want.
+               CFLAGS="${CFLAGS} -fstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
+               AS_IF([test "x$werror_status" != "xfail"],[CFLAGS="${CFLAGS} -Werror"])
+
+               AC_MSG_CHECKING([for format security flag in $CC])
+               saved_CFLAGS="${CFLAGS}"
+               CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
+               AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
+               AC_MSG_RESULT($have_format_security)
+               AS_IF([test "$have_format_security" = "no"],[CFLAGS="${saved_CFLAGS}"])
+
+               AC_MSG_CHECKING([for empty body flag in $CC])
+               saved_CFLAGS="${CFLAGS}"
+               CFLAGS="${CFLAGS} -Wempty-body"
+               AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
+               AC_MSG_RESULT($have_empty_body)
+               AS_IF([test "$have_empty_body" = "no"],[CFLAGS="${saved_CFLAGS}"])
+       ])
 ])
 
 dnl Enable double check of the data written in the reports
@@ -343,9 +339,10 @@ AC_ARG_ENABLE(doublecheck,
 AS_HELP_STRING([--enable-doublecheck],
 [Make sarg double check the data it manipulates and output a warning if an error is found]),
 [
-   if test "$enableval"; then
-      AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
-   fi
+       AS_IF([test "$enableval"],
+       [
+               AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
+       ])
 ])
 
 dnl Get the xsl stylesheet to produce the manpage
@@ -353,10 +350,11 @@ AC_ARG_ENABLE(xsl-man,
 AS_HELP_STRING([--enable-xsl-man=man-xsl-style-sheet],
 [Select the directory containing the the XSL stylesheets to convert DocBook into man page]),
 [
-       if test "$enableval"; then
+       AS_IF([test "$enableval"],
+       [
                XSL_MAN_STYLESHEET=$enableval
                AC_SUBST(XSL_MAN_STYLESHEET)
-       fi
+       ])
 ],
 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl],
 [
@@ -378,10 +376,11 @@ AC_ARG_ENABLE(xsl-html,
 AS_HELP_STRING([--enable-xsl-html=html-xsl-style-sheet],
 [Select the directory containing the the XSL stylesheets to convert DocBook into html page]),
 [
-       if test "$enableval"; then
+       AS_IF([test "$enableval"],
+       [
                XSL_HTML_STYLESHEET=$enableval
                AC_SUBST(XSL_HTML_STYLESHEET)
-       fi
+       ])
 ],
 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/html/onechunk.xsl],
 [
@@ -404,30 +403,30 @@ AC_SUBST(VERSION,"$PACKAGE_VERSION")
 AC_CONFIG_FILES([Makefile po/Makefile.in])
 AC_OUTPUT
 
-if ( test "x$gd_status" = "xdisabled" ) ; then
+AS_IF([test "x$gd_status" = "xdisabled"],[
        AC_MSG_NOTICE([Not building with gd as requested on the configuration command line])
-elif ( test "x$gd_status" = "xnot found" ) ; then
+],[test "x$gd_status" = "xnot found"],[
        AC_MSG_NOTICE([gd.h was not found so the graphs won't be available in the report])
-fi
+])
 
-if ( test "x$pcre_status" = "xdisabled" ) ; then
+AS_IF([test "x$pcre_status" = "xdisabled"],[
        AC_MSG_NOTICE([Not building with pcre as requested on the configuration command line])
-elif ( test "x$pcre_status" = "xnot found" ) ; then
+],[test "x$pcre_status" = "xnot found"],[
        AC_MSG_NOTICE([pcre.h was not found so the regexp won't be available in hostalias])
-fi
+])
 
-if ( test "x$ldap_status" = "xdisabled" ) ; then
+AS_IF([test "x$ldap_status" = "xdisabled"],[
        AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line])
-elif ( test "x$ldap_status" = "xnot found" ) ; then
+],[test "x$ldap_status" = "xnot found"],[
        AC_MSG_NOTICE([ldap header files not found so LDAP is not available to resolve user's names])
-fi
+])
 
-if ( test "x$glob_status" = "xdisabled" ) ; then
+AS_IF([test "x$glob_status" = "xdisabled"],[
        AC_MSG_NOTICE([Not building with file globbing as requested on the configuration command line])
-fi
+])
 
-if ( test "x$zlib_status" = "xdisabled" ) ; then
+AS_IF([test "x$zlib_status" = "xdisabled"],[
        AC_MSG_NOTICE([Not building with zlib as requested on the configuration command line])
-elif ( test "x$zlib_status" = "xnot found" ) ; then
+],[test "x$zlib_status" = "xnot found"],[
        AC_MSG_NOTICE([zlib.h was not found so it won't be possible to process gzipped files])
-fi
+])