michael@0: ## Process this file with autoconf to produce configure. michael@0: ## In general, the safest way to proceed is to run the following: michael@0: ## % aclocal -I . -I `pwd`/../autoconf && autoheader && autoconf && automake michael@0: michael@0: # make sure we're interpreted by some minimal autoconf michael@0: AC_PREREQ(2.57) michael@0: michael@0: AC_INIT(glog, 0.3.1, opensource@google.com) michael@0: # The argument here is just something that should be in the current directory michael@0: # (for sanity checking) michael@0: AC_CONFIG_SRCDIR(README) michael@0: AC_CONFIG_MACRO_DIR([m4]) michael@0: AM_INIT_AUTOMAKE michael@0: AM_CONFIG_HEADER(src/config.h) michael@0: michael@0: AC_LANG(C++) michael@0: michael@0: # Checks for programs. michael@0: AC_PROG_CC michael@0: AC_PROG_CPP michael@0: AC_PROG_CXX michael@0: AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc michael@0: michael@0: AC_PROG_LIBTOOL michael@0: AC_SUBST(LIBTOOL_DEPS) michael@0: michael@0: # Check whether some low-level functions/files are available michael@0: AC_HEADER_STDC michael@0: michael@0: # These are tested for by AC_HEADER_STDC, but I check again to set the var michael@0: AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0) michael@0: AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0) michael@0: AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0) michael@0: AC_CHECK_HEADERS(unistd.h, ac_cv_have_unistd_h=1, ac_cv_have_unistd_h=0) michael@0: AC_CHECK_HEADERS(syscall.h) michael@0: AC_CHECK_HEADERS(sys/syscall.h) michael@0: # For backtrace with glibc. michael@0: AC_CHECK_HEADERS(execinfo.h) michael@0: # For backtrace with libunwind. michael@0: AC_CHECK_HEADERS(libunwind.h, ac_cv_have_libunwind_h=1, ac_cv_have_libunwind_h=0) michael@0: AC_CHECK_HEADERS(ucontext.h) michael@0: AC_CHECK_HEADERS(sys/utsname.h) michael@0: AC_CHECK_HEADERS(pwd.h) michael@0: AC_CHECK_HEADERS(syslog.h) michael@0: AC_CHECK_HEADERS(sys/time.h) michael@0: AC_CHECK_HEADERS(glob.h) michael@0: michael@0: AC_CHECK_SIZEOF(void *) michael@0: michael@0: # These are the types I need. We look for them in either stdint.h, michael@0: # sys/types.h, or inttypes.h, all of which are part of the default-includes. michael@0: AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0) michael@0: AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0) michael@0: AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0) michael@0: michael@0: AC_CHECK_FUNC(sigaltstack, michael@0: AC_DEFINE(HAVE_SIGALTSTACK, 1, michael@0: [Define if you have the `sigaltstack' function])) michael@0: AC_CHECK_FUNC(dladdr, michael@0: AC_DEFINE(HAVE_DLADDR, 1, michael@0: [Define if you have the `dladdr' function])) michael@0: AC_CHECK_FUNC(fcntl, michael@0: AC_DEFINE(HAVE_FCNTL, 1, michael@0: [Define if you have the `fcntl' function])) michael@0: michael@0: AX_C___ATTRIBUTE__ michael@0: # We only care about these two attributes. michael@0: if test x"$ac_cv___attribute__" = x"yes"; then michael@0: ac_cv___attribute___noreturn="__attribute__ ((noreturn))" michael@0: ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))" michael@0: else michael@0: ac_cv___attribute___noreturn= michael@0: ac_cv___attribute___printf_4_5= michael@0: fi michael@0: michael@0: AX_C___BUILTIN_EXPECT michael@0: if test x"$ac_cv___builtin_expect" = x"yes"; then michael@0: ac_cv_have___builtin_expect=1 michael@0: else michael@0: ac_cv_have___builtin_expect=0 michael@0: fi michael@0: michael@0: AX_C___SYNC_VAL_COMPARE_AND_SWAP michael@0: michael@0: # On x86_64, instead of libunwind, we can choose to compile with frame-pointers michael@0: # (This isn't needed on i386, where -fno-omit-frame-pointer is the default). michael@0: AC_ARG_ENABLE(frame_pointers, michael@0: AS_HELP_STRING([--enable-frame-pointers], michael@0: [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),, michael@0: enable_frame_pointers=no) michael@0: AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])], michael@0: [is_x86_64=yes], [is_x86_64=no]) michael@0: AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes) michael@0: AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes) michael@0: michael@0: # Some of the code in this directory depends on pthreads michael@0: ACX_PTHREAD michael@0: if test x"$acx_pthread_ok" = x"yes"; then michael@0: # To make libglog depend on libpthread on Linux, we need to add michael@0: # -lpthread in addition to -pthread. michael@0: AC_CHECK_LIB(pthread, pthread_self) michael@0: fi michael@0: michael@0: # Check if there is google-gflags library installed. michael@0: SAVE_CFLAGS="$CFLAGS" michael@0: SAVE_LIBS="$LIBS" michael@0: AC_ARG_WITH(gflags, AS_HELP_STRING[--with-gflags=GFLAGS_DIR], michael@0: GFLAGS_CFLAGS="-I${with_gflags}/include" michael@0: GFLAGS_LIBS="-L${with_gflags}/lib -lgflags" michael@0: CFLAGS="$CFLAGS $GFLAGS_CFLAGS" michael@0: LIBS="$LIBS $GFLAGS_LIBS" michael@0: ) michael@0: AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0) michael@0: if test x"$ac_cv_have_libgflags" = x"1"; then michael@0: AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library]) michael@0: if test x"$GFLAGS_LIBS" = x""; then michael@0: GFLAGS_LIBS="-lgflags" michael@0: fi michael@0: else michael@0: GFLAGS_CFLAGS= michael@0: GFLAGS_LIBS= michael@0: fi michael@0: CFLAGS="$SAVE_CFLAGS" michael@0: LIBS="$SAVE_LIBS" michael@0: michael@0: # TODO(hamaji): Use official m4 macros provided by testing libraries michael@0: # once the m4 macro of Google Mocking becomes ready. michael@0: # Check if there is Google Test library installed. michael@0: AC_CHECK_PROG(GTEST_CONFIG, gtest-config, "yes") michael@0: if test x"$GTEST_CONFIG" = "xyes"; then michael@0: GTEST_CFLAGS=`gtest-config --cppflags --cxxflags` michael@0: GTEST_LIBS=`gtest-config --ldflags --libs` michael@0: AC_DEFINE(HAVE_LIB_GTEST, 1, [define if you have google gtest library]) michael@0: michael@0: # Check if there is Google Mocking library installed. michael@0: AC_CHECK_PROG(GMOCK_CONFIG, gmock-config, "yes") michael@0: if test x"$GMOCK_CONFIG" = "xyes"; then michael@0: GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags` michael@0: GMOCK_LIBS=`gmock-config --ldflags --libs` michael@0: AC_DEFINE(HAVE_LIB_GMOCK, 1, [define if you have google gmock library]) michael@0: else michael@0: # We don't run test cases which use Google Mocking framework. michael@0: GMOCK_CFLAGS= michael@0: GMOCK_LIBS= michael@0: fi michael@0: else michael@0: # We'll use src/googletest.h for our unittests. michael@0: GTEST_CFLAGS= michael@0: GTEST_LIBS= michael@0: fi michael@0: AM_CONDITIONAL(HAVE_GMOCK, test x"$GMOCK_CONFIG" = "xyes") michael@0: michael@0: # We want to link in libunwind if it exists michael@0: UNWIND_LIBS= michael@0: # Unfortunately, we need to check the header file in addition to the michael@0: # lib file to check if libunwind is available since libunwind-0.98 michael@0: # doesn't install all necessary header files. michael@0: if test x"$ac_cv_have_libunwind_h" = x"1"; then michael@0: AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind) michael@0: fi michael@0: AC_SUBST(UNWIND_LIBS) michael@0: if test x"$UNWIND_LIBS" != x""; then michael@0: AC_DEFINE(HAVE_LIB_UNWIND, 1, [define if you have libunwind]) michael@0: fi michael@0: michael@0: # We'd like to use read/write locks in several places in the code. michael@0: # See if our pthreads support extends to that. Note: for linux, it michael@0: # does as long as you define _XOPEN_SOURCE appropriately. michael@0: AC_RWLOCK michael@0: michael@0: # Find out what namespace 'normal' STL code lives in, and also what namespace michael@0: # the user wants our classes to be defined in michael@0: AC_CXX_STL_NAMESPACE michael@0: AC_DEFINE_GOOGLE_NAMESPACE(google) michael@0: michael@0: AC_CXX_USING_OPERATOR michael@0: michael@0: AC_PC_FROM_UCONTEXT(AC_MSG_WARN(Could not find the PC. Will not output failed addresses...)) michael@0: michael@0: AC_DEFINE_UNQUOTED(TEST_SRC_DIR, "$srcdir", [location of source code]) michael@0: michael@0: # These are what's needed by logging.h.in and raw_logging.h.in michael@0: AC_SUBST(ac_google_start_namespace) michael@0: AC_SUBST(ac_google_end_namespace) michael@0: AC_SUBST(ac_google_namespace) michael@0: AC_SUBST(ac_cv_cxx_using_operator) michael@0: AC_SUBST(ac_cv___attribute___noreturn) michael@0: AC_SUBST(ac_cv___attribute___printf_4_5) michael@0: AC_SUBST(ac_cv_have___builtin_expect) michael@0: AC_SUBST(ac_cv_have_stdint_h) michael@0: AC_SUBST(ac_cv_have_systypes_h) michael@0: AC_SUBST(ac_cv_have_inttypes_h) michael@0: AC_SUBST(ac_cv_have_unistd_h) michael@0: AC_SUBST(ac_cv_have_uint16_t) michael@0: AC_SUBST(ac_cv_have_u_int16_t) michael@0: AC_SUBST(ac_cv_have___uint16) michael@0: AC_SUBST(ac_cv_have_libgflags) michael@0: AC_SUBST(GFLAGS_CFLAGS) michael@0: AC_SUBST(GTEST_CFLAGS) michael@0: AC_SUBST(GMOCK_CFLAGS) michael@0: AC_SUBST(GFLAGS_LIBS) michael@0: AC_SUBST(GTEST_LIBS) michael@0: AC_SUBST(GMOCK_LIBS) michael@0: michael@0: # Write generated configuration file michael@0: AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h]) michael@0: AC_OUTPUT(libglog.pc)