1#
2# File:   configure.in
3# Author: James Couzens <jcouzens@codeshare.ca>
4# Date:   June 15, 2004
5#
6# Info:   'AutoTools' framework for building a configure script
7#          for libSPF
8#
9#
10#          oooo   o8o   .o8        .oooooo..o ooooooooo.   oooooooooooo
11#          `888   `"'  "888       d8P'    `Y8 `888   `Y88. `888'     `8
12#           888  oooo   888oooo.  Y88bo.       888   .d88'  888
13#           888  `888   d88' `88b  `"Y8888o.   888ooo88P'   888oooo8
14#           888   888   888   888      `"Y88b  888          888    "
15#           888   888   888   888 oo     .d8P  888          888
16#          o888o o888o  `Y8bod8P' 8""88888P'  o888o        o888o
17#
18#-------------------------------------------------------------------------------
19#           An ANSI C Implementation of the Sender Policy Framework
20#-------------------------------------------------------------------------------
21
22AC_PREREQ(2.52)
23AC_INIT(libspf,1.0.0-p5,jcouzens@codeshare.ca)
24AC_CONFIG_AUX_DIR([build_tools])
25AM_INIT_AUTOMAKE(libspf,1.0.0-p5,jcouzens@codeshare.ca)
26PACKAGE=$PACKAGE_NAME
27VERSION=$PACKAGE_VERSION
28
29
30#-------------------------------------------------------------------------------
31# Required programs
32#-------------------------------------------------------------------------------
33
34AM_CONFIG_HEADER([config.h])
35#AC_CONFIG_SRCDIR([src/libspf/main.c])
36
37AC_PROG_CC
38AC_PROG_LN_S
39AC_PROG_RANLIB
40#AC_ARG_PROGRAM
41AC_PROG_MAKE_SET
42AC_PROG_CPP
43AC_PROG_INSTALL
44AM_CONDITIONAL(GCC, test x$GCC = xyes)
45
46# Auto Make
47#AM_MAINTAINER_MODE
48
49
50#-------------------------------------------------------------------------------
51# LIBTOOL
52#-------------------------------------------------------------------------------
53
54AC_PROG_LIBTOOL
55AC_SUBST(enable_shared)
56AC_SUBST(enable_static)
57AC_SUBST(LIBTOOL_DEPS)
58
59#
60#  Making releases:
61#    LIBSPF_MICRO_VERSION += 1;
62#    LIBSPF_INTERFACE_AGE += 1;
63#    LIBSPF_BINARY_AGE += 1;
64#  if any functions have been added, set LIBSPF_INTERFACE_AGE to 0.
65#  if backwards compatibility has been broken,
66#  set LIBSPF_BINARY_AGE _and_ LIBSPF_INTERFACE_AGE to 0.
67#
68
69LIBSPF_MAJOR_VERSION=1
70LIBSPF_MINOR_VERSION=0
71LIBSPF_MICRO_VERSION=0
72LIBSPF_INTERFACE_AGE=1
73LIBSPF_BINARY_AGE=1
74LIBSPF_VERSION=$LIBSPF_MAJOR_VERSION.$LIBSPF_MINOR_VERSION.$LIBSPF_MICRO_VERSION
75
76AC_SUBST(LIBSPF_MAJOR_VERSION)
77AC_SUBST(LIBSPF_MINOR_VERSION)
78AC_SUBST(LIBSPF_MICRO_VERSION)
79AC_SUBST(LIBSPF_VERSION)
80AC_SUBST(LIBSPF_INTERFACE_AGE)
81AC_SUBST(LIBSPF_BINARY_AGE)
82
83#  -version-info "$(LT_CURRENT):$(LT_REVISION):$(LT_AGE)" \
84#  -release $(LT_RELEASE)
85#  libtool versioning
86
87LT_CURRENT="0"
88LT_REVISION="26"
89LT_AGE="0"
90LT_RELEASE="1.0"
91
92echo ""
93echo "--------------------------------------------------------------------------------"
94echo ""
95echo "LIBTOOL Version ........ ${LIBSPF_MAJOR_VERSION}.${LIBSPF_MINOR_VERSION}.${LIBSPF_MICRO_VERSION}"
96echo "LIBTOOL Interface Age .. $LIBSPF_INTERFACE_AGE"
97echo "LIBTOOL Binary Age ..... $LIBSPF_BINARY_AGE"
98echo "LIBTOOL Current ........ $LT_CURRENT"
99echo "LIBTOOL Revision ....... $LT_REVISION"
100echo "LIBTOOL Age ............ $LT_AGE"
101echo "LIBTOOL Release ........ $LT_RELEASE"
102echo ""
103echo "--------------------------------------------------------------------------------"
104echo ""
105
106
107#-------------------------------------------------------------------------------
108# LIBTOOL relating substitutionssn
109#-------------------------------------------------------------------------------
110
111AC_SUBST(LT_RELEASE)
112AC_SUBST(LT_CURRENT)
113AC_SUBST(LT_REVISION)
114AC_SUBST(LT_AGE)
115
116
117#-------------------------------------------------------------------------------
118# Check for some library functions
119#-------------------------------------------------------------------------------
120
121AC_CHECK_LIB([c], [exit])
122AC_CHECK_LIB([nsl], [inet_pton])
123AC_CHECK_LIB([socket], [socket])
124
125AC_CHECK_LIB([spf2], [SPF_sanitize], LIBSPF2_POOPOO="true")
126if test "$LIBSPF2_POOPOO" ; then
127  AC_MSG_WARN(["My word, what is that awful stench!?  Oh its libspf2"])
128  AC_MSG_WARN(["Thanks to these trolls I have no second versioning"])
129  AC_MSG_WARN(["number... http://moscow.6o4.ca/ for more info"])
130fi
131
132
133#-------------------------------------------------------------------------------
134# Check up on GCC
135#-------------------------------------------------------------------------------
136
137# We don't want gcc 2.7
138AC_MSG_CHECKING([for a supported version of gcc])
139
140gcc_version=`${CC} --version | head -n 1`
141gcc_special_cflags=""
142case "${gcc_version}" in
143		2.7.*)
144			AC_MSG_RESULT([no (${gcc_version})])
145			AC_MSG_ERROR([please use a recent (>= gcc-2.95) version of gcc])
146			;;
147		2.95.*)
148			AC_MSG_RESULT([yes (${gcc_version}) using %d instead of %zu])
149      AC_SUBST(UNSIGNED_INT_ARG, "%d")
150      gcc_special_cflags="-mcpu=pentium -malign-loops=5 -malign-jumps=5 -malign-functions=5"
151			;;
152    3.*)
153      AC_MSG_RESULT([yes (${gcc_version}) using -falign instead of -malign])
154      AC_SUBST(UNSIGNED_INT_ARG, "%zu")
155      gcc_special_cflags="-mcpu=pentium -falign-loops=5 -falign-jumps=5 -falign-functions=5"
156			;;
157    4.*)
158      AC_MSG_RESULT([yes (${gcc_version}) using -falign instead of -malign])
159      AC_SUBST(UNSIGNED_INT_ARG, "%zu")
160      gcc_special_cflags="-mcpu=pentium -falign-loops=5 -falign-jumps=5 -falign-functions=5"
161			;;
162		*)
163			AC_MSG_RESULT([ok (${gcc_version})])
164      AC_SUBST(UNSIGNED_INT_ARG, "%zu")
165			;;
166esac
167
168
169#-------------------------------------------------------------------------------
170# Define special resolver flags for various operating systems
171#-------------------------------------------------------------------------------
172
173case "$host" in
174  *-*-darwin*)
175    AC_DEFINE([_WITH_DARWINPPC],[],["Darwin/OSX"])
176    ;;
177  *-*-sunos4.1.1*)
178    LIBSPF_RESOLV_LIB="-lnsl -lsocket"
179    ;;
180  *-*-solaris*)
181    extralibflags="-R$libdir"
182    AC_MSG_WARN(Solaris install detected.  Using extralibflags for linking: $extralibflags)
183    LIBSPF_RESOLV_LIB="-lnsl -lsocket"
184    ;;
185  *-*-sunos*)
186    LIBSPF_RESOLV_LIB="-lnsl -lsocket"
187    ;;
188  *-*-freebsd*|*-*-dragonfly*)
189    AC_DEFINE([_WITH_FREEBSD],[],["FreeBSD"])
190    LIBSPF_RESOLV_LIB="-lc"
191    ;;
192  *-*-netbsd*)
193    ;;
194  *-*-openbsd*)
195    AC_DEFINE([_WITH_OPENBSD],[],["OpenBSD"])
196    ;;
197  *)
198    extralibflags=""
199    LIBSPF_RESOLV_LIB="-lresolv"
200   ;;
201esac
202#AC_DEFINE_UNQUOTED(LIBSPF_RESOLV_LIB,"$LIBSPF_RESOLV_LIB","")
203
204#-------------------------------------------------------------------------------
205# Checks for header files.
206#-------------------------------------------------------------------------------
207
208AC_HEADER_STDC
209AC_CHECK_HEADERS([arpa/inet.h, netdb.h, netinet/in.h, stdlib.h, \
210  string.h, strings.h, sys/socket.h unistd.h, error.h, inttypes.h])
211
212
213#-------------------------------------------------------------------------------
214# Required Types, structures and other compiler requirements
215#-------------------------------------------------------------------------------
216
217AC_C_CONST
218AC_C_INLINE
219AC_TYPE_SIZE_T
220AC_STRUCT_TM
221AC_C_CHAR_UNSIGNED
222AC_CHECK_TYPES([u_char, time_t])
223
224
225#-------------------------------------------------------------------------------
226#  Required functions
227#-------------------------------------------------------------------------------
228
229AC_FUNC_MALLOC
230AC_FUNC_REALLOC
231AC_FUNC_STRFTIME
232AC_CHECK_FUNCS([gethostbyname, inet_ntoa, memset, strcasecmp,  \
233  localtime_r, strchr, strdup, strrchr, strstr, mkdir])
234
235
236#-------------------------------------------------------------------------------
237# __BEGIN_DECLS / __END_DECLS defined ?
238#-------------------------------------------------------------------------------
239
240AC_MSG_CHECKING([__BEGIN_DECLS])
241AC_COMPILE_IFELSE([
242#include <features.h>
243__BEGIN_DECLS
244extern int x;
245__END_DECLS],
246  [AC_MSG_RESULT(yes)
247   AC_DEFINE(HAVE__BEGIN_DECLS,1,
248[Define to 1 if declarations in headers are surrounded by __{BEGIN,END}_DECLS])
249   AC_SUBST(__BEGIN_DECLS,__BEGIN_DECLS)
250   AC_SUBST(__END_DECLS,__END_DECLS)],
251  [AC_MSG_RESULT(no)
252   AC_SUBST_FILE(__BEGIN_DECLS_INCL)
253   __BEGIN_DECLS_INCL=$srcdir/conf/begin_decls
254   AC_SUBST_FILE(__END_DECLS_INCL)
255   __END_DECLS_INCL=$srcdir/conf/end_decls]
256)
257
258
259#-------------------------------------------------------------------------------
260# Unsigned int types
261#-------------------------------------------------------------------------------
262
263dnl AC_COMPILE_CHECK_SIZEOF (TYPE SUPPOSED-SIZE)
264dnl abort if the given type does not have the supposed size
265AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
266    [AC_MSG_CHECKING(that size of $1 is $2)
267    AC_TRY_COMPILE([],[switch (0) case 0: case (sizeof ($1) == $2):;],[],
268        [AC_MSG_ERROR([can not build a default inttypes.h])])
269    AC_MSG_RESULT([yes])])
270
271dnl Our own version of AC_CHECK_SIZEOF(int); fixes a bug when sizeof() can't
272dnl be printed with "%d", and avoids a warning for cross-compiling.
273
274AC_MSG_CHECKING(size of int)
275AC_CACHE_VAL(ac_cv_sizeof_int,
276	[AC_TRY_RUN([#include <stdio.h>
277		main()
278		{
279		  FILE *f=fopen("conftestval", "w");
280		  if (!f) exit(1);
281		  fprintf(f, "%d\n", (int)sizeof(int));
282		  exit(0);
283		}],
284	    ac_cv_sizeof_int=`cat conftestval`,
285	    ac_cv_sizeof_int=0,
286	    AC_MSG_ERROR(failed to compile test program))])
287AC_MSG_RESULT($ac_cv_sizeof_int)
288AC_DEFINE_UNQUOTED(SIZEOF_INT, [$ac_cv_sizeof_int], [Check to fix sizeof bug that can't print %d])
289#AC_DEFINE([SIZEOF_INT], [$ac_cv_sizeof_int], [Check to fix sizeof bug that can't print %d])
290
291AC_DEFUN([AC_CREATE_STDINT_H],
292[# ------ AC CREATE STDINT H -------------------------------------
293AC_MSG_CHECKING([for stdint-types....])
294ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
295if test "$ac_stdint_h" = "stdint.h" ; then
296 AC_MSG_RESULT("(are you sure you want them in ./stdint.h?)")
297elif test "$ac_stdint_h" = "inttypes.h" ; then
298 AC_MSG_RESULT("(are you sure you want them in ./inttypes.h?)")
299else
300 AC_MSG_RESULT("(putting them into $ac_stdint_h)")
301fi
302
303inttype_headers=`echo inttypes.h sys/inttypes.h sys/inttypes.h $2 \
304| sed -e 's/,/ /g'`
305
306 ac_cv_header_stdint_x="no-file"
307 ac_cv_header_stdint_o="no-file"
308 ac_cv_header_stdint_u="no-file"
309 for i in stdint.h $inttype_headers ; do
310   unset ac_cv_type_uintptr_t
311   unset ac_cv_type_uint64_t
312   _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
313     continue,[#include <$i>])
314   AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
315   AC_MSG_RESULT(... seen our uintptr_t in $i $and64)
316   break;
317 done
318 if test "$ac_cv_header_stdint_x" = "no-file" ; then
319 for i in stdint.h $inttype_headers ; do
320   unset ac_cv_type_uint32_t
321   unset ac_cv_type_uint64_t
322   AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
323     continue,[#include <$i>])
324   AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
325   AC_MSG_RESULT(... seen our uint32_t in $i $and64)
326   break;
327 done
328 if test "$ac_cv_header_stdint_o" = "no-file" ; then
329 for i in sys/types.h $inttype_headers ; do
330   unset ac_cv_type_u_int32_t
331   unset ac_cv_type_u_int64_t
332   AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
333     continue,[#include <$i>])
334   AC_CHECK_TYPE(uint64_t,[and64="(u_int64_t too)"],[and64=""],[#include<$i>])
335   AC_MSG_RESULT(... seen our u_int32_t in $i $and64)
336   break;
337 done
338 fi
339 fi
340
341# ----------------- DONE inttypes.h checks MAYBE C basic types --------
342
343if test "$ac_cv_header_stdint_x" = "no-file" ; then
344   AC_COMPILE_CHECK_SIZEOF(char)
345   AC_COMPILE_CHECK_SIZEOF(short)
346   AC_COMPILE_CHECK_SIZEOF(int)
347   AC_COMPILE_CHECK_SIZEOF(long)
348   AC_COMPILE_CHECK_SIZEOF(void*)
349   ac_cv_header_stdint_test="yes"
350else
351   ac_cv_header_stdint_test="no"
352fi
353
354# ----------------- DONE inttypes.h checks START header -------------
355_ac_stdint_h=AS_TR_CPP(_$ac_stdint_h)
356AC_MSG_RESULT(creating $ac_stdint_h : $_ac_stdint_h)
357echo "#ifndef" $_ac_stdint_h >$ac_stdint_h
358echo "#define" $_ac_stdint_h "1" >>$ac_stdint_h
359echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint_h
360echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint_h
361if test "$GCC" = "yes" ; then
362  echo "/* generated using a gnu compiler version" `$CC --version` "*/" \
363  >>$ac_stdint_h
364else
365  echo "/* generated using $CC */" >>$ac_stdint_h
366fi
367echo "" >>$ac_stdint_h
368
369if test "$ac_cv_header_stdint_x" != "no-file" ; then
370   ac_cv_header_stdint="$ac_cv_header_stdint_x"
371elif  test "$ac_cv_header_stdint_o" != "no-file" ; then
372   ac_cv_header_stdint="$ac_cv_header_stdint_o"
373elif  test "$ac_cv_header_stdint_u" != "no-file" ; then
374   ac_cv_header_stdint="$ac_cv_header_stdint_u"
375else
376   ac_cv_header_stdint="stddef.h"
377fi
378
379# ----------------- See if int_least and int_fast types are present
380unset ac_cv_type_int_least32_t
381unset ac_cv_type_int_fast32_t
382AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
383AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
384
385if test "$ac_cv_header_stdint" != "stddef.h" ; then
386if test "$ac_cv_header_stdint" != "stdint.h" ; then
387AC_MSG_RESULT(..adding include stddef.h)
388   echo "#include <stddef.h>" >>$ac_stdint_h
389fi ; fi
390AC_MSG_RESULT(..adding include $ac_cv_header_stdint)
391   echo "#include <$ac_cv_header_stdint>" >>$ac_stdint_h
392echo "" >>$ac_stdint_h
393
394# ----------------- DONE header START basic int types -------------
395if test "$ac_cv_header_stdint_x" = "no-file" ; then
396   AC_MSG_RESULT(... need to look at C basic types)
397dnl ac_cv_header_stdint_test="yes" # moved up before creating the file
398else
399   AC_MSG_RESULT(... seen good stdint.h inttypes)
400dnl ac_cv_header_stdint_test="no"  # moved up before creating the file
401fi
402
403if test "$ac_cv_header_stdint_u" != "no-file" ; then
404   AC_MSG_RESULT(... seen bsd/sysv typedefs)
405   cat >>$ac_stdint_h <<EOF
406
407/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
408typedef u_int8_t uint8_t;
409typedef u_int16_t uint16_t;
410typedef u_int32_t uint32_t;
411EOF
412    cat >>$ac_stdint_h <<EOF
413
414/* glibc compatibility */
415#ifndef __int8_t_defined
416#define __int8_t_defined
417#endif
418EOF
419fi
420
421ac_cv_sizeof_x="$ac_cv_sizeof_char:$ac_cv_sizeof_short"
422ac_cv_sizeof_X="$ac_cv_sizeof_x:$ac_cv_sizeof_int"
423ac_cv_sizeof_X="$ac_cv_sizeof_X:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long"
424if test "$ac_cv_header_stdint" = "stddef.h" ; then
425#   we must guess all the basic types. Apart from byte-adressable system,
426# there a few 32-bit-only dsp-systems. nibble-addressable systems are way off.
427    cat >>$ac_stdint_h <<EOF
428/* ------------ BITSPECIFIC INTTYPES SECTION --------------- */
429EOF
430    t="typedefs for a"
431    case "$ac_cv_sizeof_X" in
432     1:2:2:2:4) AC_MSG_RESULT(..adding $t normal 16-bit system)
433                cat >>$ac_stdint_h <<EOF
434/*              a normal 16-bit system                       */
435typedef unsigned char   uint8_t;
436typedef unsigned short  uint16_t;
437typedef unsigned long   uint32_t;
438#ifndef __int8_t_defined
439#define __int8_t_defined
440typedef          char    int8_t;
441typedef          short   int16_t;
442typedef          long    int32_t;
443#endif
444EOF
445;;
446     1:2:2:4:4) AC_MSG_RESULT(..adding $t 32-bit system derived from a 16-bit)
447                cat >>$ac_stdint_h <<EOF
448/*              a 32-bit system derived from a 16-bit        */
449typedef unsigned char   uint8_t;
450typedef unsigned short  uint16_t;
451typedef unsigned int    uint32_t;
452#ifndef __int8_t_defined
453#define __int8_t_defined
454typedef          char    int8_t;
455typedef          short   int16_t;
456typedef          int     int32_t;
457#endif
458EOF
459;;
460     1:2:4:4:4) AC_MSG_RESULT(..adding $t normal 32-bit system)
461                cat >>$ac_stdint_h <<EOF
462/*              a normal 32-bit system                       */
463typedef unsigned char   uint8_t;
464typedef unsigned short  uint16_t;
465typedef unsigned int    uint32_t;
466#ifndef __int8_t_defined
467#define __int8_t_defined
468typedef          char    int8_t;
469typedef          short   int16_t;
470typedef          int     int32_t;
471#endif
472EOF
473;;
474     1:2:4:4:8) AC_MSG_RESULT(..adding $t 32-bit system prepared for 64-bit)
475                cat >>$ac_stdint_h <<EOF
476
477/*              a 32-bit system prepared for 64-bit          */
478typedef unsigned char   uint8_t;
479typedef unsigned short  uint16_t;
480typedef unsigned int    uint32_t;
481#ifndef __int8_t_defined
482#define __int8_t_defined
483typedef          char    int8_t;
484typedef          short   int16_t;
485typedef          int     int32_t;
486#endif
487EOF
488;;
489     1:2:4:8:8) AC_MSG_RESULT(..adding $t normal 64-bit system)
490                cat >>$ac_stdint_h <<EOF
491
492/*              a normal 64-bit system                       */
493typedef unsigned char   uint8_t;
494typedef unsigned short  uint16_t;
495typedef unsigned int    uint32_t;
496#ifndef __int8_t_defined
497#define __int8_t_defined
498typedef          char    int8_t;
499typedef          short   int16_t;
500typedef          int     int32_t;
501#endif
502EOF
503;;
504     1:2:4:8:4) AC_MSG_RESULT(..adding $t 64-bit system derived from a 32-bit)
505                cat >>$ac_stdint_h <<EOF
506
507/*              a 64-bit system derived from a 32-bit system */
508typedef unsigned char   uint8_t;
509typedef unsigned short  uint16_t;
510typedef unsigned int    uint32_t;
511#ifndef __int8_t_defined
512#define __int8_t_defined
513typedef          char    int8_t;
514typedef          short   int16_t;
515typedef          int     int32_t;
516#endif
517EOF
518;;
519  *)
520    AC_MSG_ERROR([ $ac_cv_sizeof_X dnl
521 what is that a system? contact the author, quick! http://ac-archive.sf.net])
522    exit 1
523;;
524   esac
525fi
526
527# ------------- DONE basic int types START int64_t types ------------
528if test "$ac_cv_type_uint64_t" = "yes"
529then AC_MSG_RESULT(... seen good uint64_t)
530     cat >>$ac_stdint_h <<EOF
531
532/* system headers have good uint64_t */
533#ifndef _HAVE_UINT64_T
534#define _HAVE_UINT64_T
535#endif
536EOF
537
538elif test "$ac_cv_type_u_int64_t" = "yes"
539then AC_MSG_RESULT(..adding typedef u_int64_t uint64_t)
540     cat >>$ac_stdint_h <<EOF
541
542/* system headers have an u_int64_t */
543#ifndef _HAVE_UINT64_T
544#define _HAVE_UINT64_T
545typedef u_int64_t uint64_t;
546#endif
547EOF
548else AC_MSG_RESULT(..adding generic uint64_t runtime checks)
549     cat >>$ac_stdint_h <<EOF
550
551/* -------------------- 64 BIT GENERIC SECTION -------------------- */
552/* here are some common heuristics using compiler runtime specifics */
553#if defined __STDC_VERSION__ && defined __STDC_VERSION__ > 199901L
554
555#ifndef _HAVE_UINT64_T
556#define _HAVE_UINT64_T
557typedef long long int64_t;
558typedef unsigned long long uint64_t;
559#endif
560
561#elif !defined __STRICT_ANSI__
562#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
563
564#ifndef _HAVE_UINT64_T
565#define _HAVE_UINT64_T
566typedef __int64 int64_t;
567typedef unsigned __int64 uint64_t;
568#endif
569
570#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
571dnl /* note: all ELF-systems seem to have loff-support which needs 64-bit */
572
573#if !defined _NO_LONGLONG
574#ifndef _HAVE_UINT64_T
575#define _HAVE_UINT64_T
576typedef long long int64_t;
577typedef unsigned long long uint64_t;
578#endif
579#endif
580
581#elif defined __alpha || (defined __mips && defined _ABIN32)
582
583#if !defined _NO_LONGLONG
584#ifndef _HAVE_UINT64_T
585#define _HAVE_UINT64_T
586typedef long int64_t;
587typedef unsigned long uint64_t;
588#endif
589#endif
590  /* compiler/cpu type ... or just ISO C99 */
591#endif
592#endif
593EOF
594
595# plus a default 64-bit for systems that are likely to be 64-bit ready
596  case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long" in
597    1:2:8:8) AC_MSG_RESULT(..adding uint64_t default, normal 64-bit system)
598cat >>$ac_stdint_h <<EOF
599/* DEFAULT: */
600/* seen normal 64-bit system, CC has sizeof(long and void*) == 8 bytes */
601#ifndef _HAVE_UINT64_T
602#define _HAVE_UINT64_T
603typedef long int64_t;
604typedef unsigned long uint64_t;
605#endif
606EOF
607;;
608    1:2:4:8) AC_MSG_RESULT(..adding uint64_t default, typedef to long)
609cat >>$ac_stdint_h <<EOF
610/* DEFAULT: */
611/* seen 32-bit system prepared for 64-bit, CC has sizeof(long) == 8 bytes */
612#ifndef _HAVE_UINT64_T
613#define _HAVE_UINT64_T
614typedef long int64_t;
615typedef unsigned long uint64_t;
616#endif
617EOF
618;;
619    1:2:8:4) AC_MSG_RESULT(..adding uint64_t default, typedef long long)
620cat >>$ac_stdint_h <<EOF
621/* DEFAULT: */
622/* seen 64-bit derived from a 32-bit, CC has sizeof(long) == 4 bytes */
623#ifndef _HAVE_UINT64_T
624#define _HAVE_UINT64_T
625typedef long long int64_t;
626typedef unsigned long long uint64_t;
627#endif
628EOF
629;;
630   *)
631cat >>$ac_stdint_h <<EOF
632/* NOTE: */
633/* the configure-checks for the basic types did not make us believe */
634/* that we could add a fallback to a 'long long' typedef to int64_t */
635EOF
636  esac
637fi
638
639# ------------- DONE int64_t types START intptr types ------------
640if test "$ac_cv_header_stdint_x" = "no-file" ; then
641  cat >>$ac_stdint_h <<EOF
642
643/* -------------------------- INPTR SECTION --------------------------- */
644EOF
645  case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp" in
646  1:2:2)
647    a="int16_t" ; cat >>$ac_stdint_h <<EOF
648/* we tested sizeof(void*) to be of 2 chars, hence we declare it 16-bit */
649
650typedef uint16_t uintptr_t;
651typedef  int16_t  intptr_t;
652EOF
653;;
654  1:2:4)
655    a="int32_t" ; cat >>$ac_stdint_h <<EOF
656/* we tested sizeof(void*) to be of 4 chars, hence we declare it 32-bit */
657
658typedef uint32_t uintptr_t;
659typedef  int32_t  intptr_t;
660EOF
661;;
662  1:2:8)
663    a="int64_t" ; cat >>$ac_stdint_h <<EOF
664/* we tested sizeof(void*) to be of 8 chars, hence we declare it 64-bit */
665
666typedef uint64_t uintptr_t;
667typedef  int64_t  intptr_t;
668EOF
669;;
670  *)
671    a="long" ; cat >>$ac_stdint_h <<EOF
672/* we tested sizeof(void*) but got no guess, hence we declare it as if long */
673
674typedef unsigned long uintptr_t;
675typedef          long  intptr_t;
676EOF
677;;
678  esac
679AC_MSG_RESULT(..adding typedef $a intptr_t)
680fi
681
682# ------------- DONE intptr types START int_least types ------------
683if test "$ac_cv_type_int_least32_t" = "no"; then
684AC_MSG_RESULT(..adding generic int_least-types)
685     cat >>$ac_stdint_h <<EOF
686
687/* --------------GENERIC INT_LEAST ------------------ */
688
689typedef  int8_t    int_least8_t;
690typedef  int16_t   int_least16_t;
691typedef  int32_t   int_least32_t;
692#ifdef _HAVE_UINT64_T
693typedef  int64_t   int_least64_t;
694#endif
695
696typedef uint8_t   uint_least8_t;
697typedef uint16_t  uint_least16_t;
698typedef uint32_t  uint_least32_t;
699#ifdef _HAVE_UINT64_T
700typedef uint64_t  uint_least64_t;
701#endif
702EOF
703fi
704
705# ------------- DONE intptr types START int_least types ------------
706if test "$ac_cv_type_int_fast32_t" = "no"; then
707AC_MSG_RESULT(..adding generic int_fast-types)
708     cat >>$ac_stdint_h <<EOF
709
710/* --------------GENERIC INT_FAST ------------------ */
711
712typedef  int8_t    int_fast8_t;
713typedef  int32_t   int_fast16_t;
714typedef  int32_t   int_fast32_t;
715#ifdef _HAVE_UINT64_T
716typedef  int64_t   int_fast64_t;
717#endif
718
719typedef uint8_t   uint_fast8_t;
720typedef uint32_t  uint_fast16_t;
721typedef uint32_t  uint_fast32_t;
722#ifdef _HAVE_UINT64_T
723typedef uint64_t  uint_fast64_t;
724#endif
725EOF
726fi
727
728if test "$ac_cv_header_stdint_x" = "no-file" ; then
729     cat >>$ac_stdint_h <<EOF
730
731#ifdef _HAVE_UINT64_T
732typedef int64_t        intmax_t;
733typedef uint64_t      uintmax_t;
734#else
735typedef long int       intmax_t;
736typedef unsigned long uintmax_t;
737#endif
738EOF
739fi
740
741AC_MSG_RESULT(... DONE $ac_stdint_h)
742   cat >>$ac_stdint_h <<EOF
743
744  /* once */
745#endif
746#endif
747EOF
748])
749
750AC_CREATE_STDINT_H(src/libspf/_stdint.h)
751
752dnl quote from SunOS-5.8 sys/inttypes.h:
753dnl Use at your own risk.  As of February 1996, the committee is squarely
754dnl behind the fixed sized types; the "least" and "fast" types are still being
755dnl discussed.  The probability that the "fast" types may be removed before
756dnl the standard is finalized is high enough that they are not currently
757dnl implemented.
758
759#AC_CHECK_TYPE(u_int8_t, [uint="u_int8_t"
760#  AC_DEFINE(HAVE_U_INT8_T,1,[Define to 1 if type `u_int8_t' is defined])],
761#  AC_CHECK_TYPE(uint8_t, [uint="uint8_t"
762#    AC_DEFINE(HAVE_UINT8_T,1,[Define to 1 if type `uint8_t' is defined])],
763#    [uint="unsigned char"]))
764#AC_SUBST(U_INT8_T,[$uint])
765
766#AC_CHECK_TYPE(u_int16_t, [uint="u_int16_t"
767#  AC_DEFINE(HAVE_U_INT16_T,1,[Define to 1 if type `u_int16_t' is defined])],
768#  AC_CHECK_TYPE(uint16_t, [uint="uint16_t"
769#    AC_DEFINE(HAVE_UINT16_T,1,[Define to 1 if type `uint16_t' is defined])],
770#    [uint="unsigned short"]))
771#AC_SUBST(U_INT16_T,[$uint])
772
773#AC_CHECK_TYPE(u_int32_t, [uint="u_int32_t"
774#  AC_DEFINE(HAVE_U_INT32_T,1,[Define to 1 if type `u_int32_t' is defined])],
775#  AC_CHECK_TYPE(uint32_t, [uint="uint32_t"
776#    AC_DEFINE(HAVE_UINT32_T,1,[Define to 1 if type `uint32_t' is defined])],
777#    [uint="unsigned int"]))
778#AC_SUBST(U_INT32_T,[$uint])
779
780#AC_CHECK_TYPE(uintptr_t, [uint="uintptr_t"
781#  AC_DEFINE(HAVE_UINTPTR_T,1,[Define to 1 if type `uintptr_t' is defined])])
782#AC_SUBST(UINTPTR_T,[$uint])
783
784
785#-------------------------------------------------------------------------------
786# __FUNCTION__
787#-------------------------------------------------------------------------------
788
789AC_MSG_CHECKING([__FUNCTION__])
790func=none
791AC_COMPILE_IFELSE(
792  [int x() { f(__FUNCTION__); }],
793  AC_MSG_RESULT([__FUNCTION__])
794  AC_DEFINE(HAVE___FUNCTION__, [], ["Define to 1 if __FUNCTION__ is defined"]),
795  AC_COMPILE_IFELSE(
796    [int x() { f(__func__); }],
797    AC_MSG_RESULT([__func__])
798    AC_DEFINE(HAVE___FUNC__, [], ["Define to 1 if __func__ is defined"])))
799
800
801#-------------------------------------------------------------------------------
802# Setup build directories
803#-------------------------------------------------------------------------------
804
805LIBSPF_BUILD_DIRS="libspf spfqtool"
806
807
808#-------------------------------------------------------------------------------
809# Warn people configuring as root....
810#-------------------------------------------------------------------------------
811
812idcommand="id -u"
813if test `$idcommand` == "0"
814then
815  AC_MSG_WARN(=== DO NOT EVER CONFIGURE AS ROOT  ===)
816  AC_MSG_WARN(=== UNLESS EXPLICITLY EXPRESSED BY ===)
817  AC_MSG_WARN(=== SUPPLIED DOCUMENTATION FROM A  ===)
818  AC_MSG_WARN(=== REPUTABLE AUTHOR! Baka!        ===)
819fi
820
821
822#-------------------------------------------------------------------------------
823# Check to see if we want to link libbind
824#-------------------------------------------------------------------------------
825
826AC_MSG_CHECKING(whether to link libbind is eanbled)
827AC_ARG_ENABLE(libbind,
828[  --enable-libbind          Link libbind instead of libresolv (default=no)],
829[case "${enableval}" in
830  yes)
831    libbind=true
832    AC_MSG_RESULT(yes)
833    ;;
834  no)
835    libbind=false
836    AC_MSG_RESULT(no)
837    ;;
838  *)
839    AC_MSG_ERROR(bad value ${enableval} for --enable-libbind)
840    ;;
841esac],
842[libbind=false]; AC_MSG_RESULT(no))
843
844if test "$libbind" = "true"; then
845  LIBSPF_RESOLV_LIB="-lbind"
846fi
847
848if test "$libresolv" = "false"; then
849  LIBSPF_RESOLV_LIB=""
850else
851
852  #----------------------------------------------------------------------------
853  # Check to see if we want to link libresolv (default is yes)
854  #------------------------------------------------------------------
855
856  dnl res_query has been seen in libc, libbind and libresolv
857  AC_CHECK_FUNCS(res_query, res_search)
858
859  if test "x-$ac_cv_func_res_query" = "x-yes" ; then
860    have_res_query=yes
861  fi
862
863  if test "x-$ac_cv_func_res_search" = "x-yes" ; then
864    have_res_search=yes
865  fi
866
867  if test "x-$have_res_query" = "x-no" || test "x-$have_res_search" = "no" ; then
868    AC_CHECK_LIB(resolv, res_query)
869    if test "x-$ac_cv_lib_resolv_res_query" = "x-yes" ; then
870        have_res_query=yes
871    else
872      AC_CHECK_LIB(bind, res_query)
873      if test "x-$ac_cv_lib_bind_res_query" = "x-yes" ; then
874        have_res_query=yes
875      else
876        dnl some glibcs have res_query as a macro, so work around it
877        AC_MSG_CHECKING([for res_query in -lresolv (alternate version)])
878        save_libs="$LIBS"
879        libresolv=true
880        LIBS="-lresolv $LIBS"
881        LIBSPF_RESOLV_LIB="-lresolv"
882          AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <resolv.h>]],
883          [[res_query(0,0,0,0,0)]])],
884            [AC_MSG_RESULT(yes)
885            have_res_query=yes],
886          [AC_MSG_RESULT(no)
887          libresolv=false
888          LIBS="$save_libs"])
889      fi
890    fi
891  fi
892
893  if test "x-$have_res_query" = "x-yes" ; then
894    AC_DEFINE(HAVE_RES_QUERY)
895    libresolv=true
896  dnl no res_query, do windows compat checks
897  else
898    dnl !!! implement these checks
899    AC_MSG_WARN([required function res_query not found])
900    libresolv=false
901  fi
902
903fi
904
905# Checks for libraries.
906AC_CHECK_LIB([resolv], [res_search])
907AC_SUBST(LIBSPF_RESOLV_LIB)
908
909
910#-------------------------------------------------------------------------------
911# Check to see if we want to enable debugging
912#-------------------------------------------------------------------------------
913
914AC_MSG_CHECKING(whether DEBUG is eanbled)
915AC_ARG_ENABLE(debug,
916[  --enable-debug            Enables debug option (default=no)],
917[case "${enableval}" in
918  yes)
919    debug=true
920    AC_MSG_RESULT(yes)
921    ;;
922  no)
923    debug=false
924    AC_MSG_RESULT(no)
925    ;;
926  *)
927    AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
928    ;;
929esac],
930[debug=false]; AC_MSG_RESULT(no))
931
932if test "$debug" = "true"; then
933  CFLAGS="$CFLAGS -D_SPF_DEBUG"
934else
935  AC_MSG_RESULT(Enabling GCC optimisations)
936
937  if [[ "x$GCC_VERSION" = "x3" ]]; then
938    AC_MSG_RESULT(Enabling GCC v3 optimizations)
939    CFLAGS="$CFLAGS -minline-all-stringops -fno-math-errno"
940  fi
941fi
942
943case "${host_cpu}" in
944	i?86)
945		AC_MSG_RESULT([CPU: ${host_cpu}; Enabling pentium optimisations])
946		# cannot do malign-double as we link to other libraries and it
947		# would break binary compatibility
948		CFLAGS="$CFLAGS ${gcc_special_cflags}"
949	  ;;
950	*)
951		AC_MSG_RESULT(Please e-mail author optimizations for this cpu)
952		;;
953esac
954
955
956#-------------------------------------------------------------------------------
957# Check to see if we want to enable debugging output to logfile
958#-------------------------------------------------------------------------------
959
960if test "$debug" = "true"; then
961  AC_MSG_CHECKING(whether you want debug output to a logfile)
962  AC_ARG_ENABLE(debug_logfile,
963  [  --enable-debug-logfile    Enables logging debug output (default=yes)],
964  [case "${enableval}" in
965    yes)
966      debug_logfile=true
967      AC_MSG_RESULT(yes)
968      ;;
969    no)
970      debug_logfile=false
971      AC_MSG_RESULT(no)
972      ;;
973    *)
974      AC_MSG_ERROR(bad value ${enableval} for --enable-debug-logfile)
975      ;;
976  esac],
977  [debug_logfile=true]; AC_MSG_RESULT(no))
978
979  if test "$debug_logfile" = "true"; then
980    CFLAGS="-D_SPF_DEBUG_LOGFILE $CFLAGS"
981  fi
982fi
983
984
985#-------------------------------------------------------------------------------
986# Check to see if we want to enable logfile statistics
987#-------------------------------------------------------------------------------
988
989logfile_stats=false
990AC_MSG_CHECKING(whether you want logfile statistics)
991AC_ARG_ENABLE(logfile_stats,
992[  --enable-logfile-stats    Enables logfile stats (default=no)],
993[case "${enableval}" in
994  yes)
995    logfile_stats=true
996    AC_MSG_RESULT(yes)
997    ;;
998  no)
999    logfile_stats=false
1000    AC_MSG_RESULT(no)
1001    ;;
1002  *)
1003    AC_MSG_ERROR(bad value ${enableval} for --enable-logfile-stats)
1004    ;;
1005esac],
1006[logfile_stats=false]; AC_MSG_RESULT(no))
1007
1008if test "$logfile_stats" = "true"; then
1009  CFLAGS="-D_SPF_LOGFILE_STATS $CFLAGS"
1010fi
1011
1012
1013#-------------------------------------------------------------------------------
1014# Check whether to enable a memset after each malloc
1015#-------------------------------------------------------------------------------
1016
1017rfc_recursion=false
1018AC_MSG_CHECKING(whether to abide by the RFC as regards recursiveness)
1019AC_ARG_ENABLE(rfc_recursion,
1020[  --enable-rfc-recursion    Change SPF recursion to 20 (as per RFC) (default=no)],
1021[case "${enableval}" in
1022  yes)
1023    rfc_recursion=true
1024    AC_MSG_RESULT(yes)
1025    ;;
1026  no)
1027    rfc_recursion=false
1028    AC_MSG_RESULT(no)
1029    ;;
1030  *)
1031    AC_MSG_ERROR(bad value ${enableval} for --enable-rfc-recursion)
1032    ;;
1033esac],
1034[rfc_recursion=false]; AC_MSG_RESULT(no))
1035
1036if test "$rfc_recursion" = "true"; then
1037  CFLAGS="-D_RFC_RECURSION $CFLAGS"
1038  AC_MSG_WARN(=== THE INTERNET IS FULL OF ILLITERATE AND LAZY PEOPLE ===)
1039  sleep 1
1040  AC_MSG_WARN(=== MANY OF WHOM CAN NOT PUBLISH A VALID SPF RECORD TO ===)
1041  sleep 1
1042  AC_MSG_WARN(=== SAVE THEIR LIFE.  MANY OF SUCH INDIVIDUALS OFTEN   ===)
1043  sleep 1
1044  AC_MSG_WARN(=== LINK RECORDS TOGETHER FORMING A RECURSIVE PARSING  ===)
1045  sleep 1
1046  AC_MSG_WARN(=== LOOP.  YOU HAVE BEEN WARNED. THE RFC STATES THAT   ===)
1047  sleep 1
1048  AC_MSG_WARN(=== SPF PARSERS MUST SUPPORT AT LEAST TWENTY LEVELS OF ===)
1049  sleep 1
1050  AC_MSG_WARN(=== RECURSION.  THIS HAS PROVEN TO BE POINTLESS GIVEN  ===)
1051  sleep 1
1052  AC_MSG_WARN(=== GIVEN THE ABUNDANCE OF STUPIDITY PREVALENT ON THE  ===)
1053  sleep 1
1054  AC_MSG_WARN(=== INTERNET.  YOU HAVE BEEN WARNED!!                  ===)
1055  sleep 5
1056fi
1057
1058
1059#-------------------------------------------------------------------------------
1060# Check whether to enable a memset after each malloc
1061#-------------------------------------------------------------------------------
1062
1063paranoid_malloc=true
1064AC_MSG_CHECKING(whether to memset after every malloc (paranoid malloc)?)
1065AC_ARG_ENABLE(paranoid_malloc,
1066[  --enable-paranoid-malloc  Enables a memset of every malloc to NULL (default=yes)],
1067[case "${enableval}" in
1068  yes)
1069    paranoid_malloc=true
1070    AC_MSG_RESULT(yes)
1071    ;;
1072  no)
1073    paranoid_malloc=false
1074    AC_MSG_RESULT(no)
1075    ;;
1076  *)
1077    AC_MSG_ERROR(bad value ${enableval} for --enable-paranoid-malloc)
1078    ;;
1079esac],
1080[paranoid_malloc=true]; AC_MSG_RESULT(yes))
1081
1082if test "$paranoid_malloc" = "true"; then
1083  CFLAGS="-D_WITH_PARANOID_MALLOC $CFLAGS"
1084fi
1085
1086
1087#-------------------------------------------------------------------------------
1088# Check whether to enable res_search behaviour instead of RFC821/2821 required
1089# res_query behaviour.  See Debian bug tracking list thread:
1090# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=297060 for more information.
1091#-------------------------------------------------------------------------------
1092
1093res_search=false
1094AC_MSG_CHECKING(whether to use res_search instead of res_query?)
1095AC_ARG_ENABLE(res_search,
1096[  --enable-res_search       Enables DNS queries to follow default and search rules (default=no)],
1097[case "${enableval}" in
1098  yes)
1099    res_search=true
1100    AC_MSG_RESULT(yes)
1101    ;;
1102  no)
1103    res_search=false
1104    AC_MSG_RESULT(no)
1105    ;;
1106  *)
1107    AC_MSG_ERROR(bad value ${enableval} for --enable-res_search)
1108    ;;
1109esac],
1110[res_search=falsee]; AC_MSG_RESULT(no))
1111
1112if test "$res_search" = "true"; then
1113  CFLAGS="-D_WITH_RES_SEARCH $CFLAGS"
1114fi
1115
1116
1117#-------------------------------------------------------------------------------
1118# Check to see if we should build libSPF Query Tool
1119#-------------------------------------------------------------------------------
1120
1121AC_MSG_CHECKING(whether to disable build the libSPF Query Tool?)
1122AC_ARG_ENABLE(spfqtool,
1123[  --disable-spfqtool        Disables compilation of the libSPF Query Tool (default=no)],
1124[case "${enableval}" in
1125  yes)
1126    spfqtool=true
1127    AC_MSG_RESULT(yes)
1128    ;;
1129  no)
1130    spfqtool=false
1131    AC_MSG_RESULT(no)
1132    ;;
1133  *)
1134    AC_MSG_ERROR(bad value ${enableval} for --disable-spfqtool)
1135    ;;
1136esac],
1137[spfqtool=false]; AC_MSG_RESULT(no))
1138
1139if test "$spfqtool" = "true"; then
1140  LIBSPF_BUILD_DIRS="libspf"
1141fi
1142#AC_SUBST(LIBSPF_BUILD_DIRS)
1143
1144
1145#-------------------------------------------------------------------------------
1146# Check to see if we want to enable pthreads (gethostbyname_r)
1147# For now, --enable-pthreads just happens to activate our internal
1148# _DNS_gethostbyname_r reentrant wrapper to gethostbyname unless
1149# gethostbyname_r is available (GNU extention) then the wrapper will
1150# be around that instead and won't use the mutex
1151#-------------------------------------------------------------------------------
1152
1153AC_MSG_CHECKING(whether to compile with reentrant capabilities)
1154AC_ARG_ENABLE(pthreads,
1155[  --enable-pthreads         Enables reentrant (thread-safe) library (default=no)],
1156[case "${enableval}" in
1157  yes)
1158    pthreads=true
1159    AC_MSG_RESULT(yes)
1160    ;;
1161  no)
1162    pthreads=false
1163    AC_MSG_RESULT(no)
1164    ;;
1165  *)
1166    AC_MSG_ERROR(bad value ${enableval} for --enable-pthreads)
1167    ;;
1168esac],
1169[pthreads=false]; AC_MSG_RESULT(no))
1170
1171if test "$pthreads" = "true"; then
1172
1173  AC_CHECK_HEADERS(pthread.h)
1174  if test "x-$ac_cv_header_pthread_h" = "x-yes"; then
1175    AC_DEFINE(HAVE_PTHREAD_H)
1176    CFLAGS="-D_WITH_PTHREADS -D_REENTRANT $CFLAGS"
1177
1178    case "$host" in
1179      *-*-freebsd*|*-*-dragonfly*)
1180        AC_MSG_WARN([Hey we are FreeBSD we can be all HOMO and DIFFERENT!])
1181        LIBSPF_PTHREADS_LIB="-pthread"
1182        ;;
1183      *)
1184        LIBSPF_PTHREADS_LIB="-lpthread"
1185        ;;
1186    esac
1187  fi
1188
1189  AC_CHECK_FUNCS(gethostbyname_r)
1190  if test "x-$ac_cv_func_gethostbyname_r" = "x-yes"; then
1191    AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1192  else
1193    AC_MSG_WARN([GNU gethostbyname_r not found, using internal wrapper])
1194  fi
1195
1196else
1197
1198  LIBSPF_PTHREADS_LIB=""
1199  pthreads=false
1200
1201fi
1202AC_SUBST(LIBSPF_PTHREADS_LIB)
1203
1204
1205#-------------------------------------------------------------------------------
1206# Check to see if we should build Sendmail SPF milter and perform the pthreads
1207# check again and in the event it wasn't specified (its required) or it failed,
1208# we will catch it (and enable it if successful) here.
1209#-------------------------------------------------------------------------------
1210
1211AC_MSG_CHECKING(whether to build the Sendmail SPF milter?)
1212AC_ARG_ENABLE(spfmilter,
1213[  --enable-spfmilter        Enables compilation of the Sendmail SPF milter (default=no)],
1214[case "${enableval}" in
1215  yes)
1216    spfmilter=true
1217    AC_MSG_RESULT(yes)
1218    ;;
1219  no)
1220    spfmilter=false
1221    AC_MSG_RESULT(no)
1222    ;;
1223  *)
1224    AC_MSG_ERROR(bad value ${enableval} for --enable-spfmilter)
1225    ;;
1226esac],
1227[spfmilter=false]; AC_MSG_RESULT(no))
1228
1229if test "$pthreads" = "false"; then
1230  if test "$spfmilter" = "true"; then
1231    AC_MSG_ERROR([pthreads is required, please re-configure with --enable-pthreads])
1232  fi
1233fi
1234
1235if test "$spfmilter" = "true"; then
1236  LIBSPF_BUILD_DIRS="$LIBSPF_BUILD_DIRS spfmilter"
1237  echo "--------------------------------------------------------------------------------"
1238  sleep 1
1239  echo "                       spfmilter - SPF mail filter module"
1240  echo ""
1241  echo "                   Originally by Jef Poskanzer <jef@acme.com>"
1242  echo ""
1243  echo " Sendmail includes a facility for plugging in custom mail filters,"
1244  echo " called milters.  It's documented here: http://www.milter.org/milter_api/"
1245  echo ""
1246  echo " See the manual entry (man spfmilter) or the README for more details."
1247  echo ""
1248  echo " Jef Poskanzer is the original author of this spfmilter."
1249  echo ""
1250  echo " This version and future versions of this spfmilter as bundled within libSPF"
1251  echo " will be supported by the libSPF development team."
1252  echo ""
1253  echo " DO NOT REPORT PROBLEMS WITH THIS SPFMILTER TO JEF AS IT IS NOT FAIR TO ASK"
1254  echo " HIM TO SUPPORT MULTIPLE VERSIONS OF HIS MILTER AFTER WE HAVE MODIFIED IT"
1255  echo ""
1256  echo " Send bugs to: James Couzens <jcouzens@codeshare.ca>"
1257  echo ""
1258  echo "--------------------------------------------------------------------------------"
1259  sleep 3
1260  echo ""
1261
1262
1263#-------------------------------------------------------------------------------
1264# getpwuid (pwd.h)
1265#-------------------------------------------------------------------------------
1266
1267AC_MSG_CHECKING([getpwuid])
1268use_getpwuid=no
1269AC_CHECK_FUNC(getpwuid,use_getpwuid=yes,[AC_CHECK_FUNC(getpwuid)])
1270  if test "x$use_getpwuid" = "xyes"; then
1271    AC_DEFINE([HAVE_PWD_H], [], [Have pwd.h])
1272  else
1273    AC_MSG_ERROR(Can not continue without pwd.h do you really have it?)
1274  fi
1275
1276
1277#-------------------------------------------------------------------------------
1278# setgroups (grp.h)
1279#-------------------------------------------------------------------------------
1280
1281AC_MSG_CHECKING([setgroups])
1282use_setgroups=no
1283AC_CHECK_FUNC(setgroups,use_setgroups=yes,[AC_CHECK_FUNC(setgroups)])
1284  if test "x$use_setgroups" = "xyes"; then
1285    AC_DEFINE([HAVE_GRP_H], [], [Have pwd.h])
1286  else
1287    AC_MSG_ERROR(Can not continue without grp.h do you really have it?)
1288  fi
1289fi
1290AC_SUBST(LIBSPF_BUILD_DIRS)
1291
1292
1293#-------------------------------------------------------------------------------
1294# Enable compiler full-optimizations which lead to greater performance
1295#-------------------------------------------------------------------------------
1296
1297if test "$debug" = "false"; then
1298
1299  AC_MSG_CHECKING(whether I should enable full optimizations)
1300  AC_ARG_ENABLE(full_optimizations,
1301  [  --enable-full-optimizations  Enables building of an optimized library (default=no)],
1302  [case "${enableval}" in
1303    yes)
1304      full_optimizations=true
1305      AC_MSG_RESULT(yes)
1306      ;;
1307    no)
1308      full_optimizations=false
1309      AC_MSG_RESULT(no)
1310      ;;
1311    *)
1312      AC_MSG_ERROR(bad value ${enableval} for --enable-full-optimizations)
1313      ;;
1314  esac],
1315  [full_optimizations=false]; AC_MSG_RESULT(no))
1316
1317  if test "$full_optimizations" = "true"; then
1318    if [[ "x$GCCVER" != "xno" ]]; then
1319      AC_MSG_RESULT(yes, however this option is deprecated!)
1320      #CFLAGS="$CFLAGS -O2 -pipe -funroll-loops -ffast-math -ftracer -fweb"
1321      #CFLAGS="$CFLAGS -O3 -ffast-math -fomit-frame-pointer"
1322    fi
1323  fi
1324fi
1325
1326
1327#-------------------------------------------------------------------------------
1328# Generate Makefiles
1329#-------------------------------------------------------------------------------
1330
1331AC_OUTPUT( \
1332  Makefile \
1333  src/Makefile \
1334  src/libspf/Makefile \
1335  src/spfqtool/Makefile \
1336  src/libspf/spf.h \
1337  src/libspf/util.c \
1338)
1339#AC_OUTPUT(src/Makefile)
1340#AC_OUTPUT(src/libspf/Makefile)
1341#AC_OUTPUT(src/spfqtool/Makefile)
1342#AC_OUTPUT(src/libspf/spf.h)
1343#AC_OUTPUT(src/libspf/util.c)
1344#AC_OUTPUT(src/spfmilter/Makefile)
1345
1346echo ""
1347echo ""
1348echo "           oooo   o8o   .o8        .oooooo..o ooooooooo.   oooooooooooo         "
1349echo "           \`888   \`\"'  \"888       d8P'    \`Y8 \`888   \`Y88. \`888'     \`8         "
1350echo "            888  oooo   888oooo.  Y88bo.       888   .d88'  888                 "
1351echo "            888  \`888   d88' \`88b  \`\"Y8888o.   888ooo88P'   888oooo8            "
1352echo "            888   888   888   888      \`\"Y88b  888          888   \"            "
1353echo "            888   888   888   888 oo     .d8P  888          888                 "
1354echo "           o888o o888o  \`Y8bod8P' 8\"\"88888P'  o888o        o888o                "
1355echo "--------------------------------------------------------------------------------"
1356echo "                              $PACKAGE $VERSION                                 "
1357echo "            An ANSI C Implementation of the Sender Policy Framework             "
1358echo "--------------------------------------------------------------------------------"
1359echo ""
1360echo " ./CHANGELOG ............ List of documented changed between versions"
1361echo " ./docs ................. Excellent API and integration Documentation"
1362echo " ./examples ............. Examples of how to implement"
1363echo " ./FAQ .................. Frequently Asked Questions (and Answers :-) )"
1364echo " ./LICENSE .............. Terms under which libSPF is licensed"
1365echo " ./README ............... A Quick and Excellent rundown of basic information"
1366echo " ./TODO ................. Things planned for future releases that are 'To Do'"
1367echo " ./VERSION .............. Version of thie release"
1368echo " ./bin .................. Static & Dyn. versions of the libSPF Query Tool"
1369echo " ./libspf.kateproject ... KDE's excellent IDE 'kate' Project File"
1370echo " ./patches .............. MTA Patches"
1371echo " ./src .................. Its not the Swartz, but it will have to do ;)"
1372echo ""
1373echo "--------------------------------------------------------------------------------"
1374sleep 2
1375echo ""
1376echo " There are complete HOWTOs (or walkthru) documents within the 'Docs' dir for"
1377echo " the MTA's this library supports."
1378echo ""
1379echo " Commercial developers looking to integrate libSPF, there is no cost!  If you"
1380echo " require assistance (free) please contact <developers@codeshare.ca>"
1381echo ""
1382echo " Website ................................ http://libSPF.org"
1383echo " Forums ................................. http://forums.6o4.ca"
1384echo " Contact ................................ jcouzens@codeshare.ca"
1385echo ""
1386echo "--------------------------------------------------------------------------------"
1387sleep 1
1388echo ""
1389
1390
1391if test "$debug" = "true"; then
1392  tmp="ON"
1393else
1394  tmp="OFF"
1395fi
1396echo " Enable Debugging ........................................... "$tmp""
1397
1398
1399if test "$debug_logfile" = "true"; then
1400  tmp="ON"
1401else
1402  tmp="OFF"
1403fi
1404echo " Enable Debugging output to logfile (/var/log/spf.log) ...... "$tmp""
1405
1406
1407if test "$logfile_stats" = "true"; then
1408  tmp="ON"
1409else
1410  tmp="OFF"
1411fi
1412echo " Enable SPF logging statistics to /var/log/spflog.txt ....... "$tmp""
1413
1414
1415if test "$full_optimizations" = "true"; then
1416  tmp="ON"
1417else
1418  tmp="OFF"
1419fi
1420echo " Enable compilation of an optimized library ................. "$tmp""
1421
1422
1423if test "$rfc_recursion" = "true"; then
1424  tmp="ON"
1425else
1426  tmp="OFF"
1427fi
1428echo " Enable RFC recursion during SPF checks ..................... "$tmp""
1429
1430
1431if test "$res_search" = "true"; then
1432  tmp="ON"
1433else
1434  tmp="OFF"
1435fi
1436echo " Enable DNS queries to follow 'default' and 'search' rules .. "$tmp""
1437
1438
1439if test "$paranoid_malloc" = "true"; then
1440  tmp="ON"
1441else
1442  tmp="OFF"
1443fi
1444echo " Enable memset to NULL after each malloc .................... "$tmp""
1445
1446
1447if test "$spfqtool" = "true"; then
1448  tmp="ON"
1449else
1450  tmp="OFF"
1451fi
1452echo " Disable build of SPF Query Tool ............................ "$tmp""
1453
1454
1455if test "$libresolv" = "true"; then
1456  tmp="ON"
1457else
1458  tmp="OFF"
1459fi
1460echo " Enable use of libresolv resolver ........................... "$tmp""
1461
1462
1463if test "$spfmilter" = "true"; then
1464  tmp="ON"
1465else
1466  tmp="OFF"
1467fi
1468echo " Enable use of Sendmail spfmilter ........................... "$tmp""
1469
1470
1471if test "$libbind" = "true"; then
1472  tmp="ON"
1473else
1474  tmp="OFF"
1475fi
1476echo " Enable use of libbind resolver ............................. "$tmp""
1477
1478
1479if test "$pthreads" = "true"; then
1480  tmp="ON"
1481else
1482  tmp="OFF"
1483fi
1484echo " Enable use of pthreads (gethostbyname_r) ................... "$tmp""
1485
1486
1487echo ""
1488echo " libSPF Query tool binaries are in the new 'bin' dir in the libSPF root"
1489echo " libSPF Milter binaries are in the new 'bin; dir also"
1490echo ""
1491echo " libSPF libraries are in the new 'lib' dir in the libSPF root"
1492echo ""
1493echo " libSPF Milter rc scripts and docs are in 'src/spfmilter/rc_scripts'"
1494echo "--------------------------------------------------------------------------------"
1495echo ""
1496
1497# end of configure.in
1498