|
| 1 | +# sfparse |
| 2 | +# |
| 3 | +# Copyright (c) 2023 sfparse contributors |
| 4 | +# Copyright (c) 2019 nghttp3 contributors |
| 5 | +# Copyright (c) 2016 ngtcp2 contributors |
| 6 | +# Copyright (c) 2012 nghttp2 contributors |
| 7 | +# |
| 8 | +# Permission is hereby granted, free of charge, to any person obtaining |
| 9 | +# a copy of this software and associated documentation files (the |
| 10 | +# "Software"), to deal in the Software without restriction, including |
| 11 | +# without limitation the rights to use, copy, modify, merge, publish, |
| 12 | +# distribute, sublicense, and/or sell copies of the Software, and to |
| 13 | +# permit persons to whom the Software is furnished to do so, subject to |
| 14 | +# the following conditions: |
| 15 | +# |
| 16 | +# The above copyright notice and this permission notice shall be |
| 17 | +# included in all copies or substantial portions of the Software. |
| 18 | +# |
| 19 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 21 | +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 22 | +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 23 | +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 24 | +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 25 | +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 26 | +AC_PREREQ(2.61) |
| 27 | +AC_INIT([sfparse], [0.0.0-DEV], [[email protected]]) |
| 28 | +AC_CONFIG_AUX_DIR([.]) |
| 29 | +AC_CONFIG_MACRO_DIR([m4]) |
| 30 | +AC_CONFIG_HEADERS([config.h]) |
| 31 | +AC_USE_SYSTEM_EXTENSIONS |
| 32 | + |
| 33 | +LT_PREREQ([2.2.6]) |
| 34 | +LT_INIT() |
| 35 | + |
| 36 | +AC_CANONICAL_BUILD |
| 37 | +AC_CANONICAL_HOST |
| 38 | +AC_CANONICAL_TARGET |
| 39 | + |
| 40 | +AM_INIT_AUTOMAKE([subdir-objects]) |
| 41 | + |
| 42 | +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
| 43 | + |
| 44 | +# See versioning rule: |
| 45 | +# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html |
| 46 | +AC_SUBST(LT_CURRENT, 0) |
| 47 | +AC_SUBST(LT_REVISION, 0) |
| 48 | +AC_SUBST(LT_AGE, 0) |
| 49 | + |
| 50 | +# Checks for command-line options |
| 51 | +AC_ARG_ENABLE([werror], |
| 52 | + [AS_HELP_STRING([--enable-werror], |
| 53 | + [Turn on compile time warnings])], |
| 54 | + [werror=$enableval], [werror=no]) |
| 55 | + |
| 56 | +AC_ARG_WITH([cunit], |
| 57 | + [AS_HELP_STRING([--with-cunit], |
| 58 | + [Use cunit [default=check]])], |
| 59 | + [request_cunit=$withval], [request_cunit=check]) |
| 60 | + |
| 61 | +# Checks for programs |
| 62 | +AC_PROG_CC |
| 63 | +AC_PROG_CPP |
| 64 | +AC_PROG_INSTALL |
| 65 | +AC_PROG_LN_S |
| 66 | +AC_PROG_MAKE_SET |
| 67 | +AC_PROG_MKDIR_P |
| 68 | + |
| 69 | +PKG_PROG_PKG_CONFIG([0.20]) |
| 70 | + |
| 71 | +# Checks for libraries. |
| 72 | + |
| 73 | +# cunit |
| 74 | +have_cunit=no |
| 75 | +if test "x${request_cunit}" != "xno"; then |
| 76 | + PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no]) |
| 77 | + # If pkg-config does not find cunit, check it using AC_CHECK_LIB. We |
| 78 | + # do this because Debian (Ubuntu) lacks pkg-config file for cunit. |
| 79 | + if test "x${have_cunit}" = "xno"; then |
| 80 | + AC_MSG_WARN([${CUNIT_PKG_ERRORS}]) |
| 81 | + AC_CHECK_LIB([cunit], [CU_initialize_registry], |
| 82 | + [have_cunit=yes], [have_cunit=no]) |
| 83 | + if test "x${have_cunit}" = "xyes"; then |
| 84 | + CUNIT_LIBS="-lcunit" |
| 85 | + CUNIT_CFLAGS="" |
| 86 | + AC_SUBST([CUNIT_LIBS]) |
| 87 | + AC_SUBST([CUNIT_CFLAGS]) |
| 88 | + fi |
| 89 | + fi |
| 90 | + if test "x${have_cunit}" = "xyes"; then |
| 91 | + # cunit in Mac OS X requires ncurses. Note that in Mac OS X, test |
| 92 | + # program can be built without -lncurses, but it emits runtime |
| 93 | + # error. |
| 94 | + case "${build}" in |
| 95 | + *-apple-darwin*) |
| 96 | + CUNIT_LIBS="$CUNIT_LIBS -lncurses" |
| 97 | + AC_SUBST([CUNIT_LIBS]) |
| 98 | + ;; |
| 99 | + esac |
| 100 | + fi |
| 101 | +fi |
| 102 | + |
| 103 | +if test "x${request_cunit}" = "xyes" && |
| 104 | + test "x${have_cunit}" != "xyes"; then |
| 105 | + AC_MSG_ERROR([cunit was requested (--with-cunit) but not found]) |
| 106 | +fi |
| 107 | + |
| 108 | +AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ]) |
| 109 | + |
| 110 | +# Checks for header files. |
| 111 | +AC_CHECK_HEADERS([ \ |
| 112 | + assert.h \ |
| 113 | + inttypes.h \ |
| 114 | + stddef.h \ |
| 115 | + stdint.h \ |
| 116 | + stdlib.h \ |
| 117 | + string.h \ |
| 118 | + sys/types.h |
| 119 | +]) |
| 120 | + |
| 121 | +# Checks for typedefs, structures, and compiler characteristics. |
| 122 | +AC_TYPE_SIZE_T |
| 123 | +AC_TYPE_UINT8_T |
| 124 | +AC_TYPE_UINT16_T |
| 125 | +AC_TYPE_UINT32_T |
| 126 | +AC_TYPE_UINT64_T |
| 127 | + |
| 128 | +# More compiler flags from nghttp2. |
| 129 | +save_CFLAGS=$CFLAGS |
| 130 | + |
| 131 | +CFLAGS= |
| 132 | + |
| 133 | +if test "x$werror" != "xno"; then |
| 134 | + # For C compiler |
| 135 | + AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"]) |
| 136 | + AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"]) |
| 137 | + AX_CHECK_COMPILE_FLAG([-Werror], [CFLAGS="$CFLAGS -Werror"]) |
| 138 | + AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [CFLAGS="$CFLAGS -Wmissing-prototypes"]) |
| 139 | + AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], [CFLAGS="$CFLAGS -Wstrict-prototypes"]) |
| 140 | + AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], [CFLAGS="$CFLAGS -Wmissing-declarations"]) |
| 141 | + AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"]) |
| 142 | + AX_CHECK_COMPILE_FLAG([-Wdeclaration-after-statement], [CFLAGS="$CFLAGS -Wdeclaration-after-statement"]) |
| 143 | + AX_CHECK_COMPILE_FLAG([-Wformat-security], [CFLAGS="$CFLAGS -Wformat-security"]) |
| 144 | + AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"]) |
| 145 | + AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"]) |
| 146 | + AX_CHECK_COMPILE_FLAG([-Winline], [CFLAGS="$CFLAGS -Winline"]) |
| 147 | + AX_CHECK_COMPILE_FLAG([-Wnested-externs], [CFLAGS="$CFLAGS -Wnested-externs"]) |
| 148 | + AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"]) |
| 149 | + AX_CHECK_COMPILE_FLAG([-Wundef], [CFLAGS="$CFLAGS -Wundef"]) |
| 150 | + AX_CHECK_COMPILE_FLAG([-Wendif-labels], [CFLAGS="$CFLAGS -Wendif-labels"]) |
| 151 | + AX_CHECK_COMPILE_FLAG([-Wempty-body], [CFLAGS="$CFLAGS -Wempty-body"]) |
| 152 | + AX_CHECK_COMPILE_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"]) |
| 153 | + AX_CHECK_COMPILE_FLAG([-Wclobbered], [CFLAGS="$CFLAGS -Wclobbered"]) |
| 154 | + AX_CHECK_COMPILE_FLAG([-Wvla], [CFLAGS="$CFLAGS -Wvla"]) |
| 155 | + AX_CHECK_COMPILE_FLAG([-Wpragmas], [CFLAGS="$CFLAGS -Wpragmas"]) |
| 156 | + AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [CFLAGS="$CFLAGS -Wunreachable-code"]) |
| 157 | + AX_CHECK_COMPILE_FLAG([-Waddress], [CFLAGS="$CFLAGS -Waddress"]) |
| 158 | + AX_CHECK_COMPILE_FLAG([-Wattributes], [CFLAGS="$CFLAGS -Wattributes"]) |
| 159 | + AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"]) |
| 160 | + AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], [CFLAGS="$CFLAGS -Wshorten-64-to-32"]) |
| 161 | + |
| 162 | + AX_CHECK_COMPILE_FLAG([-Wconversion], [CFLAGS="$CFLAGS -Wconversion"]) |
| 163 | + AX_CHECK_COMPILE_FLAG([-Wextended-offsetof], [CFLAGS="$CFLAGS -Wextended-offsetof"]) |
| 164 | + AX_CHECK_COMPILE_FLAG([-Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat-nonliteral"]) |
| 165 | + AX_CHECK_COMPILE_FLAG([-Wlanguage-extension-token], [CFLAGS="$CFLAGS -Wlanguage-extension-token"]) |
| 166 | + AX_CHECK_COMPILE_FLAG([-Wmissing-field-initializers], [CFLAGS="$CFLAGS -Wmissing-field-initializers"]) |
| 167 | + AX_CHECK_COMPILE_FLAG([-Wmissing-noreturn], [CFLAGS="$CFLAGS -Wmissing-noreturn"]) |
| 168 | + AX_CHECK_COMPILE_FLAG([-Wmissing-variable-declarations], [CFLAGS="$CFLAGS -Wmissing-variable-declarations"]) |
| 169 | + # Not used because we cannot change public structs |
| 170 | + # AX_CHECK_COMPILE_FLAG([-Wpadded], [CFLAGS="$CFLAGS -Wpadded"]) |
| 171 | + AX_CHECK_COMPILE_FLAG([-Wsign-conversion], [CFLAGS="$CFLAGS -Wsign-conversion"]) |
| 172 | + # Not used because this basically disallows default case |
| 173 | + # AX_CHECK_COMPILE_FLAG([-Wswitch-enum], [CFLAGS="$CFLAGS -Wswitch-enum"]) |
| 174 | + AX_CHECK_COMPILE_FLAG([-Wunreachable-code-break], [CFLAGS="$CFLAGS -Wunreachable-code-break"]) |
| 175 | + AX_CHECK_COMPILE_FLAG([-Wunused-macros], [CFLAGS="$CFLAGS -Wunused-macros"]) |
| 176 | + AX_CHECK_COMPILE_FLAG([-Wunused-parameter], [CFLAGS="$CFLAGS -Wunused-parameter"]) |
| 177 | + AX_CHECK_COMPILE_FLAG([-Wredundant-decls], [CFLAGS="$CFLAGS -Wredundant-decls"]) |
| 178 | + # Only work with Clang for the moment |
| 179 | + AX_CHECK_COMPILE_FLAG([-Wheader-guard], [CFLAGS="$CFLAGS -Wheader-guard"]) |
| 180 | + AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CFLAGS="$CFLAGS -Wsometimes-uninitialized"]) |
| 181 | + |
| 182 | + # Only work with gcc7 for the moment |
| 183 | + AX_CHECK_COMPILE_FLAG([-Wduplicated-branches], [CFLAGS="$CFLAGS -Wduplicated-branches"]) |
| 184 | + |
| 185 | + # This is required because we pass format string as "const char*. |
| 186 | + AX_CHECK_COMPILE_FLAG([-Wno-format-nonliteral], [CFLAGS="$CFLAGS -Wno-format-nonliteral"]) |
| 187 | +fi |
| 188 | + |
| 189 | +WARNCFLAGS=$CFLAGS |
| 190 | + |
| 191 | +CFLAGS=$save_CFLAGS |
| 192 | + |
| 193 | +AC_SUBST([WARNCFLAGS]) |
| 194 | + |
| 195 | +AC_CONFIG_FILES([ |
| 196 | + Makefile |
| 197 | +]) |
| 198 | +AC_OUTPUT |
| 199 | + |
| 200 | +AC_MSG_NOTICE([summary of build options: |
| 201 | +
|
| 202 | + Package version: ${VERSION} |
| 203 | + Library version: $LT_CURRENT:$LT_REVISION:$LT_AGE |
| 204 | + Install prefix: ${prefix} |
| 205 | + System types: |
| 206 | + Build: ${build} |
| 207 | + Host: ${host} |
| 208 | + Target: ${target} |
| 209 | + Compiler: |
| 210 | + C preprocessor: ${CPP} |
| 211 | + CPPFLAGS: ${CPPFLAGS} |
| 212 | + C compiler: ${CC} |
| 213 | + CFLAGS: ${CFLAGS} |
| 214 | + LDFLAGS: ${LDFLAGS} |
| 215 | + WARNCFLAGS: ${WARNCFLAGS} |
| 216 | + LIBS: ${LIBS} |
| 217 | + Library: |
| 218 | + Shared: ${enable_shared} |
| 219 | + Static: ${enable_static} |
| 220 | + Test: |
| 221 | + CUnit: ${have_cunit} (CFLAGS='${CUNIT_CFLAGS}' LIBS='${CUNIT_LIBS}') |
| 222 | +]) |
0 commit comments