| 1 | dnl |
|---|
| 2 | dnl autoconf for ipfm. |
|---|
| 3 | dnl Copyright (c) 1999-2002 Robert CHERAMY <robert@cheramy.net> |
|---|
| 4 | dnl Copyright (c) 2001 Loïc Tortay & IN2P3 Computing Center <tortay@cc.in2p3.fr> |
|---|
| 5 | dnl |
|---|
| 6 | dnl 20021020 : tibob : added --enable-debug-messages option |
|---|
| 7 | |
|---|
| 8 | dnl Initialisation |
|---|
| 9 | AC_INIT(Makefile.in) |
|---|
| 10 | AC_CONFIG_HEADER(source/config.h) |
|---|
| 11 | |
|---|
| 12 | dnl |
|---|
| 13 | dnl options |
|---|
| 14 | dnl |
|---|
| 15 | dnl I can't get AC_HELP_STRING working... If somone has an idea... |
|---|
| 16 | |
|---|
| 17 | AC_ARG_ENABLE([debug-messages], |
|---|
| 18 | [ --enable-debug-messages Use debug messages], |
|---|
| 19 | [ |
|---|
| 20 | if test $enableval = "yes"; then |
|---|
| 21 | AC_DEFINE(DEBUG_MESSAGES) |
|---|
| 22 | fi |
|---|
| 23 | ]) |
|---|
| 24 | |
|---|
| 25 | AC_ARG_ENABLE([ip-check], |
|---|
| 26 | [ --enable-ip-check Additional IP packets checks], |
|---|
| 27 | [ |
|---|
| 28 | if test $enableval = "yes"; then |
|---|
| 29 | AC_DEFINE(IP_CHECK) |
|---|
| 30 | fi |
|---|
| 31 | ]) |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | dnl Version |
|---|
| 36 | VERSION=`cat $srcdir/VERSION` |
|---|
| 37 | AC_SUBST(VERSION) |
|---|
| 38 | |
|---|
| 39 | echo "Configuring ipfm $VERSION..." |
|---|
| 40 | echo |
|---|
| 41 | |
|---|
| 42 | dnl Checks for uname. |
|---|
| 43 | AC_CHECK_PROG(UNAME, uname, uname) |
|---|
| 44 | if test "x$UNAME" = "x"; then |
|---|
| 45 | echo |
|---|
| 46 | echo "No uname. can't find your OS" |
|---|
| 47 | echo |
|---|
| 48 | exit 1 |
|---|
| 49 | fi |
|---|
| 50 | |
|---|
| 51 | dnl Finds out OS. |
|---|
| 52 | AC_MSG_CHECKING(your OS) |
|---|
| 53 | system=`$UNAME` |
|---|
| 54 | case $system in |
|---|
| 55 | Linux) |
|---|
| 56 | AC_MSG_RESULT(Linux) |
|---|
| 57 | AC_DEFINE(__OS_LINUX__) |
|---|
| 58 | ;; |
|---|
| 59 | FreeBSD) |
|---|
| 60 | AC_MSG_RESULT(FreeBSD) |
|---|
| 61 | AC_DEFINE(__OS_FREEBSD__) |
|---|
| 62 | ;; |
|---|
| 63 | OpenBSD) |
|---|
| 64 | AC_MSG_RESULT(OpenBSD) |
|---|
| 65 | AC_DEFINE(__OS_OPENBSD__) |
|---|
| 66 | ;; |
|---|
| 67 | SunOS) |
|---|
| 68 | AC_MSG_RESULT(SunOS) |
|---|
| 69 | AC_DEFINE(__OS_SUNOS__) |
|---|
| 70 | LIBS="$LIBS -lnsl -lsocket" |
|---|
| 71 | ;; |
|---|
| 72 | AIX) |
|---|
| 73 | AC_MSG_RESULT(AIX) |
|---|
| 74 | AC_DEFINE(__OS_AIX__) |
|---|
| 75 | ;; |
|---|
| 76 | HP-UX) |
|---|
| 77 | AC_MSG_RESULT(HPUX) |
|---|
| 78 | AC_DEFINE(__OS_HPUX__) |
|---|
| 79 | ;; |
|---|
| 80 | OSF1) |
|---|
| 81 | AC_MSG_RESULT(OSF1) |
|---|
| 82 | AC_DEFINE(__OS_OSF1__) |
|---|
| 83 | ;; |
|---|
| 84 | esac |
|---|
| 85 | |
|---|
| 86 | dnl |
|---|
| 87 | dnl Checks for programs. |
|---|
| 88 | dnl |
|---|
| 89 | AC_PROG_CC |
|---|
| 90 | AC_PROG_CPP |
|---|
| 91 | AC_PROG_INSTALL |
|---|
| 92 | AC_PROG_LEX |
|---|
| 93 | AC_PROG_RANLIB |
|---|
| 94 | AC_PROG_YACC |
|---|
| 95 | AC_PATH_PROG(AR, ar) |
|---|
| 96 | |
|---|
| 97 | if test -z "$AR" ; then |
|---|
| 98 | AC_MSG_ERROR(You need 'ar' in order to compile ipfm) |
|---|
| 99 | fi |
|---|
| 100 | |
|---|
| 101 | dnl |
|---|
| 102 | dnl Checks for libpcap |
|---|
| 103 | dnl |
|---|
| 104 | |
|---|
| 105 | AC_MSG_CHECKING(for local libpcap) |
|---|
| 106 | dnl checks for local libpcap lib |
|---|
| 107 | pcapdirs=`ls .. | grep libpcap | sed -e 's:/$::' -e 's:^:../:' | tr '\n' ' '` |
|---|
| 108 | libpcap=FAIL |
|---|
| 109 | for pcapdir in `echo $pcapdirs` ; do |
|---|
| 110 | pcapdir=`pwd`/$pcapdir |
|---|
| 111 | if test -d $pcapdir -a -f $pcapdir/libpcap.a -a -f $pcapdir/pcap.h ; then |
|---|
| 112 | libpcap=$pcapdir/libpcap.a |
|---|
| 113 | AC_MSG_RESULT(Using $libpcap) |
|---|
| 114 | INCLS="-I$pcapdir" |
|---|
| 115 | break |
|---|
| 116 | fi |
|---|
| 117 | done |
|---|
| 118 | |
|---|
| 119 | dnl checks for pcap install |
|---|
| 120 | if test "x$libpcap" = "xFAIL" ; then |
|---|
| 121 | AC_MSG_RESULT(no) |
|---|
| 122 | AC_CHECK_LIB(pcap, main, libpcap="-lpcap", AC_MSG_ERROR(You need libpcap in order to use ipfm)) |
|---|
| 123 | pcapdir="" |
|---|
| 124 | dnl I ought to put here a test to find where pcap.h is |
|---|
| 125 | AC_CHECK_HEADER(pcap.h,, NO_PCAP_H=1) |
|---|
| 126 | if test "x$NO_PCAP_H" = "x1"; then |
|---|
| 127 | AC_MSG_CHECKING(for exotic pcap.h places) |
|---|
| 128 | if test -r /usr/include/pcap/pcap.h; then |
|---|
| 129 | INCLS="$INCLS -I/usr/include/pcap" |
|---|
| 130 | AC_MSG_RESULT(/usr/include/pcap/) |
|---|
| 131 | else if test -r /usr/local/include/pcap.h; then |
|---|
| 132 | INCLS="$INCLS -I/usr/local/include" |
|---|
| 133 | AC_MSG_RESULT(/usr/local/include/) |
|---|
| 134 | else |
|---|
| 135 | AC_MSG_WARN(pcap.h not found.) |
|---|
| 136 | AC_MSG_WARN(Specify pcap.h PATH in source/Makefile (INCLS=-I/pcap/path)) |
|---|
| 137 | fi; fi |
|---|
| 138 | fi |
|---|
| 139 | fi |
|---|
| 140 | LIBS="$LIBS $libpcap" |
|---|
| 141 | AC_SUBST(INCLS) |
|---|
| 142 | |
|---|
| 143 | dnl Checks for typedefs, structures, and compiler characteristics. |
|---|
| 144 | if test "x$CC" = "xgcc" ; then |
|---|
| 145 | WARNINGS="-Wall" |
|---|
| 146 | AC_SUBST(WARNINGS) |
|---|
| 147 | fi |
|---|
| 148 | |
|---|
| 149 | dnl |
|---|
| 150 | dnl Checks for library functions. |
|---|
| 151 | dnl |
|---|
| 152 | AC_MSG_CHECKING(for strftime) |
|---|
| 153 | AC_TRY_COMPILE([#include <time.h>], |
|---|
| 154 | [strftime(NULL, 0, NULL, NULL);], |
|---|
| 155 | [AC_DEFINE(HAVE_STRFTIME) |
|---|
| 156 | AC_MSG_RESULT(yes)], |
|---|
| 157 | [AC_MSG_ERROR(You need strftime support in order to compile ipfm)]) |
|---|
| 158 | |
|---|
| 159 | AC_MSG_CHECKING(for snprintf) |
|---|
| 160 | AC_TRY_COMPILE([#include <stdio.h>], |
|---|
| 161 | [snprintf(NULL, 0, NULL);], |
|---|
| 162 | [AC_DEFINE(HAVE_SNPRINTF) |
|---|
| 163 | AC_MSG_RESULT(yes)], |
|---|
| 164 | [AC_MSG_ERROR(You need snprintf support in order to compile ipfm)]) |
|---|
| 165 | |
|---|
| 166 | lockf_found=yes |
|---|
| 167 | AC_MSG_CHECKING(for lockf) |
|---|
| 168 | AC_TRY_COMPILE([#include <unistd.h>], |
|---|
| 169 | [lockf(0, 0, 0);], |
|---|
| 170 | [AC_DEFINE(HAVE_LOCKF) |
|---|
| 171 | AC_MSG_RESULT(yes)], |
|---|
| 172 | [AC_MSG_RESULT(no) lockf_found=no]) |
|---|
| 173 | |
|---|
| 174 | flock_found=yes |
|---|
| 175 | AC_MSG_CHECKING(for flock) |
|---|
| 176 | AC_TRY_COMPILE([#include <fcntl.h>], |
|---|
| 177 | [flock(0, 0);], |
|---|
| 178 | [AC_DEFINE(HAVE_FLOCK) |
|---|
| 179 | AC_MSG_RESULT(yes)], |
|---|
| 180 | [AC_MSG_RESULT(no) flockf_found=no]) |
|---|
| 181 | |
|---|
| 182 | if test $lockf_found = "no" -a $flock_found = "no" ; then |
|---|
| 183 | AC_MSG_ERROR(You need either flock or lockf support in order to compile ipfm) |
|---|
| 184 | fi |
|---|
| 185 | |
|---|
| 186 | AC_CHECK_FUNC(daemon, |
|---|
| 187 | [AC_DEFINE(HAVE_DAEMON)], |
|---|
| 188 | [AC_CHECK_LIB(bsd, daemon, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])] |
|---|
| 189 | ) |
|---|
| 190 | |
|---|
| 191 | AC_CHECK_FUNCS(strlcat strlcpy inet_aton inet_ntoa) |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | dnl |
|---|
| 195 | dnl Checks for useful types |
|---|
| 196 | dnl |
|---|
| 197 | |
|---|
| 198 | dnl AC_CHECK_TYPE(unsigned long long int, unsigned long) |
|---|
| 199 | dnl AC_CHECK_TYPE(long long, longlong) |
|---|
| 200 | dnl if test $ac_cv_type_long_long = no; then |
|---|
| 201 | dnl AC_MSG_ERROR(You need an \`\`long long int\'\' in order to use ipfm)) |
|---|
| 202 | dnl fi |
|---|
| 203 | dnl AC_MSG_CHECKING(for long long int) |
|---|
| 204 | dnl AC_TRY_COMPILE(, [unsigned long long int ulli;] |
|---|
| 205 | dnl [AC_DEFINE(HAVE_LONGLONG) |
|---|
| 206 | dnl AC_MSG_RESULT(yes)], |
|---|
| 207 | dnl [AC_MSG_RESULT(no)]) |
|---|
| 208 | dnl [AC_MSG_ERROR(You need long long int support in order to compile ipfm)]) |
|---|
| 209 | |
|---|
| 210 | AC_CHECK_TYPE(u_int32_t, uint32_t) |
|---|
| 211 | if test $ac_cv_type_u_int32_t = no; then |
|---|
| 212 | AC_CHECK_TYPE(uint32_t, unsigned long int) |
|---|
| 213 | fi |
|---|
| 214 | |
|---|
| 215 | AC_CHECK_TYPE(u_int8_t, uint8_t) |
|---|
| 216 | if test $ac_cv_type_u_int8_t = no; then |
|---|
| 217 | AC_CHECK_TYPE(uint8_t, unsigned char) |
|---|
| 218 | fi |
|---|
| 219 | |
|---|
| 220 | dnl |
|---|
| 221 | dnl Generate output files |
|---|
| 222 | dnl |
|---|
| 223 | |
|---|
| 224 | AC_DEFINE_UNQUOTED(VERSION, "$VERSION") |
|---|
| 225 | |
|---|
| 226 | AC_OUTPUT(Makefile Makefile.common source/Makefile source/missing/Makefile doc/Makefile) |
|---|
| 227 | |
|---|
| 228 | echo |
|---|
| 229 | make configdump |
|---|
| 230 | echo |
|---|
| 231 | echo Please check this is correct and modify Makefile.common |
|---|
| 232 | echo and source/config.h in consequence. |
|---|
| 233 | echo You can now type \`\` make \'\'. |
|---|