Add InstallFailureSignalHandler(). The function installs a signal handler that
[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.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 AC_CHECK_HEADERS(ucontext.h)
37
38 AC_CHECK_SIZEOF(void *)
39
40 # These are the types I need.  We look for them in either stdint.h,
41 # sys/types.h, or inttypes.h, all of which are part of the default-includes.
42 AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
43 AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
44 AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0)
45
46 AC_CHECK_FUNC(sigaltstack,
47               AC_DEFINE(HAVE_SIGALTSTACK, 1,
48                         [Define if you have the `sigaltstack' function]))
49 AC_CHECK_FUNC(dladdr,
50               AC_DEFINE(HAVE_DLADDR, 1,
51                         [Define if you have the `dladdr' function]))
52
53 AX_C___ATTRIBUTE__
54 # We only care about these two attributes.
55 if test x"$ac_cv___attribute__" = x"yes"; then
56   ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
57   ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
58 else
59   ac_cv___attribute___noreturn=
60   ac_cv___attribute___printf_4_5=
61 fi
62
63 AX_C___BUILTIN_EXPECT
64 if test x"$ac_cv___builtin_expect" = x"yes"; then
65   ac_cv_have___builtin_expect=1
66 else
67   ac_cv_have___builtin_expect=0
68 fi
69
70 AX_C___SYNC_VAL_COMPARE_AND_SWAP
71
72 # On x86_64, instead of libunwind, we can choose to compile with frame-pointers
73 # (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
74 AC_ARG_ENABLE(frame_pointers,
75               AS_HELP_STRING([--enable-frame-pointers],
76                              [On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),
77               enable_frame_pointers=no)
78 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
79                   [is_x86_64=yes], [is_x86_64=no])
80 AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
81 AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)
82
83 # Some of the code in this directory depends on pthreads
84 ACX_PTHREAD
85
86 # Check if there is google-gflags library installed.
87 AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0)
88 if test x"$ac_cv_have_libgflags" = x"1"; then
89   GFLAGS_LIBS=-lgflags
90   AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library])
91 else
92   GFLAGS_LIBS=
93 fi
94
95 # We'd like to use read/write locks in several places in the code.
96 # See if our pthreads support extends to that.  Note: for linux, it
97 # does as long as you define _XOPEN_SOURCE appropriately.
98 AC_RWLOCK
99
100 # Find out what namespace 'normal' STL code lives in, and also what namespace
101 # the user wants our classes to be defined in
102 AC_CXX_STL_NAMESPACE
103 AC_DEFINE_GOOGLE_NAMESPACE(google)
104
105 AC_CXX_USING_OPERATOR
106
107 # We want to access the "PC" (Program Counter) register from a struct
108 # ucontext.  Every system has its own way of doing that.  We try all the
109 # possibilities we know about.  Note REG_PC should come first (REG_RIP
110 # is also defined on solaris, but does the wrong thing).
111 AC_MSG_CHECKING([how to access the program counter from a struct ucontext])
112 pc_fields="           uc_mcontext.gregs[[REG_PC]]"  # Solaris x86 (32 + 64 bit)
113 pc_fields="$pc_fields uc_mcontext.gregs[[REG_EIP]]" # Linux (i386)
114 pc_fields="$pc_fields uc_mcontext.gregs[[REG_RIP]]" # Linux (x86_64)
115 pc_fields="$pc_fields uc_mcontext.sc_ip"            # Linux (ia64)
116 pc_fields="$pc_fields uc_mcontext.uc_regs->gregs[[PT_NIP]]" # Linux (ppc)
117 pc_fields="$pc_fields uc_mcontext.gregs[[R15]]"     # Linux (arm old [untested])
118 pc_fields="$pc_fields uc_mcontext.arm_pc"           # Linux (arm new [untested])
119 pc_fields="$pc_fields uc_mcontext.mc_eip"           # FreeBSD (i386)
120 pc_fields="$pc_fields uc_mcontext.mc_rip"           # FreeBSD (x86_64 [untested])
121 pc_fields="$pc_fields uc_mcontext->ss.eip"          # OS X (i386, <=10.4)
122 pc_fields="$pc_fields uc_mcontext->__ss.__eip"      # OS X (i386, >=10.5)
123 pc_fields="$pc_fields uc_mcontext->ss.rip"          # OS X (x86_64)
124 pc_fields="$pc_fields uc_mcontext->__ss.__rip"      # OS X (>=10.5 [untested])
125 pc_fields="$pc_fields uc_mcontext->ss.srr0"         # OS X (ppc, ppc64 [untested])
126 pc_fields="$pc_fields uc_mcontext->__ss.__srr0"     # OS X (>=10.5 [untested])
127 pc_field_found=false
128 for pc_field in $pc_fields; do
129   if ! $pc_field_found; then
130     AC_TRY_COMPILE([#define _GNU_SOURCE 1
131                     #include <ucontext.h>],
132                    [ucontext_t u; return u.$pc_field == 0;],
133                    AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field,
134                                       How to access the PC from a struct ucontext)
135                    AC_MSG_RESULT([$pc_field])
136                  pc_field_found=true)
137   fi
138 done
139 if ! $pc_field_found; then
140   AC_MSG_WARN(Could not find the PC.  Will not output failed addresses...)
141 fi
142
143 # These are what's needed by logging.h.in and raw_logging.h.in
144 AC_SUBST(ac_google_start_namespace)
145 AC_SUBST(ac_google_end_namespace)
146 AC_SUBST(ac_google_namespace)
147 AC_SUBST(ac_cv_cxx_using_operator)
148 AC_SUBST(ac_cv___attribute___noreturn)
149 AC_SUBST(ac_cv___attribute___printf_4_5)
150 AC_SUBST(ac_cv_have___builtin_expect)
151 AC_SUBST(ac_cv_have_stdint_h)
152 AC_SUBST(ac_cv_have_systypes_h)
153 AC_SUBST(ac_cv_have_inttypes_h)
154 AC_SUBST(ac_cv_have_uint16_t)
155 AC_SUBST(ac_cv_have_u_int16_t)
156 AC_SUBST(ac_cv_have___uint16)
157 AC_SUBST(ac_cv_have_libgflags)
158 AC_SUBST(GFLAGS_LIBS)
159
160 # Write generated configuration file
161 AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h])
162 AC_OUTPUT