Skip to content

Commit 2f1f7f9

Browse files
committed
Update m4/attributes.m4 to a newer upstream version
This was the last one from systemd before they switched to Meson. Needed to update some of the autoconf script to match a change w.r.t. CFLAGS in the upstream attributes.m4.
1 parent e35241d commit 2f1f7f9

File tree

3 files changed

+42
-58
lines changed

3 files changed

+42
-58
lines changed

Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ LIBS = $(GTK_LIBS) \
2828
AM_CPPFLAGS = -DPROGRAM_NAME=\"Tg\" -DVERSION=\"$(PACKAGE_VERSION)\"
2929
tg_timer_dbg_CPPFLAGS = $(AM_CPPFLAGS) -DDEBUG
3030

31-
AM_CFLAGS = $(GTK_CFLAGS) \
31+
AM_CFLAGS = $(WARNINGFLAGS) \
32+
$(GTK_CFLAGS) \
3233
$(GTHREAD_CFLAGS) \
3334
$(PORTAUDIO_CFLAGS) \
3435
$(FFTW_CFLAGS)

configure.ac

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ AC_INIT([Tg], [tg_version], [[email protected]], [tg-timer], [https://github.co
55
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
66

77
AC_PROG_CC
8+
AC_LANG(C)
89
AC_CHECK_LIB([pthread], [pthread_mutex_init], [], [AC_MSG_ERROR([pthread not found])])
910
AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([libm not found])])
1011
PKG_CHECK_MODULES([GTK], [gtk+-3.0 glib-2.0])
@@ -18,7 +19,8 @@ AM_CONDITIONAL([BE_WINDOWS], [test x$OS = xWindows_NT])
1819
AM_COND_IF([BE_WINDOWS], [AC_CONFIG_LINKS([icons/tg-timer.ico:icons/tg-timer.ico])])
1920

2021
CC_CHECK_LDFLAGS([-Wl,--as-needed], [AC_SUBST([AM_LDFLAGS], [-Wl,--as-needed])], [])
21-
CC_CHECK_CFLAGS_APPEND([-Wall -Wextra], [], [])
22+
CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-Wall -Wextra])
23+
AC_SUBST([WARNINGFLAGS], $with_cflags)
2224

2325
AC_OUTPUT([Makefile icons/Makefile])
2426

m4/attributes.m4

+37-56
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
dnl Macros to check the presence of generic (non-typed) symbols.
22
dnl Copyright (c) 2006-2008 Diego Pettenò <[email protected]>
33
dnl Copyright (c) 2006-2008 xine project
4+
dnl Copyright (c) 2012 Lucas De Marchi <[email protected]>
45
dnl
56
dnl This program is free software; you can redistribute it and/or modify
67
dnl it under the terms of the GNU General Public License as published by
@@ -32,52 +33,32 @@ dnl distribute a modified version of the Autoconf Macro, you may extend
3233
dnl this special exception to the GPL to apply to your modified version as
3334
dnl well.
3435

35-
dnl Check if the flag is supported by compiler
36-
dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
37-
38-
AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
39-
AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
40-
[ac_save_CFLAGS="$CFLAGS"
41-
CFLAGS="$CFLAGS $1"
42-
AC_COMPILE_IFELSE([int a;],
43-
[eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
44-
[eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
45-
CFLAGS="$ac_save_CFLAGS"
46-
])
47-
48-
AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
49-
[$2], [$3])
50-
])
51-
52-
dnl Check if the flag is supported by compiler (cacheable)
53-
dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
54-
55-
AC_DEFUN([CC_CHECK_CFLAGS], [
56-
AC_CACHE_CHECK([if $CC supports $1 flag],
57-
AS_TR_SH([cc_cv_cflags_$1]),
58-
CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
59-
)
60-
61-
AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
62-
[$2], [$3])
63-
])
64-
65-
dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
66-
dnl Check for CFLAG and appends them to CFLAGS if supported
67-
AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
68-
AC_CACHE_CHECK([if $CC supports $1 flag],
69-
AS_TR_SH([cc_cv_cflags_$1]),
70-
CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
71-
)
72-
73-
AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
74-
[CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
36+
dnl Check if FLAG in ENV-VAR is supported by compiler and append it
37+
dnl to WHERE-TO-APPEND variable. Note that we invert -Wno-* checks to
38+
dnl -W* as gcc cannot test for negated warnings. If a C snippet is passed,
39+
dnl use it, otherwise use a simple main() definition that just returns 0.
40+
dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG], [C-SNIPPET])
41+
42+
AC_DEFUN([CC_CHECK_FLAG_APPEND], [
43+
AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2],
44+
AS_TR_SH([cc_cv_$2_$3]),
45+
[eval "AS_TR_SH([cc_save_$2])='${$2}'"
46+
eval "AS_TR_SH([$2])='${cc_save_$2} -Werror `echo "$3" | sed 's/^-Wno-/-W/'`'"
47+
AC_LINK_IFELSE([AC_LANG_SOURCE(ifelse([$4], [],
48+
[int main(void) { return 0; } ],
49+
[$4]))],
50+
[eval "AS_TR_SH([cc_cv_$2_$3])='yes'"],
51+
[eval "AS_TR_SH([cc_cv_$2_$3])='no'"])
52+
eval "AS_TR_SH([$2])='$cc_save_$2'"])
53+
54+
AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes],
55+
[eval "$1='${$1} $3'"])
7556
])
7657

