Review at  https://gerrit.osmocom.org/7582

configure: fix --enable-sysmocom-dsp and --with-sysmobts flags

Fix multiple problems around the sysmobts DSP access and headers:

- Use the proper variable name to detect the choice: $enable_sysmocom_bts was
  not set anywhere and would actually be used from the current user env, if
  present, instead of from configure args.

- Properly evaluate AC_ARG_ENABLE(): the arguments are
  AC_ARG_ENABLE(option-name, help-string, action-if-present, 
action-if-not-present)
  and action-if-present sets to "yes" or "no" if any configure argument is 
present.
  Using action-if-present as [enable_sysmocom_dsp=yes] breaks passing a
  --disable-sysmocom-dsp option.

- Quote the $CPPFLAGS when assigning to oldCPPFLAGS and back.

- When checking SYSMOBTS_INCDIR, do not allow an empty "-I" without a dir.

- Ensure the --with-sysmobts path is used as an absolute path.

- Error out if --with-sysmobts is paired with --disable-sysmocom-dsp.

Also tweak reporting.

The resulting behavior now is:

./configure --disable-sysmocom-dsp
checking whether to enable direct DSP access for PDCH of sysmocom-bts... no

./configure --enable-sysmocom-dsp
checking whether to enable direct DSP access for PDCH of sysmocom-bts... yes
checking for sysmocom/femtobts/superfemto.h... no
configure: error: sysmocom/femtobts/superfemto.h can not be found, see 
--with-sysmobts

./configure --disable-sysmocom-dsp --with-sysmobts=../../../sysmobts/layer1-api
checking whether to enable direct DSP access for PDCH of sysmocom-bts... error
configure: error: --with-sysmobts does not work with --disable-sysmocom-dsp

./configure --enable-sysmocom-dsp --with-sysmobts=../../../sysmobts/layer1-api
checking whether to enable direct DSP access for PDCH of sysmocom-bts... yes, 
using -I/n/s/sysmobts/layer1-api
checking for sysmocom/femtobts/superfemto.h... yes

./configure --with-sysmobts=../../../sysmobts/layer1-api
checking whether to enable direct DSP access for PDCH of sysmocom-bts... yes, 
using -I/n/s/sysmobts/layer1-api
checking for sysmocom/femtobts/superfemto.h... yes

./configure --with-sysmobts=/nonexisting/path
checking whether to enable direct DSP access for PDCH of sysmocom-bts... yes, 
using -I/nonexisting/path
checking for sysmocom/femtobts/superfemto.h... no
configure: error: sysmocom/femtobts/superfemto.h can not be found in 
-I/nonexisting/path, see --with-sysmobts

./configure --with-sysmobts=/var/log
checking whether to enable direct DSP access for PDCH of sysmocom-bts... yes, 
using -I/var/log
checking for sysmocom/femtobts/superfemto.h... no
configure: error: sysmocom/femtobts/superfemto.h can not be found in 
-I/var/log, see --with-sysmobts

Change-Id: I2f5988730dbbcf3b21d8c647c499623843ed3da9
---
M configure.ac
1 file changed, 34 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/82/7582/1

diff --git a/configure.ac b/configure.ac
index 8cddd1a..33bac6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,21 +80,43 @@
 
 AC_MSG_CHECKING([whether to enable direct DSP access for PDCH of sysmocom-bts])
 AC_ARG_ENABLE(sysmocom-dsp,
-               AC_HELP_STRING([--enable-sysmocom-dsp],
-                               [enable code for sysmocom DSP [default=no]]),
-               [enable_sysmocom_dsp="$enableval"],[enable_sysmocom_dsp="no"])
-AC_ARG_WITH([sysmobts], [AS_HELP_STRING([--with-sysmobts=INCLUDE_DIR], 
[Location of the sysmobts API header files])],
-                        
[sysmobts_incdir="$withval"],[sysmobts_incdir="$incdir"])
-AC_SUBST([SYSMOBTS_INCDIR], $sysmobts_incdir)
-AC_MSG_RESULT([$enable_sysmocom_dsp])
+             AC_HELP_STRING([--enable-sysmocom-dsp],
+                            [enable code for direct sysmocom DSP 
access[default=no]]),
+             [enable_sysmocom_dsp="$enableval"], [enable_sysmocom_dsp="unset"])
+AC_ARG_WITH([sysmobts],
+           [AS_HELP_STRING([--with-sysmobts=INCLUDE_DIR],
+                           [Location of the sysmobts API header files, implies 
--enable-sysmocom-dsp])],
+           [sysmobts_incdir="$withval"], [sysmobts_incdir=""])
+if test "x$sysmobts_incdir" != "x"; then
+       # --with-sysmobts was passed, imply enable_sysmocom_dsp
+       if test "x$enable_sysmocom_dsp" = "xno"; then
+               AC_MSG_RESULT([error])
+               AC_MSG_ERROR([--with-sysmobts does not work with 
--disable-sysmocom-dsp])
+       fi
+       enable_sysmocom_dsp="yes"
+       # 'readlink' should make an absolute path, but must not return empty if 
the path does not exist,
+       # so we can still report on it below.
+       sysmobts_incdir="$(readlink -fm "$sysmobts_incdir")"
+       AC_SUBST([SYSMOBTS_INCDIR], $sysmobts_incdir)
+       AC_MSG_RESULT([yes, using -I$SYSMOBTS_INCDIR])
+else
+       AC_SUBST([SYSMOBTS_INCDIR], "")
+       AC_MSG_RESULT([$enable_sysmocom_dsp])
+fi
 AM_CONDITIONAL(ENABLE_SYSMODSP, test "x$enable_sysmocom_dsp" = "xyes")
-if test "$enable_sysmocom_bts" = "yes"; then
-       oldCPPFLAGS=$CPPFLAGS
-       CPPFLAGS="$CPPFLAGS -I$SYSMOBTS_INCDIR -I$srcdir/include 
$LIBOSMOCORE_CFLAGS"
+if test "x$enable_sysmocom_dsp" = "xyes"; then
+       oldCPPFLAGS="$CPPFLAGS"
+       SYSMOBTS_INCLUDE=""
+       SYSMOBTS_INCLUDE_MSG=""
+       if test -n "$SYSMOBTS_INCDIR"; then
+               SYSMOBTS_INCLUDE="-I$SYSMOBTS_INCDIR"
+               SYSMOBTS_INCLUDE_MSG=" in -I$SYSMOBTS_INCDIR"
+       fi
+       CPPFLAGS="$CPPFLAGS $SYSMOBTS_INCLUDE -I$srcdir/include 
$LIBOSMOCORE_CFLAGS"
        AC_CHECK_HEADER([sysmocom/femtobts/superfemto.h],[],
-                       [AC_MSG_ERROR([sysmocom/femtobts/superfemto.h can not 
be found in $sysmobts_incdir])],
+                       [AC_MSG_ERROR([sysmocom/femtobts/superfemto.h can not 
be found$SYSMOBTS_INCLUDE_MSG, see --with-sysmobts])],
                        [#include <sysmocom/femtobts/superfemto.h>])
-       CPPFLAGS=$oldCPPFLAGS
+       CPPFLAGS="$oldCPPFLAGS"
 fi
 
 AC_MSG_CHECKING([whether to enable direct PHY access for PDCH of NuRAN 
Wireless Litecell 1.5 BTS])

-- 
To view, visit https://gerrit.osmocom.org/7582
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f5988730dbbcf3b21d8c647c499623843ed3da9
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <[email protected]>

Reply via email to