source: zzuf/trunk/configure.ac @ 2578

Last change on this file since 2578 was 2578, checked in by Sam Hocevar, 12 years ago
  • configure.ac: fix the printf attribute macro.
File size: 5.3 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# Optimizations
18AC_TRY_CFLAGS(-g -O2, CFLAGS="${CFLAGS} -g -O2")
19# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
20AC_TRY_CFLAGS(-Wall, CFLAGS="${CFLAGS} -Wall")
21AC_TRY_CFLAGS(-W, CFLAGS="${CFLAGS} -W")
22AC_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
24case "${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    ;;
35esac
36AC_SUBST(WINSOCK2_LIBS)
37AC_SUBST(DLL_LDFLAGS)
38
39AC_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
41AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
42AC_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
44AC_CHECK_TYPES(sighandler_t, [], [],
45  [#define _GNU_SOURCE
46   #include <signal.h>])
47AC_CHECK_TYPES(sig_t, [], [],
48  [#include <signal.h>])
49AC_CHECK_TYPES(socklen_t, [], [],
50  [#include <sys/types.h>
51   #include <sys/socket.h>])
52
53AC_MSG_CHECKING(for read() prototype)
54AC_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
61AC_MSG_CHECKING(for recv() return value)
62ac_v_recv_t="int"
63AC_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"])
68AC_MSG_RESULT($ac_v_recv_t)
69AC_DEFINE_UNQUOTED(RECV_T, $ac_v_recv_t, [Define to the recv() return type])
70
71AC_MSG_CHECKING(for FILE* internal members)
72ac_v_fp_cnt="unknown"
73ac_v_fp_ptr="unknown"
74AC_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])])])])
86AC_MSG_RESULT($ac_v_fp_cnt/$ac_v_fp_ptr)
87AC_DEFINE_UNQUOTED(FILE_CNT, $ac_v_fp_cnt, [Define to the FILE::cnt member name])
88AC_DEFINE_UNQUOTED(FILE_PTR, $ac_v_fp_ptr, [Define to the FILE::ptr member name])
89
90dnl  On HP-UX, fpos64_t == int64_t, but on Linux it's a compound object.
91AC_MSG_CHECKING(how to access fpos64_t x)
92ac_v_fpos64_t="unknown"
93AC_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"])
98AC_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)"])
103AC_MSG_RESULT($ac_v_fpos64_t)
104AC_DEFINE_UNQUOTED(FPOS_CAST(x), $ac_v_fpos64_t, [Define to a macro for accessing an fpos64_t variable])
105
106AC_MSG_CHECKING(for pragma INIT/FINI)
107AC_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
114AC_MSG_CHECKING(for __printf__ attribute)
115ac_v_attribute_printf=""
116AC_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)])
122AC_DEFINE_UNQUOTED(ATTRIBUTE_PRINTF(x,y), $ac_v_attribute_printf, [Define to the __printf__ attribute if present])
123
124ac_cv_have_getopt_long="no"
125AC_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"])])
130if 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.)
132fi
133AM_CONDITIONAL(NEED_GETOPT_LONG, test "$ac_cv_have_getopt_long" = "no")
134AC_SUBST(GETOPT_LIBS)
135
136AC_CHECK_LIB(m, log, [MATH_LIBS="-lm"])
137AC_SUBST(MATH_LIBS)
138AC_CHECK_LIB(dl, dlopen, [DL_LIBS="-ldl"])
139AC_SUBST(DL_LIBS)
140
141AC_OUTPUT([
142  Makefile
143  src/Makefile
144  doc/Makefile
145  test/Makefile
146])
147
Note: See TracBrowser for help on using the repository browser.