Harald Welte | bad3897 | 2019-11-06 06:51:57 +0100 | [diff] [blame] | 1 | dnl Process this file with autoconf to produce a configure script |
| 2 | AC_INIT([osmo-e1-recorder], |
| 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 | |
Oliver Smith | 91a98c0 | 2021-01-27 17:47:10 +0100 | [diff] [blame] | 12 | CFLAGS="$CFLAGS -std=gnu11" |
| 13 | |
Harald Welte | bad3897 | 2019-11-06 06:51:57 +0100 | [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 check for pkg-config (explained in detail in libosmocore/configure.ac) |
| 28 | AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no) |
| 29 | if test "x$PKG_CONFIG_INSTALLED" = "xno"; then |
| 30 | AC_MSG_WARN([You need to install pkg-config]) |
| 31 | fi |
| 32 | PKG_PROG_PKG_CONFIG([0.20]) |
| 33 | |
Harald Welte | bad3897 | 2019-11-06 06:51:57 +0100 | [diff] [blame] | 34 | PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.2.0) |
| 35 | PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.2.0) |
| 36 | PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.2.0) |
| 37 | PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.6.0) |
| 38 | |
| 39 | dnl checks for header files |
| 40 | AC_HEADER_STDC |
| 41 | |
| 42 | dnl Checks for typedefs, structures and compiler characteristics |
| 43 | |
| 44 | AC_ARG_ENABLE(sanitize, |
| 45 | [AS_HELP_STRING( |
| 46 | [--enable-sanitize], |
| 47 | [Compile with address sanitizer enabled], |
| 48 | )], |
| 49 | [sanitize=$enableval], [sanitize="no"]) |
| 50 | if test x"$sanitize" = x"yes" |
| 51 | then |
| 52 | CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined" |
| 53 | CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined" |
| 54 | fi |
| 55 | |
| 56 | AC_ARG_ENABLE(werror, |
| 57 | [AS_HELP_STRING( |
| 58 | [--enable-werror], |
| 59 | [Turn all compiler warnings into errors, with exceptions: |
| 60 | a) deprecation (allow upstream to mark deprecation without breaking builds); |
| 61 | b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds) |
| 62 | ] |
| 63 | )], |
| 64 | [werror=$enableval], [werror="no"]) |
| 65 | if test x"$werror" = x"yes" |
| 66 | then |
| 67 | WERROR_FLAGS="-Werror" |
| 68 | WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations" |
| 69 | WERROR_FLAGS+=" -Wno-error=cpp" # "#warning" |
| 70 | CFLAGS="$CFLAGS $WERROR_FLAGS" |
| 71 | CPPFLAGS="$CPPFLAGS $WERROR_FLAGS" |
| 72 | fi |
| 73 | |
| 74 | # The following test is taken from WebKit's webkit.m4 |
| 75 | saved_CFLAGS="$CFLAGS" |
| 76 | CFLAGS="$CFLAGS -fvisibility=hidden " |
| 77 | AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) |
| 78 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], |
| 79 | [ AC_MSG_RESULT([yes]) |
| 80 | SYMBOL_VISIBILITY="-fvisibility=hidden"], |
| 81 | AC_MSG_RESULT([no])) |
| 82 | CFLAGS="$saved_CFLAGS" |
| 83 | AC_SUBST(SYMBOL_VISIBILITY) |
| 84 | |
Harald Welte | bad3897 | 2019-11-06 06:51:57 +0100 | [diff] [blame] | 85 | # Coverage build taken from WebKit's configure.in |
| 86 | AC_MSG_CHECKING([whether to enable code coverage support]) |
| 87 | AC_ARG_ENABLE(coverage, |
| 88 | AC_HELP_STRING([--enable-coverage], |
| 89 | [enable code coverage support [default=no]]), |
| 90 | [],[enable_coverage="no"]) |
| 91 | AC_MSG_RESULT([$enable_coverage]) |
| 92 | if test "$enable_coverage" = "yes"; then |
| 93 | COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs" |
| 94 | COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs" |
| 95 | AC_SUBST([COVERAGE_CFLAGS]) |
| 96 | AC_SUBST([COVERAGE_LDFLAGS]) |
| 97 | fi |
| 98 | |
| 99 | AC_ARG_ENABLE(profile, |
| 100 | [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )], |
| 101 | [profile=$enableval], [profile="no"]) |
| 102 | if test x"$profile" = x"yes" |
| 103 | then |
| 104 | CFLAGS="$CFLAGS -pg" |
| 105 | CPPFLAGS="$CPPFLAGS -pg" |
| 106 | fi |
| 107 | |
| 108 | AC_ARG_ENABLE([external_tests], |
| 109 | AC_HELP_STRING([--enable-external-tests], |
| 110 | [Include the VTY/CTRL tests in make check [default=no]]), |
| 111 | [enable_ext_tests="$enableval"],[enable_ext_tests="no"]) |
| 112 | if test "x$enable_ext_tests" = "xyes" ; then |
| 113 | AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes) |
| 114 | if test "x$PYTHON2_AVAIL" != "xyes" ; then |
| 115 | AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.]) |
| 116 | fi |
| 117 | AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes) |
| 118 | if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then |
Harald Welte | be5f2c7 | 2022-06-18 11:56:29 +0200 | [diff] [blame] | 119 | AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.]) |
Harald Welte | bad3897 | 2019-11-06 06:51:57 +0100 | [diff] [blame] | 120 | fi |
| 121 | fi |
| 122 | AC_MSG_CHECKING([whether to enable VTY/CTRL tests]) |
| 123 | AC_MSG_RESULT([$enable_ext_tests]) |
| 124 | AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes") |
| 125 | |
| 126 | # Generate manuals |
| 127 | AC_ARG_ENABLE(manuals, |
| 128 | [AS_HELP_STRING( |
| 129 | [--enable-manuals], |
| 130 | [Generate manual PDFs [default=no]], |
| 131 | )], |
| 132 | [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"]) |
| 133 | AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"]) |
| 134 | AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals" |
| 135 | fallback]) |
| 136 | if test x"$osmo_ac_build_manuals" = x"yes" |
| 137 | then |
| 138 | # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback) |
| 139 | if test -n "$OSMO_GSM_MANUALS_DIR"; then |
| 140 | echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)" |
| 141 | else |
| 142 | OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)" |
| 143 | if test -n "$OSMO_GSM_MANUALS_DIR"; then |
| 144 | echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)" |
| 145 | else |
| 146 | OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals" |
| 147 | echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)" |
| 148 | fi |
| 149 | fi |
| 150 | if ! test -d "$OSMO_GSM_MANUALS_DIR"; then |
| 151 | AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.") |
| 152 | fi |
| 153 | |
| 154 | # Find and run check-depends |
| 155 | CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh" |
| 156 | if ! test -x "$CHECK_DEPENDS"; then |
| 157 | CHECK_DEPENDS="osmo-gsm-manuals-check-depends" |
| 158 | fi |
| 159 | if ! $CHECK_DEPENDS; then |
| 160 | AC_MSG_ERROR("missing dependencies for --enable-manuals") |
| 161 | fi |
| 162 | |
| 163 | # Put in Makefile with absolute path |
| 164 | OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")" |
| 165 | AC_SUBST([OSMO_GSM_MANUALS_DIR]) |
| 166 | fi |
| 167 | |
| 168 | # https://www.freedesktop.org/software/systemd/man/daemon.html |
| 169 | AC_ARG_WITH([systemdsystemunitdir], |
| 170 | [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],, |
| 171 | [with_systemdsystemunitdir=auto]) |
| 172 | AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [ |
| 173 | def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) |
| 174 | |
| 175 | AS_IF([test "x$def_systemdsystemunitdir" = "x"], |
| 176 | [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], |
| 177 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) |
| 178 | with_systemdsystemunitdir=no], |
| 179 | [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) |
| 180 | AS_IF([test "x$with_systemdsystemunitdir" != "xno"], |
| 181 | [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) |
| 182 | AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) |
| 183 | |
| 184 | AC_MSG_RESULT([CFLAGS="$CFLAGS"]) |
| 185 | AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"]) |
| 186 | |
| 187 | dnl Generate the output |
| 188 | AM_CONFIG_HEADER(config.h) |
| 189 | |
| 190 | AC_OUTPUT( |
| 191 | src/Makefile |
| 192 | doc/Makefile |
| 193 | tests/Makefile |
| 194 | doc/examples/Makefile |
| 195 | Makefile) |