Annotation of hypermess/hypermail/configure.ac, revision 1.2

1.1       kahan       1: dnl Process this file with autoconf to produce a configure script.
                      2: 
                      3: AC_PREREQ([2.67])
1.2     ! kahan       4: AC_REVISION($Revision: 1.1 $)dnl
1.1       kahan       5: AC_INIT
                      6: AC_CONFIG_SRCDIR([src/hypermail.c])
                      7: AC_CONFIG_HEADER(config.h)
                      8: AC_PREFIX_DEFAULT(/usr/local)
                      9: LDFLAGS=""
                     10: LIBS=""
                     11: EXTRA_LIBS=""
                     12: INCLUDES=""
                     13: GDBM_INCLUDE=""
                     14: GDBM_LIB=""
                     15: PCRE_DEP=""
                     16: FNV_DEP=""
                     17: 
                     18: dnl ===========================================================================
                     19: dnl Get host, target and build variables filled with appropriate info.
                     20: dnl ===========================================================================
                     21: 
                     22: AC_CANONICAL_TARGET
                     23: 
                     24: dnl ===========================================================================
                     25: dnl Check to assure the cached information is valid.
                     26: dnl ===========================================================================
                     27: 
                     28: AC_MSG_CHECKING(cached information)
                     29: hostcheck="$host"
                     30: AC_CACHE_VAL(ac_cv_hostcheck, [ ac_cv_hostcheck="$hostcheck" ])
                     31: if test "$ac_cv_hostcheck" != "$hostcheck"; then
                     32:   AC_MSG_RESULT(changed)
                     33:   AC_MSG_WARN(config.cache exists!)
                     34:   AC_MSG_ERROR(you must do 'make clobber' first to compile for different host or different parameters.)
                     35: else
                     36:   AC_MSG_RESULT(ok)
                     37: fi
                     38: 
                     39: dnl ===========================================================================
                     40: dnl Checks for programs.
                     41: dnl ===========================================================================
                     42: 
                     43: AC_PROG_CC
                     44: AC_PROG_CPP
                     45: AC_PROG_YACC
                     46: AC_PROG_INSTALL
                     47: AC_PROG_LN_S
                     48: AC_PROG_MAKE_SET
                     49: AC_CHECK_PROG(AR, ar, ar, echo)
                     50: if test -z "$no_ranlib"; then
                     51:   AC_PROG_RANLIB
                     52: else
                     53:   RANLIB=":"
                     54: fi
                     55: 
                     56: dnl ===========================================================================
                     57: dnl Determine the host type and set compliation flags as needed
                     58: dnl ===========================================================================
                     59: 
                     60: INSTALL="install-sh"
                     61: 
                     62: case "$host" in
                     63:   *-*-solaris*)
                     64:     # Solaris flags 
                     65:     AC_DEFINE(NO_MACRO)
                     66:     ;;
                     67: 
                     68:   *-*-hpux*)
                     69:     # HPUX flags 
                     70:     if test -z "$GCC"; then
                     71:       CFLAGS="$CFLAGS -Ae"
                     72:     fi
                     73:     ;;
                     74:   *-dec-osf*)
                     75:     # DEC OSF flags 
                     76:     CFLAGS="$CFLAGS -mieee"
                     77:     INSTALL="install-sh"
                     78:     ;;
                     79: esac
                     80: 
                     81: export CFLAGS CC
                     82: 
                     83: AC_SUBST(INSTALL)
                     84: 
                     85: AC_MSG_CHECKING([that the compiler works])
                     86: AC_RUN_IFELSE([AC_LANG_SOURCE([[ main(int ac, char **av) { return 0; } ]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
                     87:     AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.)],[AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.)])
                     88: 
                     89: dnl ===========================================================================
                     90: dnl Determine if building on a Cygwin system so that 
                     91: dnl etc/passwd checks are to be disabled.
                     92: dnl ===========================================================================
                     93: 
                     94: case "$build" in
                     95:   *-*-cygwin*)
                     96:       suffix=.exe
                     97:       AC_SUBST(suffix)
                     98:     ;;
                     99: esac
                    100: 
                    101: dnl ===========================================================================
                    102: dnl Accepted arguments to ./configure...
                    103: dnl ===========================================================================
                    104: 
                    105: AC_MSG_CHECKING([whether to enable -Wall])
                    106: AC_ARG_ENABLE(warnings,
                    107: [  --enable-warnings       Enable -Wall if using gcc.],
                    108: [ if test -n "$GCC"; then 
                    109:     AC_MSG_RESULT(adding -Wall to CFLAGS.)
                    110:     CFLAGS="$CFLAGS -Wall"
                    111:   fi],AC_MSG_RESULT(no))
                    112: 
                    113: AC_ARG_WITH(httpddir, 
                    114:     [  --with-httpddir=DIR       webserver's root directory [/usr/local/apache]],
                    115:     httpddir=$with_httpddir,     httpddir=/usr/local/apache)
                    116: AC_SUBST(httpddir)
                    117: 
                    118: AC_ARG_WITH(cgidir, 
                    119:     [  --with-cgidir=DIR         where to install CGI scripts ],
                    120:     cgidir=$with_cgidir,         cgidir=$httpddir/cgi-bin)
                    121: AC_SUBST(cgidir)
                    122: 
                    123: AC_ARG_WITH(htmldir, 
                    124:     [  --with-htmldir=DIR        where to install Hypermail HTML pages ],
                    125:     htmldir=$with_htmldir,       htmldir=$httpddir/htdocs/hypermail)
                    126: AC_SUBST(htmldir)
                    127: 
                    128: AC_ARG_WITH(language, 
                    129:     [  --with-language=xx        two character language indicator [en] ],
                    130:     language=$with_language,     language=en)
                    131: AC_SUBST(language)
                    132: 
                    133: AC_ARG_WITH(htmlsuffix, 
                    134:     [  --with-htmlsuffix=xx      two character language indicator [html] ],
                    135:     htmlsuffix=$with_htmlsuffix,  htmlsuffix=html)
                    136: AC_SUBST(htmlsuffix)
                    137: 
                    138: AC_ARG_ENABLE(defaultindex,
                    139:     [  --enable-defaultindex=type      Default index page type [thread] ],
                    140:     [ defaultindex=$enableval ], [ defaultindex="thread" ])
                    141: AC_SUBST(defaultindex)
                    142: 
                    143: AC_ARG_WITH(domainaddr, 
                    144:     [  --with-domainaddr=YOURDOMAIN      domain address of local domain ],
                    145:     domainaddr=$with_domainaddr,  domainaddr=NONE)
                    146: AC_SUBST(domainaddr)
                    147: 
                    148: dnl ===========================================================================
                    149: dnl Configure the subdirectories
1.2     ! kahan     150: dnl
        !           151: dnl These are the subdirs that are compiled systematically
        !           152: dnl For subdirs that can be disabled thru configure options,
        !           153: dnl we configure them in a dedicated section near the test
1.1       kahan     154: dnl ===========================================================================
                    155: AC_DISABLE_OPTION_CHECKING
1.2     ! kahan     156: APR_SUBDIR_CONFIG([src/trio], 
        !           157:                     [CFLAGS=[-DTRIO_MINIMAL]],
        !           158:                    [--with-pcre=*|\'--with-pcre=*])
1.1       kahan     159: 
                    160: dnl ===========================================================================
                    161: dnl Checks headers
                    162: dnl ===========================================================================
                    163: 
                    164: AC_HEADER_STDC
                    165: 
                    166: AC_CHECK_HEADERS(alloca.h arpa/inet.h ctype.h dirent.h errno.h \
                    167:        fcntl.h locale.h malloc.h netdb.h netinet/in.h pwd.h stdarg.h \
                    168:        stdio.h stdlib.h string.h sys/dir.h sys/param.h sys/socket.h \
                    169:        sys/stat.h sys/time.h sys/types.h time.h unistd.h)
                    170: 
                    171: AC_HEADER_STAT
                    172: AC_HEADER_DIRENT
                    173: AC_HEADER_TIME
                    174: 
                    175: dnl ===========================================================================
                    176: dnl Checks for library functions.
                    177: dnl Check for typedefs, structures, and compiler characteristics.
                    178: dnl ===========================================================================
                    179: 
                    180: AC_STRUCT_TM
                    181: 
                    182: AC_FUNC_STRFTIME
                    183: AC_CHECK_FUNCS(mkdir strdup strstr strtol memcpy memset lstat strcasecmp \
                    184:                strcasestr getpwuid getopt snprintf memmove strerror)
                    185: 
                    186: AC_TYPE_SIZE_T
                    187: 
                    188: if test $ac_cv_func_snprintf != no; then
                    189:     AC_DEFINE(HAVE_SNPRINTF)
                    190: fi
                    191: 
                    192: 
                    193: dnl gdbm checks
                    194: 
                    195: AC_DEFUN([AC_TEMP_LDFLAGS],[
                    196:   old_LDFLAGS="$LDFLAGS"
                    197:   LDFLAGS="$1 $LDFLAGS"
                    198:   $2
                    199:   LDFLAGS="$old_LDFLAGS"
                    200: ])
                    201: 
                    202: dnl
                    203: dnl AC_HMAIL_ONCE(namespace, variable, code)
                    204: dnl
                    205: dnl execute code, if variable is not set in namespace
                    206: dnl
                    207: AC_DEFUN([AC_HMAIL_ONCE],[
                    208:   changequote({,})
                    209:   unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
                    210:   changequote([,])
                    211:   cmd="echo $ac_n \"\$$1$unique$ac_c\""
                    212:   if test -n "$unique" && test "`eval $cmd`" = "" ; then
                    213:     eval "$1$unique=set"
                    214:     $3
                    215:   fi
                    216: ])
                    217: 
                    218: dnl
                    219: dnl AC_EXPAND_PATH(path, variable)
                    220: dnl
                    221: dnl expands path to an absolute path and assigns it to variable
                    222: dnl
                    223: AC_DEFUN([AC_EXPAND_PATH],[
                    224:   if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
                    225:     $2="$1"
                    226:   else
                    227:     changequote({,})
                    228:     ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`"
                    229:     changequote([,])
                    230:     ep_realdir="`(cd \"$ep_dir\" && pwd)`"
                    231:     $2="$ep_realdir/`basename \"$1\"`"
                    232:   fi
                    233: ])
                    234: 
                    235: AC_DEFUN([AC_ADD_INCLUDE],[
                    236:   if test "$1" != "/usr/include"; then
                    237:     AC_EXPAND_PATH($1, ai_p)
                    238:     AC_HMAIL_ONCE(INCLUDEPATH, $ai_p, [
                    239:       INCLUDES="$INCLUDES -I$ai_p"
                    240:     ])
                    241:   fi
                    242: ])
                    243: 
                    244: dnl
                    245: dnl AC_ADD_LIBPATH(path[, shared-libadd])
                    246: dnl
                    247: dnl add a library to linkpath
                    248: dnl
                    249: AC_DEFUN([AC_ADD_LIBPATH],[
                    250:   if test "$1" != "/usr/lib"; then
                    251:     AC_EXPAND_PATH($1, ai_p)
                    252:     AC_HMAIL_ONCE(LIBPATH, $ai_p, [
                    253:       LDFLAGS="$LDFLAGS -L$ai_p"
                    254:     ])
                    255:   fi
                    256: ])
                    257: 
                    258: dnl
                    259: dnl AC_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
                    260: dnl
                    261: dnl add a library to the link line and path to linkpath/runpath.
                    262: dnl if shared-libadd is not empty and $ext_shared is yes,
                    263: dnl shared-libadd will be assigned the library information
                    264: dnl
                    265: AC_DEFUN([AC_ADD_LIBRARY_WITH_PATH],[
                    266: ifelse($3,,[
                    267:   if test -n "$2"; then
                    268:     AC_ADD_LIBPATH($2)
                    269:   fi
                    270:   EXTRA_LIBS="$EXTRA_LIBS $1" ],[
                    271:     AC_ADD_LIBRARY_WITH_PATH($1,$2)
                    272:   ])
                    273: ])
                    274: 
                    275: AC_ARG_WITH(gdbm,
                    276:    AS_HELP_STRING([--with-gdbm=[DIR]],
                    277:                   [Include GDBM support]),
                    278:    [ given_gdbm=$withval])
                    279: 
                    280: if test "$given_gdbm" != "no"; then
                    281:     for i in /usr/local /usr $withval; do
                    282:       if test -f "$i/include/gdbm.h"; then
                    283:         GDBM_INCLUDE="$i/include"
                    284:         THIS_PREFIX="$i"
                    285:       fi
                    286:     done
                    287: 
                    288:     unset ac_cv_lib_gdbm_gdbm_open
                    289:     AC_TEMP_LDFLAGS(-L$THIS_PREFIX/lib,[
                    290:        AC_CHECK_LIB(gdbm, gdbm_open, [GDBM_LIB="-lgdbm"])
                    291:     ])
                    292: 
                    293:     if test "$THIS_PREFIX" != "" && test "$THIS_PREFIX" != "/usr"; then
                    294:       THIS_LFLAGS="$THIS_PREFIX/lib"
                    295:     fi
                    296: fi
                    297: 
                    298: AC_MSG_CHECKING(for GDBM support)
                    299: 
                    300: if test "$GDBM_LIB" = "" && test "$given_gdbm" != "no"; then
                    301:   AC_CHECK_LIB(gdbm, gdbm_open,[AC_DEFINE(GDBM,1, [Whether you have GDBM]) DBM_TYPE=gdbm; GDBM_LIB=-lgdbm],
                    302:      [DBM_TYPE=""])
                    303:   AC_MSG_CHECKING([gdbm library])
                    304:   if test "a$DBM_TYPE" = a; then
                    305:     AC_MSG_RESULT(none found)
                    306:     AC_MSG_WARN(No gdbm library found - will limit a few features)
                    307:   else
                    308:     AC_MSG_RESULT($DBM_TYPE found)
                    309:   fi
                    310: else
                    311:     AC_MSG_RESULT(no)
                    312: fi
                    313: 
                    314: if test "$GDBM_LIB" = "-lgdbm" && test "$GDBM_INCLUDE" = ""; then
                    315:   AC_CHECK_HEADER(gdbm.h, [ GDBM_INCLUDE="" ], [ 
                    316:       AC_MSG_RESULT(Try /usr/local/include/gdbm.h)
                    317:       AC_CHECK_HEADER(/usr/local/include/gdbm.h, [ GDBM_INCLUDE="-I/usr/local/include" ],[
                    318:         AC_MSG_RESULT(Try /opt/local/include/gdbm.h)
                    319:         AC_CHECK_HEADER(/opt/local/include/gdbm.h, [ GDBM_INCLUDE="-I/opt/local/include" ],[
                    320:           dnl if in /usr/pkg/include, do not add anything.  See above.
                    321:           AC_MSG_RESULT(Try /usr/pkg/include/gdbm.h)
                    322:           AC_CHECK_HEADER(/usr/pkg/include/gdbm.h, [ GDBM_INCLUDE="" ],[
                    323:             AC_MSG_RESULT([Giving up - You need to install gdbm.h somewhere])
                    324:             exit
                    325:           ])
                    326:         ])
                    327:       ])  
                    328:     ])
                    329: fi
                    330: 
                    331: if test -n "$GDBM_LIB"; then
                    332:     AC_ADD_INCLUDE($GDBM_INCLUDE)
                    333:     AC_DEFINE(HAVE_GDBM_H)
                    334:     EXTRA_LIBS="$EXTRA_LIBS $GDBM_LIB"
                    335: fi
                    336: 
                    337: 
                    338: dnl
                    339: dnl iconv check
                    340: dnl
                    341: 
                    342: AC_ARG_ENABLE(i18n, [  --disable-i18n           Disable I18N support], [given_iconv=$enableval])
                    343: if test "$given_iconv" = "no"; then
                    344:   echo "disabled I18N support."
                    345: else
                    346:   AC_CHECK_FUNCS(iconv)
                    347:   AC_CHECK_HEADERS(iconv.h)
                    348: fi
                    349: 
                    350: dnl
                    351: dnl PCRE: select whether to use an external or the bundled PCRE lib
                    352: dnl borrowed from Apache's configure.in.
                    353: dnl
                    354: 
                    355: AC_MSG_NOTICE(Checking use of an external PCRE)
                    356: AC_ARG_WITH(external_pcre, 
                    357:            AS_HELP_STRING([--with-external_pcre[=DIR]],
                    358:                            [Use an external PCRE library instead of the bundled one (default /usr)])
                    359: )
                    360: 
                    361: case $with_external_pcre in
                    362: yes) AC_PATH_PROG([PCRE_CONFIG], [pcre-config], [false]) ;;
                    363:  /*) if test -d "$with_external_pcre" && test -x "$with_external_pcre/bin/pcre-config"; then
                    364:        PCRE_CONFIG=$with_external_pcre/bin/pcre-config
                    365:      elif test -x "$with_external_pcre"; then
                    366:        PCRE_CONFIG=$with_external_pcre
                    367:      fi
                    368: 
                    369:      if $PCRE_CONFIG --version >/dev/null 2>&1; then :; 
                    370:      else
                    371:         PCRE_CONFIG=false
                    372:      fi
                    373:      ;;
                    374: *) PCRE_CONFIG=false ;;
                    375: esac
                    376: 
                    377: if test "$PCRE_CONFIG" != "false"; then
                    378:   PCRE_PATH=`$PCRE_CONFIG --prefix`
                    379:   AC_CHECK_HEADER(["$PCRE_PATH/include/pcre.h"], [ ],[PCRE_CONFIG=false])
                    380: fi
                    381: 
                    382: if test "$PCRE_CONFIG" != "false"; then
                    383:   AC_MSG_NOTICE([using external PCRE library])
                    384:   APR_ADDTO(CFLAGS, [`$PCRE_CONFIG --cflags`])
                    385:   APR_ADDTO(LIBS, [`$PCRE_CONFIG --libs`])
                    386: else
                    387:   AC_MSG_NOTICE([using bundled PCRE regular expression library])
                    388:   APR_ADDTO(INCLUDES, [-Ipcre])
                    389:   APR_ADDTO(LDFLAGS, "[-Lpcre/.libs]")
                    390:   PCRE_DEP="pcre/.libs/libpcre.a"
                    391:   APR_SUBDIR_CONFIG([src/pcre], 
                    392:                     [],
                    393:                    [--with-pcre=*|\'--with-pcre=*])
                    394: fi
                    395: AC_SUBST([PCRE_DEP])
                    396: 
                    397: dnl
                    398: dnl The FNV hash library used for the nonsequential filenames
                    399: dnl
                    400: 
                    401: AC_MSG_CHECKING([whether to use fnv hash library for non-sequential filenames])
                    402: AC_ARG_ENABLE(libfnv, 
                    403:      [     AS_HELP_STRING([--enable-libfnv],
                    404:                            [use the fnv hash library for generating non-sequential filenames [no]])
                    405:      ],
                    406:      [ given_libfnv=$enableval ])
                    407:      
                    408: if test "$given_libfnv" != "yes"; then
                    409:   AC_MSG_RESULT([no])
                    410: else
                    411:   AC_MSG_RESULT([yes])
                    412:   AC_DEFINE([HAVE_LIBFNV])
                    413:   APR_ADDTO(INCLUDES, [-Ifnv])
                    414:   dnl APR_ADDTO(LDFLAGS, "[-Lfnv]")
                    415:   AC_ADD_LIBRARY_WITH_PATH([-lfnv],[src/fnv])
                    416:   FNV_DEP="fnv/libfnv.a"
                    417:   APR_SUBDIR_CONFIG([src/fnv])
                    418: fi
                    419: AC_SUBST(FNV_DEP)
                    420: 
                    421: 
                    422: dnl ===========================================================================
                    423: dnl Checks for libraries.
                    424: dnl nsl socket lib?
                    425: dnl ===========================================================================
                    426: 
                    427: USENSL=no
                    428: AC_CHECK_LIB(socket,gethostbyaddr,result=yes,result=no)
                    429: if test $result = yes; then
                    430:         LIBS="$LIBS -lsocket"
                    431: else
                    432:         AC_CHECK_LIB(socket,gethostbyaddr,result=yes,result=no,-lnsl)
                    433:         if test $result = yes; then
                    434:                 LIBS = "$LIBS -lsocket -lnsl"
                    435:                 USENSL=yes
                    436:         else
                    437:                 AC_CHECK_LIB(socket,inet_addr,result=yes,result=no)
                    438:                 if test $result = yes; then
                    439:                         LIBS="$LIBS -lsocket"
                    440:                 else
                    441:                         AC_CHECK_LIB(socket,inet_addr,result=yes,result=no,-lnsl)
                    442:                         if test $result = yes; then
                    443:                                 LIBS="$LIBS -lsocket -lnsl"
                    444:                                 USENSL=yes
                    445:                         fi
                    446:                 fi
                    447:         fi
                    448: fi
                    449: if test $USENSL != yes; then
                    450:         AC_CHECK_LIB(nsl,inet_addr,result=yes,result=no)
                    451:         if test $result = yes; then
                    452:                 LIBS="$LIBS -lnsl"
                    453:         fi
                    454: fi
                    455: 
                    456: dnl ===========================================================================
                    457: dnl Makefile variable substitution 
                    458: dnl ===========================================================================
                    459: 
                    460: AC_SUBST(HAVE_MEMMOVE)
                    461: AC_SUBST(HAVE_STRERROR)
                    462: AC_SUBST(LDFLAGS)
                    463: AC_SUBST(LIBS)
                    464: AC_SUBST(EXTRA_LIBS)
                    465: AC_SUBST(INCLUDES)
                    466: 
                    467: AC_CONFIG_FILES([Makefile archive/Makefile docs/Makefile libcgi/Makefile src/Makefile tests/testhm src/defaults.h])
                    468: AC_OUTPUT
                    469: 

Webmaster