1 dnl Process this file with autoconf to produce a configure script.
6 AC_MSG_NOTICE([Configuring ccache])
8 AC_CONFIG_HEADER(config.h)
13 *mingw32* | *mingw64* | *cygwin* | *wince* | *mingwce*)
15 AC_DEFINE(_WIN32_WINNT,0x0600, Windows Vista or newer is required)
20 AC_SUBST(include_dev_mk)
23 dnl Checks for programs.
29 if test -z "$AR"; then
30 AC_MSG_ERROR(cannot find ar)
33 m4_include(m4/feature_macros.m4)
35 # If GCC, turn on warnings.
36 if test "x$GCC" = "xyes"; then
37 CFLAGS="$CFLAGS -Wall -W"
47 AC_CHECK_TYPES(long long)
49 AC_CHECK_HEADERS(ctype.h pwd.h stdlib.h string.h strings.h sys/time.h sys/mman.h)
50 AC_CHECK_HEADERS(termios.h)
52 AC_CHECK_FUNCS(gethostname)
53 AC_CHECK_FUNCS(getopt_long)
54 AC_CHECK_FUNCS(getpwuid)
55 AC_CHECK_FUNCS(gettimeofday)
56 AC_CHECK_FUNCS(mkstemp)
57 AC_CHECK_FUNCS(realpath)
58 AC_CHECK_FUNCS(strndup)
59 AC_CHECK_FUNCS(strtok_r)
60 AC_CHECK_FUNCS(unsetenv)
61 AC_CHECK_FUNCS(utimes)
63 AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
65 [#include <stdlib.h>],
66 [void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }],
67 ccache_cv_COMPAR_FN_T=yes,
68 ccache_cv_COMPAR_FN_T=no)])
69 if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then
70 AC_DEFINE(HAVE_COMPAR_FN_T, 1,
71 Define to 1 if you have the `__compar_fn_t' typedef.)
74 dnl Replacements of snprintf and friends.
75 m4_include(m4/snprintf.m4)
81 dnl Check if -lm is needed.
82 AC_SEARCH_LIBS(cos, m)
86 AC_ARG_WITH(bundled-zlib,
87 [AS_HELP_STRING([--with-bundled-zlib],
88 [use bundled zlib instead of the system's default zlib])])
89 if test x${with_bundled_zlib} = x; then
92 [ccache_cv_zlib_1_2_3],
96 #if (ZLIB_VERNUM >= 0x1230)
98 #error "ZLIB_VERNUM < 0x1230"
101 [ccache_cv_zlib_1_2_3=yes],
102 [ccache_cv_zlib_1_2_3=no]))
103 AC_CHECK_LIB(z, gzdopen, true)
104 if test $ccache_cv_zlib_1_2_3 = yes && test $ac_cv_lib_z_gzdopen = yes; then
107 AC_MSG_WARN(using bundled zlib)
111 AC_MSG_NOTICE(using bundled zlib as requested)
115 if test x${use_bundled_zlib} = xyes; then
116 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/zlib"
117 extra_libs="zlib/libz.a"
123 dnl Linking on Windows needs ws2_32
124 if test x${windows_os} = xyes; then
125 LIBS="$LIBS -lws2_32"
132 dnl Check for "extern inline".
135 ac_cv_c_extern_inline,
137 ac_cv_c_extern_inline=no
140 extern $ac_cv_c_inline double foo(double x);
141 extern $ac_cv_c_inline double foo(double x) { return x+1.0; };
142 double foo (double x) { return x + 1.0; };
145 [ac_cv_c_extern_inline="yes"])])
146 if test "$ac_cv_c_extern_inline" != no ; then
147 AC_DEFINE(HAVE_EXTERN_INLINE, 1,
148 Define to 1 if your compiler supports extern inline)
151 dnl Enable developer mode if dev.mk.in exists.
152 if test ! -f $srcdir/dev_mode_disabled && test "$RUN_FROM_BUILD_FARM" != yes; then
153 AC_MSG_NOTICE(Developer mode enabled)
154 AC_CONFIG_FILES([dev.mk])
155 include_dev_mk='include dev.mk'
156 version=`(git --git-dir=$srcdir/.git describe --dirty 2>/dev/null || echo vunknown) | sed -e 's/v//' -e 's/-/+/' -e 's/-/_/g'`
157 echo "const char CCACHE_VERSION@<:@@:>@ = \"$version\";" >version.c
159 AC_MSG_NOTICE(Developer mode disabled)
162 if test ! -f $srcdir/version.c; then
163 AC_MSG_WARN(unable to determine ccache version)
164 echo "const char CCACHE_VERSION@<:@@:>@ = \"unknown\";" >version.c
167 dnl Find test suite files.
168 test_suites=`ls $srcdir/test/test_*.c | egrep -v 'BASE|BACKUP|LOCAL|REMOTE' | xargs echo`
170 AC_CONFIG_FILES([Makefile])
173 cat <<EOF >config.h.tmp
174 #ifndef CCACHE_CONFIG_H
175 #define CCACHE_CONFIG_H
177 cat config.h >>config.h.tmp
178 echo '#endif' >>config.h.tmp
179 mv config.h.tmp config.h
184 AC_MSG_NOTICE(now build ccache by running make)