Skip to content

Commit

Permalink
Fix build for macos
Browse files Browse the repository at this point in the history
The homebrew location for boost have changed, it's not in the default search path anymore.

We add the BOOST_CPPFLAGS to our CPPFLAGS
and we update all extra autoconf macro to have the latest update from the autoconf-archive.
The boost packages are updated to search boost in /opt/homebrew
(the update to ax_cxx_compile for C++20 is also included while at it)

Also remove an old comment that should have been removed before in the build workflow
  • Loading branch information
greenscientist committed Apr 30, 2024
1 parent f7bf8ed commit 88c3b58
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 56 deletions.
1 change: 0 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ jobs:
- name: make
run: make
- name: make check
# Disable make check on MacOS, currently does not work, issue #43
run: make check

6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ Then:
make
```

On ARM mac with boost installed by homebrew:
```
CPPFLAGS=-I/opt/homebrew/include/ ./configure --with-boost-libdir="/opt/homebrew/lib/"
make
```

## Test

trRouting uses [Googletest](https://github.com/google/googletest) to unit test the application. To run the tests, you must first fetch the googletest submodule once into the repo:
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PKG_CHECK_MODULES(JSON, nlohmann_json)
# TODO: Add link to doc of this override flag
CPPFLAGS+=" -DBOOST_BIND_GLOBAL_PLACEHOLDERS"

CPPFLAGS+=" $CAPNP_CFLAGS $PTHREAD_CFLAGS $SPDLOG_CFLAGS $JSON_CLAGS"
CPPFLAGS+=" $BOOST_CPPFLAGS $CAPNP_CFLAGS $PTHREAD_CFLAGS $SPDLOG_CFLAGS $JSON_CLAGS"

# Add BOOST flags
LDFLAGS+=" $BOOST_LDFLAGS $BOOST_REGEX_LIB $BOOST_SYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_DATE_TIME_LIB"
Expand Down
20 changes: 11 additions & 9 deletions m4/ax_boost_base.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#
# Test for the Boost C++ libraries of a particular version (or newer)
#
# If no path to the installed boost library is given the macro searchs
# under /usr, /usr/local, /opt and /opt/local and evaluates the
# $BOOST_ROOT environment variable. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
# If no path to the installed boost library is given the macro searches
# under /usr, /usr/local, /opt, /opt/local and /opt/homebrew and evaluates
# the $BOOST_ROOT environment variable. Further documentation is available
# at <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
Expand All @@ -33,7 +33,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 45
#serial 54

# example boost program (need to pass version)
m4_define([_AX_BOOST_BASE_PROGRAM],
Expand Down Expand Up @@ -113,7 +113,8 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
dnl are found, e.g. when only header-only libraries are installed!
AS_CASE([${host_cpu}],
[x86_64],[libsubdirs="lib64 libx32 lib lib64"],
[ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64],[libsubdirs="lib64 lib lib64"],
[mips*64*],[libsubdirs="lib64 lib32 lib lib64"],
[ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64|e2k|loongarch64],[libsubdirs="lib64 lib lib64"],
[libsubdirs="lib"]
)
Expand All @@ -122,11 +123,12 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
dnl are almost assuredly the ones desired.
AS_CASE([${host_cpu}],
[i?86],[multiarch_libsubdir="lib/i386-${host_os}"],
[armv7l],[multiarch_libsubdir="lib/arm-${host_os}"],
[multiarch_libsubdir="lib/${host_cpu}-${host_os}"]
)
dnl first we check the system location for boost libraries
dnl this location ist chosen if boost libraries are installed with the --layout=system option
dnl this location is chosen if boost libraries are installed with the --layout=system option
dnl or if you install boost with RPM
AS_IF([test "x$_AX_BOOST_BASE_boost_path" != "x"],[
AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) includes in "$_AX_BOOST_BASE_boost_path/include"])
Expand All @@ -149,7 +151,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
else
search_libsubdirs="$multiarch_libsubdir $libsubdirs"
fi
for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local /opt/homebrew ; do
if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then
for libsubdir in $search_libsubdirs ; do
if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
Expand Down Expand Up @@ -225,7 +227,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
fi
else
if test "x$cross_compiling" != "xyes" ; then
for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do
for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local /opt/homebrew ; do
if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then
for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
Expand Down
4 changes: 2 additions & 2 deletions m4/ax_boost_date_time.m4
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 22
#serial 23

AC_DEFUN([AX_BOOST_DATE_TIME],
[
Expand Down Expand Up @@ -100,7 +100,7 @@ AC_DEFUN([AX_BOOST_DATE_TIME],
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::Date_Time library!)
fi
if test "x$link_date_time" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
Expand Down
4 changes: 2 additions & 2 deletions m4/ax_boost_filesystem.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 27
#serial 28

AC_DEFUN([AX_BOOST_FILESYSTEM],
[
Expand Down Expand Up @@ -104,7 +104,7 @@ AC_DEFUN([AX_BOOST_FILESYSTEM],
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::Filesystem library!)
fi
if test "x$link_filesystem" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
Expand Down
4 changes: 2 additions & 2 deletions m4/ax_boost_iostreams.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 21
#serial 22

AC_DEFUN([AX_BOOST_IOSTREAMS],
[
Expand Down Expand Up @@ -103,7 +103,7 @@ AC_DEFUN([AX_BOOST_IOSTREAMS],
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::IOStreams library!)
fi
if test "x$link_iostreams" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
Expand Down
4 changes: 2 additions & 2 deletions m4/ax_boost_program_options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 25
#serial 26

AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
[
Expand Down Expand Up @@ -96,7 +96,7 @@ AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::Program_Options library!)
fi
if test "x$link_program_options" != "xyes"; then
AC_MSG_ERROR([Could not link against [$ax_lib] !])
Expand Down
5 changes: 3 additions & 2 deletions m4/ax_boost_serialization.m4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 22
#serial 24

AC_DEFUN([AX_BOOST_SERIALIZATION],
[
Expand Down Expand Up @@ -79,6 +79,7 @@ AC_DEFUN([AX_BOOST_SERIALIZATION],
if test "x$ax_cv_boost_serialization" = "xyes"; then
AC_DEFINE(HAVE_BOOST_SERIALIZATION,,[define if the Boost::Serialization library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
ax_lib=
if test "x$ax_boost_user_serialization_lib" = "x"; then
for libextension in `ls $BOOSTLIBDIR/libboost_serialization*.so* $BOOSTLIBDIR/libboost_serialization*.dylib* $BOOSTLIBDIR/libboost_serialization*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_serialization.*\)\.so.*$;\1;' -e 's;^lib\(boost_serialization.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_serialization.*\)\.a*$;\1;'` ; do
ax_lib=${libextension}
Expand All @@ -104,7 +105,7 @@ AC_DEFUN([AX_BOOST_SERIALIZATION],
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::Serialization library!)
fi
if test "x$link_serialization" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
Expand Down
4 changes: 2 additions & 2 deletions m4/ax_boost_system.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 19
#serial 20

