From 4a990fe2a971f80a5a284537ea5d7f691758bfa3 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 5 Apr 2016 11:16:23 +1000 Subject: [PATCH] enable optional inline dependency build --- Makefile.am | 2 +- configure.ac | 17 ++++++++++++----- libcruft-vk-inline.pc.in | 7 +++++++ libcruft-vk.pc.in | 2 +- m4/nc_debugging.m4 | 8 ++------ m4/nc_optimisation.m4 | 13 ++----------- m4/nc_platform.m4 | 2 ++ m4/nc_subpackage.m4 | 33 +++++++++++++++++++++++++++++++++ 8 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 libcruft-vk-inline.pc.in create mode 100644 m4/nc_subpackage.m4 diff --git a/Makefile.am b/Makefile.am index fa8df91..1112bc0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 dist-xz subdir-objects ACLOCAL_AMFLAGS = -I m4 -AM_CXXFLAGS = $(UTIL_CRUFT_CFLAGS) +AM_CXXFLAGS = $(UTIL_CFLAGS) DEFAULT_INCLUDES = -I${top_srcdir} -I${top_builddir} -I${top_builddir}/vk lib_LIBRARIES = libcruft-vk.a diff --git a/configure.ac b/configure.ac index 4093ca8..a133b9a 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,8 @@ NC_OPTIMISATION NC_WARNINGS NC_DEBUGGING +NC_SUBPACKAGE_ENABLE + LT_INIT AM_INIT_AUTOMAKE([1.14 foreign dist-xz dist-bzip2 subdir-objects]) @@ -44,15 +46,20 @@ AS_IF([test "x$XSLTPROC" == "xfalse"], [ ############################################################################### ## Required packages -PKG_CHECK_MODULES([UTIL_CRUFT], [libcruft-util]) -AC_SUBST([UTIL_CRUFT_CFLAGS]) -AC_SUBST([UTIL_CRUFT_LIBS]) - +PKG_CHECK_MODULES([UTIL], [libcruft-util]) +AC_SUBST([UTIL_CFLAGS]) +AC_SUBST([UTIL_LIBS]) ############################################################################### ## Output AX_APPEND_FLAG([-include config.h]) -AC_CONFIG_FILES([Doxyfile libcruft-vk.pc Makefile]) +NC_SUBPACKAGE_PC([libcruft-vk.pc]) + +AC_CONFIG_FILES([ + Doxyfile + Makefile +]) + AC_OUTPUT diff --git a/libcruft-vk-inline.pc.in b/libcruft-vk-inline.pc.in new file mode 100644 index 0000000..8230dee --- /dev/null +++ b/libcruft-vk-inline.pc.in @@ -0,0 +1,7 @@ +Name: libcruft-vk +Description: A Vulkan wrapper for C++ +URL: http://nerdcruft.net/ +Version: @VERSION@ +Requires: libcruft-util +Libs: @abs_top_builddir@/libcruft-vk.a +Cflags: -isystem @abs_top_builddir@/fake diff --git a/libcruft-vk.pc.in b/libcruft-vk.pc.in index dfa054c..1f16736 100644 --- a/libcruft-vk.pc.in +++ b/libcruft-vk.pc.in @@ -9,4 +9,4 @@ URL: http://nerdcruft.net/ Version: @VERSION@ Requires: libcruft-util Libs: -L${libdir} -lcruft-vk -Cflags: -I${includedir}/cruft +Cflags: -I${includedir} diff --git a/m4/nc_debugging.m4 b/m4/nc_debugging.m4 index 207505d..fbb0aef 100644 --- a/m4/nc_debugging.m4 +++ b/m4/nc_debugging.m4 @@ -6,9 +6,7 @@ AC_DEFUN([NC_DEBUGGING],[ AX_REQUIRE_DEFINED([NC_APPEND_ONE_COMPILE_FLAG]) ##------------------------------------------------------------------------- - AC_ARG_ENABLE([sanitizer], [ - AS_HELP_STRING([--enable-sanitizer], [enable memory sanitizer]) - ]) + AC_ARG_ENABLE([sanitizer], [AS_HELP_STRING([--enable-sanitizer], [enable memory sanitizer])]) AS_IF([test "x$enable_sanitizer" = "xyes"], [ m4_foreach([NAME], [ @@ -51,9 +49,7 @@ AC_DEFUN([NC_DEBUGGING],[ ]) ##------------------------------------------------------------------------- - AC_ARG_ENABLE([debugging], [ - AS_HELP_STRING([--enable-debugging], [enables developer debugging support]) - ]) + AC_ARG_ENABLE([debugging], [AS_HELP_STRING([--enable-debugging], [enables developer debugging support])]) AS_IF([test "x${enable_debugging}" = "xyes"], [ AC_DEFINE([ENABLE_DEBUGGING], [], [Debugging support enabled]) diff --git a/m4/nc_optimisation.m4 b/m4/nc_optimisation.m4 index 4d26663..5b674c4 100644 --- a/m4/nc_optimisation.m4 +++ b/m4/nc_optimisation.m4 @@ -1,7 +1,6 @@ AC_DEFUN([NC_OPTIMISATION],[ ##------------------------------------------------------------------------- AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) - AX_REQUIRE_DEFINED([AC_CANONICAL_HOST]) AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) AX_COMPILER_VENDOR @@ -9,15 +8,9 @@ AC_DEFUN([NC_OPTIMISATION],[ ##------------------------------------------------------------------------- ## Enable LTO - AC_ARG_ENABLE([lto], [ - AS_HELP_STRING([--enable-lto], [enable link-time optimisation]) - ]) + AC_ARG_ENABLE([lto], [AS_HELP_STRING([--enable-lto], [enable link-time optimisation])]) AS_IF([test "x$enable_lto" == "xyes"], [ - AS_IF([test x"${host_os}" == x"mingw32"], [ - AC_ERROR([mingw32 link-time optimisation is currently broken]) - ]) - AS_IF([test "x$ax_cv_cxx_compiler_vendor" == "xgnu"], [ AC_CHECK_TOOLS([RANLIB], [gcc-ranlib ranlib]) AC_CHECK_TOOLS([AR], [gcc-ar ar]) @@ -35,9 +28,7 @@ AC_DEFUN([NC_OPTIMISATION],[ ##------------------------------------------------------------------------- ## Enable frame pointer - AC_ARG_ENABLE([frame-pointer], [ - AS_HELP_STRING([--enable-frame-pointer], [retain the frame pointer even if optimising]) - ]) + AC_ARG_ENABLE([frame-pointer], [AS_HELP_STRING([--enable-frame-pointer], [retain the frame pointer even if optimising])]) AS_IF([test "x$enable_frame_pointer" = "xyes"], [ AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer], [], [-Werror]) diff --git a/m4/nc_platform.m4 b/m4/nc_platform.m4 index 4fcb7cf..e4f9a3e 100644 --- a/m4/nc_platform.m4 +++ b/m4/nc_platform.m4 @@ -6,6 +6,8 @@ AC_DEFUN([NC_PLATFORM],[ AS_CASE([$host_os], [mingw32], [ + AC_DEFINE([WIN32_LEAN_AND_MEAN], [], [reduce win32 header complexity]) + AC_CHECK_HEADERS([winsock2.h ws2tcpip.h]) AC_CHECK_HEADERS([windows.h],[],[],[AC_INCLUDES_DEFAULT]) AC_SUBST([NET_LIBS], [-lws2_32]) diff --git a/m4/nc_subpackage.m4 b/m4/nc_subpackage.m4 new file mode 100644 index 0000000..b0c99cd --- /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/-.*//'` + ]) + ]) +]) +