dnl Process this file with autoconf to produce a configure script. AC_INIT([sarg],[2.3]) AC_CONFIG_SRCDIR([log.c]) AC_CONFIG_AUX_DIR(cfgaux) AC_CANONICAL_HOST AC_ARG_WITH(gcc, [ --without-gcc use CC to compile]) test -n "$CC" && cc_specified=yes case ${with_gcc} in yes ) CC=gcc ;; dnl yes ) CC=g++ ;; no ) CC=cc ;; * ) AC_PROG_CC;; dnl * ) AC_PROG_CXX ;; esac if test "${CC}" = "cc" ; then CFLAGS="${CFLAGS} -g -O2 -Aa" fi CFLAGS="${CFLAGS} -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter" dnl Check for supported gcc options AC_MSG_CHECKING([for implicit-function-declaration error flag in gcc]) 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 AC_MSG_CHECKING([for format error flag in gcc]) 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_implicit_function_declaration" == "no" ; then CFLAGS="${saved_CFLAGS}" fi case "$host" in *-solaris*) LDFLAGS="${LDFLAGS} -lsocket -lnsl" CFLAGS="-DSOLARIS ${CFLAGS}" ;; esac #dnl Checks for programs. #AC_PROG_CC dnl Check for headers AC_HEADER_DIRENT AC_HEADER_STDC dnl Check for iconv AM_ICONV if test -n "$LIBICONV" ; then LIBS="$LIBS $LIBICONV" fi AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \ dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \ ctype.h gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h iconv.h \ errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h \ execinfo.h ldap.h math.h) AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD="yes", HAVE_GD="") AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="") dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_STRUCT_TM AC_SYS_LARGEFILE # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE # needs to be defined for it AC_MSG_CHECKING([for fopen64]) AC_CACHE_VAL(bu_cv_have_fopen64, [noerror_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -Werror" AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes], [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE" AC_TRY_LINK([#include ], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);], bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE", CFLAGS=$noerror_CFLAGS AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror" werror_status="fail"], [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE" AC_TRY_LINK([#include ], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);], bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror" werror_status="fail", 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 dnl check for functions AC_CHECK_FUNCS(bzero) AC_CHECK_FUNCS(backtrace) AC_CHECK_FUNCS(symlink) AC_CHECK_FUNCS(lstat) dnl check for the rlim_t size AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H #include #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\'s rlim_t type]) fi dnl Select sarg-php directory AC_ARG_ENABLE(sargphp, [ --enable-sargphp=sargphpdir Select sargphpdir as the directory to install sarg-php into ], [ if test "$enableval" -a "x$enableval" != "xno" ; then SARGPHPDIR=$enableval fi ],[SARGPHP="/var/www/html"]) if test "$SARGPHPDIR" ; then echo "using $SARGPHPDIR as the directory to install sarg-php" AC_SUBST(SARGPHPDIR) fi dnl Select languages dir AC_ARG_ENABLE(languagedir, [ --enable-languagedir=languagedir Select languagedir as the directory with the translations of sarg ], [ if test "$enableval"; then LANGDIR=$enableval fi ],[LANGDIR="${datarootdir}/sarg/languages"]) echo "using $LANGDIR as the directory of the translations" AC_SUBST(LANGDIR) dnl Select fonts dir AC_ARG_ENABLE(fontdir, [ --enable-fontdir=fontdir Select fontdir as the directory with the fonts to use in the reports ], [ if test "$enableval"; then FONTDIR=$enableval fi ],[FONTDIR="${datarootdir}/sarg/fonts"]) echo "using $FONTDIR as the directory of the fonts" AC_SUBST(FONTDIR) dnl Select images dir AC_ARG_ENABLE(imagedir, [ --enable-imagedir=imagedir Select imagedir as the directory with the images to use in the reports ], [ if test "$enableval"; then IMAGEDIR=$enableval fi ],[IMAGEDIR="${datarootdir}/sarg/images"]) echo "using $IMAGEDIR as the directory of the images" AC_SUBST(IMAGEDIR) dnl Enable extra compile and run time protection AC_ARG_ENABLE(extraprotection, [ --enable-extraprotection Enable compile and runtime extra protections ], [ if test "$enableval"; then CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2" if test "x$werror_status" != "xfail" ; then CFLAGS="${CFLAGS} -Werror" fi AC_MSG_CHECKING([for format security flag in gcc]) 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 fi ]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT