emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8c0671b9cbf 02/16: Avoid duplicate configure-time codeset tests


From: Paul Eggert
Subject: master 8c0671b9cbf 02/16: Avoid duplicate configure-time codeset tests
Date: Sun, 14 May 2023 22:28:24 -0400 (EDT)

branch: master
commit 8c0671b9cbf56bec99a7de63ead33076abb754b1
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Avoid duplicate configure-time codeset tests
    
    * admin/merge-gnulib: Copy m4/codeset.m4 too.  This is mostly for
    documentation, as it’s now automatically copied by other modules.
    * configure.ac (EMACS_PAPER_WIDTH): New macro.  This relies on
    Gnulib, to avoid duplicate tests for HAVE_LANGINFO_CODESET.
---
 admin/merge-gnulib |  2 ++
 configure.ac       | 38 +++++++++++++++-----------------------
 2 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 917ddda1fd5..7c82be98608 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -132,5 +132,7 @@ cp -- "$gnulib_srcdir"/build-aux/config.guess \
 cp -- "$gnulib_srcdir"/lib/af_alg.h \
       "$gnulib_srcdir"/lib/save-cwd.h \
    "$src"lib &&
+cp -- "$gnulib_srcdir"/m4/codeset.m4 \
+   "$src"m4 &&
 { test -z "$src" || cd "$src"; } &&
 ./autogen.sh
diff --git a/configure.ac b/configure.ac
index dd247e144f4..8b08100464e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5409,29 +5409,21 @@ if test "${emacs_cv_links_glib}" = "yes"; then
 fi
 AC_SUBST([XGSELOBJ])
 
-dnl Adapted from Haible's version.
-AC_CACHE_CHECK([for nl_langinfo and CODESET], [emacs_cv_langinfo_codeset],
-  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
-    [[char *cs = nl_langinfo(CODESET);]])],
-    [emacs_cv_langinfo_codeset=yes],
-    [emacs_cv_langinfo_codeset=no])
-  ])
-if test "$emacs_cv_langinfo_codeset" = yes; then
-  AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
-    [Define if you have <langinfo.h> and nl_langinfo (CODESET).])
-
-  AC_CACHE_CHECK([for nl_langinfo and _NL_PAPER_WIDTH],
-    [emacs_cv_langinfo__nl_paper_width],
-    [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
-      [[char *cs = nl_langinfo (_NL_PAPER_WIDTH);]])],
-      [emacs_cv_langinfo__nl_paper_width=yes],
-      [emacs_cv_langinfo__nl_paper_width=no])
-    ])
-  if test "$emacs_cv_langinfo__nl_paper_width" = yes; then
-    AC_DEFINE([HAVE_LANGINFO__NL_PAPER_WIDTH], [1],
-      [Define if you have <langinfo.h> and nl_langinfo (_NL_PAPER_WIDTH).])
-  fi
-fi
+AC_DEFUN([EMACS_PAPER_WIDTH],
+  [AC_REQUIRE([AM_LANGINFO_CODESET])
+   AS_IF([test "$am_cv_langinfo_codeset" = yes],
+     [AC_CACHE_CHECK([for nl_langinfo and _NL_PAPER_WIDTH],
+       [emacs_cv_langinfo__nl_paper_width],
+       [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
+         [[char *cs = nl_langinfo (_NL_PAPER_WIDTH);]])],
+         [emacs_cv_langinfo__nl_paper_width=yes],
+         [emacs_cv_langinfo__nl_paper_width=no])
+       ])
+      AS_IF([test "$emacs_cv_langinfo__nl_paper_width" = yes],
+       [AC_DEFINE([HAVE_LANGINFO__NL_PAPER_WIDTH], [1],
+          [Define if you have <langinfo.h>
+           and nl_langinfo (_NL_PAPER_WIDTH).])])])])
+EMACS_PAPER_WIDTH
 
 AC_TYPE_MBSTATE_T
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]