blob: 02a767f2fb80a5d3ea130b96bda3b75ca2df4bd6 [file] [log] [blame]
Austin Schuh906616c2019-01-21 20:25:11 -08001## Process this file with autoconf to produce configure.
2## In general, the safest way to proceed is to run the following:
3## % aclocal -I . -I `pwd`/../autoconf && autoheader && autoconf && automake
4
5# make sure we're interpreted by some minimal autoconf
6AC_PREREQ(2.57)
7
8AC_INIT(glog, 0.3.5, opensource@google.com)
9# The argument here is just something that should be in the current directory
10# (for sanity checking)
11AC_CONFIG_SRCDIR(README.md)
12AC_CONFIG_MACRO_DIR([m4])
13AM_INIT_AUTOMAKE
14AM_CONFIG_HEADER(src/config.h)
15
16AC_LANG(C++)
17
18# Checks for programs.
19AC_PROG_CC
20AC_PROG_CPP
21AC_PROG_CXX
22AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
23
24AC_PROG_LIBTOOL
25AC_SUBST(LIBTOOL_DEPS)
26
27# Check whether some low-level functions/files are available
28AC_HEADER_STDC
29
30# These are tested for by AC_HEADER_STDC, but I check again to set the var
31AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
32AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
33AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0)
34AC_CHECK_HEADER(pwd.h, ac_cv_have_pwd_h=1, ac_cv_have_pwd_h=0)
35AC_CHECK_HEADERS(unistd.h, ac_cv_have_unistd_h=1, ac_cv_have_unistd_h=0)
36AC_CHECK_HEADERS(syscall.h)
37AC_CHECK_HEADERS(sys/syscall.h)
38# For backtrace with glibc.
39AC_CHECK_HEADERS(execinfo.h)
40# For backtrace with libunwind.
41AC_CHECK_HEADERS(libunwind.h, ac_cv_have_libunwind_h=1, ac_cv_have_libunwind_h=0)
42AC_CHECK_HEADERS(ucontext.h)
43AC_CHECK_HEADERS(sys/utsname.h)
44AC_CHECK_HEADERS(pwd.h)
45AC_CHECK_HEADERS(syslog.h)
46AC_CHECK_HEADERS(sys/time.h)
47AC_CHECK_HEADERS(glob.h)
48# For backtrace with gcc.
49AC_CHECK_HEADERS(unwind.h)
50
51AC_CHECK_HEADER(windows.h, ac_cv_have_windows_h=1, ac_cv_have_windows_h=0)
52if test x"$ac_cv_have_windows_h" = x"1"; then
53 MINGW_CFLAGS=-Isrc/windows
54fi
55
56AC_CHECK_SIZEOF(void *)
57
58# These are the types I need. We look for them in either stdint.h,
59# sys/types.h, or inttypes.h, all of which are part of the default-includes.
60AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
61AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
62AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0)
63
64AC_CHECK_FUNC(sigaltstack,
65 AC_DEFINE(HAVE_SIGALTSTACK, 1,
66 [Define if you have the `sigaltstack' function]))
67AC_CHECK_FUNC(sigaction,
68 AC_DEFINE(HAVE_SIGACTION, 1,
69 [Define if you have the 'sigaction' function]))
70AC_CHECK_FUNC(dladdr,
71 AC_DEFINE(HAVE_DLADDR, 1,
72 [Define if you have the `dladdr' function]))
73AC_CHECK_FUNC(fcntl,
74 AC_DEFINE(HAVE_FCNTL, 1,
75 [Define if you have the `fcntl' function]))
76AC_CHECK_FUNC(pread,
77 AC_DEFINE(HAVE_PREAD, 1,
78 [Define if you have the 'pread' function]))
79AC_CHECK_FUNC(pwrite,
80 AC_DEFINE(HAVE_PWRITE, 1,
81 [Define if you have the 'pwrite' function]))
82
83AX_C___ATTRIBUTE__
84# We only care about these two attributes.
85if test x"$ac_cv___attribute__" = x"yes"; then
86 ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
87 ac_cv___attribute___noinline="__attribute__ ((noinline))"
88 ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
89else
90 ac_cv___attribute___noreturn=
91 ac_cv___attribute___noinline=
92 ac_cv___attribute___printf_4_5=
93fi
94
95AX_C___BUILTIN_EXPECT
96if test x"$ac_cv___builtin_expect" = x"yes"; then
97 ac_cv_have___builtin_expect=1
98else
99 ac_cv_have___builtin_expect=0
100fi
101
102AX_C___SYNC_VAL_COMPARE_AND_SWAP
103
104# On x86_64, instead of libunwind, we can choose to compile with frame-pointers
105# (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
106AC_ARG_ENABLE(frame_pointers,
107 AS_HELP_STRING([--enable-frame-pointers],
108 [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),,
109 enable_frame_pointers=no)
110AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
111 [is_x86_64=yes], [is_x86_64=no])
112AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
113AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)
114
115AC_ARG_ENABLE(rtti,
116 AS_HELP_STRING([--disable-rtti],
117 [Disable RTTI in glog]))
118AM_CONDITIONAL(DISABLE_RTTI, test x"$enable_rtti" = x"no")
119if test x"$enable_rtti" = x"no"; then
120 AC_DEFINE(DISABLE_RTTI, 1, [define if glog doesn't use RTTI])
121fi
122
123# Some of the code in this directory depends on pthreads
124ACX_PTHREAD
125if test x"$acx_pthread_ok" = x"yes"; then
126 # To make libglog depend on libpthread on Linux, we need to add
127 # -lpthread in addition to -pthread.
128 AC_CHECK_LIB(pthread, pthread_self)
129fi
130
131# Check if there is google-gflags library installed.
132SAVE_CFLAGS="$CFLAGS"
133SAVE_LIBS="$LIBS"
134AC_ARG_WITH(gflags, AS_HELP_STRING[--with-gflags=GFLAGS_DIR],
135 GFLAGS_CFLAGS="-I${with_gflags}/include"
136 GFLAGS_LIBS="-L${with_gflags}/lib -lgflags"
137 CFLAGS="$CFLAGS $GFLAGS_CFLAGS"
138 LIBS="$LIBS $GFLAGS_LIBS"
139)
140AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0)
141if test x"$ac_cv_have_libgflags" = x"1"; then
142 AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library])
143 if test x"$GFLAGS_LIBS" = x""; then
144 GFLAGS_LIBS="-lgflags"
145 fi
146else
147 GFLAGS_CFLAGS=
148 GFLAGS_LIBS=
149fi
150CFLAGS="$SAVE_CFLAGS"
151LIBS="$SAVE_LIBS"
152
153# TODO(hamaji): Use official m4 macros provided by testing libraries
154# once the m4 macro of Google Mocking becomes ready.
155# Check if there is Google Test library installed.
156AC_CHECK_PROG(GTEST_CONFIG, gtest-config, "yes")
157AC_CHECK_LIB(gtest, main, have_gtest_lib="yes")
158if test x"$GTEST_CONFIG" = "xyes" -a x"$have_gtest_lib" = "xyes"; then
159 GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
160 GTEST_LIBS=`gtest-config --ldflags --libs`
161 AC_DEFINE(HAVE_LIB_GTEST, 1, [define if you have google gtest library])
162
163 # Check if there is Google Mocking library installed.
164 AC_CHECK_PROG(GMOCK_CONFIG, gmock-config, "yes")
165 if test x"$GMOCK_CONFIG" = "xyes"; then
166 GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
167 GMOCK_LIBS=`gmock-config --ldflags --libs`
168 AC_DEFINE(HAVE_LIB_GMOCK, 1, [define if you have google gmock library])
169 else
170 # We don't run test cases which use Google Mocking framework.
171 GMOCK_CFLAGS=
172 GMOCK_LIBS=
173 fi
174else
175 # We'll use src/googletest.h for our unittests.
176 GTEST_CFLAGS=
177 GTEST_LIBS=
178fi
179AM_CONDITIONAL(HAVE_GMOCK, test x"$GMOCK_CONFIG" = "xyes")
180
181# We want to link in libunwind if it exists
182UNWIND_LIBS=
183# Unfortunately, we need to check the header file in addition to the
184# lib file to check if libunwind is available since libunwind-0.98
185# doesn't install all necessary header files.
186if test x"$ac_cv_have_libunwind_h" = x"1"; then
187 AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind)
188fi
189AC_SUBST(UNWIND_LIBS)
190if test x"$UNWIND_LIBS" != x""; then
191 AC_DEFINE(HAVE_LIB_UNWIND, 1, [define if you have libunwind])
192fi
193
194# We'd like to use read/write locks in several places in the code.
195# See if our pthreads support extends to that. Note: for linux, it
196# does as long as you define _XOPEN_SOURCE appropriately.
197AC_RWLOCK
198
199# Find out what namespace 'normal' STL code lives in, and also what namespace
200# the user wants our classes to be defined in
201AC_CXX_STL_NAMESPACE
202AC_DEFINE_GOOGLE_NAMESPACE(google)
203
204AC_CXX_USING_OPERATOR
205
206AC_PC_FROM_UCONTEXT(AC_MSG_WARN(Could not find the PC. Will not output failed addresses...))
207
208AC_DEFINE_UNQUOTED(TEST_SRC_DIR, "$srcdir", [location of source code])
209
210AC_ARG_ENABLE(unsymbolized-traces,
211 AS_HELP_STRING([--enable-unsymbolized-traces],
212 [Print raw pc values when symbolization is failed.]),
213 enable_unsymbolized_traces=yes)
214if test x"$enable_unsymbolized_traces" = x"yes"; then
215 AC_DEFINE(PRINT_UNSYMBOLIZED_STACK_TRACES, 1,
216 [define if we should print raw pc values on symbolization failure.])
217fi
218
219# These are what's needed by logging.h.in and raw_logging.h.in
220AC_SUBST(ac_google_start_namespace)
221AC_SUBST(ac_google_end_namespace)
222AC_SUBST(ac_google_namespace)
223AC_SUBST(ac_cv_cxx_using_operator)
224AC_SUBST(ac_cv___attribute___noreturn)
225AC_SUBST(ac_cv___attribute___noinline)
226AC_SUBST(ac_cv___attribute___printf_4_5)
227AC_SUBST(ac_cv_have___builtin_expect)
228AC_SUBST(ac_cv_have_stdint_h)
229AC_SUBST(ac_cv_have_systypes_h)
230AC_SUBST(ac_cv_have_inttypes_h)
231AC_SUBST(ac_cv_have_unistd_h)
232AC_SUBST(ac_cv_have_uint16_t)
233AC_SUBST(ac_cv_have_u_int16_t)
234AC_SUBST(ac_cv_have___uint16)
235AC_SUBST(ac_cv_have_libgflags)
236AC_SUBST(GFLAGS_CFLAGS)
237AC_SUBST(GTEST_CFLAGS)
238AC_SUBST(GMOCK_CFLAGS)
239AC_SUBST(MINGW_CFLAGS)
240AC_SUBST(GFLAGS_LIBS)
241AC_SUBST(GTEST_LIBS)
242AC_SUBST(GMOCK_LIBS)
243
244# Write generated configuration file
245AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h])
246AC_OUTPUT(libglog.pc)