1 ## 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
5 # make sure we're interpreted by some minimal autoconf
8 AC_INIT(glog, 0.3.2, opensource@google.com)
9 # The argument here is just something that should be in the current directory
10 # (for sanity checking)
11 AC_CONFIG_SRCDIR(README)
12 AC_CONFIG_MACRO_DIR([m4])
14 AM_CONFIG_HEADER(src/config.h)
18 # Checks for programs.
22 AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
25 AC_SUBST(LIBTOOL_DEPS)
27 # Check whether some low-level functions/files are available
30 # These are tested for by AC_HEADER_STDC, but I check again to set the var
31 AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
32 AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
33 AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0)
34 AC_CHECK_HEADERS(unistd.h, ac_cv_have_unistd_h=1, ac_cv_have_unistd_h=0)
35 AC_CHECK_HEADERS(syscall.h)
36 AC_CHECK_HEADERS(sys/syscall.h)
37 # For backtrace with glibc.
38 AC_CHECK_HEADERS(execinfo.h)
39 # For backtrace with libunwind.
40 AC_CHECK_HEADERS(libunwind.h, ac_cv_have_libunwind_h=1, ac_cv_have_libunwind_h=0)
41 AC_CHECK_HEADERS(ucontext.h)
42 AC_CHECK_HEADERS(sys/utsname.h)
43 AC_CHECK_HEADERS(pwd.h)
44 AC_CHECK_HEADERS(syslog.h)
45 AC_CHECK_HEADERS(sys/time.h)
46 AC_CHECK_HEADERS(glob.h)
47 # For backtrace with gcc.
48 AC_CHECK_HEADERS(unwind.h)
50 AC_CHECK_SIZEOF(void *)
52 # These are the types I need. We look for them in either stdint.h,
53 # sys/types.h, or inttypes.h, all of which are part of the default-includes.
54 AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
55 AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
56 AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0)
58 AC_CHECK_FUNC(sigaltstack,
59 AC_DEFINE(HAVE_SIGALTSTACK, 1,
60 [Define if you have the `sigaltstack' function]))
62 AC_DEFINE(HAVE_DLADDR, 1,
63 [Define if you have the `dladdr' function]))
65 AC_DEFINE(HAVE_FCNTL, 1,
66 [Define if you have the `fcntl' function]))
69 # We only care about these two attributes.
70 if test x"$ac_cv___attribute__" = x"yes"; then
71 ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
72 ac_cv___attribute___noinline="__attribute__ ((noinline))"
73 ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
75 ac_cv___attribute___noreturn=
76 ac_cv___attribute___noinline=
77 ac_cv___attribute___printf_4_5=
81 if test x"$ac_cv___builtin_expect" = x"yes"; then
82 ac_cv_have___builtin_expect=1
84 ac_cv_have___builtin_expect=0
87 AX_C___SYNC_VAL_COMPARE_AND_SWAP
89 # On x86_64, instead of libunwind, we can choose to compile with frame-pointers
90 # (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
91 AC_ARG_ENABLE(frame_pointers,
92 AS_HELP_STRING([--enable-frame-pointers],
93 [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),,
94 enable_frame_pointers=no)
95 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
96 [is_x86_64=yes], [is_x86_64=no])
97 AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
98 AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)
101 AS_HELP_STRING([--disable-rtti],
102 [Disable RTTI in glog]))
103 AM_CONDITIONAL(DISABLE_RTTI, test x"$enable_rtti" = x"no")
104 if test x"$enable_rtti" = x"no"; then
105 AC_DEFINE(DISABLE_RTTI, 1, [define if glog doesn't use RTTI])
108 # Some of the code in this directory depends on pthreads
110 if test x"$acx_pthread_ok" = x"yes"; then
111 # To make libglog depend on libpthread on Linux, we need to add
112 # -lpthread in addition to -pthread.
113 AC_CHECK_LIB(pthread, pthread_self)
116 # Check if there is google-gflags library installed.
117 SAVE_CFLAGS="$CFLAGS"
119 AC_ARG_WITH(gflags, AS_HELP_STRING[--with-gflags=GFLAGS_DIR],
120 GFLAGS_CFLAGS="-I${with_gflags}/include"
121 GFLAGS_LIBS="-L${with_gflags}/lib -lgflags"
122 CFLAGS="$CFLAGS $GFLAGS_CFLAGS"
123 LIBS="$LIBS $GFLAGS_LIBS"
125 AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0)
126 if test x"$ac_cv_have_libgflags" = x"1"; then
127 AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library])
128 if test x"$GFLAGS_LIBS" = x""; then
129 GFLAGS_LIBS="-lgflags"
135 CFLAGS="$SAVE_CFLAGS"
138 # TODO(hamaji): Use official m4 macros provided by testing libraries
139 # once the m4 macro of Google Mocking becomes ready.
140 # Check if there is Google Test library installed.
141 AC_CHECK_PROG(GTEST_CONFIG, gtest-config, "yes")
142 if test x"$GTEST_CONFIG" = "xyes"; then
143 GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
144 GTEST_LIBS=`gtest-config --ldflags --libs`
145 AC_DEFINE(HAVE_LIB_GTEST, 1, [define if you have google gtest library])
147 # Check if there is Google Mocking library installed.
148 AC_CHECK_PROG(GMOCK_CONFIG, gmock-config, "yes")
149 if test x"$GMOCK_CONFIG" = "xyes"; then
150 GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
151 GMOCK_LIBS=`gmock-config --ldflags --libs`
152 AC_DEFINE(HAVE_LIB_GMOCK, 1, [define if you have google gmock library])
154 # We don't run test cases which use Google Mocking framework.
159 # We'll use src/googletest.h for our unittests.
163 AM_CONDITIONAL(HAVE_GMOCK, test x"$GMOCK_CONFIG" = "xyes")
165 # We want to link in libunwind if it exists
167 # Unfortunately, we need to check the header file in addition to the
168 # lib file to check if libunwind is available since libunwind-0.98
169 # doesn't install all necessary header files.
170 if test x"$ac_cv_have_libunwind_h" = x"1"; then
171 AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind)
173 AC_SUBST(UNWIND_LIBS)
174 if test x"$UNWIND_LIBS" != x""; then
175 AC_DEFINE(HAVE_LIB_UNWIND, 1, [define if you have libunwind])
178 # We'd like to use read/write locks in several places in the code.
179 # See if our pthreads support extends to that. Note: for linux, it
180 # does as long as you define _XOPEN_SOURCE appropriately.
183 # Find out what namespace 'normal' STL code lives in, and also what namespace
184 # the user wants our classes to be defined in
186 AC_DEFINE_GOOGLE_NAMESPACE(google)
188 AC_CXX_USING_OPERATOR
190 AC_PC_FROM_UCONTEXT(AC_MSG_WARN(Could not find the PC. Will not output failed addresses...))
192 AC_DEFINE_UNQUOTED(TEST_SRC_DIR, "$srcdir", [location of source code])
194 # These are what's needed by logging.h.in and raw_logging.h.in
195 AC_SUBST(ac_google_start_namespace)
196 AC_SUBST(ac_google_end_namespace)
197 AC_SUBST(ac_google_namespace)
198 AC_SUBST(ac_cv_cxx_using_operator)
199 AC_SUBST(ac_cv___attribute___noreturn)
200 AC_SUBST(ac_cv___attribute___noinline)
201 AC_SUBST(ac_cv___attribute___printf_4_5)
202 AC_SUBST(ac_cv_have___builtin_expect)
203 AC_SUBST(ac_cv_have_stdint_h)
204 AC_SUBST(ac_cv_have_systypes_h)
205 AC_SUBST(ac_cv_have_inttypes_h)
206 AC_SUBST(ac_cv_have_unistd_h)
207 AC_SUBST(ac_cv_have_uint16_t)
208 AC_SUBST(ac_cv_have_u_int16_t)
209 AC_SUBST(ac_cv_have___uint16)
210 AC_SUBST(ac_cv_have_libgflags)
211 AC_SUBST(GFLAGS_CFLAGS)
212 AC_SUBST(GTEST_CFLAGS)
213 AC_SUBST(GMOCK_CFLAGS)
214 AC_SUBST(GFLAGS_LIBS)
218 # Write generated configuration file
219 AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h])
220 AC_OUTPUT(libglog.pc)