source: zzuf/trunk/configure.ac @ 4887

Last change on this file since 4887 was 4887, checked in by Sam Hocevar, 5 years ago

build: remove the libcaca dependency and embed code instead.

File size: 7.1 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([subdir-objects no-define tar-ustar silent-rules])
7
8AC_PREREQ(2.50)
9
10AM_PROG_CC_C_O
11AC_PROG_CPP
12AC_PROG_LIBTOOL
13
14dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
15dnl now otherwise it might be set in an obscure if statement. Same thing for
16dnl PKG_PROG_PKG_CONFIG which needs to be called first.
17AC_EGREP_CPP(yes, foo)
18PKG_PROG_PKG_CONFIG()
19
20dnl Don't let pkg-config fuck our cross-compilation environment
21m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
22if test "$build" != "$host" -a "${PKG_CONFIG_LIBDIR}" = ""; then
23  export PKG_CONFIG_LIBDIR=/dev/null
24fi
25
26AC_C_INLINE
27AC_C_FUNC
28
29# Library suffix
30AC_MSG_CHECKING(for libzzuf full name)
31case "$shrext_cmds" in
32  "") SONAME="libzzuf.so" ;;
33  *) eval SONAME="libzzuf$shrext_cmds" ;;
34esac
35AC_MSG_RESULT($SONAME)
36AC_DEFINE_UNQUOTED(SONAME, "$SONAME", [Define to the libzzuf full name])
37
38# Optimizations
39AC_TRY_CFLAGS(-g -O2, CFLAGS="${CFLAGS} -g -O2")
40# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
41AC_TRY_CFLAGS(-Wall, CFLAGS="${CFLAGS} -Wall")
42AC_TRY_CFLAGS(-W, CFLAGS="${CFLAGS} -W")
43AC_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")
44
45case "${host_os}" in
46  *mingw32*)
47    DLL_LDFLAGS="-Wl,-l,imagehlp" # Trick libtool here
48    WINSOCK2_LIBS="-lws2_32"
49    ac_cv_func_recv=yes
50    ac_cv_func_recvfrom=yes
51    ac_cv_func_socket=yes
52    ac_cv_func_accept=yes
53    ac_cv_func_bind=yes
54    ac_cv_func_connect=yes
55    ;;
56esac
57AC_SUBST(WINSOCK2_LIBS)
58AC_SUBST(DLL_LDFLAGS)
59
60AC_CHECK_HEADERS(windows.h winsock2.h io.h process.h unistd.h inttypes.h stdint.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)
61
62AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe)
63AC_CHECK_FUNCS(regexec regwexec)
64AC_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)
65AC_CHECK_FUNCS(getc_unlocked getchar_unlocked fgetc_unlocked fread_unlocked fgets_unlocked)
66AC_CHECK_FUNCS(__getdelim __srefill __filbuf __srget __uflow)
67AC_CHECK_FUNCS(open64 lseek64 mmap64 fopen64 freopen64 ftello64 fseeko64 fsetpos64)
68AC_CHECK_FUNCS(__open64 __lseek64 __fopen64 __freopen64 __ftello64 __fseeko64 __fsetpos64)
69AC_CHECK_FUNCS(__fgets_chk __fgets_unlocked_chk __fread_chk __fread_unlocked_chk __read_chk __recv_chk __recvfrom_chk)
70AC_CHECK_FUNCS(CreateFileA CreateFileW ReOpenFile ReadFile CloseHandle)
71AC_CHECK_FUNCS(AllocConsole AttachConsole SetConsoleMode WriteConsoleOutputA WriteConsoleOutputW)
72
73AC_CHECK_TYPES(sighandler_t, [], [],
74  [#define _GNU_SOURCE
75   #include <signal.h>])
76AC_CHECK_TYPES(sig_t, [], [],
77  [#include <signal.h>])
78AC_CHECK_TYPES(socklen_t, [], [],
79  [#include <sys/types.h>
80   #include <sys/socket.h>])
81
82AC_MSG_CHECKING(for connect() second argument)
83AC_TRY_COMPILE([#include <sys/types.h>
84                #include <sys/socket.h>],
85 [#if defined HAVE_SOCKLEN_T
86  int connect(int, const struct sockaddr *, socklen_t);
87  #else
88  int connect(int, const struct sockaddr *, int);
89  #endif],
90 [AC_MSG_RESULT(const struct sockaddr *)
91  AC_DEFINE(CONNECT_USES_STRUCT_SOCKADDR, 1, [Define to 1 if connect() uses struct sockaddr.])],
92 [AC_MSG_RESULT(const void *)])
93
94AC_MSG_CHECKING(for read() prototype)
95AC_TRY_COMPILE([#define _INCLUDE_POSIX_SOURCE
96                #include <unistd.h>],
97 [ssize_t read(int fd, void *buf, size_t count);],
98 [AC_MSG_RESULT(ssize_t read(... size_t);)
99  AC_DEFINE(READ_USES_SSIZE_T, 1, [Define to 1 if read() uses ssize_t.])],
100 [AC_MSG_RESULT(int read(... unsigned int);)])
101
102AC_MSG_CHECKING(for recv() return value)
103ac_v_recv_t="int"
104AC_TRY_COMPILE([#define _XOPEN_SOURCE_EXTENDED
105                #include <sys/types.h>
106                #include <sys/socket.h>],
107 [ssize_t recv(int s, void *buf, size_t len, int flags);],
108 [ac_v_recv_t="ssize_t"])
109AC_MSG_RESULT($ac_v_recv_t)
110AC_DEFINE_UNQUOTED(RECV_T, $ac_v_recv_t, [Define to the recv() return type])
111
112AC_MSG_CHECKING([for _IO_read_ptr and _IO_read_end in FILE (glibc-style)])
113AC_TRY_COMPILE([#include <stdio.h>],
114 [FILE *fp; fp->_IO_read_ptr++; fp->_IO_read_end++],
115 [ac_cv_have_glibc_file=yes],
116 [ac_cv_have_glibc_file=no])
117AC_MSG_RESULT($ac_cv_have_glibc_file)
118if test "$ac_cv_have_glibc_file" != "no"; then
119  AC_DEFINE(HAVE_GLIBC_FILE, 1, [Define to 1 if FILE has glibc-style members])
120fi
121
122AC_MSG_CHECKING([for _bf._base, _r and _p in FILE (FreeBSD-style)])
123AC_TRY_COMPILE([#include <stdio.h>],
124 [FILE *fp; fp->_bf._base++; fp->_r++; fp->_p++],
125 [ac_cv_have_freebsd_file=yes],
126 [ac_cv_have_freebsd_file=no])
127AC_MSG_RESULT($ac_cv_have_freebsd_file)
128if test "$ac_cv_have_freebsd_file" != "no"; then
129  AC_DEFINE(HAVE_FREEBSD_FILE, 1, [Define to 1 if FILE has FreeBSD-style members])
130fi
131
132AC_MSG_CHECKING([for _base, _cnt and _ptr in FILE (Solaris-style)])
133AC_TRY_COMPILE([#include <stdio.h>],
134 [FILE *fp; fp->_base++; fp->_cnt++; fp->_ptr++],
135 [ac_cv_have_solaris_file=yes],
136 [ac_cv_have_solaris_file=no])
137AC_MSG_RESULT($ac_cv_have_solaris_file)
138if test "$ac_cv_have_solaris_file" != "no"; then
139  AC_DEFINE(HAVE_SOLARIS_FILE, 1, [Define to 1 if FILE has Solaris-style members])
140fi
141
142dnl  On HP-UX, fpos64_t == int64_t, but on Linux it's a compound object.
143AC_MSG_CHECKING(how to access fpos64_t x)
144ac_v_fpos64_t="unknown"
145AC_TRY_COMPILE(
146 [#define _LARGEFILE64_SOURCE
147  #define _LARGEFILE_SOURCE
148  #include <stdio.h>],
149 [fpos64_t x; long long int y = x.__pos;],
150 [ac_v_fpos64_t="(x).__pos"])
151AC_TRY_COMPILE(
152 [#define _LARGEFILE64_SOURCE
153  #define _LARGEFILE_SOURCE
154  #include <stdio.h>],
155 [fpos64_t x; long long int y = (long long int)x;],
156 [ac_v_fpos64_t="(x)"])
157AC_MSG_RESULT($ac_v_fpos64_t)
158AC_DEFINE_UNQUOTED(FPOS_CAST(x), $ac_v_fpos64_t, [Define to a macro for accessing an fpos64_t variable])
159
160AC_MSG_CHECKING(for pragma INIT/FINI)
161AC_TRY_COMPILE([],
162 [#pragma INIT "my_init"
163  void my_init(void)],
164 [AC_MSG_RESULT(yes)
165  AC_DEFINE(HAVE_PRAGMA_INIT, 1, [Define to 1 if you have pragma INIT])],
166 [AC_MSG_RESULT(no)])
167
168AC_MSG_CHECKING(for __printf__ attribute)
169ac_v_attribute_printf=""
170AC_TRY_COMPILE([],
171 [extern void foo(const char *, ...)
172     __attribute__((__format__(__printf__, 1, 2)));],
173 [AC_MSG_RESULT(yes)
174  ac_v_attribute_printf="__attribute__((__format__(__printf__, x, y)))"],
175 [AC_MSG_RESULT(no)])
176AC_DEFINE_UNQUOTED(ATTRIBUTE_PRINTF(x,y), $ac_v_attribute_printf, [Define to the __printf__ attribute if present])
177
178AC_CHECK_LIB(dl, dladdr,
179 [AC_DEFINE(HAVE_DLADDR, 1, Define to 1 if you have the `dladdr' function.)])
180
181AC_CHECK_LIB(m, log, [MATH_LIBS="-lm"])
182AC_SUBST(MATH_LIBS)
183AC_CHECK_LIB(dl, dlopen, [DL_LIBS="-ldl"])
184AC_SUBST(DL_LIBS)
185
186AC_CONFIG_FILES([
187  Makefile
188  src/Makefile
189  doc/Makefile
190  test/Makefile
191])
192AC_CONFIG_FILES([
193  doc/zzat.1
194  doc/zzuf.1
195  doc/libzzuf.3
196])
197AC_OUTPUT
198
Note: See TracBrowser for help on using the repository browser.