77-
dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
78-
AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
79-
for flag in $1; do
80-
CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
58+
dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2], [C-SNIPPET])
59+
AC_DEFUN([CC_CHECK_FLAGS_APPEND], [
60+
for flag in [$3]; do
61+
CC_CHECK_FLAG_APPEND([$1], [$2], $flag, [$4])
8162
done
8263
])
8364

@@ -112,13 +93,13 @@ AC_DEFUN([CC_NOUNDEFINED], [
11293
*-freebsd* | *-openbsd*) ;;
11394
*)
11495
dnl First of all check for the --no-undefined variant of GNU ld. This allows
115-
dnl for a much more readable commandline, so that people can understand what
96+
dnl for a much more readable command line, so that people can understand what
11697
dnl it does without going to look for what the heck -z defs does.
117-
for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
118-
CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
119-
break
98+
for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
99+
CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
100+
break
120101
done
121-
;;
102+
;;
122103
esac
123104
124105
AC_SUBST([LDFLAGS_NOUNDEFINED])
@@ -147,7 +128,7 @@ AC_DEFUN([CC_CHECK_ATTRIBUTE], [
147128
AS_TR_SH([cc_cv_attribute_$1]),
148129
[ac_save_CFLAGS="$CFLAGS"
149130
CFLAGS="$CFLAGS $cc_cv_werror"
150-
AC_COMPILE_IFELSE([$3],
131+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
151132
[eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
152133
[eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
153134
CFLAGS="$ac_save_CFLAGS"
@@ -254,8 +235,8 @@ AC_DEFUN([CC_FLAG_VISIBILITY], [
254235
[cc_flag_visibility_save_CFLAGS="$CFLAGS"
255236
CFLAGS="$CFLAGS $cc_cv_werror"
256237
CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
257-
cc_cv_flag_visibility='yes',
258-
cc_cv_flag_visibility='no')
238+
cc_cv_flag_visibility='yes',
239+
cc_cv_flag_visibility='no')
259240
CFLAGS="$cc_flag_visibility_save_CFLAGS"])
260241
261242
AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
@@ -271,11 +252,11 @@ AC_DEFUN([CC_FUNC_EXPECT], [
271252
[cc_cv_func_expect],
272253
[ac_save_CFLAGS="$CFLAGS"
273254
CFLAGS="$CFLAGS $cc_cv_werror"
274-
AC_COMPILE_IFELSE(
255+
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
275256
[int some_function() {
276257
int a = 3;
277258
return (int)__builtin_expect(a, 3);
278-
}],
259+
}])],
279260
[cc_cv_func_expect=yes],
280261
[cc_cv_func_expect=no])
281262
CFLAGS="$ac_save_CFLAGS"
@@ -295,11 +276,11 @@ AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
295276
[ac_save_CFLAGS="$CFLAGS"
296277
CFLAGS="$CFLAGS $cc_cv_werror"
297278
for cc_attribute_align_try in 64 32 16 8 4 2; do
298-
AC_COMPILE_IFELSE([
279+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
299280
int main() {
300281
static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
301282
return c;
302-
}], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
283+
}])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
303284
done
304285
CFLAGS="$ac_save_CFLAGS"
305286
])

0 commit comments

Comments
 (0)