source: zzuf/trunk/configure.ac @ 4650

Last change on this file since 4650 was 4372, checked in by Sam Hocevar, 11 years ago

Add support for fortified glibc functions (fgets_chk, read_chk, etc.).

File size: 6.8 KB
Line 
1# $Id: configure.ac 98 2006-09-22 16:27:37Z sam $
2
3AC_INIT(zzuf, 0.13)
4AC_CONFIG_AUX_DIR(.auto)
5AM_CONFIG_HEADER(config.h)
6AM_INIT_AUTOMAKE([no-define tar-ustar])
7
8AC_PREREQ(2.50)
9
10AM_PROG_CC_C_O
11AC_PROG_CPP
12AC_PROG_LIBTOOL
13
14AC_C_INLINE
15AC_C_FUNC
16
17# Library suffix
18AC_MSG_CHECKING(for libzzuf full name)
19case "$shrext_cmds" in
20  "") SONAME="libzzuf.so" ;;
21  *) eval SONAME="libzzuf$shrext_cmds" ;;
22esac
23AC_MSG_RESULT($SONAME)
24AC_DEFINE_UNQUOTED(SONAME, "$SONAME", [Define to the libzzuf full name])
25
26# Optimizations
27AC_TRY_CFLAGS(-g -O2, CFLAGS="${CFLAGS} -g -O2")
28# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
29AC_TRY_CFLAGS(-Wall, CFLAGS="${CFLAGS} -Wall")
30AC_TRY_CFLAGS(-W, CFLAGS="${CFLAGS} -W")
31AC_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")
32
33case "${host_os}" in
34  *mingw32*)
35    DLL_LDFLAGS="-Wl,-l,imagehlp" # Trick libtool here
36    WINSOCK2_LIBS="-lws2_32"
37    ac_cv_func_recv=yes
38    ac_cv_func_recvfrom=yes
39    ac_cv_func_socket=yes
40    ac_cv_func_accept=yes
41    ac_cv_func_bind=yes
42    ac_cv_func_connect=yes
43    ;;
44esac
45AC_SUBST(WINSOCK2_LIBS)
46AC_SUBST(DLL_LDFLAGS)
47
48AC_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 mach/task.h)
49
50AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
51AC_CHECK_FUNCS(dup dup2 ftello fseeko _IO_getc getline getdelim fgetln map_fd memalign posix_memalign aio_read accept bind connect socket readv pread recv recvfrom recvmsg mmap valloc sigaction getpagesize)
52AC_CHECK_FUNCS(getc_unlocked getchar_unlocked fgetc_unlocked fread_unlocked fgets_unlocked)
53AC_CHECK_FUNCS(__getdelim __srefill __filbuf __srget __uflow)
54AC_CHECK_FUNCS(open64 lseek64 mmap64 fopen64 freopen64 ftello64 fseeko64 fsetpos64)
55AC_CHECK_FUNCS(__open64 __lseek64 __fopen64 __freopen64 __ftello64 __fseeko64 __fsetpos64)
56AC_CHECK_FUNCS(__fgets_chk __fgets_unlocked_chk __fread_chk __fread_unlocked_chk __read_chk __recv_chk __recvfrom_chk)
57
58AC_CHECK_TYPES(sighandler_t, [], [],
59  [#define _GNU_SOURCE
60   #include <signal.h>])
61AC_CHECK_TYPES(sig_t, [], [],
62  [#include <signal.h>])
63AC_CHECK_TYPES(socklen_t, [], [],
64  [#include <sys/types.h>
65   #include <sys/socket.h>])
66
67AC_MSG_CHECKING(for connect() second argument)
68AC_TRY_COMPILE([#include <sys/types.h>
69                #include <sys/socket.h>],
70 [#if defined HAVE_SOCKLEN_T
71  int connect(int, const struct sockaddr *, socklen_t);
72  #else
73  int connect(int, const struct sockaddr *, int);
74  #endif],
75 [AC_MSG_RESULT(const struct sockaddr *)
76  AC_DEFINE(CONNECT_USES_STRUCT_SOCKADDR, 1, [Define to 1 if connect() uses struct sockaddr.])],
77 [AC_MSG_RESULT(const void *)])
78
79AC_MSG_CHECKING(for read() prototype)
80AC_TRY_COMPILE([#define _INCLUDE_POSIX_SOURCE
81                #include <unistd.h>],
82 [ssize_t read(int fd, void *buf, size_t count);],
83 [AC_MSG_RESULT(ssize_t read(... size_t);)
84  AC_DEFINE(READ_USES_SSIZE_T, 1, [Define to 1 if read() uses ssize_t.])],
85 [AC_MSG_RESULT(int read(... unsigned int);)])
86
87AC_MSG_CHECKING(for recv() return value)
88ac_v_recv_t="int"
89AC_TRY_COMPILE([#define _XOPEN_SOURCE_EXTENDED
90                #include <sys/types.h>
91                #include <sys/socket.h>],
92 [ssize_t recv(int s, void *buf, size_t len, int flags);],
93 [ac_v_recv_t="ssize_t"])
94AC_MSG_RESULT($ac_v_recv_t)
95AC_DEFINE_UNQUOTED(RECV_T, $ac_v_recv_t, [Define to the recv() return type])
96
97AC_MSG_CHECKING([for _IO_read_ptr and _IO_read_end in FILE (glibc-style)])
98AC_TRY_COMPILE([#include <stdio.h>],
99 [FILE *fp; fp->_IO_read_ptr++; fp->_IO_read_end++],
100 [ac_cv_have_glibc_file=yes],
101 [ac_cv_have_glibc_file=no])
102AC_MSG_RESULT($ac_cv_have_glibc_file)
103if test "$ac_cv_have_glibc_file" != "no"; then
104  AC_DEFINE(HAVE_GLIBC_FILE, 1, [Define to 1 if FILE has glibc-style members])
105fi
106
107AC_MSG_CHECKING([for _bf._base, _r and _p in FILE (FreeBSD-style)])
108AC_TRY_COMPILE([#include <stdio.h>],
109 [FILE *fp; fp->_bf._base++; fp->_r++; fp->_p++],
110 [ac_cv_have_freebsd_file=yes],
111 [ac_cv_have_freebsd_file=no])
112AC_MSG_RESULT($ac_cv_have_freebsd_file)
113if test "$ac_cv_have_freebsd_file" != "no"; then
114  AC_DEFINE(HAVE_FREEBSD_FILE, 1, [Define to 1 if FILE has FreeBSD-style members])
115fi
116
117AC_MSG_CHECKING([for _base, _cnt and _ptr in FILE (Solaris-style)])
118AC_TRY_COMPILE([#include <stdio.h>],
119 [FILE *fp; fp->_base++; fp->_cnt++; fp->_ptr++],
120 [ac_cv_have_solaris_file=yes],
121 [ac_cv_have_solaris_file=no])
122AC_MSG_RESULT($ac_cv_have_solaris_file)
123if test "$ac_cv_have_solaris_file" != "no"; then
124  AC_DEFINE(HAVE_SOLARIS_FILE, 1, [Define to 1 if FILE has Solaris-style members])
125fi
126
127dnl  On HP-UX, fpos64_t == int64_t, but on Linux it's a compound object.
128AC_MSG_CHECKING(how to access fpos64_t x)
129ac_v_fpos64_t="unknown"
130AC_TRY_COMPILE(
131 [#define _LARGEFILE64_SOURCE
132  #define _LARGEFILE_SOURCE
133  #include <stdio.h>],
134 [fpos64_t x; long long int y = x.__pos;],
135 [ac_v_fpos64_t="(x).__pos"])
136AC_TRY_COMPILE(
137 [#define _LARGEFILE64_SOURCE
138  #define _LARGEFILE_SOURCE
139  #include <stdio.h>],
140 [fpos64_t x; long long int y = (long long int)x;],
141 [ac_v_fpos64_t="(x)"])
142AC_MSG_RESULT($ac_v_fpos64_t)
143AC_DEFINE_UNQUOTED(FPOS_CAST(x), $ac_v_fpos64_t, [Define to a macro for accessing an fpos64_t variable])
144
145AC_MSG_CHECKING(for pragma INIT/FINI)
146AC_TRY_COMPILE([],
147 [#pragma INIT "my_init"
148  void my_init(void)],
149 [AC_MSG_RESULT(yes)
150  AC_DEFINE(HAVE_PRAGMA_INIT, 1, [Define to 1 if you have pragma INIT])],
151 [AC_MSG_RESULT(no)])
152
153AC_MSG_CHECKING(for __printf__ attribute)
154ac_v_attribute_printf=""
155AC_TRY_COMPILE([],
156 [extern void foo(const char *, ...)
157     __attribute__((__format__(__printf__, 1, 2)));],
158 [AC_MSG_RESULT(yes)
159  ac_v_attribute_printf="__attribute__((__format__(__printf__, x, y)))"],
160 [AC_MSG_RESULT(no)])
161AC_DEFINE_UNQUOTED(ATTRIBUTE_PRINTF(x,y), $ac_v_attribute_printf, [Define to the __printf__ attribute if present])
162
163ac_cv_have_getopt_long="no"
164AC_CHECK_FUNCS(getopt_long,
165 [ac_cv_have_getopt_long="yes"],
166 [AC_CHECK_LIB(gnugetopt, getopt_long,
167   [ac_cv_have_getopt_long="yes"
168    GETOPT_LIBS="${GETOPT_LIBS} -lgnugetopt"])])
169if test "$ac_cv_have_getopt_long" != "no"; then
170  AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)
171fi
172AM_CONDITIONAL(NEED_GETOPT_LONG, test "$ac_cv_have_getopt_long" = "no")
173AC_SUBST(GETOPT_LIBS)
174
175AC_CHECK_LIB(m, log, [MATH_LIBS="-lm"])
176AC_SUBST(MATH_LIBS)
177AC_CHECK_LIB(dl, dlopen, [DL_LIBS="-ldl"])
178AC_SUBST(DL_LIBS)
179
180AC_CONFIG_FILES([
181  Makefile
182  src/Makefile
183  doc/Makefile
184  test/Makefile
185])
186AC_CONFIG_FILES([
187  doc/zzat.1
188  doc/zzuf.1
189  doc/libzzuf.3
190])
191AC_OUTPUT
192
Note: See TracBrowser for help on using the repository browser.