1 | # $Id: configure.ac 98 2006-09-22 16:27:37Z sam $ |
---|
2 | |
---|
3 | AC_INIT(zzuf, 0.12) |
---|
4 | AC_CONFIG_AUX_DIR(.auto) |
---|
5 | AM_CONFIG_HEADER(config.h) |
---|
6 | AM_INIT_AUTOMAKE([no-define tar-ustar]) |
---|
7 | |
---|
8 | AC_PREREQ(2.50) |
---|
9 | |
---|
10 | AM_PROG_CC_C_O |
---|
11 | AC_PROG_CPP |
---|
12 | AC_PROG_LIBTOOL |
---|
13 | |
---|
14 | AC_C_INLINE |
---|
15 | AC_C_FUNC |
---|
16 | |
---|
17 | # Optimizations |
---|
18 | AC_TRY_CFLAGS(-g -O2, CFLAGS="${CFLAGS} -g -O2") |
---|
19 | # Code qui fait des warnings == code de porc == deux baffes dans ta gueule |
---|
20 | AC_TRY_CFLAGS(-Wall, CFLAGS="${CFLAGS} -Wall") |
---|
21 | AC_TRY_CFLAGS(-W, CFLAGS="${CFLAGS} -W") |
---|
22 | AC_TRY_CFLAGS(-Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare, CFLAGS="${CFLAGS} -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare") |
---|
23 | |
---|
24 | case "${host_os}" in |
---|
25 | *mingw32*) |
---|
26 | DLL_LDFLAGS="-Wl,-l,imagehlp" # Trick libtool here |
---|
27 | WINSOCK2_LIBS="-lws2_32" |
---|
28 | ac_cv_func_recv=yes |
---|
29 | ac_cv_func_recvfrom=yes |
---|
30 | ac_cv_func_socket=yes |
---|
31 | ac_cv_func_accept=yes |
---|
32 | ac_cv_func_bind=yes |
---|
33 | ac_cv_func_connect=yes |
---|
34 | ;; |
---|
35 | esac |
---|
36 | AC_SUBST(WINSOCK2_LIBS) |
---|
37 | AC_SUBST(DLL_LDFLAGS) |
---|
38 | |
---|
39 | AC_CHECK_HEADERS(windows.h winsock2.h io.h process.h unistd.h inttypes.h stdint.h getopt.h libc.h malloc.h dlfcn.h regex.h sys/cdefs.h sys/socket.h netinet/in.h arpa/inet.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h sys/time.h endian.h) |
---|
40 | |
---|
41 | AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe) |
---|
42 | AC_CHECK_FUNCS(open64 __open64 lseek64 __lseek64 mmap64 fopen64 __fopen64 freopen64 __freopen64 dup dup2 fseeko fseeko64 __fseeko64 fsetpos64 __fsetpos64 _IO_getc getline getdelim __getdelim fgetln __srefill __filbuf __srget map_fd memalign posix_memalign aio_read accept bind connect socket readv pread recv recvfrom recvmsg mmap valloc sigaction getpagesize getc_unlocked getchar_unlocked fgetc_unlocked fread_unlocked fgets_unlocked) |
---|
43 | |
---|
44 | AC_CHECK_TYPES(sighandler_t, [], [], |
---|
45 | [#define _GNU_SOURCE |
---|
46 | #include <signal.h>]) |
---|
47 | AC_CHECK_TYPES(sig_t, [], [], |
---|
48 | [#include <signal.h>]) |
---|
49 | AC_CHECK_TYPES(socklen_t, [], [], |
---|
50 | [#include <sys/types.h> |
---|
51 | #include <sys/socket.h>]) |
---|
52 | |
---|
53 | AC_MSG_CHECKING(for read() prototype) |
---|
54 | AC_TRY_COMPILE([#define _INCLUDE_POSIX_SOURCE |
---|
55 | #include <unistd.h>], |
---|
56 | [ssize_t read(int fd, void *buf, size_t count);], |
---|
57 | [AC_MSG_RESULT(ssize_t read(... size_t);) |
---|
58 | AC_DEFINE(READ_USES_SSIZE_T, 1, [Define to 1 if read() uses ssize_t.])], |
---|
59 | [AC_MSG_RESULT(int read(... unsigned int);)]) |
---|
60 | |
---|
61 | AC_MSG_CHECKING(for recv() return value) |
---|
62 | ac_v_recv_t="int" |
---|
63 | AC_TRY_COMPILE([#define _XOPEN_SOURCE_EXTENDED |
---|
64 | #include <sys/types.h> |
---|
65 | #include <sys/socket.h>], |
---|
66 | [ssize_t recv(int s, void *buf, size_t len, int flags);], |
---|
67 | [ac_v_recv_t="ssize_t"]) |
---|
68 | AC_MSG_RESULT($ac_v_recv_t) |
---|
69 | AC_DEFINE_UNQUOTED(RECV_T, $ac_v_recv_t, [Define to the recv() return type]) |
---|
70 | |
---|
71 | AC_MSG_CHECKING(for FILE* internal members) |
---|
72 | ac_v_fp_cnt="unknown" |
---|
73 | ac_v_fp_ptr="unknown" |
---|
74 | AC_TRY_COMPILE([#include <stdio.h>], |
---|
75 | [FILE *fp; fp->__cnt++; fp->__ptr++], |
---|
76 | [ac_v_fp_cnt=__cnt; ac_v_fp_ptr=__ptr], |
---|
77 | [AC_TRY_COMPILE([#include <stdio.h>], |
---|
78 | [FILE *fp; fp->_cnt++; fp->_ptr++], |
---|
79 | [ac_v_fp_cnt=_cnt; ac_v_fp_ptr=_ptr], |
---|
80 | [AC_TRY_COMPILE([#include <stdio.h>], |
---|
81 | [FILE *fp; fp->_c++; fp->_p++], |
---|
82 | [ac_v_fp_cnt=_c; ac_v_fp_ptr=_p], |
---|
83 | [AC_TRY_COMPILE([#include <stdio.h>], |
---|
84 | [FILE *fp; fp->_r++; fp->_p++], |
---|
85 | [ac_v_fp_cnt=_r; ac_v_fp_ptr=_p])])])]) |
---|
86 | AC_MSG_RESULT($ac_v_fp_cnt/$ac_v_fp_ptr) |
---|
87 | AC_DEFINE_UNQUOTED(FILE_CNT, $ac_v_fp_cnt, [Define to the FILE::cnt member name]) |
---|
88 | AC_DEFINE_UNQUOTED(FILE_PTR, $ac_v_fp_ptr, [Define to the FILE::ptr member name]) |
---|
89 | |
---|
90 | dnl On HP-UX, fpos64_t == int64_t, but on Linux it's a compound object. |
---|
91 | AC_MSG_CHECKING(how to access fpos64_t x) |
---|
92 | ac_v_fpos64_t="unknown" |
---|
93 | AC_TRY_COMPILE( |
---|
94 | [#define _LARGEFILE64_SOURCE |
---|
95 | #include <stdio.h>], |
---|
96 | [fpos64_t x; long long int y = x.__pos;], |
---|
97 | [ac_v_fpos64_t="(x).__pos"]) |
---|
98 | AC_TRY_COMPILE( |
---|
99 | [#define _LARGEFILE64_SOURCE |
---|
100 | #include <stdio.h>], |
---|
101 | [fpos64_t x; long long int y = (long long int)x;], |
---|
102 | [ac_v_fpos64_t="(x)"]) |
---|
103 | AC_MSG_RESULT($ac_v_fpos64_t) |
---|
104 | AC_DEFINE_UNQUOTED(FPOS_CAST(x), $ac_v_fpos64_t, [Define to a macro for accessing an fpos64_t variable]) |
---|
105 | |
---|
106 | AC_MSG_CHECKING(for pragma INIT/FINI) |
---|
107 | AC_TRY_COMPILE([], |
---|
108 | [#pragma INIT "my_init" |
---|
109 | void my_init(void)], |
---|
110 | [AC_MSG_RESULT(yes) |
---|
111 | AC_DEFINE(HAVE_PRAGMA_INIT, 1, [Define to 1 if you have pragma INIT])], |
---|
112 | [AC_MSG_RESULT(no)]) |
---|
113 | |
---|
114 | AC_MSG_CHECKING(for __printf__ attribute) |
---|
115 | ac_v_attribute_printf="" |
---|
116 | AC_TRY_COMPILE([], |
---|
117 | [extern void foo(const char *, ...) |
---|
118 | __attribute__((__format__(__printf__, 1, 2)));], |
---|
119 | [AC_MSG_RESULT(yes) |
---|
120 | ac_v_attribute_printf="__attribute__((__format__(__printf__, x, y)))"], |
---|
121 | [AC_MSG_RESULT(no)]) |
---|
122 | AC_DEFINE_UNQUOTED(ATTRIBUTE_PRINTF(x,y), $ac_v_attribute_printf, [Define to the __printf__ attribute if present]) |
---|
123 | |
---|
124 | ac_cv_have_getopt_long="no" |
---|
125 | AC_CHECK_FUNCS(getopt_long, |
---|
126 | [ac_cv_have_getopt_long="yes"], |
---|
127 | [AC_CHECK_LIB(gnugetopt, getopt_long, |
---|
128 | [ac_cv_have_getopt_long="yes" |
---|
129 | GETOPT_LIBS="${GETOPT_LIBS} -lgnugetopt"])]) |
---|
130 | if test "$ac_cv_have_getopt_long" != "no"; then |
---|
131 | AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.) |
---|
132 | fi |
---|
133 | AM_CONDITIONAL(NEED_GETOPT_LONG, test "$ac_cv_have_getopt_long" = "no") |
---|
134 | AC_SUBST(GETOPT_LIBS) |
---|
135 | |
---|
136 | AC_CHECK_LIB(m, log, [MATH_LIBS="-lm"]) |
---|
137 | AC_SUBST(MATH_LIBS) |
---|
138 | AC_CHECK_LIB(dl, dlopen, [DL_LIBS="-ldl"]) |
---|
139 | AC_SUBST(DL_LIBS) |
---|
140 | |
---|
141 | AC_OUTPUT([ |
---|
142 | Makefile |
---|
143 | src/Makefile |
---|
144 | doc/Makefile |
---|
145 | test/Makefile |
---|
146 | ]) |
---|
147 | |
---|