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)
21 AC_SUBST(getopt_long_c)
22 AC_SUBST(include_dev_mk)
23 AC_SUBST(more_warnings)
24 AC_SUBST(no_implicit_fallthrough_warning)
27 m4_include(m4/feature_macros.m4)
28 m4_include(m4/clang.m4)
30 dnl Checks for programs.
32 _AC_LANG_COMPILER_CLANG
34 if test "$ac_cv_prog_cc_c99" = no; then
35 AC_MSG_ERROR(cannot find a C99-compatible compiler)
42 if test -z "$AR"; then
43 AC_MSG_ERROR(cannot find ar)
46 # Prefer bash, needed for test.sh
47 AC_PATH_TOOL(BASH, bash, "/bin/bash")
49 # If GCC (or clang), turn on warnings.
50 if test "$ac_compiler_gnu" = yes; then
51 CFLAGS="$CFLAGS -Wall -W"
56 more_warnings="-Wextra -Wpedantic"
57 if test "$ac_compiler_clang" = yes; then
58 more_warnings="$more_warnings -Weverything"
59 more_warnings="$more_warnings -Wno-conversion"
60 more_warnings="$more_warnings -Wno-disabled-macro-expansion"
61 more_warnings="$more_warnings -Wno-format-nonliteral"
62 more_warnings="$more_warnings -Wno-padded"
63 more_warnings="$more_warnings -Wno-shorten-64-to-32"
64 more_warnings="$more_warnings -Wno-sign-conversion"
67 AC_ARG_ENABLE(more_warnings,
68 [AS_HELP_STRING([--enable-more-warnings],
69 [enable more compiler warnings])])
70 if test x${enable_more_warnings} = xyes; then
71 CFLAGS="$CFLAGS $more_warnings"
78 AC_CHECK_TYPES(long long)
80 AC_CHECK_HEADERS(ctype.h pwd.h stdlib.h string.h strings.h sys/time.h sys/mman.h)
81 AC_CHECK_HEADERS(termios.h)
83 AC_CHECK_FUNCS(gethostname)
84 AC_CHECK_FUNCS(getopt_long)
85 AC_CHECK_FUNCS(getpwuid)
86 AC_CHECK_FUNCS(gettimeofday)
87 AC_CHECK_FUNCS(mkstemp)
88 AC_CHECK_FUNCS(realpath)
89 AC_CHECK_FUNCS(strndup)
90 AC_CHECK_FUNCS(strtok_r)
91 AC_CHECK_FUNCS(unsetenv)
92 AC_CHECK_FUNCS(utimes)
94 if test x"$ac_cv_func_getopt_long" != x"yes"; then
95 getopt_long_c="src/getopt_long.c"
98 AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
100 [#include <stdlib.h>],
101 [void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }],
102 ccache_cv_COMPAR_FN_T=yes,
103 ccache_cv_COMPAR_FN_T=no)])
104 if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then
105 AC_DEFINE(HAVE_COMPAR_FN_T, 1,
106 Define to 1 if you have the `__compar_fn_t' typedef.)
109 dnl Replacements of snprintf and friends.
110 m4_include(m4/snprintf.m4)
116 dnl Check if -lm is needed.
117 AC_SEARCH_LIBS(cos, m)
121 AC_ARG_WITH(bundled-zlib,
122 [AS_HELP_STRING([--with-bundled-zlib],
123 [use bundled zlib instead of the system's default zlib])])
124 if test x${with_bundled_zlib} = x; then
127 [ccache_cv_zlib_1_2_3],
131 #if (ZLIB_VERNUM >= 0x1230)
133 #error "ZLIB_VERNUM < 0x1230"
136 [ccache_cv_zlib_1_2_3=yes],
137 [ccache_cv_zlib_1_2_3=no]))
138 AC_CHECK_LIB(z, gzdopen, true)
139 if test $ccache_cv_zlib_1_2_3 = yes && test $ac_cv_lib_z_gzdopen = yes; then
142 AC_MSG_WARN(using bundled zlib)
146 if test x${with_bundled_zlib} = xno; then
147 AC_MSG_NOTICE(using system zlib as requested)
150 AC_MSG_NOTICE(using bundled zlib as requested)
155 if test x${use_bundled_zlib} = xyes; then
156 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/src/zlib"
157 extra_libs="src/zlib/libz.a"
164 [AS_HELP_STRING([--disable-man],
165 [disable installing man pages])])
166 if test x${enable_man} = xno; then
170 dnl Linking on Windows needs ws2_32
171 if test x${windows_os} = xyes; then
172 LIBS="$LIBS -lws2_32"
173 AC_CHECK_FUNCS(GetFinalPathNameByHandleW,[],[LIBS="$LIBS -lpsapi"])
180 dnl Check for "extern inline".
183 ac_cv_c_extern_inline,
185 ac_cv_c_extern_inline=no
188 extern $ac_cv_c_inline double foo(double x);
189 extern $ac_cv_c_inline double foo(double x) { return x+1.0; };
190 double foo (double x) { return x + 1.0; };
193 [ac_cv_c_extern_inline="yes"])])
194 if test "$ac_cv_c_extern_inline" != no ; then
195 AC_DEFINE(HAVE_EXTERN_INLINE, 1,
196 Define to 1 if your compiler supports extern inline)
199 mkdir -p .deps src unittest
201 dnl Enable developer mode if dev.mk.in exists.
202 if test ! -f $srcdir/dev_mode_disabled && test "$RUN_FROM_BUILD_FARM" != yes; then
203 AC_MSG_NOTICE(developer mode enabled)
204 AC_CONFIG_FILES([dev.mk])
205 include_dev_mk='include dev.mk'
206 version=`(git --git-dir=$srcdir/.git describe --dirty 2>/dev/null || echo vunknown) | sed -e 's/v//' -e 's/-/+/' -e 's/-/_/g'`
207 echo "extern const char CCACHE_VERSION@<:@@:>@; const char CCACHE_VERSION@<:@@:>@ = \"$version\";" >src/version.c
209 AC_MSG_NOTICE(developer mode disabled)
212 if test ! -f $srcdir/src/version.c -a ! -f src/version.c ; then
213 AC_MSG_WARN(unable to determine ccache version)
214 echo "extern const char CCACHE_VERSION@<:@@:>@; const char CCACHE_VERSION@<:@@:>@ = \"unknown\";" >src/version.c
217 dnl Check for -Wno-implicit-fallthrough
218 AC_MSG_CHECKING([whether C compiler supports -Wno-implicit-fallthrough])
220 CFLAGS=-Wno-implicit-fallthrough
221 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
222 [AC_MSG_RESULT([yes])]
223 [no_implicit_fallthrough_warning="-Wno-implicit-fallthrough"],
224 [AC_MSG_RESULT([no])]
228 dnl Find test suite files.
229 test_suites=`cd $srcdir && ls unittest/test_*.c | egrep -v 'BASE|BACKUP|LOCAL|REMOTE' | xargs echo`
231 AC_CONFIG_FILES([Makefile])
234 cat <<EOF >config.h.tmp
235 #ifndef CCACHE_CONFIG_H
236 #define CCACHE_CONFIG_H
238 #pragma clang diagnostic push
239 #if __clang_major__ >= 4
240 #pragma clang diagnostic ignored "-Wreserved-id-macro"
245 cat config.h >>config.h.tmp
246 cat <<EOF >>config.h.tmp
249 #pragma clang diagnostic pop
251 #endif // ifndef CCACHE_CONFIG_H
253 mv config.h.tmp config.h
255 AC_MSG_NOTICE(now build ccache by running make)