source: zzuf/trunk/configure.ac @ 4032

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

We need to know the FILE buffer's current fill status. Implemented for
glibc for now.

File size: 6.1 KB
Line 
1# $Id: configure.ac 98 2006-09-22 16:27:37Z sam $
2
3AC_INIT(zzuf, 0.12)
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  *) 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)
49
50AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
51AC_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 __uflow 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)
52
53AC_CHECK_TYPES(sighandler_t, [], [],
54  [#define _GNU_SOURCE
55   #include <signal.h>])
56AC_CHECK_TYPES(sig_t, [], [],
57  [#include <signal.h>])
58AC_CHECK_TYPES(socklen_t, [], [],
59  [#include <sys/types.h>
60   #include <sys/socket.h>])
61
62AC_MSG_CHECKING(for read() prototype)
63AC_TRY_COMPILE([#define _INCLUDE_POSIX_SOURCE
64                #include <unistd.h>],
65 [ssize_t read(int fd, void *buf, size_t count);],
66 [AC_MSG_RESULT(ssize_t read(... size_t);)
67  AC_DEFINE(READ_USES_SSIZE_T, 1, [Define to 1 if read() uses ssize_t.])],
68 [AC_MSG_RESULT(int read(... unsigned int);)])
69
70AC_MSG_CHECKING(for recv() return value)
71ac_v_recv_t="int"
72AC_TRY_COMPILE([#define _XOPEN_SOURCE_EXTENDED
73                #include <sys/types.h>
74                #include <sys/socket.h>],
75 [ssize_t recv(int s, void *buf, size_t len, int flags);],
76 [ac_v_recv_t="ssize_t"])
77AC_MSG_RESULT($ac_v_recv_t)
78AC_DEFINE_UNQUOTED(RECV_T, $ac_v_recv_t, [Define to the recv() return type])
79
80AC_MSG_CHECKING(for FILE* internal members)
81ac_cv_have_glibc_fp="no"
82ac_v_fp_base="unknown"
83ac_v_fp_ptr="unknown"
84ac_v_fp_cnt="unknown"
85AC_TRY_COMPILE([#include <stdio.h>],
86 [FILE *fp; fp->_IO_read_ptr++; fp->_IO_read_end++],
87 [ac_cv_have_glibc_fp=yes; ac_v_fp_base=_IO_read_base
88  ac_v_fp_cnt=_IO_read_end; ac_v_fp_ptr=_IO_read_ptr],
89 [AC_TRY_COMPILE([#include <stdio.h>],
90   [FILE *fp; fp->__cnt++; fp->__ptr++],
91   [ac_v_fp_base=FIXME; ac_v_fp_ptr=__ptr; ac_v_fp_cnt=__cnt],
92   [AC_TRY_COMPILE([#include <stdio.h>],
93     [FILE *fp; fp->_cnt++; fp->_ptr++],
94     [aac_v_fp_base=FIXME; c_v_fp_ptr=_ptr; ac_v_fp_cnt=_cnt],
95     [AC_TRY_COMPILE([#include <stdio.h>],
96       [FILE *fp; fp->_c++; fp->_p++],
97       [aac_v_fp_base=FIXME; c_v_fp_ptr=_p; ac_v_fp_cnt=_c],
98       [AC_TRY_COMPILE([#include <stdio.h>],
99         [FILE *fp; fp->_r++; fp->_p++],
100         [aac_v_fp_base=FIXME; c_v_fp_ptr=_p; ac_v_fp_cnt=_r])])])])])
101AC_MSG_RESULT($ac_v_fp_base/$ac_v_fp_ptr/$ac_v_fp_cnt)
102if test "$ac_cv_have_glibc_fp" != "no"; then
103  AC_DEFINE(HAVE_GLIBC_FP, 1, [Define to 1 if FILE has glibc-style members])
104fi
105AC_DEFINE_UNQUOTED(FILE_BASE, $ac_v_fp_base, [Define to the FILE::base member])
106AC_DEFINE_UNQUOTED(FILE_PTR, $ac_v_fp_ptr, [Define to the FILE::ptr member])
107AC_DEFINE_UNQUOTED(FILE_CNT, $ac_v_fp_cnt, [Define to the FILE::cnt member])
108
109dnl  On HP-UX, fpos64_t == int64_t, but on Linux it's a compound object.
110AC_MSG_CHECKING(how to access fpos64_t x)
111ac_v_fpos64_t="unknown"
112AC_TRY_COMPILE(
113 [#define _LARGEFILE64_SOURCE
114  #include <stdio.h>],
115 [fpos64_t x; long long int y = x.__pos;],
116 [ac_v_fpos64_t="(x).__pos"])
117AC_TRY_COMPILE(
118 [#define _LARGEFILE64_SOURCE
119  #include <stdio.h>],
120 [fpos64_t x; long long int y = (long long int)x;],
121 [ac_v_fpos64_t="(x)"])
122AC_MSG_RESULT($ac_v_fpos64_t)
123AC_DEFINE_UNQUOTED(FPOS_CAST(x), $ac_v_fpos64_t, [Define to a macro for accessing an fpos64_t variable])
124
125AC_MSG_CHECKING(for pragma INIT/FINI)
126AC_TRY_COMPILE([],
127 [#pragma INIT "my_init"
128  void my_init(void)],
129 [AC_MSG_RESULT(yes)
130  AC_DEFINE(HAVE_PRAGMA_INIT, 1, [Define to 1 if you have pragma INIT])],
131 [AC_MSG_RESULT(no)])
132
133AC_MSG_CHECKING(for __printf__ attribute)
134ac_v_attribute_printf=""
135AC_TRY_COMPILE([],
136 [extern void foo(const char *, ...)
137     __attribute__((__format__(__printf__, 1, 2)));],
138 [AC_MSG_RESULT(yes)
139  ac_v_attribute_printf="__attribute__((__format__(__printf__, x, y)))"],
140 [AC_MSG_RESULT(no)])
141AC_DEFINE_UNQUOTED(ATTRIBUTE_PRINTF(x,y), $ac_v_attribute_printf, [Define to the __printf__ attribute if present])
142
143ac_cv_have_getopt_long="no"
144AC_CHECK_FUNCS(getopt_long,
145 [ac_cv_have_getopt_long="yes"],
146 [AC_CHECK_LIB(gnugetopt, getopt_long,
147   [ac_cv_have_getopt_long="yes"
148    GETOPT_LIBS="${GETOPT_LIBS} -lgnugetopt"])])
149if test "$ac_cv_have_getopt_long" != "no"; then
150  AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)
151fi
152AM_CONDITIONAL(NEED_GETOPT_LONG, test "$ac_cv_have_getopt_long" = "no")
153AC_SUBST(GETOPT_LIBS)
154
155AC_CHECK_LIB(m, log, [MATH_LIBS="-lm"])
156AC_SUBST(MATH_LIBS)
157AC_CHECK_LIB(dl, dlopen, [DL_LIBS="-ldl"])
158AC_SUBST(DL_LIBS)
159
160AC_OUTPUT([
161  Makefile
162  src/Makefile
163  doc/Makefile
164  test/Makefile
165])
166
Note: See TracBrowser for help on using the repository browser.