Skip to content

Commit

Permalink
boost::systemのチェックおよびライブラリのリンク指定を追加
Browse files Browse the repository at this point in the history
	modified:   configure.ac
	new file:   m4/ax_boost_system.m4
	modified:   reconfig.sh
	modified:   src/Makefile.am
  • Loading branch information
hidehisaakiyama committed Aug 16, 2020
1 parent c3999e9 commit 7033d21
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 14 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ AX_CXX_COMPILE_STDCXX_14(noext)
##################################################

AX_BOOST_BASE([1.38.0])
AX_BOOST_SYSTEM
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"

Expand Down
121 changes: 121 additions & 0 deletions m4/ax_boost_system.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_boost_system.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_SYSTEM
#
# DESCRIPTION
#
# Test for System library from the Boost C++ libraries. The macro requires
# a preceding call to AX_BOOST_BASE. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_SYSTEM_LIB)
#
# And sets:
#
# HAVE_BOOST_SYSTEM
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <[email protected]>
# Copyright (c) 2008 Michael Tindal
# Copyright (c) 2008 Daniel Casimiro <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 20

AC_DEFUN([AX_BOOST_SYSTEM],
[
AC_ARG_WITH([boost-system],
AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@],
[use the System library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-system=boost_system-gcc-mt ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_system_lib=""
else
want_boost="yes"
ax_boost_user_system_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_BUILD])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::System library is available,
ax_cv_boost_system,
[AC_LANG_PUSH([C++])
CXXFLAGS_SAVE=$CXXFLAGS
CXXFLAGS=
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
[[boost::system::error_category *a = 0;]])],
ax_cv_boost_system=yes, ax_cv_boost_system=no)
CXXFLAGS=$CXXFLAGS_SAVE
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_system" = "xyes"; then
AC_SUBST(BOOST_CPPFLAGS)
AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
LDFLAGS_SAVE=$LDFLAGS
if test "x$ax_boost_user_system_lib" = "x"; then
for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
if test "x$link_system" != "xyes"; then
for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
fi
else
for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
AC_CHECK_LIB($ax_lib, exit,
[BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
[link_system="no"])
done
fi
if test "x$ax_lib" = "x"; then
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 !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])
2 changes: 1 addition & 1 deletion reconfig.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

./bootstrap
./configure --prefix=$HOME/local --disable-unit-test
./configure --prefix=$HOME/.local --disable-unit-test

25 changes: 12 additions & 13 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,53 @@ rclmscheduler_CXXFLAGS = -Wall -W
rclmscheduler_LDFLAGS =
rclmscheduler_LDADD =

rcgresultprinter_SOURCES = \
resultprinter.cpp
rcgresultprinter_CXXFLAGS = -Wall -W
rcgresultprinter_LDFLAGS = \
-L$(top_builddir)/rcsc \
-L$(top_builddir)/rcsc
rcgresultprinter_LDADD = -lrcsc

rclmtableprinter_SOURCES = \
tableprinter.cpp
rclmtableprinter_CXXFLAGS = -Wall -W
rclmtableprinter_LDFLAGS =
rclmtableprinter_LDADD =


rcgresultprinter_SOURCES = \
resultprinter.cpp
rcgresultprinter_CXXFLAGS = -Wall -W
rcgresultprinter_LDFLAGS = \
-L$(top_builddir)/rcsc
rcgresultprinter_LDADD = -lrcsc $(BOOST_SYSTEM_LIB)

rcg2txt_SOURCES = \
rcg2txt.cpp
rcg2txt_CXXFLAGS = -Wall -W
rcg2txt_LDFLAGS = \
-L$(top_builddir)/rcsc
rcg2txt_LDADD = -lrcsc
rcg2txt_LDADD = -lrcsc $(BOOST_SYSTEM_LIB)

rcgrenameteam_SOURCES = \
rcgrenameteam.cpp
rcgrenameteam_CXXFLAGS = -Wall -W
rcgrenameteam_LDFLAGS = \
-L$(top_builddir)/rcsc
rcgrenameteam_LDADD = -lrcsc
rcgrenameteam_LDADD = -lrcsc $(BOOST_SYSTEM_LIB)

rcgreverse_SOURCES = \
rcgreverse.cpp
rcgreverse_CXXFLAGS = -Wall -W
rcgreverse_LDFLAGS = \
-L$(top_builddir)/rcsc
rcgreverse_LDADD = -lrcsc
rcgreverse_LDADD = -lrcsc $(BOOST_SYSTEM_LIB)

rcgverconv_SOURCES = \
rcgverconv.cpp
rcgversion_CXXFLAGS = -Wall -W
rcgverconv_LDFLAGS = \
-L$(top_builddir)/rcsc
rcgverconv_LDADD = -lrcsc
rcgverconv_LDADD = -lrcsc $(BOOST_SYSTEM_LIB)

rcgversion_SOURCES = \
rcgversion.cpp
rcgversion_LDFLAGS = \
-L$(top_builddir)/rcsc
rcgversion_LDADD = -lrcsc
rcgversion_LDADD = -lrcsc $(BOOST_SYSTEM_LIB)

AM_CPPFLAGS = -I$(top_srcdir)
AM_CXXFLAGS = -Wall -W
Expand Down

0 comments on commit 7033d21

Please sign in to comment.