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