summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-08-06 18:00:00 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-08-07 08:00:00 +0000
commit84726f58785a22847cb67c2e009b5be0e207a256 (patch)
tree4d2b87abc2c127f6fe01d75a1074c01df5c8fbe8
parent650273e77b643f14d937f26f8b628481a4b4b56a (diff)
downloadlinux-pam-git-84726f58785a22847cb67c2e009b5be0e207a256.tar.gz
m4: rewrite __attribute__((unused)) check
Rewrite using AC_CACHE_CHECK to create a more readable autoconf macro. * m4/attribute.m4: New file. * m4/japhar_grep_cflags.m4: Remove. * m4/.gitignore: Replace japhar_grep_cflags.m4 with attribute.m4. * configure.ac: Replace AC_C___ATTRIBUTE__ with PAM_ATTRIBUTE_UNUSED.
-rw-r--r--configure.ac2
-rw-r--r--m4/.gitignore2
-rw-r--r--m4/attribute.m416
-rw-r--r--m4/japhar_grep_cflags.m432
4 files changed, 18 insertions, 34 deletions
diff --git a/configure.ac b/configure.ac
index a01cca9f..a8e5d9ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,7 +119,7 @@ if test "x${BUILD_LDFLAGS+set}" != "xset" ; then
fi
AC_SUBST(BUILD_LDFLAGS)
-AC_C___ATTRIBUTE__
+PAM_ATTRIBUTE_UNUSED
dnl
dnl Check if --version-script is supported by ld
diff --git a/m4/.gitignore b/m4/.gitignore
index 4cbba3eb..6937d745 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -1,5 +1,5 @@
*.m4
-!japhar_grep_cflags.m4
+!attribute.m4
!jh_path_xml_catalog.m4
!ld-as-needed.m4
!ld-no-undefined.m4
diff --git a/m4/attribute.m4 b/m4/attribute.m4
new file mode 100644
index 00000000..3aa2e5fc
--- /dev/null
+++ b/m4/attribute.m4
@@ -0,0 +1,16 @@
+#!/usr/bin/m4
+dnl Check for compiler attributes
+
+AC_DEFUN([PAM_ATTRIBUTE_UNUSED], [
+ AC_CACHE_CHECK([for __attribute__((unused))], [pam_cv_attribute_unused],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[int fun(int i __attribute__((unused)));]],
+ [[return fun(0);]])],
+ [pam_cv_attribute_unused=yes],
+ [pam_cv_attribute_unused=no])])
+ AS_IF([test "$pam_cv_attribute_unused" = yes],
+ [unused='__attribute__((unused))'],
+ [unused=])
+ AC_DEFINE_UNQUOTED([UNUSED], [$unused],
+ [Define if the compiler supports __attribute__((unused))])
+])
diff --git a/m4/japhar_grep_cflags.m4 b/m4/japhar_grep_cflags.m4
deleted file mode 100644
index 4e8c4598..00000000
--- a/m4/japhar_grep_cflags.m4
+++ /dev/null
@@ -1,32 +0,0 @@
-dnl
-dnl Test for __attribute__ ((unused))
-dnl Based on code from the tcpdump version 3.7.2 source.
-dnl
-
-AC_DEFUN([AC_C___ATTRIBUTE__], [
-AC_MSG_CHECKING(for __attribute__)
-AC_CACHE_VAL(ac_cv___attribute__, [
-AC_COMPILE_IFELSE([
-AC_LANG_PROGRAM([[
-#include <stdlib.h>
-static void foo (void) __attribute__ ((unused));
-
-static void
-foo (void)
-{
- exit(1);
-}
-]],
-[[
- exit (0);
-]])],
-[ac_cv___attribute__=yes],
-[ac_cv___attribute__=no])])
-if test "$ac_cv___attribute__" = "yes"; then
- AC_DEFINE(UNUSED, __attribute__ ((unused)), [define if your compiler has __att
-ribute__ ((unused))])
-else
- AC_DEFINE(UNUSED,,)
-fi
-AC_MSG_RESULT($ac_cv___attribute__)
-])