From e321b9eee734cfb0fc583f1d41d6566ad2187238 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 5 Apr 2016 11:11:59 +1000 Subject: [PATCH] enable optional inline dependency build --- configure.ac | 5 ++++- libcruft-util-inline.pc.in | 6 ++++++ libcruft-util.pc.in | 4 ++-- m4/nc_subpackage.m4 | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 libcruft-util-inline.pc.in create mode 100644 m4/nc_subpackage.m4 diff --git a/configure.ac b/configure.ac index f0f12de0..003f2b0c 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,8 @@ NC_OPTIMISATION NC_WARNINGS NC_DEBUGGING +NC_SUBPACKAGE_ENABLE + LT_INIT AM_INIT_AUTOMAKE([1.14 dist-bzip2 dist-xz foreign subdir-objects]) @@ -104,10 +106,11 @@ AC_SUBST(LIBS) # failure on a clean build AX_APPEND_FLAG([-include config.h]) +NC_SUBPACKAGE_PC([libcruft-util.pc]) + AC_CONFIG_FILES([ Doxyfile Makefile - libcruft-util.pc ]) AC_CONFIG_FILES([test/json-parse], [chmod a+x test/json-parse]) diff --git a/libcruft-util-inline.pc.in b/libcruft-util-inline.pc.in new file mode 100644 index 00000000..58f2a0d9 --- /dev/null +++ b/libcruft-util-inline.pc.in @@ -0,0 +1,6 @@ +Name: libcruft-util +Description: A simple utility library in C++ +URL: http://nerdcruft.net/ +Version: @VERSION@ +Libs: @abs_top_builddir@/libcruft-util.a @BOOST_LDFLAGS@ @LIBS@ +Cflags: -isystem @abs_top_builddir@/fake @BOOST_CPPFLAGS@ diff --git a/libcruft-util.pc.in b/libcruft-util.pc.in index 819459f5..13d07bdc 100644 --- a/libcruft-util.pc.in +++ b/libcruft-util.pc.in @@ -7,5 +7,5 @@ Name: libcruft-util Description: A simple utility library in C++ URL: http://nerdcruft.net/ Version: @VERSION@ -Libs: -L${libdir} -lcruft-util @BOOST_LDFLAGS@ @BOOST_FILESYSTEM_LIB@ @BOOST_SYSTEM_LIB@ -lrt -Cflags: -I${includedir}/cruft @BOOST_CPPFLAGS@ +Libs: -L${libdir} -lcruft-util @BOOST_LDFLAGS@ @LIBS@ +Cflags: -I${includedir} @BOOST_CPPFLAGS@ diff --git a/m4/nc_subpackage.m4 b/m4/nc_subpackage.m4 new file mode 100644 index 00000000..b0c99cd3 --- /dev/null +++ b/m4/nc_subpackage.m4 @@ -0,0 +1,33 @@ +AC_DEFUN([NC_SUBPACKAGE_PC], [ + base=`basename $1 .pc` + AC_CONFIG_FILES([$1:$base$nc_cv_config_pc_postfix.pc.in]) +]) + + +AC_DEFUN([NC_SUBPACKAGE_ENABLE],[ + AC_ARG_ENABLE([inline], [AS_HELP_STRING([--enable-inline], [enable building for use as an inline dependency])]) + + AS_IF([test "x$enable_inline" == "xyes"], [ + AC_PROG_LN_S + + AC_CACHE_VAL([nc_cv_config_pc_postfix], [nc_cv_config_pc_postfix='-inline']) + + AC_CONFIG_COMMANDS([fake/cruft], [ + dnl make a fake include directory which looks like the typical + dnl installation prefix. we should probably use AC_CONFIG_LINKS + dnl but i'm not proficient enough at m4 to process the globs + dnl correctly. + + AS_ECHO(["fake/cruft/$cruft_base"]) + AS_MKDIR_P(["fake/cruft"]) + $LN_S -nf "$ac_abs_top_srcdir" "fake/cruft/$cruft_base" + + AS_IF([test ! -L "fake/cruft/$cruft_base"], [ + AC_MSG_ERROR([could not create inline include directory]) + ]) + ], [ + cruft_base=`echo "${PACKAGE_NAME}" | sed 's/-.*//'` + ]) + ]) +]) +