Use dladdr to get symbols for environments which doesn't use ELF and
[platform/upstream/glog.git] / configure.ac
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
5 # make sure we're interpreted by some minimal autoconf
6 AC_PREREQ(2.57)
7
8 AC_INIT(glog, 0.1, 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 AM_INIT_AUTOMAKE
13 AM_CONFIG_HEADER(src/config.h)
14
15 # Checks for programs.
16 AC_PROG_CC
17 AC_PROG_CPP
18 AC_PROG_CXX
19 AM_CONDITIONAL(GCC, test "$GCC" = yes)   # let the Makefile know if we're gcc
20
21 AC_PROG_LIBTOOL
22 AC_SUBST(LIBTOOL_DEPS)
23
24 # Check whether some low-level functions/files are available
25 AC_HEADER_STDC
26
27 # These are tested for by AC_HEADER_STDC, but I check again to set the var
28 AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
29 AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
30 AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0)
31 AC_CHECK_HEADERS(syscall.h)
32 AC_CHECK_HEADERS(sys/syscall.h)
33 # For backtrace with glibc.
34 # TODO(hamaji): Support other platforms using libgcc.
35 AC_CHECK_HEADERS(execinfo.h)
36
37 AC_CHECK_SIZEOF(void *)
38
39 # These are the types I need.  We look for them in either stdint.h,
40 # sys/types.h, or inttypes.h, all of which are part of the default-includes.
41 AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
42 AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
43 AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0)
44
45 AC_CHECK_FUNC(sigaltstack,
46               AC_DEFINE(HAVE_SIGALTSTACK, 1,
47                         [Define if you have the `sigaltstack' function]))
48 AC_CHECK_FUNC(dladdr,
49               AC_DEFINE(HAVE_DLADDR, 1,
50                         [Define if you have the `dladdr' function]))
51
52 AX_C___ATTRIBUTE__
53 # We only care about these two attributes.
54 if test x"$ac_cv___attribute__" = x"yes"; then
55   ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
56   ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
57 else
58   ac_cv___attribute___noreturn=
59   ac_cv___attribute___printf_4_5=
60 fi
61
62 AX_C___BUILTIN_EXPECT
63 if test x"$ac_cv___builtin_expect" = x"yes"; then
64   ac_cv_have___builtin_expect=1
65 else
66   ac_cv_have___builtin_expect=0
67 fi
68
69 # On x86_64, instead of libunwind, we can choose to compile with frame-pointers
70 # (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
71 AC_ARG_ENABLE(frame_pointers,
72               AS_HELP_STRING([--enable-frame-pointers],
73                              [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),
74               enable_frame_pointers=no)
75 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
76                   [is_x86_64=yes], [is_x86_64=no])
77 AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
78 AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)
79
80 # Some of the code in this directory depends on pthreads
81 ACX_PTHREAD
82
83 # Check if there is google-gflags library installed.
84 AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0)
85 if test x"$ac_cv_have_libgflags" = x"1"; then
86   GFLAGS_LIBS=-lgflags
87   AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library])
88 else
89   GFLAGS_LIBS=
90 fi
91
92 # We'd like to use read/write locks in several places in the code.
93 # See if our pthreads support extends to that.  Note: for linux, it
94 # does as long as you define _XOPEN_SOURCE appropriately.
95 AC_RWLOCK
96
97 # Find out what namespace 'normal' STL code lives in, and also what namespace
98 # the user wants our classes to be defined in
99 AC_CXX_STL_NAMESPACE
100 AC_DEFINE_GOOGLE_NAMESPACE(google)
101
102 AC_CXX_USING_OPERATOR
103
104 # These are what's needed by logging.h.in and raw_logging.h.in
105 AC_SUBST(ac_google_start_namespace)
106 AC_SUBST(ac_google_end_namespace)
107 AC_SUBST(ac_google_namespace)
108 AC_SUBST(ac_cv_cxx_using_operator)
109 AC_SUBST(ac_cv___attribute___noreturn)
110 AC_SUBST(ac_cv___attribute___printf_4_5)
111 AC_SUBST(ac_cv_have___builtin_expect)
112 AC_SUBST(ac_cv_have_stdint_h)
113 AC_SUBST(ac_cv_have_systypes_h)
114 AC_SUBST(ac_cv_have_inttypes_h)
115 AC_SUBST(ac_cv_have_uint16_t)
116 AC_SUBST(ac_cv_have_u_int16_t)
117 AC_SUBST(ac_cv_have___uint16)
118 AC_SUBST(ac_cv_have_libgflags)
119 AC_SUBST(GFLAGS_LIBS)
120
121 # Write generated configuration file
122 AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h])
123 AC_OUTPUT