summaryrefslogtreecommitdiffstats
path: root/gl/m4/gnulib-common.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/gnulib-common.m4')
-rw-r--r--gl/m4/gnulib-common.m4133
1 files changed, 129 insertions, 4 deletions
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 12b19db..30911d1 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
1# gnulib-common.m4 serial 67 1# gnulib-common.m4 serial 73
2dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -69,7 +69,9 @@ AC_DEFUN([gl_COMMON_BODY], [
69[/* Attributes. */ 69[/* Attributes. */
70#if (defined __has_attribute \ 70#if (defined __has_attribute \
71 && (!defined __clang_minor__ \ 71 && (!defined __clang_minor__ \
72 || 3 < __clang_major__ + (5 <= __clang_minor__))) 72 || (defined __apple_build_version__ \
73 ? 6000000 <= __apple_build_version__ \
74 : 3 < __clang_major__ + (5 <= __clang_minor__))))
73# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) 75# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
74#else 76#else
75# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr 77# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
@@ -104,6 +106,10 @@ AC_DEFUN([gl_COMMON_BODY], [
104#endif 106#endif
105 107
106#ifdef __has_c_attribute 108#ifdef __has_c_attribute
109# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710 \
110 && _GL_GNUC_PREREQ (4, 6))
111# pragma GCC diagnostic ignored "-Wpedantic"
112# endif
107# define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__) 113# define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__)
108#else 114#else
109# define _GL_HAS_C_ATTRIBUTE(attr) 0 115# define _GL_HAS_C_ATTRIBUTE(attr) 0
@@ -181,7 +187,12 @@ AC_DEFUN([gl_COMMON_BODY], [
181#else 187#else
182# define _GL_ATTRIBUTE_DEALLOC(f, i) 188# define _GL_ATTRIBUTE_DEALLOC(f, i)
183#endif 189#endif
184#define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) 190/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
191 to use this earlier definition, since <stdlib.h> may not have been included
192 yet. */
193#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
194# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
195#endif
185 196
186/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated. 197/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
187 The compiler may warn if the entity is used. */ 198 The compiler may warn if the entity is used. */
@@ -813,6 +824,24 @@ AC_DEFUN([gl_CACHE_VAL_SILENT],
813 ]) 824 ])
814]) 825])
815 826
827# gl_CONDITIONAL(conditional, condition)
828# is like AM_CONDITIONAL(conditional, condition), except that it does not
829# produce an error
830# configure: error: conditional "..." was never defined.
831# Usually this means the macro was only invoked conditionally.
832# when only invoked conditionally. Instead, in that case, both the _TRUE
833# and the _FALSE case are disabled.
834AC_DEFUN([gl_CONDITIONAL],
835[
836 pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
837 AM_CONDITIONAL([$1], [$2])
838 popdef([AC_CONFIG_COMMANDS_PRE])dnl
839 if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
840 [$1]_TRUE='#'
841 [$1]_FALSE='#'
842 fi
843])
844
816# gl_CC_ALLOW_WARNINGS 845# gl_CC_ALLOW_WARNINGS
817# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option 846# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
818# that reverts a preceding '-Werror' option, if available. 847# that reverts a preceding '-Werror' option, if available.
@@ -879,6 +908,102 @@ AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
879 AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS]) 908 AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
880]) 909])
881 910
911# gl_CC_GNULIB_WARNINGS
912# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
913# set that enables or disables warnings as suitable for the Gnulib coding style.
914AC_DEFUN([gl_CC_GNULIB_WARNINGS],
915[
916 AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
917 dnl Assume that the compiler supports -Wno-* options only if it also supports
918 dnl -Wno-error.
919 GL_CFLAG_GNULIB_WARNINGS=''
920 if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
921 dnl Enable these warning options:
922 dnl
923 dnl GCC clang
924 dnl -Wno-cast-qual >= 3 >= 3.9
925 dnl -Wno-conversion >= 3 >= 3.9
926 dnl -Wno-float-conversion >= 4.9 >= 3.9
927 dnl -Wno-float-equal >= 3 >= 3.9
928 dnl -Wimplicit-fallthrough >= 7 >= 3.9
929 dnl -Wno-pedantic >= 4.8 >= 3.9
930 dnl -Wno-sign-compare >= 3 >= 3.9
931 dnl -Wno-sign-conversion >= 4.3 >= 3.9
932 dnl -Wno-type-limits >= 4.3 >= 3.9
933 dnl -Wno-undef >= 3 >= 3.9
934 dnl -Wno-unsuffixed-float-constants >= 4.5
935 dnl -Wno-unused-function >= 3 >= 3.9
936 dnl -Wno-unused-parameter >= 3 >= 3.9
937 dnl
938 cat > conftest.c <<\EOF
939 #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
940 -Wno-cast-qual
941 -Wno-conversion
942 -Wno-float-equal
943 -Wno-sign-compare
944 -Wno-undef
945 -Wno-unused-function
946 -Wno-unused-parameter
947 #endif
948 #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
949 -Wno-float-conversion
950 #endif
951 #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
952 -Wimplicit-fallthrough
953 #endif
954 #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
955 -Wno-pedantic
956 #endif
957 #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
958 -Wno-sign-conversion
959 -Wno-type-limits
960 #endif
961 #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
962 -Wno-unsuffixed-float-constants
963 #endif
964EOF
965 gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
966 if AC_TRY_EVAL([gl_command]); then
967 gl_options=`grep -v '#' conftest.out`
968 for word in $gl_options; do
969 GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
970 done
971 fi
972 rm -f conftest.c conftest.out
973 fi
974 AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
975])
976
977dnl gl_CONDITIONAL_HEADER([foo.h])
978dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
979dnl and produces
980dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
981dnl on whether GL_GENERATE_FOO_H is true or false,
982dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
983dnl the shell variable GL_GENERATE_FOO_H.
984AC_DEFUN([gl_CONDITIONAL_HEADER],
985[
986 m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
987 m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
988 m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
989 case "$gl_generate_var" in
990 false) gl_header_name='' ;;
991 true)
992 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
993 dnl versa.
994 if test -z "$gl_header_name"; then
995 gl_header_name="${gl_source_base_prefix}$1"
996 fi
997 ;;
998 *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
999 esac
1000 AC_SUBST(gl_header_name)
1001 gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
1002 m4_popdef([gl_generate_cond])
1003 m4_popdef([gl_generate_var])
1004 m4_popdef([gl_header_name])
1005])
1006
882dnl Expands to some code for use in .c programs that, on native Windows, defines 1007dnl Expands to some code for use in .c programs that, on native Windows, defines
883dnl the Microsoft deprecated alias function names to the underscore-prefixed 1008dnl the Microsoft deprecated alias function names to the underscore-prefixed
884dnl actual function names. With this macro, these function names are available 1009dnl actual function names. With this macro, these function names are available