configure.ac 8.29 KB
Newer Older
's avatar
committed
1 2 3 4 5 6 7
## Process this file with autoconf to produce configure.
## In general, the safest way to proceed is to run the following:
##    % aclocal -I . -I `pwd`/../autoconf && autoheader && autoconf && automake

# make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57)

Fumitoshi Ukai's avatar
Fumitoshi Ukai committed
8
AC_INIT(glog, 0.3.4, opensource@google.com)
's avatar
committed
9 10 11
# The argument here is just something that should be in the current directory
# (for sanity checking)
AC_CONFIG_SRCDIR(README)
12
AC_CONFIG_MACRO_DIR([m4])
's avatar
committed
13 14 15
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(src/config.h)

16 17
AC_LANG(C++)

's avatar
committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AM_CONDITIONAL(GCC, test "$GCC" = yes)   # let the Makefile know if we're gcc

AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)

# Check whether some low-level functions/files are available
AC_HEADER_STDC

# These are tested for by AC_HEADER_STDC, but I check again to set the var
AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
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)
's avatar
committed
35 36 37 38
AC_CHECK_HEADERS(syscall.h)
AC_CHECK_HEADERS(sys/syscall.h)
# For backtrace with glibc.
AC_CHECK_HEADERS(execinfo.h)
39
# For backtrace with libunwind.
's avatar
committed
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 43 44 45 46
AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(syslog.h)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(glob.h)
47 48
# For backtrace with gcc.
AC_CHECK_HEADERS(unwind.h)
's avatar
committed
49

50 51 52 53 54
AC_CHECK_HEADER(windows.h, ac_cv_have_windows_h=1, ac_cv_have_windows_h=0)
if test x"$ac_cv_have_windows_h" = x"1"; then
  MINGW_CFLAGS=-Isrc/windows
fi

's avatar
committed
55 56 57 58 59 60 61 62 63 64 65
AC_CHECK_SIZEOF(void *)

# These are the types I need.  We look for them in either stdint.h,
# sys/types.h, or inttypes.h, all of which are part of the default-includes.
AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0)

