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