Harald Welte | b53e2bf | 2020-08-21 16:33:42 +0200 | [diff] [blame] | 1 | dnl Process this file with autoconf to produce a configure script |
| 2 | AC_INIT([osmo-smlc], |
| 3 | m4_esyscmd([./git-version-gen .tarball-version]), |
| 4 | [openbsc@lists.osmocom.org]) |
| 5 | |
| 6 | dnl *This* is the root dir, even if an install-sh exists in ../ or ../../ |
| 7 | AC_CONFIG_AUX_DIR([.]) |
| 8 | |
| 9 | AM_INIT_AUTOMAKE([dist-bzip2]) |
| 10 | AC_CONFIG_TESTDIR(tests) |
| 11 | |
| 12 | dnl kernel style compile messages |
| 13 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
| 14 | |
| 15 | dnl include release helper |
| 16 | RELMAKE='-include osmo-release.mk' |
| 17 | AC_SUBST([RELMAKE]) |
| 18 | |
| 19 | dnl checks for programs |
| 20 | AC_PROG_MAKE_SET |
| 21 | AC_PROG_CC |
| 22 | AC_PROG_INSTALL |
| 23 | LT_INIT |
| 24 | |
| 25 | dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang |
| 26 | AS_CASE(["$LD"],[*clang*], |
| 27 | [AS_CASE(["${host_os}"], |
| 28 | [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])]) |
| 29 | |
| 30 | dnl check for pkg-config (explained in detail in libosmocore/configure.ac) |
| 31 | AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no) |
| 32 | if test "x$PKG_CONFIG_INSTALLED" = "xno"; then |
| 33 | AC_MSG_WARN([You need to install pkg-config]) |
| 34 | fi |
| 35 | PKG_PROG_PKG_CONFIG([0.20]) |
| 36 | |
| 37 | dnl check for AX_CHECK_COMPILE_FLAG |
| 38 | m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [ |
| 39 | AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.]) |
| 40 | ]) |
| 41 | |
| 42 | PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.3.0) |
| 43 | PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.3.0) |
| 44 | PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.3.0) |
| 45 | PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.3.0) |
| 46 | PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.10.0) |
| 47 | PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.10.0) |
| 48 | |
| 49 | dnl checks for header files |
| 50 | AC_HEADER_STDC |
| 51 | |
| 52 | dnl Checks for typedefs, structures and compiler characteristics |
| 53 | |
| 54 | AC_ARG_ENABLE(sanitize, |
| 55 | [AS_HELP_STRING( |
| 56 | [--enable-sanitize], |
| 57 | [Compile with address sanitizer enabled], |
| 58 | )], |
| 59 | [sanitize=$enableval], [sanitize="no"]) |
| 60 | if test x"$sanitize" = x"yes" |
| 61 | then |
| 62 | CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined" |
| 63 | CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined" |
| 64 | fi |
| 65 | |
| 66 | AC_ARG_ENABLE(werror, |
| 67 | [AS_HELP_STRING( |
| 68 | [--enable-werror], |
| 69 | [Turn all compiler warnings into errors, with exceptions: |
| 70 | a) deprecation (allow upstream to mark deprecation without breaking builds); |
| 71 | b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds) |
| 72 | ] |
| 73 | )], |
| 74 | [werror=$enableval], [werror="no"]) |
| 75 | if test x"$werror" = x"yes" |
| 76 | then |
| 77 | WERROR_FLAGS="-Werror" |
| 78 | WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations" |
| 79 | WERROR_FLAGS+=" -Wno-error=cpp" # "#warning" |
| 80 | CFLAGS="$CFLAGS $WERROR_FLAGS" |
| 81 | CPPFLAGS="$CPPFLAGS $WERROR_FLAGS" |
| 82 | fi |
| 83 | |
| 84 | # The following test is taken from WebKit's webkit.m4 |
| 85 | saved_CFLAGS="$CFLAGS" |
| 86 | CFLAGS="$CFLAGS -fvisibility=hidden " |
| 87 | AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) |
| 88 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], |
| 89 | [ AC_MSG_RESULT([yes]) |
| 90 | SYMBOL_VISIBILITY="-fvisibility=hidden"], |
| 91 | AC_MSG_RESULT([no])) |
| 92 | CFLAGS="$saved_CFLAGS" |
| 93 | AC_SUBST(SYMBOL_VISIBILITY) |
| 94 | |
| 95 | AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"]) |
| 96 | AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"]) |
| 97 | AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"]) |
| 98 | AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"]) |
| 99 | AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"]) |
| 100 | AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"]) |
| 101 | |
| 102 | # Coverage build taken from WebKit's configure.in |
| 103 | AC_MSG_CHECKING([whether to enable code coverage support]) |
| 104 | AC_ARG_ENABLE(coverage, |
| 105 | AC_HELP_STRING([--enable-coverage], |
| 106 | [enable code coverage support [default=no]]), |
| 107 | [],[enable_coverage="no"]) |
| 108 | AC_MSG_RESULT([$enable_coverage]) |
| 109 | if test "$enable_coverage" = "yes"; then |
| 110 | COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs" |
| 111 | COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs" |
| 112 | AC_SUBST([COVERAGE_CFLAGS]) |
| 113 | AC_SUBST([COVERAGE_LDFLAGS]) |
| 114 | fi |
| 115 | |
| 116 | AC_ARG_ENABLE(profile, |
| 117 | [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )], |
| 118 | [profile=$enableval], [profile="no"]) |
| 119 | if test x"$profile" = x"yes" |
| 120 | then |
| 121 | CFLAGS="$CFLAGS -pg" |
| 122 | CPPFLAGS="$CPPFLAGS -pg" |
| 123 | fi |
| 124 | |
| 125 | AC_ARG_ENABLE([external_tests], |
| 126 | AC_HELP_STRING([--enable-external-tests], |
| 127 | [Include the VTY/CTRL tests in make check [default=no]]), |
| 128 | [enable_ext_tests="$enableval"],[enable_ext_tests="no"]) |
| 129 | if test "x$enable_ext_tests" = "xyes" ; then |
| 130 | AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes) |
| 131 | if test "x$PYTHON2_AVAIL" != "xyes" ; then |
| 132 | AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.]) |
| 133 | fi |
| 134 | AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes) |
| 135 | if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then |
| 136 | AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.]) |
| 137 | fi |
| 138 | fi |
| 139 | AC_MSG_CHECKING([whether to enable VTY/CTRL tests]) |
| 140 | AC_MSG_RESULT([$enable_ext_tests]) |
| 141 | AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes") |
| 142 | |
| 143 | # Generate manuals |
| 144 | AC_ARG_ENABLE(manuals, |
| 145 | [AS_HELP_STRING( |
| 146 | [--enable-manuals], |
| 147 | [Generate manual PDFs [default=no]], |
| 148 | )], |
| 149 | [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"]) |
| 150 | AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"]) |
| 151 | AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals" |
| 152 | fallback]) |
| 153 | if test x"$osmo_ac_build_manuals" = x"yes" |
| 154 | then |
| 155 | # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback) |
| 156 | if test -n "$OSMO_GSM_MANUALS_DIR"; then |
| 157 | echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)" |
| 158 | else |
| 159 | OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)" |
| 160 | if test -n "$OSMO_GSM_MANUALS_DIR"; then |
| 161 | echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)" |
| 162 | else |
| 163 | OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals" |
| 164 | echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)" |
| 165 | fi |
| 166 | fi |
| 167 | if ! test -d "$OSMO_GSM_MANUALS_DIR"; then |
| 168 | AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.") |
| 169 | fi |
| 170 | |
| 171 | # Find and run check-depends |
| 172 | CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh" |
| 173 | if ! test -x "$CHECK_DEPENDS"; then |
| 174 | CHECK_DEPENDS="osmo-gsm-manuals-check-depends" |
| 175 | fi |
| 176 | if ! $CHECK_DEPENDS; then |
| 177 | AC_MSG_ERROR("missing dependencies for --enable-manuals") |
| 178 | fi |
| 179 | |
| 180 | # Put in Makefile with absolute path |
| 181 | OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")" |
| 182 | AC_SUBST([OSMO_GSM_MANUALS_DIR]) |
| 183 | fi |
| 184 | |
| 185 | # https://www.freedesktop.org/software/systemd/man/daemon.html |
| 186 | AC_ARG_WITH([systemdsystemunitdir], |
| 187 | [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],, |
| 188 | [with_systemdsystemunitdir=auto]) |
| 189 | AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [ |
| 190 | def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
| 191 | |
| 192 | AS_IF([test "x$def_systemdsystemunitdir" = "x"], |
| 193 | [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], |
| 194 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) |
| 195 | with_systemdsystemunitdir=no], |
| 196 | [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) |
| 197 | AS_IF([test "x$with_systemdsystemunitdir" != "xno"], |
| 198 | [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) |
| 199 | AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) |
| 200 | |
| 201 | AC_MSG_RESULT([CFLAGS="$CFLAGS"]) |
| 202 | AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"]) |
| 203 | |
| 204 | dnl Generate the output |
| 205 | AM_CONFIG_HEADER(config.h) |
| 206 | |
| 207 | AC_OUTPUT( |
| 208 | include/Makefile |
| 209 | include/osmocom/Makefile |
| 210 | include/osmocom/smlc/Makefile |
| 211 | src/Makefile |
| 212 | src/osmo-smlc/Makefile |
| 213 | tests/Makefile |
| 214 | tests/atlocal |
Neels Hofmeyr | 7299215 | 2020-09-19 02:36:08 +0200 | [diff] [blame] | 215 | tests/smlc_subscr/Makefile |
Harald Welte | b53e2bf | 2020-08-21 16:33:42 +0200 | [diff] [blame] | 216 | doc/Makefile |
| 217 | doc/examples/Makefile |
| 218 | doc/manuals/Makefile |
| 219 | contrib/Makefile |
| 220 | contrib/systemd/Makefile |
| 221 | contrib/osmo-smlc.spec |
| 222 | Makefile) |