blob: 8365989aeb86e02202f475eb6b7444d3b5bc2e3b [file] [log] [blame]
Brian Silverman70325d62015-09-20 17:00:43 -04001## Process this file with autoconf to produce configure.
2## In general, the safest way to proceed is to run ./autogen.sh
3
4# make sure we're interpreted by some minimal autoconf
5AC_PREREQ(2.57)
6
7AC_INIT(ctemplate, 2.3, google-ctemplate@googlegroups.com)
8AM_SILENT_RULES([yes])
9
10# Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
11# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
12SO_VERSION=3:0:0
13
14# The argument here is just something that should be in the current directory
15# (for sanity checking)
16AC_CONFIG_SRCDIR(README)
17AC_CONFIG_MACRO_DIR([m4])
18AC_CANONICAL_HOST
19AM_INIT_AUTOMAKE([subdir-objects dist-zip])
20AM_CONFIG_HEADER(src/config.h)
21
22# Checks for programs.
23AC_PROG_CXX
24AC_PROG_CC
25AM_PROG_CC_C_O
26AC_PROG_CPP
27AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
28
29# MinGW uses autoconf, but also needs the windows shim routines
30# (since it doesn't have its own support for, say, pthreads).
31# This requires us to #include a special header file, and also to
32# link in some windows versions of .o's instead of the unix versions.
33AH_BOTTOM([
34#if defined( __MINGW32__) || defined(__MINGW64__)
35#include "windows/port.h"
36#endif
37])
38case $host_os in
39 *mingw*)
40 # Disabling fast install keeps libtool from creating wrapper scripts
41 # around the executables it builds. Such scripts have caused failures on
42 # MinGW. Using this option means an extra link step is executed during
43 # "make install".
44 AC_DISABLE_FAST_INSTALL
45 ;;
46 *)
47 AC_ENABLE_FAST_INSTALL
48 ;;
49esac
50AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1)
51
52# Uncomment this if you'll be exporting libraries (.so's)
53AC_PROG_LIBTOOL
54AC_SUBST(LIBTOOL_DEPS)
55AC_SUBST(SO_VERSION)
56
57AC_PROG_LN_S
58
59AX_C___ATTRIBUTE__
60
61# Check whether some low-level functions/files are available
62AC_HEADER_STDC
63
64# Defines PRIuS
65AC_COMPILER_CHARACTERISTICS
66
67# Here are some examples of how to check for the existence of a fn or file
68AC_CHECK_FUNCS([getopt_long getopt])
69AC_CHECK_HEADERS([getopt.h])
70AC_CHECK_HEADERS([utime.h]) # used by unittests to mock file-times
71
72# These are the types I need. We look for them in either stdint.h,
73# sys/types.h, or inttypes.h, all of which are part of the default-includes.
74AC_CHECK_TYPES([uint32_t])
75AC_CHECK_TYPES([u_int32_t])
76AC_CHECK_TYPES([__int32])
77AC_CHECK_TYPES([uint64_t])
78AC_CHECK_TYPES([u_int64_t])
79AC_CHECK_TYPES([__int64])
80
81AC_HEADER_DIRENT # for template_unittest.cc, template_regtest.cc
82
83# We need to do byte-swapping efficiently to hash efficiently in
84# template_string.cc. Different architectures do this differently.
85AC_CHECK_HEADERS(byteswap.h) # Linux (GNU in general)
86AC_CHECK_HEADERS(libkern/OSByteOrder.h) # OS X
87AC_CHECK_HEADERS(sys/byteorder.h) # Solaris 10
88AC_CHECK_HEADERS(endian.h) # Linux
89AC_CHECK_HEADERS(machine/endian.h) # OS X
90AC_CHECK_HEADERS(sys/endian.h) # FreeBSD
91AC_CHECK_HEADERS(sys/isa_defs.h) # Solaris 10
92
93# A lot of the code in this directory depends on pthreads
94ACX_PTHREAD
95
96# We'd like to use read/write locks in several places in the code.
97# See if our pthreads support extends to that. Note: for linux, it
98# does as long as you define _XOPEN_SOURCE appropriately.
99AC_RWLOCK
100
101# For mingw/cygwin, figure out if the mutex code needs to use
102# 'volatile' in some places. They differ from MSVC, and the API is
103# unclear, so it's best just to check.
104AC_INTERLOCKED_EXCHANGE_NONVOLATILE
105
106# Find out what namespace 'normal' STL code lives in, and also what namespace
107# the user wants our classes to be defined in
108AC_CXX_STL_NAMESPACE
109AC_DEFINE_GOOGLE_NAMESPACE(ctemplate)
110
111# Figures out where hash_map and hash_set live, and what namespace they use
112AC_CXX_STL_HASH
113
114# If we found tr1/unordered_map, prefer unordered_map/unordered_set to
115# hash_map/hash_set.
116if test "$ac_cv_cxx_have_unordered_map" = yes; then
117 ac_cv_cxx_hash_map_class="$ac_cv_cxx_hash_namespace::unordered_map"
118 ac_cv_cxx_hash_set_class="$ac_cv_cxx_hash_namespace::unordered_set"
119else
120 ac_cv_cxx_hash_map_class="$ac_cv_cxx_hash_namespace::hash_map"
121 ac_cv_cxx_hash_set_class="$ac_cv_cxx_hash_namespace::hash_set"
122fi
123
124AC_SUBST(ac_google_namespace)
125AC_SUBST(ac_google_start_namespace)
126AC_SUBST(ac_google_end_namespace)
127AC_SUBST(ac_cv_cxx_hash_map)
128AC_SUBST(ac_cv_cxx_hash_set)
129AC_SUBST(ac_cv_cxx_hash_map_class)
130AC_SUBST(ac_cv_cxx_hash_set_class)
131if test "$ac_cv___attribute__" = "yes"; then
132 AC_SUBST(ac_google_attribute, 1)
133else
134 AC_SUBST(ac_google_attribute, 0)
135fi
136if test "$ac_cv_type_u_int64_t" = "yes"; then
137 AC_SUBST(ac_cv_uint64, u_int64_t)
138elif test "$ac_cv_type_uint64_t" = "yes"; then
139 AC_SUBST(ac_cv_uint64, uint64_t)
140elif test "$ac_cv_type___int64" = "yes"; then
141 AC_SUBST(ac_cv_uint64, unsigned __int64)
142else
143 AC_SUBST(ac_cv_uint64, unsigned long long) # best we can do
144fi
145# These are used by template_string.h.in
146if test "$ac_cv_header_stdint_h" = "yes"; then
147 AC_SUBST(ac_cv_have_stdint_h, 1)
148else
149 AC_SUBST(ac_cv_have_stdint_h, 0)
150fi
151if test "$ac_cv_header_inttypes_h" = "yes"; then
152 AC_SUBST(ac_cv_have_inttypes_h, 1)
153else
154 AC_SUBST(ac_cv_have_inttypes_h, 0)
155fi
156
157
158# One some systems (eg gnu/linux), the linker defines _start and
159# data_start to indicate the extent of the .text section. We can use
160# this to know strings are immutable. In the code, we make the
161# variables weak, just in case, but for this check, we only want to
162# say "yes" if the linker supports the vars, *and* the compiler supports
163# attribute-weak.
164AC_TRY_LINK([], [ extern char _start[];
165 extern char data_start[];
166 extern char dummy[] __attribute__((weak));
167 return (_start && data_start && dummy); ],
168 [ ac_have_attribute_weak=1 ], [ ac_have_attribute_weak=0 ])
169AC_SUBST(ac_have_attribute_weak)
170
171# In unix (that is, using this script), this dll-export stuff will always
172# be the empty string. In windows, we'll replace it with windows-specific
173# text.
174ac_windows_dllexport_defines=
175ac_windows_dllexport=
176AC_SUBST(ac_windows_dllexport_defines)
177AC_SUBST(ac_windows_dllexport)
178
179# This will (should) never change, but we put it here so if we do need
180# to change it, to avoid naming conflicts or something, it's easy to
181# do in one place.
182ac_htmlparser_namespace=ctemplate_htmlparser
183AC_SUBST(ac_htmlparser_namespace)
184AC_DEFINE_UNQUOTED(HTMLPARSER_NAMESPACE, $ac_htmlparser_namespace,
185 [The namespace to put the htmlparser code.])
186
187# Write generated configuration file, and also .h files
188AC_CONFIG_FILES([Makefile \
189 src/ctemplate/template_string.h \
190 src/ctemplate/template_enums.h \
191 src/ctemplate/template.h \
192 src/ctemplate/template_cache.h \
193 src/ctemplate/template_modifiers.h \
194 src/ctemplate/template_emitter.h \
195 src/ctemplate/template_annotator.h \
196 src/ctemplate/template_dictionary.h \
197 src/ctemplate/template_pathops.h \
198 src/ctemplate/template_namelist.h \
199 src/ctemplate/find_ptr.h \
200 src/ctemplate/per_expand_data.h \
201 src/ctemplate/str_ref.h \
202 src/ctemplate/template_dictionary_interface.h \
203 ])
204AC_OUTPUT