VirtualBox

source: kBuild/trunk/src/sed/configure.ac@ 3613

最後變更 在這個檔案從3613是 3613,由 bird 提交於 6 月 前

src/sed: Merged in changes between 4.1.5 and 4.9 from the vendor branch. (svn merge /vendor/sed/4.1.5 /vendor/sed/current .)

檔案大小: 9.5 KB
 
1# Copyright (C) 1993-2022 Free Software Foundation, Inc.
2
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16dnl Process this file with -*- autoconf -*- to produce a configure script.
17AC_INIT([GNU sed],
18 m4_esyscmd([build-aux/git-version-gen .tarball-version]),
19 [[email protected]])
20AC_CONFIG_AUX_DIR(build-aux)
21AC_CONFIG_SRCDIR([sed/sed.c])
22AC_CONFIG_HEADERS([config.h:config_h.in])
23AC_PREREQ([2.64])
24AM_INIT_AUTOMAKE([1.11.1 dist-xz color-tests parallel-tests subdir-objects])
25AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
26AC_CONFIG_MACRO_DIR([m4])
27
28AC_PROG_CC
29AM_PROG_CC_C_O
30gl_EARLY
31gl_INIT
32gl_DISABLE_THREADS
33
34# Ensure VLAs are not used.
35# Note -Wvla is implicitly added by gl_MANYWARN_ALL_GCC
36AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
37
38# The test suite needs to know if we have a working perl.
39AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
40
41# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
42# ------------------------------------------------
43# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
44# Otherwise, run RUN-IF-NOT-FOUND.
45AC_DEFUN([gl_GCC_VERSION_IFELSE],
46 [AC_PREPROC_IFELSE(
47 [AC_LANG_PROGRAM(
48 [[
49#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
50/* ok */
51#else
52# error "your version of gcc is older than $1.$2"
53#endif
54 ]]),
55 ], [$3], [$4])
56 ]
57)
58
59AC_CACHE_CHECK([whether "rt" can be used with fopen], [sed_cv_fopen_rt], [
60AC_RUN_IFELSE(
61 [AC_LANG_SOURCE([[
62#include <stdio.h>
63#include <errno.h>
64
65int main()
66{
67 FILE *fp;
68 int result;
69 errno = 0;
70 fp = fopen ("conftest.c", "rt");
71 if (fp) fclose (fp);
72 return fp ? 0 : 1;
73}]])], [sed_cv_fopen_rt=yes],
74 [sed_cv_fopen_rt=no],
75 [case $host in
76 *cygwin* | *mingw*) sed_cv_fopen_rt=yes ;;
77 *) sed_cv_fopen_rt='assuming no' ;;
78 esac])])
79if test "$sed_cv_fopen_rt" = yes; then
80 AC_DEFINE([HAVE_FOPEN_RT], [1],
81 [Defined if "rt" can be used as a mode to fopen.])
82fi
83
84AC_CACHE_CHECK([whether -lcP is needed], [sed_cv_libcp_needed], [
85AC_RUN_IFELSE(
86 [AC_LANG_SOURCE([[
87#include <stdio.h>
88#include <errno.h>
89
90int main()
91{
92 FILE *fp;
93 int result;
94 errno = 0;
95 fp = fopen ("conftest.c", "r");
96 if (!fp) return 0; /* error, assume not needed */
97 result = fflush (fp) == EOF && errno == 0;
98 fclose (fp);
99 return result;
100}]])], [sed_cv_libcp_needed=no],
101 [sed_cv_libcp_needed=yes],
102 [sed_cv_libcp_needed="assuming no"])
103])
104if test "$sed_cv_libcp_needed" = yes; then
105 LIBS="-lcP $LIBS"
106fi
107
108AC_CHECK_HEADERS_ONCE(locale.h errno.h wchar.h wctype.h mcheck.h,
109 [], [], [AC_INCLUDES_DEFAULT])
110AC_C_CONST
111AC_TYPE_SIZE_T
112
113AM_GNU_GETTEXT_VERSION([0.19.2])
114AM_GNU_GETTEXT([external])
115
116AC_CHECK_FUNCS_ONCE(isatty isascii memcpy strchr strtoul readlink
117 popen pathconf fchown fchmod setlocale)
118
119AM_CONDITIONAL([TEST_SYMLINKS],
120 [test "$ac_cv_func_readlink" = yes])
121
122AC_ARG_ENABLE(i18n,
123[ --disable-i18n disable internationalization (default=enabled)], ,
124enable_i18n=yes)
125if test "x$enable_i18n" = xno; then
126 ac_cv_func_wcscoll=no
127fi
128
129
130# Determine whether we should run UTF-8 tests by checking if cyrillic
131# letters are case-folded properly. The test for UTF-8 locales (both
132# in general and specifically for a Russian one) is a bit weak, but it
133# should match exactly what is done in the testsuite. In fact, sed's
134# logic is portable (though testing it requires care) so it is enough to
135# have a couple of platforms where these tests pass. Right now, only
136# Windows and HP/UX do not support the tests.
137AC_MSG_CHECKING([whether UTF-8 case folding tests should pass])
138AC_RUN_IFELSE(
139 [AC_LANG_SOURCE([[
140#include <locale.h>
141#include <string.h>
142#include <stdlib.h>
143#include <wchar.h>
144#ifdef HAVE_WCTYPE_H
145#include <wctype.h>
146#endif
147
148int test(void)
149{
150 char in[] = "\xD0\xB4";
151 char good[] = "\xD0\x94";
152 char out[10];
153 wchar_t in_wc, good_wc;
154 if (mbtowc (&in_wc, in, 3) == -1)
155 return 0;
156 if (mbtowc (&good_wc, good, 3) == -1)
157 return 0;
158 if (towupper (in_wc) != good_wc)
159 return 0;
160 if (wctomb (out, good_wc) != 2)
161 return 0;
162 if (memcmp (out, good, 2))
163 return 0;
164 return 1;
165}
166
167int main()
168{
169 char *old;
170 int len;
171
172 /* Try hardcoding a Russian UTF-8 locale. If the name "ru_RU.UTF-8"
173 is invalid, use setlocale again just to get the current locale. */
174 old = setlocale (LC_CTYPE, "ru_RU.UTF-8");
175 if (old)
176 {
177 if (test())
178 exit (0);
179 }
180 else
181 old = setlocale (LC_CTYPE, "C");
182
183 /* Maybe cyrillic case folding is implemented for all UTF-8 locales.
184 If the current locale is not UTF-8, the test will be skipped. */
185 len = strlen (old);
186 if ((len > 6 && !strcmp (old + len - 6, ".UTF-8"))
187 || (len > 6 && !strcmp (old + len - 6, ".utf-8"))
188 || (len > 5 && !strcmp (old + len - 5, ".UTF8"))
189 || (len > 5 && !strcmp (old + len - 5, ".utf8")))
190
191 /* ok */
192 ;
193 else
194 exit (1);
195
196 /* Run the test in the detected UTF-8 locale. */
197 setlocale (LC_CTYPE, old);
198 exit (!test ());
199}
200]])], [AC_MSG_RESULT([yes]); XFAIL_TESTS=],
201 [AC_MSG_RESULT([no]); XFAIL_TESTS='testsuite/utf8-1 testsuite/utf8-2 \
202 testsuite/utf8-3 testsuite/utf8-4'],
203 [AC_MSG_RESULT([don't care (cross compiling)]); XFAIL_TESTS=])
204
205# Under MinGW, the bsd.sh test fails because of the EOF character (^Z).
206case $host in
207 *mingw*) XFAIL_TESTS="$XFAIL_TESTS bsd" ;;
208 *) ;;
209esac
210AC_SUBST([XFAIL_TESTS])
211
212AC_ARG_ENABLE([gcc-warnings],
213 [AS_HELP_STRING([--enable-gcc-warnings],
214 [turn on many GCC warnings (for developers; best with GNU make)])],
215 [case $enableval in
216 yes|no) ;;
217 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
218 esac
219 gl_gcc_warnings=$enableval],
220 [
221 # GCC provides fine-grained control over diagnostics which
222 # is used in gnulib for example to suppress warnings from
223 # certain sections of code. So if this is available and
224 # we're running from a git repo, then auto enable the warnings.
225 gl_gcc_warnings=no
226 gl_GCC_VERSION_IFELSE([4], [6],
227 [test -d "$srcdir"/.git \
228 && ! test -f "$srcdir"/.tarball-version \
229 && gl_gcc_warnings=yes])]
230)
231
232if test "$gl_gcc_warnings" = yes; then
233 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
234 AC_SUBST([WERROR_CFLAGS])
235
236 nw=
237 # This, $nw, is the list of warnings we disable.
238 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
239 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
240 nw="$nw -Wsign-conversion" # Too many warnings for now
241 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
242 nw="$nw -Wswitch-default" # Too many warnings for now
243
244 gl_MANYWARN_ALL_GCC([ws])
245 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
246 for w in $ws; do
247 gl_WARN_ADD([$w])
248 done
249 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
250
251 # clang is unduly picky about some things.
252 AC_CACHE_CHECK([whether the compiler is clang], [utils_cv_clang],
253 [AC_COMPILE_IFELSE(
254 [AC_LANG_PROGRAM([[
255 #ifndef __clang__
256 #error "not clang"
257 #endif
258 ]])],
259 [utils_cv_clang=yes],
260 [utils_cv_clang=no])])
261 if test $utils_cv_clang = yes; then
262 gl_WARN_ADD([-Wno-format-extra-args])
263 gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
264 fi
265
266 gl_WARN_ADD([-fdiagnostics-show-option])
267 gl_WARN_ADD([-funit-at-a-time])
268
269 AC_SUBST([WARN_CFLAGS])
270
271 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
272 AH_VERBATIM([FORTIFY_SOURCE],
273 [/* Enable compile-time and run-time bounds-checking, and some warnings,
274 without upsetting glibc 2.15+. */
275 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
276 # define _FORTIFY_SOURCE 2
277 #endif
278 ])
279 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
280
281 # For gnulib-tests, the set is slightly smaller still.
282 nw=
283 gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
284 [$WARN_CFLAGS], [$nw])
285 AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
286fi
287
288AC_ARG_ENABLE([bold-man-page-references],
289 [AS_HELP_STRING([--disable-bold-man-page-references],
290 [When generating man pages, do not apply bold style around any
291 references like name(1) etc.])],
292 [gl_bold_manpages=yes ;
293 case $enableval in
294 no|yes) gl_bold_manpages=$enableval ;;
295 *) AC_MSG_ERROR([bad value $enableval for bold-man-page-references.
296 Options are: yes, no.]) ;;
297 esac],
298 [gl_bold_manpages=yes]
299)
300AM_CONDITIONAL([BOLD_MAN_REFS], [test "$gl_bold_manpages" != no])
301
302AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
303
304# Perl is needed for help2man
305AC_PATH_PROG([PERL], [perl])
306
307# This is needed when building outside the source dir
308# with --disable-dependency-tracking, see https://bugs.gnu.org/25371
309AS_MKDIR_P([lib])
310AS_MKDIR_P([sed])
311AS_MKDIR_P([doc])
312AS_MKDIR_P([testsuite])
313
314AC_CONFIG_FILES([
315 Makefile
316 po/Makefile.in
317 gnulib-tests/Makefile
318])
319AC_OUTPUT
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette