diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8ed95be --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "m4/nc"] + path = m4/nc + url = git://git.nerdcruft.net/autocruft diff --git a/configure.ac b/configure.ac index 809e51b..b66e9c5 100644 --- a/configure.ac +++ b/configure.ac @@ -9,6 +9,7 @@ AC_INIT([vk-cruft], [0.0.1], [danny@nerdcruft.net], [], [http://nerdcruft.net/]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_MACRO_DIR([m4/nc]) AC_USE_SYSTEM_EXTENSIONS AC_CANONICAL_HOST diff --git a/m4/nc b/m4/nc new file mode 160000 index 0000000..c028034 --- /dev/null +++ b/m4/nc @@ -0,0 +1 @@ +Subproject commit c028034a395077d08d5458ae605a05a26bf4fcf5 diff --git a/m4/nc_append_one_compile_flag.m4 b/m4/nc_append_one_compile_flag.m4 deleted file mode 100644 index 967dd0e..0000000 --- a/m4/nc_append_one_compile_flag.m4 +++ /dev/null @@ -1,25 +0,0 @@ -# SYNOPSIS -# -# NC_APPEND_ONE_COMPILE_FLAG([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) -# -# DESCRIPTION -# -# Append the first valid compilation flag in the provided list to FLAGS-VARIABLE - - -AC_DEFUN([NC_APPEND_ONE_COMPILE_FLAG], [ - AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) - AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) - - for __dummy in "1"; do - for flag in $1; do - AX_CHECK_COMPILE_FLAG([$flag], - [AX_APPEND_FLAG([$flag], [$2]) - break 2], - [], - [$3]) - done - - AC_MSG_ERROR([unable to find a valid compilation flag in '$1']) - done -]) diff --git a/m4/nc_cxx.m4 b/m4/nc_cxx.m4 deleted file mode 100644 index c8538c1..0000000 --- a/m4/nc_cxx.m4 +++ /dev/null @@ -1,24 +0,0 @@ -AC_DEFUN([NC_CXX],[ - AX_CHECK_COMPILE_FLAG( - [-std=c++1z], - [AX_APPEND_FLAG([-std=c++1z], [CXXFLAGS])], - [AC_MSG_ERROR([Unable to enable c++1z])] - ) - - AX_APPEND_COMPILE_FLAGS([-pipe], [], [-Werror]) - - AX_APPEND_COMPILE_FLAGS([-fno-deduce-init-list], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-fno-deduce-init-list], [], [-Werror]) - - AC_C_CONST - AC_C_RESTRICT - AC_C_INLINE - - AC_ARG_ENABLE([libcxx], [AS_HELP_STRING([--enable-libcxx], [use clang's cxx library])]) - - AS_IF([test "x${enable_libcxx}" == "xyes"], [ - AX_APPEND_COMPILE_FLAGS([-stdlib=libc++]) - ]) - - AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden], [], [-Werror]) -]) diff --git a/m4/nc_debugging.m4 b/m4/nc_debugging.m4 deleted file mode 100644 index 4e5f50f..0000000 --- a/m4/nc_debugging.m4 +++ /dev/null @@ -1,43 +0,0 @@ -AC_DEFUN([NC_DEBUGGING],[ - ##------------------------------------------------------------------------- - AX_REQUIRE_DEFINED([AS_HELP_STRING]) - AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) - AX_REQUIRE_DEFINED([AX_APPEND_LINK_FLAGS]) - - ##------------------------------------------------------------------------- - AC_ARG_ENABLE([sanitizer], [AS_HELP_STRING([--enable-sanitizer], [enable memory sanitizer])]) - - AS_IF([test "x$enable_sanitizer" = "xyes"], [ - AX_APPEND_COMPILE_FLAGS([-fsanitize=address]) - AX_APPEND_COMPILE_FLAGS([-fsanitize=undefined]) - - AX_APPEND_COMPILE_FLAGS([-ftrapv]) - ]) - - AM_CONDITIONAL([WITH_SANITIZER], [test "x${enable_sanitizer}" == "xyes"]) - - ##------------------------------------------------------------------------- - 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]) - AC_DEFINE([_GLIBCXX_DEBUG], [], [Use glibcxx debugging mode]) - - AX_APPEND_COMPILE_FLAGS([-O0]) - - AX_APPEND_COMPILE_FLAGS([-fstack-protector]) - ], [ - AX_APPEND_COMPILE_FLAGS([-O2]) - AX_APPEND_COMPILE_FLAGS([-fno-rtti]) - AC_DEFINE([NO_RTTI], [], [RTTI disabled]) - ]) - - ##------------------------------------------------------------------------- - AS_CASE([${host_os}], - [mingw*], [AX_APPEND_COMPILE_FLAGS([-gstabs])], - [ - AX_APPEND_COMPILE_FLAGS([-g]) - AX_APPEND_COMPILE_FLAGS([-ggdb]) - ] - ) -]) diff --git a/m4/nc_optimisation.m4 b/m4/nc_optimisation.m4 deleted file mode 100644 index 06ca352..0000000 --- a/m4/nc_optimisation.m4 +++ /dev/null @@ -1,113 +0,0 @@ -AC_DEFUN([NC_OPTIMISATION],[ - ##------------------------------------------------------------------------- - AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) - AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) - - AX_COMPILER_VENDOR - - ##------------------------------------------------------------------------- - ## Enable LTO - - AC_ARG_ENABLE([lto], [AS_HELP_STRING([--enable-lto], [enable link-time optimisation])]) - - AS_IF([test "x$enable_lto" == "xyes"], [ - AS_IF([test "x$ax_cv_cxx_compiler_vendor" == "xgnu"], [ - AC_CHECK_TOOLS([RANLIB], [gcc-ranlib ranlib]) - AC_CHECK_TOOLS([AR], [gcc-ar ar]) - AC_CHECK_TOOLS([NM], [gcc-nm nm]) - ]) - - AX_APPEND_COMPILE_FLAGS([-flto], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-fno-fat-lto-objects], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-flto-odr-type-merging], [], [-Werror]) - AX_APPEND_LINK_FLAGS([-fuse-linker-plugin], [], [-Werror]) - - AX_APPEND_COMPILE_FLAGS([-fdevirtualize-at-ltrans], [], [-Werror]) - ]) - - ##------------------------------------------------------------------------- - ## Enable frame pointer - - 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]) - ]) - - - ##------------------------------------------------------------------------- - ## Choose the most performant processor architecture and features - - AC_CANONICAL_HOST - - AS_CASE([$host_cpu], - [x86_64], [ - AX_APPEND_COMPILE_FLAGS([-mtune=generic], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-msse], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-msse2], [], [-Werror]) - ], - - [i686], [ - AX_APPEND_COMPILE_FLAGS([-march=prescott], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-mtune=generic], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-mcmov], [], [-Werror]) - ], - - [AC_MSG_WARN([unknown host_cpu])] - ) - - AX_APPEND_COMPILE_FLAGS([-pipe]) - - # base instruction set requirements for x86 - AX_APPEND_COMPILE_FLAGS([-mfpmath=sse], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-msahf], [], [-Werror]) - - ##------------------------------------------------------------------------- - ## Enable aggressive code generation optimisations - - AS_IF([test "x$enable_debugging" != "xyes"], [ - # gcc vectorisation - AX_APPEND_COMPILE_FLAGS([-ftree-vectorize], [], [-Werror]) - - # clang vectorisation - AX_APPEND_COMPILE_FLAGS([-fvectorize], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-fslp-vectorize], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-fslp-vectorize-aggressive], [], [-Werror]) - - # loop hosting/distribution - AX_APPEND_COMPILE_FLAGS([-floop-nest-optimize], [], [-Werror]) - - AX_APPEND_COMPILE_FLAGS([-ftree-loop-distribution], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-ftree-loop-distribute-patterns], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-ftree-loop-im], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-ftree-loop-if-convert-stores], [], [-Werror]) - - AX_APPEND_COMPILE_FLAGS([-fivopts], [], [-Werror]) - - AX_APPEND_COMPILE_FLAGS([-funsafe-loop-optimizations], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-floop-interchange], [], [-Werror]) - - AX_APPEND_COMPILE_FLAGS([-fpredictive-commoning], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-funswitch-loops], [], [-Werror]) - - # options that require substantial time/memory - AX_APPEND_COMPILE_FLAGS([-fipa-pta]) - - dnl # safety removal for performance - AX_APPEND_COMPILE_FLAGS([-fno-stack-protector], [], [-Werror]) - ]) - - ##------------------------------------------------------------------------- - ## Enable code size optimisations (that don't impact performance) - ## Note: we assume CXX, and that CXXLINK is g++ not ld, hence the -Wl opt - AS_IF([test "x$enable_debugging" != "xyes"], [ - AX_APPEND_COMPILE_FLAGS([-fdevirtualize], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-fdevirtualize-speculatively], [], [-Werror]) - - AX_CHECK_LINK_FLAG([-Wl,--gc-sections], [ - AX_APPEND_COMPILE_FLAGS([-fdata-sections], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-ffunction-sections], [], [-Werror]) - AX_APPEND_LINK_FLAGS([-Wl,--gc-sections], [], [-Werror]) - ]) - ]) -]) diff --git a/m4/nc_platform.m4 b/m4/nc_platform.m4 deleted file mode 100644 index c4b28a1..0000000 --- a/m4/nc_platform.m4 +++ /dev/null @@ -1,43 +0,0 @@ -AC_DEFUN([NC_PLATFORM],[ - AC_CANONICAL_HOST - - AS_CASE([x${host_os}], - [xmingw*], [nc_cv_platform_win32=yes], - [xlinux*], [nc_cv_platform_linux=yes], - [xfreebsd*], [nc_cv_platform_freebsd=yes], - [AC_MSG_ERROR([unhandled platform ${host_os}])] - ) - - AM_CONDITIONAL([PLATFORM_WIN32], [test "x$nc_cv_platform_win32" = "xyes"]) - AM_CONDITIONAL([PLATFORM_LINUX], [test "x$nc_cv_platform_linux" = "xyes"]) - AM_CONDITIONAL([PLATFORM_FREEBSD], [test "x$nc_cv_platform_freebsd" = "xyes"]) - - 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]) - - AX_APPEND_COMPILE_FLAGS([-DBOOST_THREAD_USE_LIB], [], [-Werror]) - - ## Force as many static libraries as possible to avoid bullshit libc - ## cross-library memory management issues. - AX_APPEND_LINK_FLAGS([-static-libstdc++], [], [-Werror]) - AX_APPEND_LINK_FLAGS([-static-libgcc], [], [-Werror]) - ], - - [freebsd*], [ - AX_APPEND_COMPILE_FLAGS([-I/usr/local/include]) - AX_APPEND_LINK_FLAGS([-L/usr/local/lib]) - ], - - [linux*], [:], - - [AC_MSG_ERROR([Unknown platform])] - ) - - AX_APPEND_COMPILE_FLAGS([-fno-common], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-fno-nonansi-builtins], [], [-Werror]) -]) diff --git a/m4/nc_subpackage.m4 b/m4/nc_subpackage.m4 deleted file mode 100644 index 53c53ed..0000000 --- a/m4/nc_subpackage.m4 +++ /dev/null @@ -1,32 +0,0 @@ -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_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/-.*//'` - ]) - ]) -]) - diff --git a/m4/nc_warnings.m4 b/m4/nc_warnings.m4 deleted file mode 100644 index 11a66df..0000000 --- a/m4/nc_warnings.m4 +++ /dev/null @@ -1,99 +0,0 @@ -AC_DEFUN([NC_WARNINGS],[ - AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) - AC_REQUIRE([AX_COMPILER_VENDOR]) - - AX_COMPILER_VENDOR - - # ------------------------------------------------------------------------- - # Compound warnings - AX_APPEND_COMPILE_FLAGS([-Wall], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wextra], [], [-Werror]) - - # ------------------------------------------------------------------------- - # General warnings - AX_APPEND_COMPILE_FLAGS([-Wbool-compare], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wcast-align], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wcast-qual], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wdisabled-optimization], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wfloat-conversion], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wfloat-equal], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-aggressive-loop-optimizations], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wnoexcept], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wnon-virtual-dtor], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-parentheses], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wpointer-arith], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wredundant-decls], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wshadow], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wsign-compare], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wsign-promo], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wstrict-aliasing], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wstrict-overflow], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wtype-limits], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wunsafe-loop-optimizations], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wunused-but-set-variable], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wunused-parameter], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wpessimizing-move], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wswitch-enum], [], [-Werror]) - - dnl gcc-6.1.0 warnings - AX_APPEND_COMPILE_FLAGS([-Wshift-negative-value], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wnull-dereference], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wduplicated-cond], [], [-Werror]) - - dnl useless-cast isn't usable on gcc-6.1 due to spurious warnings - dnl see gcc#70844 - AX_APPEND_COMPILE_FLAGS([-Wuseless-cast], [], [-Werror]) - - dnl clang 3.7.1 warnings - AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wdeprecated], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wcovered-switch-default], [], [-Werror]) - - # ------------------------------------------------------------------------- - # Required extensions - #AX_APPEND_COMPILE_FLAGS([-Wgnu-flexible-array-union-member], [], [-Werror]) - #AX_APPEND_COMPILE_FLAGS([-Wno-c99-extensions], [], [-Werror]) - #AX_APPEND_COMPILE_FLAGS([-Wno-vla-extension], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-vla], [], [-Werror]) - - dnl GCC will happily compile with any "-Wno" argument, so enable GCC-isms - dnl only if we aren't GCC - AS_IF([test "x$ax_cv_cxx_compiler_vendor" != "xgnu"], [ - AX_APPEND_COMPILE_FLAGS([-Wno-c99-extensions], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-flexible-array-extensions], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-gnu-anonymous-struct]) - AX_APPEND_COMPILE_FLAGS([-Wno-gnu-conditional-omitted-operand], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-gnu-empty-struct], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-gnu-flexible-array-union-member], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-gnu-zero-variadic-macro-arguments], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-vla-extension], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-zero-length-array], [], [-Werror]) - ]) - - # ------------------------------------------------------------------------- - # Excessive warnings - AX_APPEND_COMPILE_FLAGS([-Wno-missing-braces], [], [-Werror]) - - AS_IF([test "x$ax_cv_cxx_compiler_vendor" != "xgnu"], [ - AX_APPEND_COMPILE_FLAGS([-Wno-nested-anon-types], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wno-unused-const-variable], [], [-Werror]) - ]) - - # ------------------------------------------------------------------------- - # Strict warnings - - # ------------------------------------------------------------------------- - # Advisory warnings - AC_ARG_ENABLE([advisory], [ - AS_HELP_STRING([--enable-advisory], [enable advisory warnings]) - ]) - - AS_IF([test "x$enable_advisory" = "xyes"], [ - AX_APPEND_COMPILE_FLAGS([-Winline], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wsuggest-final-types], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wsuggest-final-methods], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wsuggest-override], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wweak-vtables], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wpadded], [], [-Werror]) - ], []) -])