Skip to content

Commit 1fbbb2d

Browse files
Explorer09BenBE
authored andcommitted
build: Update ax_check_compile_flag module
The AX_CHECK_COMPILE_FLAG macro included in htop's configure was serial 6 (introduced in commit 2cde4a7). Update to the latest upstream version (serial 11). Also import the macro as a separate file rather than copy-and-paste to configure.ac. This makes the macro not subject to htop's coding style and it also makes future update easier. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 09ba4c1 commit 1fbbb2d

File tree

2 files changed

+87
-24
lines changed

2 files changed

+87
-24
lines changed

configure.ac

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AC_PREREQ([2.69])
1717
AC_INIT([htop], [m4_join([-],m4_defn([htop_release_version]),m4_defn([htop_git_version]))], [htop@groups.io], [], [https://htop.dev/])
1818

1919
AC_CONFIG_SRCDIR([htop.c])
20+
AC_CONFIG_MACRO_DIRS([m4])
2021
AC_CONFIG_AUX_DIR([build-aux])
2122
AC_CONFIG_HEADERS([config.h])
2223

@@ -1432,35 +1433,34 @@ AM_CFLAGS="$AM_CFLAGS\
14321433
-Wunused\
14331434
-Wwrite-strings"
14341435

1435-
dnl https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
1436-
AC_DEFUN(
1436+
m4_ifdef(
14371437
[AX_CHECK_COMPILE_FLAG],
14381438
[
1439-
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
1440-
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
1441-
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
1442-
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
1443-
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
1444-
[AS_VAR_SET(CACHEVAR,[yes])],
1445-
[AS_VAR_SET(CACHEVAR,[no])])
1446-
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags
1447-
])
1448-
AS_VAR_IF(CACHEVAR,yes,
1449-
[m4_default([$2], :)],
1450-
[m4_default([$3], :)]
1439+
dnl During the check of '-Wextra-semi-stmt' we must treat
1440+
dnl 'extra-semi-stmt' as a non-error because the AC_LANG_PROGRAM
1441+
dnl template will generate a warning of this (by design).
1442+
AX_CHECK_COMPILE_FLAG(
1443+
[-Wextra-semi-stmt],
1444+
[AM_CFLAGS="$AM_CFLAGS -Wextra-semi-stmt"],
1445+
[],
1446+
[-Wno-error=extra-semi-stmt]
1447+
)
1448+
1449+
AX_CHECK_COMPILE_FLAG(
1450+
[-Wimplicit-int-conversion],
1451+
[AM_CFLAGS="$AM_CFLAGS -Wimplicit-int-conversion"]
1452+
)
1453+
AX_CHECK_COMPILE_FLAG(
1454+
[-Wnull-dereference],
1455+
[AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"]
1456+
)
1457+
], [
1458+
m4_warn(
1459+
[syntax],
1460+
[module m4/ax_check_compile_flag.m4 is missing]
14511461
)
1452-
AS_VAR_POPDEF([CACHEVAR])dnl
14531462
]
14541463
)
1455-
dnl AX_CHECK_COMPILE_FLAGS
1456-
1457-
dnl During the check of '-Wextra-semi-stmt' we must treat
1458-
dnl 'extra-semi-stmt' as a non-error because the AC_LANG_PROGRAM
1459-
dnl template will generate a warning of this (by design).
1460-
AX_CHECK_COMPILE_FLAG([-Wextra-semi-stmt], [AM_CFLAGS="$AM_CFLAGS -Wextra-semi-stmt"], , [-Werror -Wno-error=extra-semi-stmt])
1461-
1462-
AX_CHECK_COMPILE_FLAG([-Wimplicit-int-conversion], [AM_CFLAGS="$AM_CFLAGS -Wimplicit-int-conversion"], , [-Werror])
1463-
AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
14641464

14651465
AC_ARG_ENABLE(
14661466
[werror],

m4/ax_check_compile_flag.m4

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# ===========================================================================
2+
# https://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+
# Copying and distribution of this file, with or without modification, are
33+
# permitted in any medium without royalty provided the copyright notice
34+
# and this notice are preserved. This file is offered as-is, without any
35+
# warranty.
36+
37+
#serial 11
38+
39+
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
40+
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41+
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
42+
AC_CACHE_CHECK([whether the _AC_LANG compiler accepts $1], CACHEVAR, [
43+
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
44+
if test x"m4_case(_AC_LANG,
45+
[C], [$GCC],
46+
[C++], [$GXX],
47+
[Fortran], [$GFC],
48+
[Fortran 77], [$G77],
49+
[Objective C], [$GOBJC],
50+
[Objective C++], [$GOBJCXX],
51+
[no])" = xyes ; then
52+
add_gnu_werror="-Werror"
53+
fi
54+
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1 $add_gnu_werror"
55+
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
56+
[AS_VAR_SET(CACHEVAR,[yes])],
57+
[AS_VAR_SET(CACHEVAR,[no])])
58+
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
59+
AS_VAR_IF(CACHEVAR,yes,
60+
[m4_default([$2], :)],
61+
[m4_default([$3], :)])
62+
AS_VAR_POPDEF([CACHEVAR])dnl
63+
])dnl AX_CHECK_COMPILE_FLAGS

0 commit comments

Comments
 (0)