configure.ac 8.3 KB

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