AC_DEFUN([AX_BOOST_SYSTEM],
[
Expand Down Expand Up @@ -108,7 +108,7 @@ AC_DEFUN([AX_BOOST_SYSTEM],
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::System library!)
fi
if test "x$link_system" = "xno"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
Expand Down
56 changes: 40 additions & 16 deletions m4/ax_boost_thread.m4
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 31
#serial 33

AC_DEFUN([AX_BOOST_THREAD],
[
Expand Down Expand Up @@ -67,13 +67,24 @@ AC_DEFUN([AX_BOOST_THREAD],
[AC_LANG_PUSH([C++])
CXXFLAGS_SAVE=$CXXFLAGS
if test "x$host_os" = "xsolaris" ; then
CXXFLAGS="-pthreads $CXXFLAGS"
elif test "x$host_os" = "xmingw32" ; then
CXXFLAGS="-mthreads $CXXFLAGS"
else
CXXFLAGS="-pthread $CXXFLAGS"
fi
case "x$host_os" in
xsolaris )
CXXFLAGS="-pthreads $CXXFLAGS"
break;
;;
xmingw32 )
CXXFLAGS="-mthreads $CXXFLAGS"
break;
;;
*android* )
break;
;;
* )
CXXFLAGS="-pthread $CXXFLAGS"
break;
;;
esac
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[[@%:@include <boost/thread/thread.hpp>]],
Expand All @@ -84,13 +95,23 @@ AC_DEFUN([AX_BOOST_THREAD],
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_thread" = "xyes"; then
if test "x$host_os" = "xsolaris" ; then
BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
elif test "x$host_os" = "xmingw32" ; then
BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
else
BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
fi
case "x$host_os" in
xsolaris )
BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
break;
;;
xmingw32 )
BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS"
break;
;;
*android* )
break;
;;
* )
BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS"
break;
;;
esac
AC_SUBST(BOOST_CPPFLAGS)
Expand Down Expand Up @@ -130,7 +151,7 @@ AC_DEFUN([AX_BOOST_THREAD],
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::Thread library!)
fi
if test "x$link_thread" = "xno"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
Expand All @@ -148,6 +169,9 @@ AC_DEFUN([AX_BOOST_THREAD],
xmingw32 )
break;
;;
*android* )
break;
;;
* )
BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread"
break;
Expand Down
Loading

0 comments on commit 88c3b58

Please sign in to comment.