Created
August 4, 2014 07:11
-
-
Save suxue/4ff6e8bd5612f77be882 to your computer and use it in GitHub Desktop.
autoconf common files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shared autoconf/automake files, for personal use. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ============================================================================ | |
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html | |
# ============================================================================ | |
# | |
# SYNOPSIS | |
# | |
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) | |
# | |
# DESCRIPTION | |
# | |
# Check for baseline language coverage in the compiler for the C++11 | |
# standard; if necessary, add switches to CXXFLAGS to enable support. | |
# | |
# The first argument, if specified, indicates whether you insist on an | |
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. | |
# -std=c++11). If neither is specified, you get whatever works, with | |
# preference for an extended mode. | |
# | |
# The second argument, if specified 'mandatory' or if left unspecified, | |
# indicates that baseline C++11 support is required and that the macro | |
# should error out if no mode with that support is found. If specified | |
# 'optional', then configuration proceeds regardless, after defining | |
# HAVE_CXX11 if and only if a supporting mode is found. | |
# | |
# LICENSE | |
# | |
# Copyright (c) 2008 Benjamin Kosnik <[email protected]> | |
# Copyright (c) 2012 Zack Weinberg <[email protected]> | |
# Copyright (c) 2013 Roy Stogner <[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 3 | |
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [ | |
template <typename T> | |
struct check | |
{ | |
static_assert(sizeof(int) <= sizeof(T), "not big enough"); | |
}; | |
typedef check<check<bool>> right_angle_brackets; | |
int a; | |
decltype(a) b; | |
typedef check<int> check_type; | |
check_type c; | |
check_type&& cr = static_cast<check_type&&>(c); | |
auto d = a; | |
]) | |
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl | |
m4_if([$1], [], [], | |
[$1], [ext], [], | |
[$1], [noext], [], | |
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl | |
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], | |
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true], | |
[$2], [optional], [ax_cxx_compile_cxx11_required=false], | |
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl | |
AC_LANG_PUSH([C++])dnl | |
ac_success=no | |
AC_CACHE_CHECK(whether $CXX supports C++11 features by default, | |
ax_cv_cxx_compile_cxx11, | |
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], | |
[ax_cv_cxx_compile_cxx11=yes], | |
[ax_cv_cxx_compile_cxx11=no])]) | |
if test x$ax_cv_cxx_compile_cxx11 = xyes; then | |
ac_success=yes | |
fi | |
m4_if([$1], [noext], [], [dnl | |
if test x$ac_success = xno; then | |
for switch in -std=gnu++11 -std=gnu++0x; do | |
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) | |
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, | |
$cachevar, | |
[ac_save_CXXFLAGS="$CXXFLAGS" | |
CXXFLAGS="$CXXFLAGS $switch" | |
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], | |
[eval $cachevar=yes], | |
[eval $cachevar=no]) | |
CXXFLAGS="$ac_save_CXXFLAGS"]) | |
if eval test x\$$cachevar = xyes; then | |
CXXFLAGS="$CXXFLAGS $switch" | |
ac_success=yes | |
break | |
fi | |
done | |
fi]) | |
m4_if([$1], [ext], [], [dnl | |
if test x$ac_success = xno; then | |
for switch in -std=c++11 -std=c++0x; do | |
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) | |
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, | |
$cachevar, | |
[ac_save_CXXFLAGS="$CXXFLAGS" | |
CXXFLAGS="$CXXFLAGS $switch" | |
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], | |
[eval $cachevar=yes], | |
[eval $cachevar=no]) | |
CXXFLAGS="$ac_save_CXXFLAGS"]) | |
if eval test x\$$cachevar = xyes; then | |
CXXFLAGS="$CXXFLAGS $switch" | |
ac_success=yes | |
break | |
fi | |
done | |
fi]) | |
AC_LANG_POP([C++]) | |
if test x$ax_cxx_compile_cxx11_required = xtrue; then | |
if test x$ac_success = xno; then | |
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) | |
fi | |
else | |
if test x$ac_success = xno; then | |
HAVE_CXX11=0 | |
AC_MSG_NOTICE([No compiler with C++11 support was found]) | |
else | |
HAVE_CXX11=1 | |
AC_DEFINE(HAVE_CXX11,1, | |
[define if the compiler supports basic C++11 syntax]) | |
fi | |
AC_SUBST(HAVE_CXX11) | |
fi | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2012 Canonical Ltd. | |
# | |
# This program is free software: you can redistribute it and/or modify it | |
# under the terms of the GNU General Public License version 3, as published | |
# by the Free Software Foundation. | |
# | |
# This program is distributed in the hope that it will be useful, but | |
# WITHOUT ANY WARRANTY; without even the implied warranties of | |
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | |
# PURPOSE. See the GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License along | |
# with this program. If not, see <http://www.gnu.org/licenses/>. | |
# Checks for existence of coverage tools: | |
# * gcov | |
# * lcov | |
# * genhtml | |
# * gcovr | |
# | |
# Sets ac_cv_check_gcov to yes if tooling is present | |
# and reports the executables to the variables LCOV, GCOVR and GENHTML. | |
AC_DEFUN([AC_TDD_GCOV], | |
[ | |
AC_ARG_ENABLE(gcov, | |
AS_HELP_STRING([--enable-gcov], | |
[enable coverage testing with gcov]), | |
[use_gcov=${enableval}], [use_gcov=no]) | |
AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") | |
if test "x$use_gcov" = "xyes"; then | |
# we need gcc: | |
if test "$GCC" != "yes"; then | |
AC_MSG_ERROR([GCC is required for --enable-gcov]) | |
fi | |
# Check if ccache is being used | |
AC_CHECK_PROG(SHTOOL, shtool, shtool) | |
if test "$SHTOOL"; then | |
AS_CASE([`$SHTOOL path $CC`], | |
[*ccache*], [gcc_ccache=yes], | |
[gcc_ccache=no]) | |
fi | |
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then | |
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) | |
fi | |
lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11" | |
AC_CHECK_PROG(LCOV, lcov, lcov) | |
AC_CHECK_PROG(GENHTML, genhtml, genhtml) | |
if test "$LCOV"; then | |
AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ | |
glib_cv_lcov_version=invalid | |
lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` | |
for lcov_check_version in $lcov_version_list; do | |
if test "$lcov_version" = "$lcov_check_version"; then | |
glib_cv_lcov_version="$lcov_check_version (ok)" | |
fi | |
done | |
]) | |
else | |
lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" | |
AC_MSG_ERROR([$lcov_msg]) | |
fi | |
case $glib_cv_lcov_version in | |
""|invalid[)] | |
lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." | |
AC_MSG_ERROR([$lcov_msg]) | |
LCOV="exit 0;" | |
;; | |
esac | |
if test -z "$GENHTML"; then | |
AC_MSG_ERROR([Could not find genhtml from the lcov package]) | |
fi | |
# Remove all optimization flags from CFLAGS | |
changequote({,}) | |
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` | |
CPPFLAGS=`echo "$CPPFLAGS" | $SED -e 's/-O[0-9]*//g'` | |
changequote([,]) | |
# Add the special gcc flags | |
COVERAGE_CFLAGS="--coverage -DDEBUG" | |
COVERAGE_CXXFLAGS="--coverage -DDEBUG" | |
COVERAGE_LDFLAGS="--coverage -lgcov" | |
fi | |
]) # AC_TDD_GCOV | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Coverage targets | |
if HAVE_GCOV | |
.PHONY: clean-gcda | |
clean-gcda: | |
@echo Removing old coverage results | |
-find -name '*.gcda' -print | xargs -r rm | |
.PHONY: coverage-html generate-coverage-html clean-coverage-html | |
#coverage-html: clean-gcda | |
coverage-html: coverage-executation | |
-$(MAKE) $(AM_MAKEFLAGS) -k check | |
$(MAKE) $(AM_MAKEFLAGS) generate-coverage-html | |
generate-coverage-html: | |
@echo Collecting coverage data with lcov | |
$(LCOV) --base-directory . --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool | |
$(LCOV) --remove coverage.info "/usr*" -o coverage.info | |
$(LCOV) --remove coverage.info "/opt*" -o coverage.info | |
LANG=C++ $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info | |
clean-coverage-html: clean-gcda | |
-$(LCOV) --directory $(top_builddir) -z | |
-rm -rf coverage.info coveragereport | |
clean-local: clean-coverage-html | |
endif # HAVE_GCOV |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AC_DEFUN([MY_COMMON], | |
[ | |
AC_ARG_ENABLE([demos], | |
AS_HELP_STRING([--disable-demos], [disable building demos]), | |
[build_demos=${enableval}], | |
[build_demos=yes]) | |
AM_CONDITIONAL([BUILD_DEMOS], [test "$build_demos" = yes]) | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment