]> granicus.if.org Git - zziplib/blob - configure.ac
aligned access
[zziplib] / configure.ac
1 AC_INIT(zziplib.spec)
2 AC_PREREQ(2.49)
3 AC_COPYRIGHT([Guido Draheim <guido@gmx.de> for ZZipLib.SF.net])
4 AC_REVISION($Revision: 1.7 $)
5 AC_CONFIG_AUX_DIR(uses)
6 # =======================================================================
7 AC_CANONICAL_SYSTEM
8 dnl AM_ENABLE_MULTILIB([Makefile],[$host])
9 AX_ENABLE_BUILDDIR_UNAME
10 AC_SET_DEFAULT_PATHS_SYSTEM
11 # -----------------------------------------------------------------------
12 AC_ARG_ENABLE(thread-safe,AC_HELP_STRING(
13    [--disable-thread-safe],[disable thread-safe libtool option])
14    ,,[ enable_thread_safe="yes"])
15 THREAD_SAFE=""
16 test "$enable_thread_safe" = "yes" && THREAD_SAFE="-thread-safe"
17 test "$enable_thread_safe" = "$host_os" && THREAD_SAFE="-thread-safe"
18 AC_SUBST(THREAD_SAFE)
19 if test -n "$THREAD_SAFE" ; then
20   AC_MSG_RESULT(...using thread-safe linkage)
21 else
22   AC_MSG_RESULT(disabled thread-safe linkage)
23 fi
24 # ----------------------------------------------------------------
25 AC_MSG_CHECKING(zlib install prefix)
26 AC_ARG_WITH(zlib, AC_HELP_STRING(
27     [--with-zlib],[zlib prefix (e.g. '$HOME/software')])
28     ,,[with_zlib="no"])
29 if test "${with_zlib}" = yes ; then # choose --prefix paths
30    if test "${prefix}" = NONE ; then
31       AC_MSG_RESULT(oops, but only itself...)
32       AC_MSG_ERROR(--with-zlib requires a path argument or a --prefix path set)
33    fi
34    with_zlib="$prefix"
35 fi
36
37 case ".$with_zlib" in
38    .no|.no,*)
39       AC_MSG_RESULT(none) 
40       with_zlib="no, not configured" ;;
41   ./usr)
42       AC_MSG_RESULT([oops, ignored (may try --with-zlib=/usr/.)])
43       with_zlib="no, /usr ignored" ;;
44   *)  if test ! -d "$with_zlib/include" ; then
45          AC_MSG_RESULT(oops, given but...)
46          AC_MSG_ERROR("$with_zlib/include" is not a directory)
47       fi
48       if test ! -d "$with_zlib/lib" ; then
49          AC_MSG_RESULT(oops, given but...)
50          AC_MSG_ERROR("$with_zlib/lib" is not a directory)
51       fi
52       AC_MSG_RESULT($with_zlib)
53       ZLIB_INCL="-I$with_zlib/include"
54       ZLIB_LDIR="-L$with_zlib/lib"
55       AC_MSG_RESULT(..adding CPPFLAGS $ZLIB_INCL)
56       AC_MSG_RESULT(..adding LDFLAGS  $ZLIB_LDIR)
57       CPPFLAGS="$CPPFLAGS $ZLIB_INCL"
58       LDFLAGS="$LDFLAGS $ZLIB_LDIR"
59   ;;
60 esac
61 AC_SUBST(ZLIB_INCL)
62 AC_SUBST(ZLIB_LDIR)
63 # -----------------------------------------------------------------------
64 AX_SPEC_DEFAULTS
65 AM_INIT_AUTOMAKE($PACKAGE,$VERSION)
66 dnl test ".$CFLAGS" = "." && CFLAGS="" 
67 AC_PROG_CC
68 dnl test ".$CFLAGS" = "." && test "$GCC" = "yes" && CFLAGS="-O3"
69 AC_PROG_INSTALL
70 AC_LIBTOOL_WIN32_DLL
71 AM_PROG_LIBTOOL
72 AX_SET_VERSION_INFO
73
74 # -----------------------------------------------------------------------
75 AC_MSG_RESULT([creating zzip/_msvc.in via zzip/_msvc.sed of config.h.in])
76 test -d zzip || mkdir zzip
77 sed -f $srcdir/zzip/_msvc.sed $srcdir/config.h.in >zzip/_msvc.in
78 AC_CONFIG_HEADER(config.h)
79 AX_PREFIX_CONFIG_H([zzip/_config.h],[zzip],[config.h])
80 AX_PREFIX_CONFIG_H([zzip/_msvc.h],[zzip],[zzip/_msvc.in])
81 AM_MAINTAINER_MODE
82
83 AX_CREATE_PKGCONFIG_INFO(dnl
84 [zzip/zziplib.pc], [zzip-zlib-config],[-lzzip])
85 # -----------------------------------------------------------------------
86 AC_PATH_PROGS(PERL, perl5 perl, echo no perl found for)
87 AC_PATH_PROGS(PYTHON, python2.2 python2.3 python, echo no python found for)
88 AC_PATH_PROGS(MKZIP, zip pkzip, :)
89 AC_PATH_PROGS(XMLTO, xmlto, :)
90
91 AC_C_INLINE
92 AC_C_CONST
93 ACX_C_RESTRICT
94 AC_STDC_HEADERS
95 AC_HEADER_DIRENT
96 AC_CHECK_HEADERS(stdint.h unistd.h windows.h winnt.h winbase.h sys/int_types.h)
97 AC_CHECK_HEADERS(sys/types.h sys/mman.h sys/stat.h sys/param.h) dnl posix'ish
98 AC_CHECK_HEADERS(io.h direct.h zlib.h byteswap.h)
99 AC_CHECK_HEADERS(fnmatch.h)
100 AC_CHECK_FUNCS( strcasecmp strndup )
101
102 AC_TYPE_OFF_T
103 AC_TYPE_SIZE_T
104 dnl AC_TYPE_SSIZE_T
105 AC_CHECK_TYPE(ssize_t,int)
106 AC_CHECK_TYPE(off64_t,_zzip_off_t)
107 AC_CHECK_TYPE(__int64,long long)
108 AC_COMPILE_CHECK_SIZEOF(short)
109 AC_COMPILE_CHECK_SIZEOF(int)
110 AC_COMPILE_CHECK_SIZEOF(long)
111 AC_C_BIGENDIAN
112 AX_CHECK_ALIGNED_ACCESS_REQUIRED
113 dnl -------------------------------------------------------------
114 # the default is _disabled_!! anyway, result is prefixed in zzip/_config.h!!
115 AC_SYS_LARGEFILE_SENSITIVE
116 test ".$LARGEFILE_CFLAGS" = "." && LARGEFILE_CFLAGS=""
117 AC_ARG_WITH(largefile,AC_HELP_STRING(
118     [--with-largefile],[compile as off64_t instead of 32bit off_t])
119     ,,[with_largefile="no"])
120 if test ".$ac_cv_sys_largefile_sensitive" = ".no" ; then
121   AC_MSG_RESULT(compiles library with the only off_t seen)
122 elif test ".$with_largefile" != ".no" ; then
123   AC_MSG_RESULT(compiles library as 64bit off_t variant dnl
124 - and renaming some function names)
125   LARGEFILE_CFLAGS="$LARGEFILE_CFLAGS -D_LARGEFILE_SOURCE"  
126   AC_MSG_RESULT(..adding CFLAGS $LARGEFILE_CFLAGS)
127   CFLAGS="$CFLAGS $LARGEFILE_CFLAGS"
128   AC_MSG_RESULT(..adding 64 into RELEASE_INFO for the libraries)
129   RELEASE_INFO="$RELEASE_INFO-64"
130 else
131   AC_MSG_RESULT(compiles library as 32bit off_t variant dnl
132 - largefile is not the default here)
133 fi
134 AC_SUBST(LARGEFILE_CFLAGS)
135 dnl -------------------------------------------------------------
136 AC_MSG_CHECKING(for zlib being found)
137 if test "_$ac_cv_header_zlib_h" != "_yes" ; then
138   AC_MSG_RESULT(dnl
139 ...oops: zlib.h not found - try adding some CPPFLAGS to configure call)
140          AC_MSG_RESULT(dnl
141 ...note: and when linkage fails you might also need to set some LDFLAGS)
142   case "$prefix" in
143     NONE|/usr) 
144             AC_MSG_RESULT(dnl
145 ...note: both can be set by specifying the install prefix of the zlib library)
146             AC_MSG_RESULT(dnl
147 ...note: via --with-zlib=path ... it will test for -Ipath/include -Lpath/lib)
148     ;;
149     *) if test -d $prefix/include ; then
150          AC_MSG_RESULT(dnl
151 ...note: -I$prefix/include is not added to CPPFLAGS automatically and)
152          AC_MSG_RESULT(dnl
153 ...note: neither is -L$prefix/lib for LDFLAGS .. both will be if you specify)
154          AC_MSG_RESULT(dnl
155 ...note: --with-zlib to configure call, or use --with-zlib=installprefix)
156        fi
157      ;;
158   esac
159   AC_MSG_ERROR(zlib.h not found: "zlib" is required to build "$PACKAGE")
160   exit 1
161 fi
162 cat >conftest.c <<EOF
163 #include <zlib.h>
164 const char* zlib_VeRsIoN = ZLIB_VERSION "dEtEcT";
165 EOF
166 ZLIB_VERSION=`(eval "$ac_cpp conftest.c") 2>/dev/null \
167 | grep zlib_VeRsIoN | sed -e 's,.*= *.,,' -e 's,. *.dEtEcT.*,,'`
168 rm conftest.c
169 AC_SUBST(ZLIB_VERSION)
170 AC_MSG_RESULT(yes - $ZLIB_VERSION)
171 # ----------------------------------------------------------------
172 AC_MSG_CHECKING(docdir default)
173 AC_ARG_WITH(docdir, AC_HELP_STRING(
174     [--with-docdir],[docdir prefix (prefix/share/doc)])
175     ,,[with_docdir="no"])
176 case "${with_docdir}" in
177  prefix/*)  docdir=` echo "$withval" | sed 's/^prefix/${prefix}'` ;;
178  datadir/*) docdir=` echo "$withval" | sed 's/^datadir/${datadir}'` ;;
179  yes) docdir='${prefix}/doc' ;;
180  no)  docdir='${datadir}/doc' ;;
181  /*|\\*|[a-zA-Z]:*) docdir="$with_docdir"  ;;
182  *) AC_MSG_RESULT(oops)
183     AC_MSG_ERROR(bad value ${withval} for --with-docdir) 
184  ;;
185 esac
186 AC_SUBST(docdir)
187 AC_MSG_RESULT($docdir)
188 # ----------------------------------------------------------------
189 AC_MSG_CHECKING(whether using debugging messages in libraries)
190 AC_ARG_WITH(debug, AC_HELP_STRING(
191     [--with-debug],[debug messages in library])
192     , [case "${withval}" in
193                 yes|no) with_debug="$withval" ;;
194                 *) AC_MSG_RESULT(oops)
195                    AC_MSG_ERROR(bad value ${withval} for --with-debug) ;;
196        esac], [with_debug="no"])
197 test "$with_debug" != "yes" && with_debug="no" # yes or no
198 test "$with_debug" = "yes" && export CFLAGS="$CFLAGS -DDEBUG" 
199 result="$with_debug" ; test "$result" = "yes" && result="yes, added -DDEBUG"
200 AC_MSG_RESULT($result)
201 if test "$with_debug" = "yes" ; then if test -n "$RELEASE_INFO" ; then
202    RELEASE_INFO="$RELEASE_INFO-dbg"
203    AC_MSG_RESULT(modified release, $RELEASE_INFO)
204 fi fi
205 # ----------------------------------------------------------------
206 AC_MSG_CHECKING(whether thread stack is too small for bufsiz buffers)
207  # many embedded platforms, superthreaded systems and kernel usage
208  # will severely limit the stackspace for its threads. Use _LOWSTK
209  # compile-define on those platforms.
210 AC_ARG_WITH(lowstk, AC_HELP_STRING(
211     [--with-lowstk], [limited thread stack])
212     , [case "${withval}" in
213                 yes|no|auto) with_lowstk="$withval" ;;
214                 *) AC_MSG_ERROR(bad value ${withval} for --with-lowstk) ;;
215        esac], [with_lowstk="auto"])
216 if test "$with_lowstk" = "auto"; then
217   case $target in
218         *-palmos-*) $with_lowstk="yes" ;;
219   esac
220 fi
221 test "$with_lowstk" != "yes" && with_lowstk="no" # yes or no
222 test "$with_lowstk" = "yes" && CFLAGS="$CFLAGS -D_LOWSTK" 
223 result="$with_lowstk" ; test "$result" = "yes" && result="yes, added -D_LOWSTK"
224 AC_MSG_RESULT($with_lowstk)
225 # ---------------------------------------------------------------
226 AC_MSG_CHECKING(whether can use mmap for file scanning)
227  # system with mmap are probably better performing an searching
228  # and parsing - atleast memory consumption is far better
229 AC_ARG_ENABLE(mmap, AC_HELP_STRING(
230    [--disable-mmap],[disable mmap usage])
231    , [case "${enableval}" in
232                 yes|no|auto) enable_mmap="${enableval}" ;;
233                 *) AC_MSG_RESULT(oops)
234                    AC_MSG_ERROR(bad value ${enableval} for --disable-mmap) ;;
235       esac], [enable_mmap="auto"])
236 if test "$enable_mmap" = "auto"
237 then
238     test "$ac_cv_header_winbase_h"  && enable_mmap="yes, winbase.h"
239     test "$ac_cv_header_sys_mman_h" && enable_mmap="yes, sys/mman.h"
240 fi
241 case "$enable_mmap" in
242    yes|yes,*) CFLAGS="$CFLAGS -D_USE_MMAP"
243       AC_MSG_RESULT($enable_mmap, added -D_USE_MMAP) ;;
244    *) enable_mmap="no"
245       AC_MSG_RESULT(no (just a bit slower)) ;;
246 esac
247 # ---------------------------------------------------------------
248 AC_MSG_CHECKING(whether making SDL parts)
249 SDL=""
250 AC_ARG_ENABLE(sdl, AC_HELP_STRING(
251     [--enable-sdl],[enable SDL usage (if present)])
252     ,,[enable_sdl="no"])
253 if test "$enable_sdl" = "no" ; then
254    AC_MSG_RESULT([no, disabled])
255 else
256    enable_sdl=`sdl-config --version 2>/dev/null`
257    case ".$enable_sdl" in
258      .1.*) AC_MSG_RESULT([yes, for SDL $enable_sdl])
259            SDL="SDL" ;;
260      .2.*) AC_MSG_RESULT([yes, untested $enable_sdl])
261            SDL="SDL" ;;
262      *)    AC_MSG_RESULT([no, $enable_sdl]) ;;
263    esac
264 fi
265 AC_SUBST(SDL)
266 # ---------------------------------------------------------------
267 AC_MSG_CHECKING(running extra tests on make check)
268 if test "MKZIP" != ":" ; then
269   AC_MSG_RESULT(yes)
270   ZIPTESTS=""
271 else
272   AC_MSG_RESULT(no)
273   ZIPTESTS="#"
274 fi
275 AC_SUBST(ZIPTESTS)
276 # ---------------------------------------------------------------
277 AC_MSG_CHECKING(link options)
278 case "$host_os" in
279   mingw*) 
280     ZZIPLIB_LDFLAGS="-no-undefined -export-all-symbols -mconsole"
281     RESOLVES=' '
282   ;;
283   *)
284     ZZIPLIB_LDFLAGS="--export-dynamic"
285     RESOLVES=' # '
286   ;;
287 esac
288 AC_MSG_RESULT([$ZZIPLIB_LDFLAGS $RESOLVES])
289 AC_SUBST([ZZIPLIB_LDFLAGS])
290 AC_SUBST([RESOLVES])
291 # ---------------------------------------------------------------
292 AX_MAINTAINER_MODE_AUTO_SILENT
293 AX_NOT_ENABLE_FRAME_POINTER
294 AX_CFLAGS_WARN_ALL
295 AX_CFLAGS_NO_WRITABLE_STRINGS
296 AX_CFLAGS_STRICT_PROTOTYPES
297 AX_CFLAGS_GCC_OPTION(-Wpointer-arith)
298 AX_CFLAGS_GCC_OPTION(-Wsign-compare)
299 AX_CFLAGS_GCC_OPTION(-Wmissing-declarations)
300 # ---------------------------------------------------------------
301 AX_ENABLE_DEFAULT_PKGCONFIGDIR
302 AX_ENABLE_DEFAULT_ACLOCALDIR
303 AC_SUBST([CONFIG_FILES])
304 AC_OUTPUT([Makefile zzip/Makefile zzipwrap/Makefile SDL/Makefile
305            docs/Makefile test/Makefile bins/Makefile])
306 dnl -------------------------------------------------------------
307 PATCH_LIBTOOL_ON_DARWIN_ZSH_OVERQUOTING
308 PATCH_LIBTOOL_SYS_LIB_SEARCH_PATH_SPEC
309 PATCH_LIBTOOL_TO_ADD_HOST_CC
310 # ---------------------------------------------------------------
311 echo '-----' $PACKAGE $VERSION $prefix
312 $SHELL libtool --features || true
313 echo "CFLAGS=$CFLAGS"
314 test "$enable_mmap" != "no" && echo "enable  mmap   ($enable_mmap)"
315 test "$enable_mmap"  = "no" && echo "disable mmap   ($enable_mmap)"
316 test "$with_lowstk" != "no" && echo "with    lowstk ($with_lowstk)"
317 test "$with_lowstk"  = "no" && echo "without lowstk ($with_lowstk)"
318 test "$with_debug"  != "no" && echo "with    debug  ($with_debug)"
319 test "$with_debug"   = "no" && echo "without debug  ($with_debug)"
320 # test -f ./zziplib.spec && echo warning - do not build in the source dirs
321 echo '# make  && make check  && make install'