Brian Silverman | 70325d6 | 2015-09-20 17:00:43 -0400 | [diff] [blame] | 1 | ## 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 |
| 5 | AC_PREREQ(2.57) |
| 6 | |
| 7 | AC_INIT(ctemplate, 2.3, google-ctemplate@googlegroups.com) |
| 8 | AM_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 |
| 12 | SO_VERSION=3:0:0 |
| 13 | |
| 14 | # The argument here is just something that should be in the current directory |
| 15 | # (for sanity checking) |
| 16 | AC_CONFIG_SRCDIR(README) |
| 17 | AC_CONFIG_MACRO_DIR([m4]) |
| 18 | AC_CANONICAL_HOST |
| 19 | AM_INIT_AUTOMAKE([subdir-objects dist-zip]) |
| 20 | AM_CONFIG_HEADER(src/config.h) |
| 21 | |
| 22 | # Checks for programs. |
| 23 | AC_PROG_CXX |
| 24 | AC_PROG_CC |
| 25 | AM_PROG_CC_C_O |
| 26 | AC_PROG_CPP |
| 27 | AM_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. |
| 33 | AH_BOTTOM([ |
| 34 | #if defined( __MINGW32__) || defined(__MINGW64__) |
| 35 | #include "windows/port.h" |
| 36 | #endif |
| 37 | ]) |
| 38 | case $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 | ;; |
| 49 | esac |
| 50 | AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1) |
| 51 | |
| 52 | # Uncomment this if you'll be exporting libraries (.so's) |
| 53 | AC_PROG_LIBTOOL |
| 54 | AC_SUBST(LIBTOOL_DEPS) |
| 55 | AC_SUBST(SO_VERSION) |
| 56 | |
| 57 | AC_PROG_LN_S |
| 58 | |
| 59 | AX_C___ATTRIBUTE__ |
| 60 | |
| 61 | # Check whether some low-level functions/files are available |
| 62 | AC_HEADER_STDC |
| 63 | |
| 64 | # Defines PRIuS |
| 65 | AC_COMPILER_CHARACTERISTICS |
| 66 | |
| 67 | # Here are some examples of how to check for the existence of a fn or file |
| 68 | AC_CHECK_FUNCS([getopt_long getopt]) |
| 69 | AC_CHECK_HEADERS([getopt.h]) |
| 70 | AC_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. |
| 74 | AC_CHECK_TYPES([uint32_t]) |
| 75 | AC_CHECK_TYPES([u_int32_t]) |
| 76 | AC_CHECK_TYPES([__int32]) |
| 77 | AC_CHECK_TYPES([uint64_t]) |
| 78 | AC_CHECK_TYPES([u_int64_t]) |
| 79 | AC_CHECK_TYPES([__int64]) |
| 80 | |
| 81 | AC_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. |
| 85 | AC_CHECK_HEADERS(byteswap.h) # Linux (GNU in general) |
| 86 | AC_CHECK_HEADERS(libkern/OSByteOrder.h) # OS X |
| 87 | AC_CHECK_HEADERS(sys/byteorder.h) # Solaris 10 |
| 88 | AC_CHECK_HEADERS(endian.h) # Linux |
| 89 | AC_CHECK_HEADERS(machine/endian.h) # OS X |
| 90 | AC_CHECK_HEADERS(sys/endian.h) # FreeBSD |
| 91 | AC_CHECK_HEADERS(sys/isa_defs.h) # Solaris 10 |
| 92 | |
| 93 | # A lot of the code in this directory depends on pthreads |
| 94 | ACX_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. |
| 99 | AC_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. |
| 104 | AC_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 |
| 108 | AC_CXX_STL_NAMESPACE |
| 109 | AC_DEFINE_GOOGLE_NAMESPACE(ctemplate) |
| 110 | |
| 111 | # Figures out where hash_map and hash_set live, and what namespace they use |
| 112 | AC_CXX_STL_HASH |
| 113 | |
| 114 | # If we found tr1/unordered_map, prefer unordered_map/unordered_set to |
| 115 | # hash_map/hash_set. |
| 116 | if 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" |
| 119 | else |
| 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" |
| 122 | fi |
| 123 | |
| 124 | AC_SUBST(ac_google_namespace) |
| 125 | AC_SUBST(ac_google_start_namespace) |
| 126 | AC_SUBST(ac_google_end_namespace) |
| 127 | AC_SUBST(ac_cv_cxx_hash_map) |
| 128 | AC_SUBST(ac_cv_cxx_hash_set) |
| 129 | AC_SUBST(ac_cv_cxx_hash_map_class) |
| 130 | AC_SUBST(ac_cv_cxx_hash_set_class) |
| 131 | if test "$ac_cv___attribute__" = "yes"; then |
| 132 | AC_SUBST(ac_google_attribute, 1) |
| 133 | else |
| 134 | AC_SUBST(ac_google_attribute, 0) |
| 135 | fi |
| 136 | if test "$ac_cv_type_u_int64_t" = "yes"; then |
| 137 | AC_SUBST(ac_cv_uint64, u_int64_t) |
| 138 | elif test "$ac_cv_type_uint64_t" = "yes"; then |
| 139 | AC_SUBST(ac_cv_uint64, uint64_t) |
| 140 | elif test "$ac_cv_type___int64" = "yes"; then |
| 141 | AC_SUBST(ac_cv_uint64, unsigned __int64) |
| 142 | else |
| 143 | AC_SUBST(ac_cv_uint64, unsigned long long) # best we can do |
| 144 | fi |
| 145 | # These are used by template_string.h.in |
| 146 | if test "$ac_cv_header_stdint_h" = "yes"; then |
| 147 | AC_SUBST(ac_cv_have_stdint_h, 1) |
| 148 | else |
| 149 | AC_SUBST(ac_cv_have_stdint_h, 0) |
| 150 | fi |
| 151 | if test "$ac_cv_header_inttypes_h" = "yes"; then |
| 152 | AC_SUBST(ac_cv_have_inttypes_h, 1) |
| 153 | else |
| 154 | AC_SUBST(ac_cv_have_inttypes_h, 0) |
| 155 | fi |
| 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. |
| 164 | AC_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 ]) |
| 169 | AC_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. |
| 174 | ac_windows_dllexport_defines= |
| 175 | ac_windows_dllexport= |
| 176 | AC_SUBST(ac_windows_dllexport_defines) |
| 177 | AC_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. |
| 182 | ac_htmlparser_namespace=ctemplate_htmlparser |
| 183 | AC_SUBST(ac_htmlparser_namespace) |
| 184 | AC_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 |
| 188 | AC_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 | ]) |
| 204 | AC_OUTPUT |