diff options
| author | Simeon Simeonov | 2020-03-12 12:30:51 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2020-03-12 12:30:51 +0100 |
| commit | 69a05d516bd0c7e369a0ba1fb78aac57a5ea26f2 (patch) | |
| tree | 87e37110ea0e328533a41c3b16b64036ff132641 /m4 | |
Initial commit for the last i3lock commit at this time f3b061233e28ad0cf920c9421adc2459b6920812
Diffstat (limited to 'm4')
| -rw-r--r-- | m4/ax_append_flag.m4 | 71 | ||||
| -rw-r--r-- | m4/ax_cflags_warn_all.m4 | 122 | ||||
| -rw-r--r-- | m4/ax_check_compile_flag.m4 | 74 | ||||
| -rw-r--r-- | m4/ax_check_enable_debug.m4 | 124 | ||||
| -rw-r--r-- | m4/ax_check_gnu_make.m4 | 84 | ||||
| -rw-r--r-- | m4/ax_check_link_flag.m4 | 74 | ||||
| -rw-r--r-- | m4/ax_code_coverage.m4 | 273 | ||||
| -rw-r--r-- | m4/ax_configure_args.m4 | 70 | ||||
| -rw-r--r-- | m4/ax_enable_builddir.m4 | 302 | ||||
| -rw-r--r-- | m4/ax_extend_srcdir.m4 | 86 | ||||
| -rw-r--r-- | m4/ax_require_defined.m4 | 37 | ||||
| -rw-r--r-- | m4/ax_sanitizers.m4 | 130 |
12 files changed, 1447 insertions, 0 deletions
diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 new file mode 100644 index 0000000..08f2e07 --- /dev/null +++ b/m4/ax_append_flag.m4 | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_append_flag.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space | ||
| 12 | # added in between. | ||
| 13 | # | ||
| 14 | # If FLAGS-VARIABLE is not specified, the current language's flags (e.g. | ||
| 15 | # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains | ||
| 16 | # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly | ||
| 17 | # FLAG. | ||
| 18 | # | ||
| 19 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. | ||
| 20 | # | ||
| 21 | # LICENSE | ||
| 22 | # | ||
| 23 | # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> | ||
| 24 | # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> | ||
| 25 | # | ||
| 26 | # This program is free software: you can redistribute it and/or modify it | ||
| 27 | # under the terms of the GNU General Public License as published by the | ||
| 28 | # Free Software Foundation, either version 3 of the License, or (at your | ||
| 29 | # option) any later version. | ||
| 30 | # | ||
| 31 | # This program is distributed in the hope that it will be useful, but | ||
| 32 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 33 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 34 | # Public License for more details. | ||
| 35 | # | ||
| 36 | # You should have received a copy of the GNU General Public License along | ||
| 37 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 38 | # | ||
| 39 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 40 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 41 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 42 | # need not follow the terms of the GNU General Public License when using | ||
| 43 | # or distributing such scripts, even though portions of the text of the | ||
| 44 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 45 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 46 | # | ||
| 47 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 48 | # Macro released by the Autoconf Archive. When you make and distribute a | ||
| 49 | # modified version of the Autoconf Macro, you may extend this special | ||
| 50 | # exception to the GPL to apply to your modified version as well. | ||
| 51 | |||
| 52 | #serial 6 | ||
| 53 | |||
| 54 | AC_DEFUN([AX_APPEND_FLAG], | ||
| 55 | [dnl | ||
| 56 | AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF | ||
| 57 | AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) | ||
| 58 | AS_VAR_SET_IF(FLAGS,[ | ||
| 59 | AS_CASE([" AS_VAR_GET(FLAGS) "], | ||
| 60 | [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], | ||
| 61 | [ | ||
| 62 | AS_VAR_APPEND(FLAGS,[" $1"]) | ||
| 63 | AC_RUN_LOG([: FLAGS="$FLAGS"]) | ||
| 64 | ]) | ||
| 65 | ], | ||
| 66 | [ | ||
| 67 | AS_VAR_SET(FLAGS,[$1]) | ||
| 68 | AC_RUN_LOG([: FLAGS="$FLAGS"]) | ||
| 69 | ]) | ||
| 70 | AS_VAR_POPDEF([FLAGS])dnl | ||
| 71 | ])dnl AX_APPEND_FLAG | ||
diff --git a/m4/ax_cflags_warn_all.m4 b/m4/ax_cflags_warn_all.m4 new file mode 100644 index 0000000..1f07799 --- /dev/null +++ b/m4/ax_cflags_warn_all.m4 | |||
| @@ -0,0 +1,122 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] | ||
| 8 | # AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] | ||
| 9 | # AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] | ||
| 10 | # | ||
| 11 | # DESCRIPTION | ||
| 12 | # | ||
| 13 | # Try to find a compiler option that enables most reasonable warnings. | ||
| 14 | # | ||
| 15 | # For the GNU compiler it will be -Wall (and -ansi -pedantic) The result | ||
| 16 | # is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. | ||
| 17 | # | ||
| 18 | # Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, | ||
| 19 | # HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and | ||
| 20 | # Intel compilers. For a given compiler, the Fortran flags are much more | ||
| 21 | # experimental than their C equivalents. | ||
| 22 | # | ||
| 23 | # - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS | ||
| 24 | # - $2 add-value-if-not-found : nothing | ||
| 25 | # - $3 action-if-found : add value to shellvariable | ||
| 26 | # - $4 action-if-not-found : nothing | ||
| 27 | # | ||
| 28 | # NOTE: These macros depend on AX_APPEND_FLAG. | ||
| 29 | # | ||
| 30 | # LICENSE | ||
| 31 | # | ||
| 32 | # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> | ||
| 33 | # Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com> | ||
| 34 | # | ||
| 35 | # This program is free software; you can redistribute it and/or modify it | ||
| 36 | # under the terms of the GNU General Public License as published by the | ||
| 37 | # Free Software Foundation; either version 3 of the License, or (at your | ||
| 38 | # option) any later version. | ||
| 39 | # | ||
| 40 | # This program is distributed in the hope that it will be useful, but | ||
| 41 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 42 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 43 | # Public License for more details. | ||
| 44 | # | ||
| 45 | # You should have received a copy of the GNU General Public License along | ||
| 46 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 47 | # | ||
| 48 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 49 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 50 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 51 | # need not follow the terms of the GNU General Public License when using | ||
| 52 | # or distributing such scripts, even though portions of the text of the | ||
| 53 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 54 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 55 | # | ||
| 56 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 57 | # Macro released by the Autoconf Archive. When you make and distribute a | ||
| 58 | # modified version of the Autoconf Macro, you may extend this special | ||
| 59 | # exception to the GPL to apply to your modified version as well. | ||
| 60 | |||
| 61 | #serial 15 | ||
| 62 | |||
| 63 | AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl | ||
| 64 | AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl | ||
| 65 | AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl | ||
| 66 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], | ||
| 67 | VAR,[VAR="no, unknown" | ||
| 68 | ac_save_[]FLAGS="$[]FLAGS" | ||
| 69 | for ac_arg dnl | ||
| 70 | in "-warn all % -warn all" dnl Intel | ||
| 71 | "-pedantic % -Wall" dnl GCC | ||
| 72 | "-xstrconst % -v" dnl Solaris C | ||
| 73 | "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix | ||
| 74 | "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX | ||
| 75 | "-ansi -ansiE % -fullwarn" dnl IRIX | ||
| 76 | "+ESlit % +w1" dnl HP-UX C | ||
| 77 | "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) | ||
| 78 | "-h conform % -h msglevel 2" dnl Cray C (Unicos) | ||
| 79 | # | ||
| 80 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` | ||
| 81 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM], | ||
| 82 | [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) | ||
| 83 | done | ||
| 84 | FLAGS="$ac_save_[]FLAGS" | ||
| 85 | ]) | ||
| 86 | AS_VAR_POPDEF([FLAGS])dnl | ||
| 87 | AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) | ||
| 88 | case ".$VAR" in | ||
| 89 | .ok|.ok,*) m4_ifvaln($3,$3) ;; | ||
| 90 | .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; | ||
| 91 | *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; | ||
| 92 | esac | ||
| 93 | AS_VAR_POPDEF([VAR])dnl | ||
| 94 | ])dnl AX_FLAGS_WARN_ALL | ||
| 95 | dnl implementation tactics: | ||
| 96 | dnl the for-argument contains a list of options. The first part of | ||
| 97 | dnl these does only exist to detect the compiler - usually it is | ||
| 98 | dnl a global option to enable -ansi or -extrawarnings. All other | ||
| 99 | dnl compilers will fail about it. That was needed since a lot of | ||
| 100 | dnl compilers will give false positives for some option-syntax | ||
| 101 | dnl like -Woption or -Xoption as they think of it is a pass-through | ||
| 102 | dnl to later compile stages or something. The "%" is used as a | ||
| 103 | dnl delimiter. A non-option comment can be given after "%%" marks | ||
| 104 | dnl which will be shown but not added to the respective C/CXXFLAGS. | ||
| 105 | |||
| 106 | AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl | ||
| 107 | AC_LANG_PUSH([C]) | ||
| 108 | AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) | ||
| 109 | AC_LANG_POP([C]) | ||
| 110 | ]) | ||
| 111 | |||
| 112 | AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl | ||
| 113 | AC_LANG_PUSH([C++]) | ||
| 114 | AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) | ||
| 115 | AC_LANG_POP([C++]) | ||
| 116 | ]) | ||
| 117 | |||
| 118 | AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl | ||
| 119 | AC_LANG_PUSH([Fortran]) | ||
| 120 | AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) | ||
| 121 | AC_LANG_POP([Fortran]) | ||
| 122 | ]) | ||
diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000..ca36397 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Check whether the given FLAG works with the current language's compiler | ||
| 12 | # or gives an error. (Warnings, however, are ignored) | ||
| 13 | # | ||
| 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on | ||
| 15 | # success/failure. | ||
| 16 | # | ||
| 17 | # If EXTRA-FLAGS is defined, it is added to the current language's default | ||
| 18 | # flags (e.g. CFLAGS) when the check is done. The check is thus made with | ||
| 19 | # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to | ||
| 20 | # force the compiler to issue an error when a bad flag is given. | ||
| 21 | # | ||
| 22 | # INPUT gives an alternative input source to AC_COMPILE_IFELSE. | ||
| 23 | # | ||
| 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this | ||
| 25 | # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. | ||
| 26 | # | ||
| 27 | # LICENSE | ||
| 28 | # | ||
| 29 | # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> | ||
| 30 | # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> | ||
| 31 | # | ||
| 32 | # This program is free software: you can redistribute it and/or modify it | ||
| 33 | # under the terms of the GNU General Public License as published by the | ||
| 34 | # Free Software Foundation, either version 3 of the License, or (at your | ||
| 35 | # option) any later version. | ||
| 36 | # | ||
| 37 | # This program is distributed in the hope that it will be useful, but | ||
| 38 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 40 | # Public License for more details. | ||
| 41 | # | ||
| 42 | # You should have received a copy of the GNU General Public License along | ||
| 43 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 44 | # | ||
| 45 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 46 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 47 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 48 | # need not follow the terms of the GNU General Public License when using | ||
| 49 | # or distributing such scripts, even though portions of the text of the | ||
| 50 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 51 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 52 | # | ||
| 53 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 54 | # Macro released by the Autoconf Archive. When you make and distribute a | ||
| 55 | # modified version of the Autoconf Macro, you may extend this special | ||
| 56 | # exception to the GPL to apply to your modified version as well. | ||
| 57 | |||
| 58 | #serial 4 | ||
| 59 | |||
| 60 | AC_DEFUN([AX_CHECK_COMPILE_FLAG], | ||
| 61 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF | ||
| 62 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl | ||
| 63 | AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ | ||
| 64 | ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS | ||
| 65 | _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" | ||
| 66 | AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], | ||
| 67 | [AS_VAR_SET(CACHEVAR,[yes])], | ||
| 68 | [AS_VAR_SET(CACHEVAR,[no])]) | ||
| 69 | _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) | ||
| 70 | AS_VAR_IF(CACHEVAR,yes, | ||
| 71 | [m4_default([$2], :)], | ||
| 72 | [m4_default([$3], :)]) | ||
| 73 | AS_VAR_POPDEF([CACHEVAR])dnl | ||
| 74 | ])dnl AX_CHECK_COMPILE_FLAGS | ||
diff --git a/m4/ax_check_enable_debug.m4 b/m4/ax_check_enable_debug.m4 new file mode 100644 index 0000000..f99d75f --- /dev/null +++ b/m4/ax_check_enable_debug.m4 | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Check for the presence of an --enable-debug option to configure, with | ||
| 12 | # the specified default value used when the option is not present. Return | ||
| 13 | # the value in the variable $ax_enable_debug. | ||
| 14 | # | ||
| 15 | # Specifying 'yes' adds '-g -O0' to the compilation flags for all | ||
| 16 | # languages. Specifying 'info' adds '-g' to the compilation flags. | ||
| 17 | # Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to | ||
| 18 | # the linking flags. Otherwise, nothing is added. | ||
| 19 | # | ||
| 20 | # Define the variables listed in the second argument if debug is enabled, | ||
| 21 | # defaulting to no variables. Defines the variables listed in the third | ||
| 22 | # argument if debug is disabled, defaulting to NDEBUG. All lists of | ||
| 23 | # variables should be space-separated. | ||
| 24 | # | ||
| 25 | # If debug is not enabled, ensure AC_PROG_* will not add debugging flags. | ||
| 26 | # Should be invoked prior to any AC_PROG_* compiler checks. | ||
| 27 | # | ||
| 28 | # IS-RELEASE can be used to change the default to 'no' when making a | ||
| 29 | # release. Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it | ||
| 30 | # uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE | ||
| 31 | # macro, there is no need to pass this parameter. | ||
| 32 | # | ||
| 33 | # AX_IS_RELEASE([git-directory]) | ||
| 34 | # AX_CHECK_ENABLE_DEBUG() | ||
| 35 | # | ||
| 36 | # LICENSE | ||
| 37 | # | ||
| 38 | # Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com> | ||
| 39 | # Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk> | ||
| 40 | # | ||
| 41 | # Copying and distribution of this file, with or without modification, are | ||
| 42 | # permitted in any medium without royalty provided the copyright notice | ||
| 43 | # and this notice are preserved. | ||
| 44 | |||
| 45 | #serial 5 | ||
| 46 | |||
| 47 | AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[ | ||
| 48 | AC_BEFORE([$0],[AC_PROG_CC])dnl | ||
| 49 | AC_BEFORE([$0],[AC_PROG_CXX])dnl | ||
| 50 | AC_BEFORE([$0],[AC_PROG_F77])dnl | ||
| 51 | AC_BEFORE([$0],[AC_PROG_FC])dnl | ||
| 52 | |||
| 53 | AC_MSG_CHECKING(whether to enable debugging) | ||
| 54 | |||
| 55 | ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1]))) | ||
| 56 | ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],, | ||
| 57 | [$ax_is_release], | ||
| 58 | [$4]))) | ||
| 59 | |||
| 60 | # If this is a release, override the default. | ||
| 61 | AS_IF([test "$ax_enable_debug_is_release" = "yes"], | ||
| 62 | [ax_enable_debug_default="no"]) | ||
| 63 | |||
| 64 | m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))]) | ||
| 65 | m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))]) | ||
| 66 | |||
| 67 | AC_ARG_ENABLE(debug, | ||
| 68 | [AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])], | ||
| 69 | [],enable_debug=$ax_enable_debug_default) | ||
| 70 | |||
| 71 | # empty mean debug yes | ||
| 72 | AS_IF([test "x$enable_debug" = "x"], | ||
| 73 | [enable_debug="yes"]) | ||
| 74 | |||
| 75 | # case of debug | ||
| 76 | AS_CASE([$enable_debug], | ||
| 77 | [yes],[ | ||
| 78 | AC_MSG_RESULT(yes) | ||
| 79 | CFLAGS="${CFLAGS} -g -O0" | ||
| 80 | CXXFLAGS="${CXXFLAGS} -g -O0" | ||
| 81 | FFLAGS="${FFLAGS} -g -O0" | ||
| 82 | FCFLAGS="${FCFLAGS} -g -O0" | ||
| 83 | OBJCFLAGS="${OBJCFLAGS} -g -O0" | ||
| 84 | ], | ||
| 85 | [info],[ | ||
| 86 | AC_MSG_RESULT(info) | ||
| 87 | CFLAGS="${CFLAGS} -g" | ||
| 88 | CXXFLAGS="${CXXFLAGS} -g" | ||
| 89 | FFLAGS="${FFLAGS} -g" | ||
| 90 | FCFLAGS="${FCFLAGS} -g" | ||
| 91 | OBJCFLAGS="${OBJCFLAGS} -g" | ||
| 92 | ], | ||
| 93 | [profile],[ | ||
| 94 | AC_MSG_RESULT(profile) | ||
| 95 | CFLAGS="${CFLAGS} -g -pg" | ||
| 96 | CXXFLAGS="${CXXFLAGS} -g -pg" | ||
| 97 | FFLAGS="${FFLAGS} -g -pg" | ||
| 98 | FCFLAGS="${FCFLAGS} -g -pg" | ||
| 99 | OBJCFLAGS="${OBJCFLAGS} -g -pg" | ||
| 100 | LDFLAGS="${LDFLAGS} -pg" | ||
| 101 | ], | ||
| 102 | [ | ||
| 103 | AC_MSG_RESULT(no) | ||
| 104 | dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags | ||
| 105 | dnl by setting any unset environment flag variables | ||
| 106 | AS_IF([test "x${CFLAGS+set}" != "xset"], | ||
| 107 | [CFLAGS=""]) | ||
| 108 | AS_IF([test "x${CXXFLAGS+set}" != "xset"], | ||
| 109 | [CXXFLAGS=""]) | ||
| 110 | AS_IF([test "x${FFLAGS+set}" != "xset"], | ||
| 111 | [FFLAGS=""]) | ||
| 112 | AS_IF([test "x${FCFLAGS+set}" != "xset"], | ||
| 113 | [FCFLAGS=""]) | ||
| 114 | AS_IF([test "x${OBJCFLAGS+set}" != "xset"], | ||
| 115 | [OBJCFLAGS=""]) | ||
| 116 | ]) | ||
| 117 | |||
| 118 | dnl Define various variables if debugging is disabled. | ||
| 119 | dnl assert.h is a NOP if NDEBUG is defined, so define it by default. | ||
| 120 | AS_IF([test "x$enable_debug" = "xyes"], | ||
| 121 | [m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])], | ||
| 122 | [m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])]) | ||
| 123 | ax_enable_debug=$enable_debug | ||
| 124 | ]) | ||
diff --git a/m4/ax_check_gnu_make.m4 b/m4/ax_check_gnu_make.m4 new file mode 100644 index 0000000..6762e9e --- /dev/null +++ b/m4/ax_check_gnu_make.m4 | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_CHECK_GNU_MAKE() | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # This macro searches for a GNU version of make. If a match is found: | ||
| 12 | # | ||
| 13 | # * The makefile variable `ifGNUmake' is set to the empty string, otherwise | ||
| 14 | # it is set to "#". This is useful for including a special features in a | ||
| 15 | # Makefile, which cannot be handled by other versions of make. | ||
| 16 | # * The variable `_cv_gnu_make_command` is set to the command to invoke | ||
| 17 | # GNU make if it exists, the empty string otherwise. | ||
| 18 | # * The variable `ax_cv_gnu_make_command` is set to the command to invoke | ||
| 19 | # GNU make by copying `_cv_gnu_make_command`, otherwise it is unset. | ||
| 20 | # * If GNU Make is found, its version is extracted from the output of | ||
| 21 | # `make --version` as the last field of a record of space-separated | ||
| 22 | # columns and saved into the variable `ax_check_gnu_make_version`. | ||
| 23 | # | ||
| 24 | # Here is an example of its use: | ||
| 25 | # | ||
| 26 | # Makefile.in might contain: | ||
| 27 | # | ||
| 28 | # # A failsafe way of putting a dependency rule into a makefile | ||
| 29 | # $(DEPEND): | ||
| 30 | # $(CC) -MM $(srcdir)/*.c > $(DEPEND) | ||
| 31 | # | ||
| 32 | # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND))) | ||
| 33 | # @ifGNUmake@ include $(DEPEND) | ||
| 34 | # @ifGNUmake@ endif | ||
| 35 | # | ||
| 36 | # Then configure.in would normally contain: | ||
| 37 | # | ||
| 38 | # AX_CHECK_GNU_MAKE() | ||
| 39 | # AC_OUTPUT(Makefile) | ||
| 40 | # | ||
| 41 | # Then perhaps to cause gnu make to override any other make, we could do | ||
| 42 | # something like this (note that GNU make always looks for GNUmakefile | ||
| 43 | # first): | ||
| 44 | # | ||
| 45 | # if ! test x$_cv_gnu_make_command = x ; then | ||
| 46 | # mv Makefile GNUmakefile | ||
| 47 | # echo .DEFAULT: > Makefile ; | ||
| 48 | # echo \ $_cv_gnu_make_command \$@ >> Makefile; | ||
| 49 | # fi | ||
| 50 | # | ||
| 51 | # Then, if any (well almost any) other make is called, and GNU make also | ||
| 52 | # exists, then the other make wraps the GNU make. | ||
| 53 | # | ||
| 54 | # LICENSE | ||
| 55 | # | ||
| 56 | # Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au> | ||
| 57 | # Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com> | ||
| 58 | # | ||
| 59 | # Copying and distribution of this file, with or without modification, are | ||
| 60 | # permitted in any medium without royalty provided the copyright notice | ||
| 61 | # and this notice are preserved. This file is offered as-is, without any | ||
| 62 | # warranty. | ||
| 63 | |||
| 64 | #serial 8 | ||
| 65 | |||
| 66 | AC_DEFUN([AX_CHECK_GNU_MAKE],dnl | ||
| 67 | [AC_PROG_AWK | ||
| 68 | AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl | ||
| 69 | _cv_gnu_make_command="" ; | ||
| 70 | dnl Search all the common names for GNU make | ||
| 71 | for a in "$MAKE" make gmake gnumake ; do | ||
| 72 | if test -z "$a" ; then continue ; fi ; | ||
| 73 | if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then | ||
| 74 | _cv_gnu_make_command=$a ; | ||
| 75 | AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make") | ||
| 76 | ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }') | ||
| 77 | break ; | ||
| 78 | fi | ||
| 79 | done ;]) | ||
| 80 | dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise | ||
| 81 | AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])]) | ||
| 82 | AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])]) | ||
| 83 | AC_SUBST([ifGNUmake]) | ||
| 84 | ]) | ||
diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4 new file mode 100644 index 0000000..eb01a6c --- /dev/null +++ b/m4/ax_check_link_flag.m4 | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Check whether the given FLAG works with the linker or gives an error. | ||
| 12 | # (Warnings, however, are ignored) | ||
| 13 | # | ||
| 14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on | ||
| 15 | # success/failure. | ||
| 16 | # | ||
| 17 | # If EXTRA-FLAGS is defined, it is added to the linker's default flags | ||
| 18 | # when the check is done. The check is thus made with the flags: "LDFLAGS | ||
| 19 | # EXTRA-FLAGS FLAG". This can for example be used to force the linker to | ||
| 20 | # issue an error when a bad flag is given. | ||
| 21 | # | ||
| 22 | # INPUT gives an alternative input source to AC_LINK_IFELSE. | ||
| 23 | # | ||
| 24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this | ||
| 25 | # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. | ||
| 26 | # | ||
| 27 | # LICENSE | ||
| 28 | # | ||
| 29 | # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> | ||
| 30 | # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> | ||
| 31 | # | ||
| 32 | # This program is free software: you can redistribute it and/or modify it | ||
| 33 | # under the terms of the GNU General Public License as published by the | ||
| 34 | # Free Software Foundation, either version 3 of the License, or (at your | ||
| 35 | # option) any later version. | ||
| 36 | # | ||
| 37 | # This program is distributed in the hope that it will be useful, but | ||
| 38 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 40 | # Public License for more details. | ||
| 41 | # | ||
| 42 | # You should have received a copy of the GNU General Public License along | ||
| 43 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 44 | # | ||
| 45 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 46 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 47 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 48 | # need not follow the terms of the GNU General Public License when using | ||
| 49 | # or distributing such scripts, even though portions of the text of the | ||
| 50 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 51 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 52 | # | ||
| 53 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 54 | # Macro released by the Autoconf Archive. When you make and distribute a | ||
| 55 | # modified version of the Autoconf Macro, you may extend this special | ||
| 56 | # exception to the GPL to apply to your modified version as well. | ||
| 57 | |||
| 58 | #serial 4 | ||
| 59 | |||
| 60 | AC_DEFUN([AX_CHECK_LINK_FLAG], | ||
| 61 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF | ||
| 62 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl | ||
| 63 | AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ | ||
| 64 | ax_check_save_flags=$LDFLAGS | ||
| 65 | LDFLAGS="$LDFLAGS $4 $1" | ||
| 66 | AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], | ||
| 67 | [AS_VAR_SET(CACHEVAR,[yes])], | ||
| 68 | [AS_VAR_SET(CACHEVAR,[no])]) | ||
| 69 | LDFLAGS=$ax_check_save_flags]) | ||
| 70 | AS_VAR_IF(CACHEVAR,yes, | ||
| 71 | [m4_default([$2], :)], | ||
| 72 | [m4_default([$3], :)]) | ||
| 73 | AS_VAR_POPDEF([CACHEVAR])dnl | ||
| 74 | ])dnl AX_CHECK_LINK_FLAGS | ||
diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4 new file mode 100644 index 0000000..6c985eb --- /dev/null +++ b/m4/ax_code_coverage.m4 | |||
| @@ -0,0 +1,273 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_code_coverage.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_CODE_COVERAGE() | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS, | ||
| 12 | # CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LDFLAGS which should be | ||
| 13 | # included in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LDFLAGS variables of | ||
| 14 | # every build target (program or library) which should be built with code | ||
| 15 | # coverage support. Also defines CODE_COVERAGE_RULES which should be | ||
| 16 | # substituted in your Makefile; and $enable_code_coverage which can be | ||
| 17 | # used in subsequent configure output. CODE_COVERAGE_ENABLED is defined | ||
| 18 | # and substituted, and corresponds to the value of the | ||
| 19 | # --enable-code-coverage option, which defaults to being disabled. | ||
| 20 | # | ||
| 21 | # Test also for gcov program and create GCOV variable that could be | ||
| 22 | # substituted. | ||
| 23 | # | ||
| 24 | # Note that all optimisation flags in CFLAGS must be disabled when code | ||
| 25 | # coverage is enabled. | ||
| 26 | # | ||
| 27 | # Usage example: | ||
| 28 | # | ||
| 29 | # configure.ac: | ||
| 30 | # | ||
| 31 | # AX_CODE_COVERAGE | ||
| 32 | # | ||
| 33 | # Makefile.am: | ||
| 34 | # | ||
| 35 | # @CODE_COVERAGE_RULES@ | ||
| 36 | # my_program_LIBS = ... $(CODE_COVERAGE_LDFLAGS) ... | ||
| 37 | # my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ... | ||
| 38 | # my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ... | ||
| 39 | # my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ... | ||
| 40 | # | ||
| 41 | # This results in a "check-code-coverage" rule being added to any | ||
| 42 | # Makefile.am which includes "@CODE_COVERAGE_RULES@" (assuming the module | ||
| 43 | # has been configured with --enable-code-coverage). Running `make | ||
| 44 | # check-code-coverage` in that directory will run the module's test suite | ||
| 45 | # (`make check`) and build a code coverage report detailing the code which | ||
| 46 | # was touched, then print the URI for the report. | ||
| 47 | # | ||
| 48 | # This code was derived from Makefile.decl in GLib, originally licenced | ||
| 49 | # under LGPLv2.1+. | ||
| 50 | # | ||
| 51 | # LICENSE | ||
| 52 | # | ||
| 53 | # Copyright (c) 2012, 2016 Philip Withnall | ||
| 54 | # Copyright (c) 2012 Xan Lopez | ||
| 55 | # Copyright (c) 2012 Christian Persch | ||
| 56 | # Copyright (c) 2012 Paolo Borelli | ||
| 57 | # Copyright (c) 2012 Dan Winship | ||
| 58 | # Copyright (c) 2015 Bastien ROUCARIES | ||
| 59 | # | ||
| 60 | # This library is free software; you can redistribute it and/or modify it | ||
| 61 | # under the terms of the GNU Lesser General Public License as published by | ||
| 62 | # the Free Software Foundation; either version 2.1 of the License, or (at | ||
| 63 | # your option) any later version. | ||
| 64 | # | ||
| 65 | # This library is distributed in the hope that it will be useful, but | ||
| 66 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 67 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
| 68 | # General Public License for more details. | ||
| 69 | # | ||
| 70 | # You should have received a copy of the GNU Lesser General Public License | ||
| 71 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 72 | |||
| 73 | #serial 15 | ||
| 74 | |||
| 75 | AC_DEFUN([AX_CODE_COVERAGE],[ | ||
| 76 | dnl Check for --enable-code-coverage | ||
| 77 | AC_REQUIRE([AC_PROG_SED]) | ||
| 78 | |||
| 79 | # allow to override gcov location | ||
| 80 | AC_ARG_WITH([gcov], | ||
| 81 | [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])], | ||
| 82 | [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov], | ||
| 83 | [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov]) | ||
| 84 | |||
| 85 | AC_MSG_CHECKING([whether to build with code coverage support]) | ||
| 86 | AC_ARG_ENABLE([code-coverage], | ||
| 87 | AS_HELP_STRING([--enable-code-coverage], | ||
| 88 | [Whether to enable code coverage support]),, | ||
| 89 | enable_code_coverage=no) | ||
| 90 | |||
| 91 | AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test x$enable_code_coverage = xyes]) | ||
| 92 | AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage]) | ||
| 93 | AC_MSG_RESULT($enable_code_coverage) | ||
| 94 | |||
| 95 | AS_IF([ test "$enable_code_coverage" = "yes" ], [ | ||
| 96 | # check for gcov | ||
| 97 | AC_CHECK_TOOL([GCOV], | ||
| 98 | [$_AX_CODE_COVERAGE_GCOV_PROG_WITH], | ||
| 99 | [:]) | ||
| 100 | AS_IF([test "X$GCOV" = "X:"], | ||
| 101 | [AC_MSG_ERROR([gcov is needed to do coverage])]) | ||
| 102 | AC_SUBST([GCOV]) | ||
| 103 | |||
| 104 | dnl Check if gcc is being used | ||
| 105 | AS_IF([ test "$GCC" = "no" ], [ | ||
| 106 | AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage]) | ||
| 107 | ]) | ||
| 108 | |||
| 109 | # List of supported lcov versions. | ||
| 110 | lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11 1.12" | ||
| 111 | |||
| 112 | AC_CHECK_PROG([LCOV], [lcov], [lcov]) | ||
| 113 | AC_CHECK_PROG([GENHTML], [genhtml], [genhtml]) | ||
| 114 | |||
| 115 | AS_IF([ test "$LCOV" ], [ | ||
| 116 | AC_CACHE_CHECK([for lcov version], ax_cv_lcov_version, [ | ||
| 117 | ax_cv_lcov_version=invalid | ||
| 118 | lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` | ||
| 119 | for lcov_check_version in $lcov_version_list; do | ||
| 120 | if test "$lcov_version" = "$lcov_check_version"; then | ||
| 121 | ax_cv_lcov_version="$lcov_check_version (ok)" | ||
| 122 | fi | ||
| 123 | done | ||
| 124 | ]) | ||
| 125 | ], [ | ||
| 126 | lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" | ||
| 127 | AC_MSG_ERROR([$lcov_msg]) | ||
| 128 | ]) | ||
| 129 | |||
| 130 | case $ax_cv_lcov_version in | ||
| 131 | ""|invalid[)] | ||
| 132 | lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." | ||
| 133 | AC_MSG_ERROR([$lcov_msg]) | ||
| 134 | LCOV="exit 0;" | ||
| 135 | ;; | ||
| 136 | esac | ||
| 137 | |||
| 138 | AS_IF([ test -z "$GENHTML" ], [ | ||
| 139 | AC_MSG_ERROR([Could not find genhtml from the lcov package]) | ||
| 140 | ]) | ||
| 141 | |||
| 142 | dnl Build the code coverage flags | ||
| 143 | CODE_COVERAGE_CPPFLAGS="-DNDEBUG" | ||
| 144 | CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" | ||
| 145 | CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" | ||
| 146 | CODE_COVERAGE_LDFLAGS="-lgcov" | ||
| 147 | |||
| 148 | AC_SUBST([CODE_COVERAGE_CPPFLAGS]) | ||
| 149 | AC_SUBST([CODE_COVERAGE_CFLAGS]) | ||
| 150 | AC_SUBST([CODE_COVERAGE_CXXFLAGS]) | ||
| 151 | AC_SUBST([CODE_COVERAGE_LDFLAGS]) | ||
| 152 | ]) | ||
| 153 | |||
| 154 | [CODE_COVERAGE_RULES=' | ||
| 155 | # Code coverage | ||
| 156 | # | ||
| 157 | # Optional: | ||
| 158 | # - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. | ||
| 159 | # Multiple directories may be specified, separated by whitespace. | ||
| 160 | # (Default: $(top_builddir)) | ||
| 161 | # - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated | ||
| 162 | # by lcov for code coverage. (Default: | ||
| 163 | # $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info) | ||
| 164 | # - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage | ||
| 165 | # reports to be created. (Default: | ||
| 166 | # $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage) | ||
| 167 | # - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage, | ||
| 168 | # set to 0 to disable it and leave empty to stay with the default. | ||
| 169 | # (Default: empty) | ||
| 170 | # - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov | ||
| 171 | # instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) | ||
| 172 | # - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov | ||
| 173 | # instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) | ||
| 174 | # - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov | ||
| 175 | # - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the | ||
| 176 | # collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) | ||
| 177 | # - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov | ||
| 178 | # instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) | ||
| 179 | # - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering | ||
| 180 | # lcov instance. (Default: empty) | ||
| 181 | # - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov | ||
| 182 | # instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) | ||
| 183 | # - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the | ||
| 184 | # genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) | ||
| 185 | # - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml | ||
| 186 | # instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) | ||
| 187 | # - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore | ||
| 188 | # | ||
| 189 | # The generated report will be titled using the $(PACKAGE_NAME) and | ||
| 190 | # $(PACKAGE_VERSION). In order to add the current git hash to the title, | ||
| 191 | # use the git-version-gen script, available online. | ||
| 192 | |||
| 193 | # Optional variables | ||
| 194 | CODE_COVERAGE_DIRECTORY ?= $(top_builddir) | ||
| 195 | CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info | ||
| 196 | CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage | ||
| 197 | CODE_COVERAGE_BRANCH_COVERAGE ?= | ||
| 198 | CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ | ||
| 199 | --rc lcov_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) | ||
| 200 | CODE_COVERAGE_LCOV_SHOPTS ?= $(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) | ||
| 201 | CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)" | ||
| 202 | CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) | ||
| 203 | CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) | ||
| 204 | CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?= | ||
| 205 | CODE_COVERAGE_LCOV_RMOPTS ?= $(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) | ||
| 206 | CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\ | ||
| 207 | $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ | ||
| 208 | --rc genhtml_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) | ||
| 209 | CODE_COVERAGE_GENHTML_OPTIONS ?= $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULTS) | ||
| 210 | CODE_COVERAGE_IGNORE_PATTERN ?= | ||
| 211 | |||
| 212 | code_coverage_v_lcov_cap = $(code_coverage_v_lcov_cap_$(V)) | ||
| 213 | code_coverage_v_lcov_cap_ = $(code_coverage_v_lcov_cap_$(AM_DEFAULT_VERBOSITY)) | ||
| 214 | code_coverage_v_lcov_cap_0 = @echo " LCOV --capture"\ | ||
| 215 | $(CODE_COVERAGE_OUTPUT_FILE); | ||
| 216 | code_coverage_v_lcov_ign = $(code_coverage_v_lcov_ign_$(V)) | ||
| 217 | code_coverage_v_lcov_ign_ = $(code_coverage_v_lcov_ign_$(AM_DEFAULT_VERBOSITY)) | ||
| 218 | code_coverage_v_lcov_ign_0 = @echo " LCOV --remove /tmp/*"\ | ||
| 219 | $(CODE_COVERAGE_IGNORE_PATTERN); | ||
| 220 | code_coverage_v_genhtml = $(code_coverage_v_genhtml_$(V)) | ||
| 221 | code_coverage_v_genhtml_ = $(code_coverage_v_genhtml_$(AM_DEFAULT_VERBOSITY)) | ||
| 222 | code_coverage_v_genhtml_0 = @echo " GEN " $(CODE_COVERAGE_OUTPUT_DIRECTORY); | ||
| 223 | code_coverage_quiet = $(code_coverage_quiet_$(V)) | ||
| 224 | code_coverage_quiet_ = $(code_coverage_quiet_$(AM_DEFAULT_VERBOSITY)) | ||
| 225 | code_coverage_quiet_0 = --quiet | ||
| 226 | |||
| 227 | # sanitizes the test-name: replaces with underscores: dashes and dots | ||
| 228 | code_coverage_sanitize = $(subst -,_,$(subst .,_,$(1))) | ||
| 229 | |||
| 230 | # Use recursive makes in order to ignore errors during check | ||
| 231 | check-code-coverage: | ||
| 232 | ifeq ($(CODE_COVERAGE_ENABLED),yes) | ||
| 233 | -$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k check | ||
| 234 | $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture | ||
| 235 | else | ||
| 236 | @echo "Need to reconfigure with --enable-code-coverage" | ||
| 237 | endif | ||
| 238 | |||
| 239 | # Capture code coverage data | ||
| 240 | code-coverage-capture: code-coverage-capture-hook | ||
| 241 | ifeq ($(CODE_COVERAGE_ENABLED),yes) | ||
| 242 | $(code_coverage_v_lcov_cap)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(call code_coverage_sanitize,$(PACKAGE_NAME)-$(PACKAGE_VERSION))" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_OPTIONS) | ||
| 243 | $(code_coverage_v_lcov_ign)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_RMOPTS) | ||
| 244 | -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp | ||
| 245 | $(code_coverage_v_genhtml)LANG=C $(GENHTML) $(code_coverage_quiet) $(addprefix --prefix ,$(CODE_COVERAGE_DIRECTORY)) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS) | ||
| 246 | @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html" | ||
| 247 | else | ||
| 248 | @echo "Need to reconfigure with --enable-code-coverage" | ||
| 249 | endif | ||
| 250 | |||
| 251 | # Hook rule executed before code-coverage-capture, overridable by the user | ||
| 252 | code-coverage-capture-hook: | ||
| 253 | |||
| 254 | ifeq ($(CODE_COVERAGE_ENABLED),yes) | ||
| 255 | clean: code-coverage-clean | ||
| 256 | code-coverage-clean: | ||
| 257 | -$(LCOV) --directory $(top_builddir) -z | ||
| 258 | -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) | ||
| 259 | -find . -name "*.gcda" -o -name "*.gcov" -delete | ||
| 260 | endif | ||
| 261 | |||
| 262 | GITIGNOREFILES ?= | ||
| 263 | GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) | ||
| 264 | |||
| 265 | A''M_DISTCHECK_CONFIGURE_FLAGS ?= | ||
| 266 | A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage | ||
| 267 | |||
| 268 | .PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean | ||
| 269 | '] | ||
| 270 | |||
| 271 | AC_SUBST([CODE_COVERAGE_RULES]) | ||
| 272 | m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([CODE_COVERAGE_RULES])]) | ||
| 273 | ]) | ||
diff --git a/m4/ax_configure_args.m4 b/m4/ax_configure_args.m4 new file mode 100644 index 0000000..0726b1b --- /dev/null +++ b/m4/ax_configure_args.m4 | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_configure_args.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_CONFIGURE_ARGS | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Helper macro for AX_ENABLE_BUILDDIR. | ||
| 12 | # | ||
| 13 | # The traditional way of starting a subdir-configure is running the script | ||
| 14 | # with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have | ||
| 15 | # to rely on eval'ing $ac_configure_args however some old autoconf | ||
| 16 | # versions do not provide that. To ensure maximum portability of autoconf | ||
| 17 | # extension macros this helper can be AC_REQUIRE'd so that | ||
| 18 | # $ac_configure_args will alsways be present. | ||
| 19 | # | ||
| 20 | # Sadly, the traditional "exec $SHELL" of the enable_builddir macros is | ||
| 21 | # spoiled now and must be replaced by "eval + exit $?". | ||
| 22 | # | ||
| 23 | # Example: | ||
| 24 | # | ||
| 25 | # AC_DEFUN([AX_ENABLE_SUBDIR],[dnl | ||
| 26 | # AC_REQUIRE([AX_CONFIGURE_ARGS])dnl | ||
| 27 | # eval $SHELL $ac_configure_args || exit $? | ||
| 28 | # ...]) | ||
| 29 | # | ||
| 30 | # LICENSE | ||
| 31 | # | ||
| 32 | # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> | ||
| 33 | # | ||
| 34 | # This program is free software; you can redistribute it and/or modify it | ||
| 35 | # under the terms of the GNU General Public License as published by the | ||
| 36 | # Free Software Foundation; either version 3 of the License, or (at your | ||
| 37 | # option) any later version. | ||
| 38 | # | ||
| 39 | # This program is distributed in the hope that it will be useful, but | ||
| 40 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 41 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 42 | # Public License for more details. | ||
| 43 | # | ||
| 44 | # You should have received a copy of the GNU General Public License along | ||
| 45 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 46 | # | ||
| 47 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 48 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 49 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 50 | # need not follow the terms of the GNU General Public License when using | ||
| 51 | # or distributing such scripts, even though portions of the text of the | ||
| 52 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 53 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 54 | # | ||
| 55 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 56 | # Macro released by the Autoconf Archive. When you make and distribute a | ||
| 57 | # modified version of the Autoconf Macro, you may extend this special | ||
| 58 | # exception to the GPL to apply to your modified version as well. | ||
| 59 | |||
| 60 | #serial 9 | ||
| 61 | |||
| 62 | AC_DEFUN([AX_CONFIGURE_ARGS],[ | ||
| 63 | # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args | ||
| 64 | if test "${ac_configure_args+set}" != "set" ; then | ||
| 65 | ac_configure_args= | ||
| 66 | for ac_arg in ${1+"[$]@"}; do | ||
| 67 | ac_configure_args="$ac_configure_args '$ac_arg'" | ||
| 68 | done | ||
| 69 | fi | ||
| 70 | ]) | ||
diff --git a/m4/ax_enable_builddir.m4 b/m4/ax_enable_builddir.m4 new file mode 100644 index 0000000..5f4ba32 --- /dev/null +++ b/m4/ax_enable_builddir.m4 | |||
| @@ -0,0 +1,302 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_enable_builddir.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])] | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # If the current configure was run within the srcdir then we move all | ||
| 12 | # configure-files into a subdir and let the configure steps continue | ||
| 13 | # there. We provide an option --disable-builddir to suppress the move into | ||
| 14 | # a separate builddir. | ||
| 15 | # | ||
| 16 | # Defaults: | ||
| 17 | # | ||
| 18 | # $1 = $host (overridden with $HOST) | ||
| 19 | # $2 = Makefile.mk | ||
| 20 | # $3 = -all | ||
| 21 | # | ||
| 22 | # This macro must be called before AM_INIT_AUTOMAKE. It creates a default | ||
| 23 | # toplevel srcdir Makefile from the information found in the created | ||
| 24 | # toplevel builddir Makefile. It just copies the variables and | ||
| 25 | # rule-targets, each extended with a default rule-execution that recurses | ||
| 26 | # into the build directory of the current "HOST". You can override the | ||
| 27 | # auto-dection through `config.guess` and build-time of course, as in | ||
| 28 | # | ||
| 29 | # make HOST=i386-mingw-cross | ||
| 30 | # | ||
| 31 | # which can of course set at configure time as well using | ||
| 32 | # | ||
| 33 | # configure --host=i386-mingw-cross | ||
| 34 | # | ||
| 35 | # After the default has been created, additional rules can be appended | ||
| 36 | # that will not just recurse into the subdirectories and only ever exist | ||
| 37 | # in the srcdir toplevel makefile - these parts are read from the $2 = | ||
| 38 | # Makefile.mk file | ||
| 39 | # | ||
| 40 | # The automatic rules are usually scanning the toplevel Makefile for lines | ||
| 41 | # like '#### $host |$builddir' to recognize the place where to recurse | ||
| 42 | # into. Usually, the last one is the only one used. However, almost all | ||
| 43 | # targets have an additional "*-all" rule which makes the script to | ||
| 44 | # recurse into _all_ variants of the current HOST (!!) setting. The "-all" | ||
| 45 | # suffix can be overriden for the macro as well. | ||
| 46 | # | ||
| 47 | # a special rule is only given for things like "dist" that will copy the | ||
| 48 | # tarball from the builddir to the sourcedir (or $(PUB)) for reason of | ||
| 49 | # convenience. | ||
| 50 | # | ||
| 51 | # LICENSE | ||
| 52 | # | ||
| 53 | # Copyright (c) 2009 Guido U. Draheim <guidod@gmx.de> | ||
| 54 | # Copyright (c) 2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk> | ||
| 55 | # | ||
| 56 | # This program is free software; you can redistribute it and/or modify it | ||
| 57 | # under the terms of the GNU General Public License as published by the | ||
| 58 | # Free Software Foundation; either version 3 of the License, or (at your | ||
| 59 | # option) any later version. | ||
| 60 | # | ||
| 61 | # This program is distributed in the hope that it will be useful, but | ||
| 62 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 63 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 64 | # Public License for more details. | ||
| 65 | # | ||
| 66 | # You should have received a copy of the GNU General Public License along | ||
| 67 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 68 | # | ||
| 69 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 70 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 71 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 72 | # need not follow the terms of the GNU General Public License when using | ||
| 73 | # or distributing such scripts, even though portions of the text of the | ||
| 74 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 75 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 76 | # | ||
| 77 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 78 | # Macro released by the Autoconf Archive. When you make and distribute a | ||
| 79 | # modified version of the Autoconf Macro, you may extend this special | ||
| 80 | # exception to the GPL to apply to your modified version as well. | ||
| 81 | |||
| 82 | #serial 25 | ||
| 83 | |||
| 84 | AC_DEFUN([AX_ENABLE_BUILDDIR],[ | ||
| 85 | AC_REQUIRE([AC_CANONICAL_HOST])[]dnl | ||
| 86 | AC_REQUIRE([AC_CANONICAL_TARGET])[]dnl | ||
| 87 | AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl | ||
| 88 | AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl | ||
| 89 | AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl | ||
| 90 | AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl | ||
| 91 | AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl | ||
| 92 | AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl | ||
| 93 | SUB="." | ||
| 94 | AC_ARG_ENABLE([builddir], AS_HELP_STRING( | ||
| 95 | [--disable-builddir],[disable automatic build in subdir of sources]) | ||
| 96 | ,[SUB="$enableval"], [SUB="auto"]) | ||
| 97 | if test ".$ac_srcdir_defaulted" != ".no" ; then | ||
| 98 | if test ".$srcdir" = ".." ; then | ||
| 99 | if test -f config.status ; then | ||
| 100 | AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build) | ||
| 101 | else | ||
| 102 | test ".$SUB" = "." && SUB="." | ||
| 103 | test ".$SUB" = ".no" && SUB="." | ||
| 104 | test ".$TARGET" = "." && TARGET="$target" | ||
| 105 | test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])" | ||
| 106 | if test ".$SUB" != ".." ; then # we know where to go and | ||
| 107 | AS_MKDIR_P([$SUB]) | ||
| 108 | echo __.$SUB.__ > $SUB/conftest.tmp | ||
| 109 | cd $SUB | ||
| 110 | if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then | ||
| 111 | rm conftest.tmp | ||
| 112 | AC_MSG_RESULT([continue configure in default builddir "./$SUB"]) | ||
| 113 | else | ||
| 114 | AC_MSG_ERROR([could not change to default builddir "./$SUB"]) | ||
| 115 | fi | ||
| 116 | srcdir=`echo "$SUB" | | ||
| 117 | sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'` | ||
| 118 | # going to restart from subdirectory location | ||
| 119 | test -f $srcdir/config.log && mv $srcdir/config.log . | ||
| 120 | test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h . | ||
| 121 | test -f $srcdir/conftest.log && mv $srcdir/conftest.log . | ||
| 122 | test -f $srcdir/$cache_file && mv $srcdir/$cache_file . | ||
| 123 | AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"}) | ||
| 124 | case "[$]0" in # restart | ||
| 125 | [[\\/]]* | ?:[[\\/]]*) # Asbolute name | ||
| 126 | eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; | ||
| 127 | *) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;; | ||
| 128 | esac ; exit $? | ||
| 129 | fi | ||
| 130 | fi | ||
| 131 | fi fi | ||
| 132 | test ".$SUB" = ".auto" && SUB="." | ||
| 133 | dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec" | ||
| 134 | AC_PATH_PROG(SED,gsed sed, sed) | ||
| 135 | AUX="$am_aux_dir" | ||
| 136 | AS_VAR_POPDEF([SED])dnl | ||
| 137 | AS_VAR_POPDEF([AUX])dnl | ||
| 138 | AS_VAR_POPDEF([SUB])dnl | ||
| 139 | AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status .............. | ||
| 140 | AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl | ||
| 141 | AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl | ||
| 142 | AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl | ||
| 143 | AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl | ||
| 144 | AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl | ||
| 145 | pushdef([END],[Makefile.mk])dnl | ||
| 146 | pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl | ||
| 147 | SRC="$ax_enable_builddir_srcdir" | ||
| 148 | if test ".$SUB" = ".." ; then | ||
| 149 | if test -f "$TOP/Makefile" ; then | ||
| 150 | AC_MSG_NOTICE([skipping TOP/Makefile - left untouched]) | ||
| 151 | else | ||
| 152 | AC_MSG_NOTICE([skipping TOP/Makefile - not created]) | ||
| 153 | fi | ||
| 154 | else | ||
| 155 | if test -f "$SRC/Makefile" ; then | ||
| 156 | a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile` | ||
| 157 | test "$a" != "$b" && rm "$SRC/Makefile" | ||
| 158 | fi | ||
| 159 | if test -f "$SRC/Makefile" ; then | ||
| 160 | echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk | ||
| 161 | echo " []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk | ||
| 162 | eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null" | ||
| 163 | if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null | ||
| 164 | then rm $SRC/Makefile ; fi | ||
| 165 | cp $tmp/conftemp.mk $SRC/makefiles.mk~ ## DEBUGGING | ||
| 166 | fi | ||
| 167 | if test ! -f "$SRC/Makefile" ; then | ||
| 168 | AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile]) | ||
| 169 | x='`' ; cat >$tmp/conftemp.sed <<_EOF | ||
| 170 | /^\$/n | ||
| 171 | x | ||
| 172 | /^\$/bS | ||
| 173 | x | ||
| 174 | /\\\\\$/{H;d;} | ||
| 175 | {H;s/.*//;x;} | ||
| 176 | bM | ||
| 177 | :S | ||
| 178 | x | ||
| 179 | /\\\\\$/{h;d;} | ||
| 180 | {h;s/.*//;x;} | ||
| 181 | :M | ||
| 182 | s/\\(\\n\\) /\\1 /g | ||
| 183 | /^ /d | ||
| 184 | /^[[ ]]*[[\\#]]/d | ||
| 185 | /^VPATH *=/d | ||
| 186 | s/^srcdir *=.*/srcdir = ./ | ||
| 187 | s/^top_srcdir *=.*/top_srcdir = ./ | ||
| 188 | /[[:=]]/!d | ||
| 189 | /^\\./d | ||
| 190 | dnl Now handle rules (i.e. lines containing ":" but not " = "). | ||
| 191 | / = /b | ||
| 192 | / .= /b | ||
| 193 | /:/!b | ||
| 194 | s/:.*/:/ | ||
| 195 | s/ / /g | ||
| 196 | s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g | ||
| 197 | s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/ | ||
| 198 | s/ / /g | ||
| 199 | /^all all[]_ALL[[ :]]/i\\ | ||
| 200 | all-configured : all[]_ALL | ||
| 201 | dnl dist-all exists... and would make for dist-all-all | ||
| 202 | s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g | ||
| 203 | /[]_ALL[]_ALL/d | ||
| 204 | a\\ | ||
| 205 | @ HOST="\$(HOST)\" \\\\\\ | ||
| 206 | ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ | ||
| 207 | ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ | ||
| 208 | ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ | ||
| 209 | ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\ | ||
| 210 | ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\ | ||
| 211 | ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ | ||
| 212 | ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\ | ||
| 213 | ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ | ||
| 214 | ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done | ||
| 215 | dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree) | ||
| 216 | /dist[]_ALL *:/a\\ | ||
| 217 | @ HOST="\$(HOST)\" \\\\\\ | ||
| 218 | ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ | ||
| 219 | ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ | ||
| 220 | ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ | ||
| 221 | ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\ | ||
| 222 | ; if test "\$\$found" -eq "0" ; then : \\\\\\ | ||
| 223 | ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ | ||
| 224 | ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ | ||
| 225 | ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\ | ||
| 226 | ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done | ||
| 227 | dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree) | ||
| 228 | /dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\ | ||
| 229 | @ HOST="\$(HOST)\" \\\\\\ | ||
| 230 | ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\ | ||
| 231 | ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\ | ||
| 232 | ; found=$x echo \$\$BUILD | wc -w $x \\\\\\ | ||
| 233 | ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\ | ||
| 234 | ; if test "\$\$found" -eq "0" ; then : \\\\\\ | ||
| 235 | ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\ | ||
| 236 | ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ | ||
| 237 | ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\ | ||
| 238 | ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done | ||
| 239 | dnl special rule add-on: "distclean" removes all local builddirs completely | ||
| 240 | /distclean[]_ALL *:/a\\ | ||
| 241 | @ HOST="\$(HOST)\" \\\\\\ | ||
| 242 | ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\ | ||
| 243 | ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\ | ||
| 244 | ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\ | ||
| 245 | ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\ | ||
| 246 | ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\ | ||
| 247 | ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ | ||
| 248 | ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\ | ||
| 249 | ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\ | ||
| 250 | ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\ | ||
| 251 | ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\ | ||
| 252 | ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile | ||
| 253 | _EOF | ||
| 254 | cp "$tmp/conftemp.sed" "$SRC/makefile.sed~" ## DEBUGGING | ||
| 255 | $SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile | ||
| 256 | if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then | ||
| 257 | AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])]) | ||
| 258 | cat $SRC/END >>$SRC/Makefile | ||
| 259 | fi ; xxxx="####" | ||
| 260 | echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile | ||
| 261 | # sanity check | ||
| 262 | if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then | ||
| 263 | AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts]) | ||
| 264 | $SED -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $SRC/Makefile \ | ||
| 265 | >$SRC/Makefile~ | ||
| 266 | (test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null | ||
| 267 | fi | ||
| 268 | else | ||
| 269 | xxxx="\\#\\#\\#\\#" | ||
| 270 | # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed | ||
| 271 | echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed | ||
| 272 | $SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp | ||
| 273 | cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~" ## DEBUGGING | ||
| 274 | cp "$tmp/mkfile.tmp" "$SRC/makefiles.out~" ## DEBUGGING | ||
| 275 | if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then | ||
| 276 | AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure]) | ||
| 277 | rm "$tmp/mkfile.tmp" | ||
| 278 | else | ||
| 279 | AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure]) | ||
| 280 | mv "$tmp/mkfile.tmp" "$SRC/Makefile" | ||
| 281 | fi | ||
| 282 | fi | ||
| 283 | AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)]) | ||
| 284 | xxxx="####" | ||
| 285 | echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile | ||
| 286 | fi | ||
| 287 | popdef([END])dnl | ||
| 288 | AS_VAR_POPDEF([SED])dnl | ||
| 289 | AS_VAR_POPDEF([AUX])dnl | ||
| 290 | AS_VAR_POPDEF([SRC])dnl | ||
| 291 | AS_VAR_POPDEF([TOP])dnl | ||
| 292 | AS_VAR_POPDEF([SUB])dnl | ||
| 293 | ],[dnl | ||
| 294 | ax_enable_builddir_srcdir="$srcdir" # $srcdir | ||
| 295 | ax_enable_builddir_host="$HOST" # $HOST / $host | ||
| 296 | ax_enable_builddir_version="$VERSION" # $VERSION | ||
| 297 | ax_enable_builddir_package="$PACKAGE" # $PACKAGE | ||
| 298 | ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX | ||
| 299 | ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED | ||
| 300 | ax_enable_builddir="$ax_enable_builddir" # $SUB | ||
| 301 | ])dnl | ||
| 302 | ]) | ||
diff --git a/m4/ax_extend_srcdir.m4 b/m4/ax_extend_srcdir.m4 new file mode 100644 index 0000000..40f3787 --- /dev/null +++ b/m4/ax_extend_srcdir.m4 | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_extend_srcdir.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_EXTEND_SRCDIR | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # The AX_EXTEND_SRCDIR macro extends $srcdir by one path component. | ||
| 12 | # | ||
| 13 | # As an example, when working in /home/michael/i3-4.12/build and calling | ||
| 14 | # ../configure, your $srcdir is "..". After calling AX_EXTEND_SRCDIR, | ||
| 15 | # $srcdir will be set to "../../i3-4.12". | ||
| 16 | # | ||
| 17 | # The result of extending $srcdir is that filenames (e.g. in the output of | ||
| 18 | # the "backtrace" gdb command) will include one more path component of the | ||
| 19 | # absolute source path. The additional path component makes it easy for | ||
| 20 | # users to recognize which files belong to the PACKAGE, and -- provided a | ||
| 21 | # dist tarball was unpacked -- which version of PACKAGE was used. | ||
| 22 | # | ||
| 23 | # As an example, in "backtrace", you will see: | ||
| 24 | # | ||
| 25 | # #0 main (argc=1, argv=0x7fffffff1fc8) at ../../i3-4.12/src/main.c:187 | ||
| 26 | # | ||
| 27 | # instead of: | ||
| 28 | # | ||
| 29 | # #0 main (argc=1, argv=0x7fffffff1fc8) at ../src/main.c:187 | ||
| 30 | # | ||
| 31 | # In case your code uses the __FILE__ preprocessor directive to refer to | ||
| 32 | # the filename of the current source file (e.g. in debug messages), using | ||
| 33 | # the extended path might be undesirable. For this purpose, | ||
| 34 | # AX_EXTEND_SRCDIR defines the output variable AX_EXTEND_SRCDIR_CPPFLAGS, | ||
| 35 | # which can be added to AM_CPPFLAGS in Makefile.am in order to define the | ||
| 36 | # preprocessor directive STRIPPED__FILE__. As an example, when compiling | ||
| 37 | # the file "../../i3-4.12/src/main.c", STRIPPED__FILE__ evaluates to | ||
| 38 | # "main.c". | ||
| 39 | # | ||
| 40 | # There are some caveats: When $srcdir is "." (i.e. when ./configure was | ||
| 41 | # called instead of ../configure in a separate build directory), | ||
| 42 | # AX_EXTEND_SRCDIR will still extend $srcdir, but the intended effect will | ||
| 43 | # not be achieved because of the way automake specifies file paths: | ||
| 44 | # automake defines COMPILE to use "`test -f '$source' || echo | ||
| 45 | # '\$(srcdir)/'`$source" in order to prefer files in the current directory | ||
| 46 | # over specifying $srcdir explicitly. | ||
| 47 | # | ||
| 48 | # The AX_EXTEND_SRCDIR author is not aware of any way to influence this | ||
| 49 | # automake behavior. Patches very welcome. | ||
| 50 | # | ||
| 51 | # To work around this issue, you can use AX_ENABLE_BUILDDIR i.e. by adding | ||
| 52 | # the following code to configure.ac: | ||
| 53 | # | ||
| 54 | # AX_ENABLE_BUILDDIR | ||
| 55 | # dnl ... | ||
| 56 | # AX_EXTEND_SRCDIR | ||
| 57 | # | ||
| 58 | # Then also add this bit to Makefile.am (if you wish to use | ||
| 59 | # STRIPPED__FILE__ in your code): | ||
| 60 | # | ||
| 61 | # AM_CPPFLAGS = @AX_EXTEND_SRCDIR_CPPFLAGS@ | ||
| 62 | # | ||
| 63 | # LICENSE | ||
| 64 | # | ||
| 65 | # Copyright (c) 2016 Michael Stapelberg <michael@i3wm.org> | ||
| 66 | # | ||
| 67 | # Copying and distribution of this file, with or without modification, are | ||
| 68 | # permitted in any medium without royalty provided the copyright notice | ||
| 69 | # and this notice are preserved. This file is offered as-is, without any | ||
| 70 | # warranty. | ||
| 71 | |||
| 72 | #serial 3 | ||
| 73 | |||
| 74 | AC_DEFUN([AX_EXTEND_SRCDIR], | ||
| 75 | [dnl | ||
| 76 | AS_CASE([$srcdir], | ||
| 77 | [.|.*|/*], | ||
| 78 | [ | ||
| 79 | # pwd -P is specified in IEEE 1003.1 from 2004 | ||
| 80 | as_dir=`cd "$srcdir" && pwd -P` | ||
| 81 | as_base=`AS_BASENAME([$as_dir])` | ||
| 82 | srcdir=${srcdir}/../${as_base} | ||
| 83 | |||
| 84 | AC_SUBST([AX_EXTEND_SRCDIR_CPPFLAGS], ["-DSTRIPPED__FILE__=AS_ESCAPE([\"$$(basename $<)\"])"]) | ||
| 85 | ]) | ||
| 86 | ])dnl AX_EXTEND_SRCDIR | ||
diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4 new file mode 100644 index 0000000..cae1111 --- /dev/null +++ b/m4/ax_require_defined.m4 | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_require_defined.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_REQUIRE_DEFINED(MACRO) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have | ||
| 12 | # been defined and thus are available for use. This avoids random issues | ||
| 13 | # where a macro isn't expanded. Instead the configure script emits a | ||
| 14 | # non-fatal: | ||
| 15 | # | ||
| 16 | # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found | ||
| 17 | # | ||
| 18 | # It's like AC_REQUIRE except it doesn't expand the required macro. | ||
| 19 | # | ||
| 20 | # Here's an example: | ||
| 21 | # | ||
| 22 | # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) | ||
| 23 | # | ||
| 24 | # LICENSE | ||
| 25 | # | ||
| 26 | # Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org> | ||
| 27 | # | ||
| 28 | # Copying and distribution of this file, with or without modification, are | ||
| 29 | # permitted in any medium without royalty provided the copyright notice | ||
| 30 | # and this notice are preserved. This file is offered as-is, without any | ||
| 31 | # warranty. | ||
| 32 | |||
| 33 | #serial 1 | ||
| 34 | |||
| 35 | AC_DEFUN([AX_REQUIRE_DEFINED], [dnl | ||
| 36 | m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) | ||
| 37 | ])dnl AX_REQUIRE_DEFINED | ||
diff --git a/m4/ax_sanitizers.m4 b/m4/ax_sanitizers.m4 new file mode 100644 index 0000000..836d4af --- /dev/null +++ b/m4/ax_sanitizers.m4 | |||
| @@ -0,0 +1,130 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_sanitizers.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AX_SANITIZERS([SANITIZERS], [ENABLED-BY-DEFAULT], [ACTION-SUCCESS]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Offers users to enable one or more sanitizers (see | ||
| 12 | # https://github.com/google/sanitizers) with the corresponding | ||
| 13 | # --enable-<sanitizer>-sanitizer option. | ||
| 14 | # | ||
| 15 | # SANITIZERS is a whitespace-separated list of sanitizers to offer via | ||
| 16 | # --enable-<sanitizer>-sanitizer options, e.g. "address memory" for the | ||
| 17 | # address sanitizer and the memory sanitizer. If SANITIZERS is not specified, | ||
| 18 | # all known sanitizers to AX_SANITIZERS will be offered, which at the time of | ||
| 19 | # writing are "address memory undefined". | ||
| 20 | # NOTE that SANITIZERS is expanded at autoconf time, not at configure time, | ||
| 21 | # i.e. you cannot use shell variables in SANITIZERS. | ||
| 22 | # | ||
| 23 | # ENABLED-BY-DEFAULT is a whitespace-separated list of sanitizers which | ||
| 24 | # should be enabled by default, e.g. "memory undefined". Note that not all | ||
| 25 | # sanitizers can be combined, e.g. memory sanitizer cannot be enabled when | ||
| 26 | # address sanitizer is already enabled. | ||
| 27 | # Set ENABLED-BY-DEFAULT to a single whitespace in order to disable all | ||
| 28 | # sanitizers by default. | ||
| 29 | # ENABLED-BY-DEFAULT is expanded at configure time, so you can use shell | ||
| 30 | # variables. | ||
| 31 | # | ||
| 32 | # ACTION-SUCCESS allows to specify shell commands to execute on success, i.e. | ||
| 33 | # when one of the sanitizers was successfully enabled. This is a good place | ||
| 34 | # to call AC_DEFINE for any precompiler constants you might need to make your | ||
| 35 | # code play nice with sanitizers. | ||
| 36 | # | ||
| 37 | # The variable ax_enabled_sanitizers contains a whitespace-separated list of | ||
| 38 | # all enabled sanitizers, so that you can print them at the end of configure, | ||
| 39 | # if you wish. | ||
| 40 | # | ||
| 41 | # The additional --enable-sanitizers option allows users to enable/disable | ||
| 42 | # all sanitizers, effectively overriding ENABLED-BY-DEFAULT. | ||
| 43 | # | ||
| 44 | # EXAMPLES | ||
| 45 | # | ||
| 46 | # AX_SANITIZERS([address]) | ||
| 47 | # dnl offer users to enable address sanitizer via --enable-address-sanitizer | ||
| 48 | # | ||
| 49 | # is_debug_build=… | ||
| 50 | # if test "x$is_debug_build" = "xyes"; then | ||
| 51 | # default_sanitizers="address memory" | ||
| 52 | # else | ||
| 53 | # default_sanitizers= | ||
| 54 | # fi | ||
| 55 | # AX_SANITIZERS([address memory], [$default_sanitizers]) | ||
| 56 | # dnl enable address sanitizer and memory sanitizer by default for debug | ||
| 57 | # dnl builds, e.g. when building from git instead of a dist tarball. | ||
| 58 | # | ||
| 59 | # AX_SANITIZERS(, , [ | ||
| 60 | # AC_DEFINE([SANITIZERS_ENABLED], | ||
| 61 | # [], | ||
| 62 | # [At least one sanitizer was enabled])]) | ||
| 63 | # dnl enable all sanitizers known to AX_SANITIZERS by default and set the | ||
| 64 | # dnl SANITIZERS_ENABLED precompiler constant. | ||
| 65 | # | ||
| 66 | # AX_SANITIZERS(, [ ]) | ||
| 67 | # dnl provide all sanitizers, but enable none by default. | ||
| 68 | # | ||
| 69 | # LICENSE | ||
| 70 | # | ||
| 71 | # Copyright (c) 2016 Michael Stapelberg <michael@i3wm.org> | ||
| 72 | # | ||
| 73 | # Copying and distribution of this file, with or without modification, | ||
| 74 | # are permitted in any medium without royalty provided the copyright | ||
| 75 | # notice and this notice are preserved. This file is offered as-is, | ||
| 76 | # without any warranty. | ||
| 77 | |||
| 78 | AC_DEFUN([AX_SANITIZERS], | ||
| 79 | [AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) | ||
| 80 | AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) | ||
| 81 | AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) | ||
| 82 | AC_ARG_ENABLE(sanitizers, | ||
| 83 | AS_HELP_STRING( | ||
| 84 | [--enable-sanitizers], | ||
| 85 | [enable all known sanitizers]), | ||
| 86 | [ax_sanitizers_default=$enableval], | ||
| 87 | [ax_sanitizers_default=]) | ||
| 88 | ax_enabled_sanitizers= | ||
| 89 | m4_foreach_w([mysan], m4_default($1, [address memory undefined]), [ | ||
| 90 | dnl If ax_sanitizers_default is unset, i.e. the user neither explicitly | ||
| 91 | dnl enabled nor explicitly disabled all sanitizers, we get the default value | ||
| 92 | dnl for this sanitizer based on whether it is listed in ENABLED-BY-DEFAULT. | ||
| 93 | AS_IF([test "x$ax_sanitizers_default" = "x"], [dnl | ||
| 94 | ax_sanitizer_default= | ||
| 95 | for mycheck in m4_default([$2], [address memory undefined]); do | ||
| 96 | AS_IF([test "x$mycheck" = "x[]mysan"], [ax_sanitizer_default=yes]) | ||
| 97 | done | ||
| 98 | AS_IF([test "x$ax_sanitizer_default" = "x"], [ax_sanitizer_default=no]) | ||
| 99 | ], | ||
| 100 | [ax_sanitizer_default=$ax_sanitizers_default]) | ||
| 101 | AC_ARG_ENABLE(mysan[]-sanitizer, | ||
| 102 | AS_HELP_STRING( | ||
| 103 | [--enable-[]mysan[]-sanitizer], | ||
| 104 | [enable -fsanitize=mysan]), | ||
| 105 | [ax_sanitizer_enabled=$enableval], | ||
| 106 | [ax_sanitizer_enabled=$ax_sanitizer_default]) | ||
| 107 | |||
| 108 | AS_IF([test "x$ax_sanitizer_enabled" = "xyes"], [ | ||
| 109 | dnl Not using AX_APPEND_COMPILE_FLAGS and AX_APPEND_LINK_FLAGS because they | ||
| 110 | dnl lack the ability to specify ACTION-SUCCESS. | ||
| 111 | AX_CHECK_COMPILE_FLAG([-fsanitize=[]mysan], [ | ||
| 112 | AX_CHECK_LINK_FLAG([-fsanitize=[]mysan], [ | ||
| 113 | AX_APPEND_FLAG([-fsanitize=[]mysan], []) | ||
| 114 | dnl If and only if libtool is being used, LDFLAGS needs to contain -Wc,-fsanitize=…. | ||
| 115 | dnl See e.g. https://sources.debian.net/src/systemd/231-7/configure.ac/?hl=128#L135 | ||
| 116 | dnl TODO: how can recognize that situation and add -Wc,? | ||
| 117 | AX_APPEND_FLAG([-fsanitize=[]mysan], [LDFLAGS]) | ||
| 118 | dnl TODO: add -fPIE -pie for memory | ||
| 119 | # -fno-omit-frame-pointer results in nicer stack traces in error | ||
| 120 | # messages, see http://clang.llvm.org/docs/AddressSanitizer.html#usage | ||
| 121 | AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer], [ | ||
| 122 | AX_APPEND_FLAG([-fno-omit-frame-pointer], [])]) | ||
| 123 | dnl TODO: at least for clang, we should specify exactly -O1, not -O2 or -O0, so that performance is reasonable but stacktraces are not tampered with (due to inlining), see http://clang.llvm.org/docs/AddressSanitizer.html#usage | ||
| 124 | m4_default([$3], :) | ||
| 125 | ax_enabled_sanitizers="[]mysan $ax_enabled_sanitizers" | ||
| 126 | ]) | ||
| 127 | ]) | ||
| 128 | ]) | ||
| 129 | ])dnl | ||
| 130 | ])dnl AX_SANITIZERS | ||
