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.
25 if test "$ac_cv_prog_cc_c99" = no; then
26 AC_MSG_ERROR(cannot find a C99-compatible compiler)
33 if test -z "$AR"; then
34 AC_MSG_ERROR(cannot find ar)
37 m4_include(m4/feature_macros.m4)
39 # If GCC, turn on warnings.
40 if test "x$GCC" = "xyes"; then
41 CFLAGS="$CFLAGS -Wall -W"
50 AC_CHECK_TYPES(long long)
52 AC_CHECK_HEADERS(ctype.h pwd.h stdlib.h string.h strings.h sys/time.h sys/mman.h)
53 AC_CHECK_HEADERS(termios.h)
55 AC_CHECK_FUNCS(gethostname)
56 AC_CHECK_FUNCS(getopt_long)
57 AC_CHECK_FUNCS(getpwuid)
58 AC_CHECK_FUNCS(gettimeofday)
59 AC_CHECK_FUNCS(mkstemp)
60 AC_CHECK_FUNCS(realpath)
61 AC_CHECK_FUNCS(strndup)
62 AC_CHECK_FUNCS(strtok_r)
63 AC_CHECK_FUNCS(unsetenv)
64 AC_CHECK_FUNCS(utimes)
66 AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
68 [#include <stdlib.h>],
69 [void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }],
70 ccache_cv_COMPAR_FN_T=yes,
71 ccache_cv_COMPAR_FN_T=no)])
72 if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then
73 AC_DEFINE(HAVE_COMPAR_FN_T, 1,
74 Define to 1 if you have the `__compar_fn_t' typedef.)
77 dnl Replacements of snprintf and friends.
78 m4_include(m4/snprintf.m4)
84 dnl Check if -lm is needed.
85 AC_SEARCH_LIBS(cos, m)
89 AC_ARG_WITH(bundled-zlib,
90 [AS_HELP_STRING([--with-bundled-zlib],
91 [use bundled zlib instead of the system's default zlib])])
92 if test x${with_bundled_zlib} = x; then
95 [ccache_cv_zlib_1_2_3],
99 #if (ZLIB_VERNUM >= 0x1230)
101 #error "ZLIB_VERNUM < 0x1230"
104 [ccache_cv_zlib_1_2_3=yes],
105 [ccache_cv_zlib_1_2_3=no]))
106 AC_CHECK_LIB(z, gzdopen, true)
107 if test $ccache_cv_zlib_1_2_3 = yes && test $ac_cv_lib_z_gzdopen = yes; then
110 AC_MSG_WARN(using bundled zlib)
114 AC_MSG_NOTICE(using bundled zlib as requested)
118 if test x${use_bundled_zlib} = xyes; then
119 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/zlib"
120 extra_libs="zlib/libz.a"
126 dnl Linking on Windows needs ws2_32
127 if test x${windows_os} = xyes; then
128 LIBS="$LIBS -lws2_32"
129 AC_CHECK_FUNCS(GetFinalPathNameByHandleW,[],[LIBS="$LIBS -lpsapi"])
136 dnl Check for "extern inline".
139 ac_cv_c_extern_inline,
141 ac_cv_c_extern_inline=no
144 extern $ac_cv_c_inline double foo(double x);
145 extern $ac_cv_c_inline double foo(double x) { return x+1.0; };
146 double foo (double x) { return x + 1.0; };
149 [ac_cv_c_extern_inline="yes"])])
150 if test "$ac_cv_c_extern_inline" != no ; then
151 AC_DEFINE(HAVE_EXTERN_INLINE, 1,
152 Define to 1 if your compiler supports extern inline)
155 dnl Enable developer mode if dev.mk.in exists.
156 if test ! -f $srcdir/dev_mode_disabled && test "$RUN_FROM_BUILD_FARM" != yes; then
157 AC_MSG_NOTICE(Developer mode enabled)
158 AC_CONFIG_FILES([dev.mk])
159 include_dev_mk='include dev.mk'
160 version=`(git --git-dir=$srcdir/.git describe --dirty 2>/dev/null || echo vunknown) | sed -e 's/v//' -e 's/-/+/' -e 's/-/_/g'`
161 echo "const char CCACHE_VERSION@<:@@:>@ = \"$version\";" >version.c
163 AC_MSG_NOTICE(Developer mode disabled)
166 if test ! -f $srcdir/version.c; then
167 AC_MSG_WARN(unable to determine ccache version)
168 echo "const char CCACHE_VERSION@<:@@:>@ = \"unknown\";" >version.c
171 dnl Find test suite files.
172 test_suites=`ls $srcdir/test/test_*.c | egrep -v 'BASE|BACKUP|LOCAL|REMOTE' | xargs echo`
174 AC_CONFIG_FILES([Makefile])
177 cat <<EOF >config.h.tmp
178 #ifndef CCACHE_CONFIG_H
179 #define CCACHE_CONFIG_H
181 cat config.h >>config.h.tmp
182 echo '#endif' >>config.h.tmp
183 mv config.h.tmp config.h
188 AC_MSG_NOTICE(now build ccache by running make)