From 2088891f11ab7aa3f843239cebe06a2850117b0b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Sep 2010 22:25:48 +0200 Subject: Add automake build system support --- m4/disable-rpath.m4 | 26 +++++++++++++++++ m4/gcc-plugin.m4 | 28 ++++++++++++++++++ m4/libcutl.m4 | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ m4/libtool-link.m4 | 31 ++++++++++++++++++++ 4 files changed, 168 insertions(+) create mode 100644 m4/disable-rpath.m4 create mode 100644 m4/gcc-plugin.m4 create mode 100644 m4/libcutl.m4 create mode 100644 m4/libtool-link.m4 (limited to 'm4') diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 new file mode 100644 index 0000000..da77bbe --- /dev/null +++ b/m4/disable-rpath.m4 @@ -0,0 +1,26 @@ +dnl file : m4/disable-rpath.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +AC_DEFUN([DISABLE_RPATH],[ + +AC_MSG_CHECKING([whether to use rpath]) +AC_ARG_ENABLE( + [rpath], + [AC_HELP_STRING([--disable-rpath], [patch libtool to not use rpath])], + [libtool_rpath="$enable_rpath"], + [libtool_rpath="yes"]) +AC_MSG_RESULT($libtool_rpath) + +# Patch libtool to not use rpath if requested. +# +AC_CONFIG_COMMANDS( + [libtool-rpath-patch], + [if test "$libtool_use_rpath" = "no"; then + sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/' + mv libtool-2 libtool + chmod 755 libtool + fi], + [libtool_use_rpath=$libtool_rpath]) +])dnl diff --git a/m4/gcc-plugin.m4 b/m4/gcc-plugin.m4 new file mode 100644 index 0000000..d270ce0 --- /dev/null +++ b/m4/gcc-plugin.m4 @@ -0,0 +1,28 @@ +dnl file : m4/gcc-plugin.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl GCC_PLUGIN +dnl +AC_DEFUN([GCC_PLUGIN], [ +gcc_plugin_support=no + +if test x"$GXX" != xyes; then + AC_MSG_ERROR([$CXX is not a GNU C++ compiler]) +fi + +AC_MSG_CHECKING([whether $CXX supports plugins]) + +gcc_plugin_base=`$CXX -print-file-name=plugin 2>/dev/null` + +if test x"$gcc_plugin_base" = xplugin; then + AC_MSG_RESULT([no]) + AC_MSG_ERROR([$CXX does not support plugins; reconfigure GCC with --enable-plugin]) +else + AC_MSG_RESULT([yes]) + gcc_plugin_support=yes +fi + +CPPFLAGS="$CPPFLAGS -I$gcc_plugin_base/include" +])dnl diff --git a/m4/libcutl.m4 b/m4/libcutl.m4 new file mode 100644 index 0000000..f51aee5 --- /dev/null +++ b/m4/libcutl.m4 @@ -0,0 +1,83 @@ +dnl file : m4/libcutl.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : MIT; see accompanying LICENSE file +dnl +dnl LIBCUTL([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl +AC_DEFUN([LIBCUTL], [ +libcutl_found=no + +AC_ARG_WITH( + [libcutl], + [AC_HELP_STRING([--with-libcutl=DIR],[location of libcutl build directory])], + [libcutl_dir=${withval}], + [libcutl_dir=]) + +AC_MSG_CHECKING([for libcutl]) + +# If libcutl_dir was given, add the necessary preprocessor and linker flags. +# +if test x"$libcutl_dir" != x; then + save_CPPFLAGS="$CPPFLAGS" + save_LDFLAGS="$LDFLAGS" + + AS_SET_CATFILE([abs_libcutl_dir], [$ac_pwd], [$libcutl_dir]) + + CPPFLAGS="$CPPFLAGS -I$abs_libcutl_dir" + LDFLAGS="$LDFLAGS -L$abs_libcutl_dir/cutl" +fi + +save_LIBS="$LIBS" +LIBS="-lcutl $LIBS" + +CXX_LIBTOOL_LINK_IFELSE( +AC_LANG_SOURCE([[ +#include + +void +f () +{ +} + +const char* +g () +{ + try + { + f (); + } + catch (const cutl::exception& e) + { + return e.what (); + } + return 0; +} + +int +main () +{ + const char* m (g ()); + return m != 0; +} +]]), +[libcutl_found=yes]) + +if test x"$libcutl_found" = xno; then + LIBS="$save_LIBS" + + if test x"$libcutl_dir" != x; then + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + fi +fi + +if test x"$libcutl_found" = xyes; then + AC_MSG_RESULT([yes]) + $1 +else + AC_MSG_RESULT([no]) + $2 +fi +])dnl diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 new file mode 100644 index 0000000..229b270 --- /dev/null +++ b/m4/libtool-link.m4 @@ -0,0 +1,31 @@ +dnl file : m4/libtool-link.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl +dnl CXX_LIBTOOL_LINK_IFELSE (input, [action-if-true], [action-if-false]) +dnl +dnl Similar to AC_LINK_IFELSE except it uses libtool to perform the +dnl linking and it does this using the C++ compiler. +dnl +AC_DEFUN([CXX_LIBTOOL_LINK_IFELSE],[ +AC_LANG_SAVE +save_CXX="$CXX" +CXX="./libtool --tag=CXX --mode=link $CXX -no-install" +AC_LANG(C++) + +if test -d .libs; then + delete_libs_dir=no +else + delete_libs_dir=yes +fi + +AC_LINK_IFELSE([$1], [$2], [$3]) + +if test x"$delete_libs_dir" != xyes; then + rm -rf .libs +fi + +CXX="$save_CXX" +AC_LANG_RESTORE])dnl -- cgit v1.1