AC_CHECK_FUNC(sigaltstack,
              AC_DEFINE(HAVE_SIGALTSTACK, 1,
                        [Define if you have the `sigaltstack' function]))
66 67 68
AC_CHECK_FUNC(sigaction,
              AC_DEFINE(HAVE_SIGACTION, 1,
                        [Define if you have the 'sigaction' function]))
69 70 71
AC_CHECK_FUNC(dladdr,
              AC_DEFINE(HAVE_DLADDR, 1,
                        [Define if you have the `dladdr' function]))
72 73 74
AC_CHECK_FUNC(fcntl,
              AC_DEFINE(HAVE_FCNTL, 1,
                        [Define if you have the `fcntl' function]))
75 76 77 78 79 80
AC_CHECK_FUNC(pread,
              AC_DEFINE(HAVE_PREAD, 1,
                        [Define if you have the 'pread' function]))
AC_CHECK_FUNC(pwrite,
              AC_DEFINE(HAVE_PWRITE, 1,
                        [Define if you have the 'pwrite' function]))
's avatar
committed
81 82 83 84 85

AX_C___ATTRIBUTE__
# We only care about these two attributes.
if test x"$ac_cv___attribute__" = x"yes"; then
  ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
86
  ac_cv___attribute___noinline="__attribute__ ((noinline))"
's avatar
committed
87 88 89
  ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
else
  ac_cv___attribute___noreturn=
90
  ac_cv___attribute___noinline=
's avatar
committed
91 92 93 94 95 96 97 98 99 100
  ac_cv___attribute___printf_4_5=
fi

AX_C___BUILTIN_EXPECT
if test x"$ac_cv___builtin_expect" = x"yes"; then
  ac_cv_have___builtin_expect=1
else
  ac_cv_have___builtin_expect=0
fi

101 102
AX_C___SYNC_VAL_COMPARE_AND_SWAP

's avatar
committed
103 104 105 106
# On x86_64, instead of libunwind, we can choose to compile with frame-pointers
# (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
AC_ARG_ENABLE(frame_pointers,
              AS_HELP_STRING([--enable-frame-pointers],
's avatar
committed
107
                             [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),,
's avatar
committed
108 109 110 111 112 113
              enable_frame_pointers=no)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
                  [is_x86_64=yes], [is_x86_64=no])
AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)

's avatar
committed
114 115 116 117 118 119 120 121
AC_ARG_ENABLE(rtti,
              AS_HELP_STRING([--disable-rtti],
                             [Disable RTTI in glog]))
AM_CONDITIONAL(DISABLE_RTTI, test x"$enable_rtti" = x"no")
if test x"$enable_rtti" = x"no"; then
  AC_DEFINE(DISABLE_RTTI, 1, [define if glog doesn't use RTTI])
fi

's avatar
committed
122 123
# Some of the code in this directory depends on pthreads
ACX_PTHREAD
's avatar
committed
124 125 126 127 128
if test x"$acx_pthread_ok" = x"yes"; then
  # To make libglog depend on libpthread on Linux, we need to add
  # -lpthread in addition to -pthread.
  AC_CHECK_LIB(pthread, pthread_self)
fi
's avatar
committed
129 130

# Check if there is google-gflags library installed.
131 132 133 134 135 136 137 138
SAVE_CFLAGS="$CFLAGS"
SAVE_LIBS="$LIBS"
AC_ARG_WITH(gflags, AS_HELP_STRING[--with-gflags=GFLAGS_DIR],
  GFLAGS_CFLAGS="-I${with_gflags}/include"
  GFLAGS_LIBS="-L${with_gflags}/lib -lgflags"
  CFLAGS="$CFLAGS $GFLAGS_CFLAGS"
  LIBS="$LIBS $GFLAGS_LIBS"
)
's avatar
committed
139 140 141
AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0)
if test x"$ac_cv_have_libgflags" = x"1"; then
  AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library])
142 143 144
  if test x"$GFLAGS_LIBS" = x""; then
    GFLAGS_LIBS="-lgflags"
  fi
's avatar
committed
145
else
146
  GFLAGS_CFLAGS=
's avatar
committed
147 148
  GFLAGS_LIBS=
fi
149 150
CFLAGS="$SAVE_CFLAGS"
LIBS="$SAVE_LIBS"
's avatar
committed
151

's avatar
committed
152 153 154 155
# TODO(hamaji): Use official m4 macros provided by testing libraries
#               once the m4 macro of Google Mocking becomes ready.
# Check if there is Google Test library installed.
AC_CHECK_PROG(GTEST_CONFIG, gtest-config, "yes")
156 157
AC_CHECK_LIB(gtest, main, have_gtest_lib="yes")
if test x"$GTEST_CONFIG" = "xyes" -a x"$have_gtest_lib" = "xyes"; then
's avatar
committed
158 159
  GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
  GTEST_LIBS=`gtest-config --ldflags --libs`
's avatar
committed
160 161
  AC_DEFINE(HAVE_LIB_GTEST, 1, [define if you have google gtest library])

's avatar
committed
162 163 164 165 166
  # Check if there is Google Mocking library installed.
  AC_CHECK_PROG(GMOCK_CONFIG, gmock-config, "yes")
  if test x"$GMOCK_CONFIG" = "xyes"; then
    GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
    GMOCK_LIBS=`gmock-config --ldflags --libs`
's avatar
committed
167 168
    AC_DEFINE(HAVE_LIB_GMOCK, 1, [define if you have google gmock library])
  else
's avatar
committed
169 170
    # We don't run test cases which use Google Mocking framework.
    GMOCK_CFLAGS=
's avatar
committed
171 172 173
    GMOCK_LIBS=
  fi
else
's avatar
committed
174 175
  # We'll use src/googletest.h for our unittests.
  GTEST_CFLAGS=
's avatar
committed
176 177
  GTEST_LIBS=
fi
's avatar
committed
178
AM_CONDITIONAL(HAVE_GMOCK, test x"$GMOCK_CONFIG" = "xyes")
's avatar
committed
179

180 181 182 183 184 185 186 187 188 189 190 191 192
# We want to link in libunwind if it exists
UNWIND_LIBS=
# Unfortunately, we need to check the header file in addition to the
# lib file to check if libunwind is available since libunwind-0.98
# doesn't install all necessary header files.
if test x"$ac_cv_have_libunwind_h" = x"1"; then
 AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind)
fi
AC_SUBST(UNWIND_LIBS)
if test x"$UNWIND_LIBS" != x""; then
  AC_DEFINE(HAVE_LIB_UNWIND, 1, [define if you have libunwind])
fi

's avatar
committed
193 194 195 196 197 198 199 200 201 202 203 204
# We'd like to use read/write locks in several places in the code.
# See if our pthreads support extends to that.  Note: for linux, it
# does as long as you define _XOPEN_SOURCE appropriately.
AC_RWLOCK

# Find out what namespace 'normal' STL code lives in, and also what namespace
# the user wants our classes to be defined in
AC_CXX_STL_NAMESPACE
AC_DEFINE_GOOGLE_NAMESPACE(google)

AC_CXX_USING_OPERATOR

205
AC_PC_FROM_UCONTEXT(AC_MSG_WARN(Could not find the PC.  Will not output failed addresses...))
206

207 208
AC_DEFINE_UNQUOTED(TEST_SRC_DIR, "$srcdir", [location of source code])

's avatar
committed
209 210 211 212 213 214
# These are what's needed by logging.h.in and raw_logging.h.in
AC_SUBST(ac_google_start_namespace)
AC_SUBST(ac_google_end_namespace)
AC_SUBST(ac_google_namespace)
AC_SUBST(ac_cv_cxx_using_operator)
AC_SUBST(ac_cv___attribute___noreturn)
215
AC_SUBST(ac_cv___attribute___noinline)
's avatar
committed
216 217 218 219 220
AC_SUBST(ac_cv___attribute___printf_4_5)
AC_SUBST(ac_cv_have___builtin_expect)
AC_SUBST(ac_cv_have_stdint_h)
AC_SUBST(ac_cv_have_systypes_h)
AC_SUBST(ac_cv_have_inttypes_h)
221
AC_SUBST(ac_cv_have_unistd_h)
's avatar
committed
222 223 224 225
AC_SUBST(ac_cv_have_uint16_t)
AC_SUBST(ac_cv_have_u_int16_t)
AC_SUBST(ac_cv_have___uint16)
AC_SUBST(ac_cv_have_libgflags)
226
AC_SUBST(GFLAGS_CFLAGS)
's avatar
committed
227 228
AC_SUBST(GTEST_CFLAGS)
AC_SUBST(GMOCK_CFLAGS)
229
AC_SUBST(MINGW_CFLAGS)
230
AC_SUBST(GFLAGS_LIBS)
's avatar
committed
231 232
AC_SUBST(GTEST_LIBS)
AC_SUBST(GMOCK_LIBS)
's avatar
committed
233 234 235

# Write generated configuration file
AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h])
236
AC_OUTPUT(libglog.pc)