xref: /aosp_15_r20/external/e2fsprogs/aclocal.m4 (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker# generated automatically by aclocal 1.16.5 -*- Autoconf -*-
2*6a54128fSAndroid Build Coastguard Worker
3*6a54128fSAndroid Build Coastguard Worker# Copyright (C) 1996-2021 Free Software Foundation, Inc.
4*6a54128fSAndroid Build Coastguard Worker
5*6a54128fSAndroid Build Coastguard Worker# This file is free software; the Free Software Foundation
6*6a54128fSAndroid Build Coastguard Worker# gives unlimited permission to copy and/or distribute it,
7*6a54128fSAndroid Build Coastguard Worker# with or without modifications, as long as this notice is preserved.
8*6a54128fSAndroid Build Coastguard Worker
9*6a54128fSAndroid Build Coastguard Worker# This program is distributed in the hope that it will be useful,
10*6a54128fSAndroid Build Coastguard Worker# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11*6a54128fSAndroid Build Coastguard Worker# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12*6a54128fSAndroid Build Coastguard Worker# PARTICULAR PURPOSE.
13*6a54128fSAndroid Build Coastguard Worker
14*6a54128fSAndroid Build Coastguard Workerm4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
15*6a54128fSAndroid Build Coastguard Worker# ===========================================================================
16*6a54128fSAndroid Build Coastguard Worker#        https://www.gnu.org/software/autoconf-archive/ax_pthread.html
17*6a54128fSAndroid Build Coastguard Worker# ===========================================================================
18*6a54128fSAndroid Build Coastguard Worker#
19*6a54128fSAndroid Build Coastguard Worker# SYNOPSIS
20*6a54128fSAndroid Build Coastguard Worker#
21*6a54128fSAndroid Build Coastguard Worker#   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
22*6a54128fSAndroid Build Coastguard Worker#
23*6a54128fSAndroid Build Coastguard Worker# DESCRIPTION
24*6a54128fSAndroid Build Coastguard Worker#
25*6a54128fSAndroid Build Coastguard Worker#   This macro figures out how to build C programs using POSIX threads. It
26*6a54128fSAndroid Build Coastguard Worker#   sets the PTHREAD_LIBS output variable to the threads library and linker
27*6a54128fSAndroid Build Coastguard Worker#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
28*6a54128fSAndroid Build Coastguard Worker#   flags that are needed. (The user can also force certain compiler
29*6a54128fSAndroid Build Coastguard Worker#   flags/libs to be tested by setting these environment variables.)
30*6a54128fSAndroid Build Coastguard Worker#
31*6a54128fSAndroid Build Coastguard Worker#   Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is
32*6a54128fSAndroid Build Coastguard Worker#   needed for multi-threaded programs (defaults to the value of CC
33*6a54128fSAndroid Build Coastguard Worker#   respectively CXX otherwise). (This is necessary on e.g. AIX to use the
34*6a54128fSAndroid Build Coastguard Worker#   special cc_r/CC_r compiler alias.)
35*6a54128fSAndroid Build Coastguard Worker#
36*6a54128fSAndroid Build Coastguard Worker#   NOTE: You are assumed to not only compile your program with these flags,
37*6a54128fSAndroid Build Coastguard Worker#   but also to link with them as well. For example, you might link with
38*6a54128fSAndroid Build Coastguard Worker#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
39*6a54128fSAndroid Build Coastguard Worker#   $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
40*6a54128fSAndroid Build Coastguard Worker#
41*6a54128fSAndroid Build Coastguard Worker#   If you are only building threaded programs, you may wish to use these
42*6a54128fSAndroid Build Coastguard Worker#   variables in your default LIBS, CFLAGS, and CC:
43*6a54128fSAndroid Build Coastguard Worker#
44*6a54128fSAndroid Build Coastguard Worker#     LIBS="$PTHREAD_LIBS $LIBS"
45*6a54128fSAndroid Build Coastguard Worker#     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
46*6a54128fSAndroid Build Coastguard Worker#     CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
47*6a54128fSAndroid Build Coastguard Worker#     CC="$PTHREAD_CC"
48*6a54128fSAndroid Build Coastguard Worker#     CXX="$PTHREAD_CXX"
49*6a54128fSAndroid Build Coastguard Worker#
50*6a54128fSAndroid Build Coastguard Worker#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
51*6a54128fSAndroid Build Coastguard Worker#   has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
52*6a54128fSAndroid Build Coastguard Worker#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
53*6a54128fSAndroid Build Coastguard Worker#
54*6a54128fSAndroid Build Coastguard Worker#   Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
55*6a54128fSAndroid Build Coastguard Worker#   PTHREAD_PRIO_INHERIT symbol is defined when compiling with
56*6a54128fSAndroid Build Coastguard Worker#   PTHREAD_CFLAGS.
57*6a54128fSAndroid Build Coastguard Worker#
58*6a54128fSAndroid Build Coastguard Worker#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
59*6a54128fSAndroid Build Coastguard Worker#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
60*6a54128fSAndroid Build Coastguard Worker#   is not found. If ACTION-IF-FOUND is not specified, the default action
61*6a54128fSAndroid Build Coastguard Worker#   will define HAVE_PTHREAD.
62*6a54128fSAndroid Build Coastguard Worker#
63*6a54128fSAndroid Build Coastguard Worker#   Please let the authors know if this macro fails on any platform, or if
64*6a54128fSAndroid Build Coastguard Worker#   you have any other suggestions or comments. This macro was based on work
65*6a54128fSAndroid Build Coastguard Worker#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
66*6a54128fSAndroid Build Coastguard Worker#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
67*6a54128fSAndroid Build Coastguard Worker#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
68*6a54128fSAndroid Build Coastguard Worker#   grateful for the helpful feedback of numerous users.
69*6a54128fSAndroid Build Coastguard Worker#
70*6a54128fSAndroid Build Coastguard Worker#   Updated for Autoconf 2.68 by Daniel Richard G.
71*6a54128fSAndroid Build Coastguard Worker#
72*6a54128fSAndroid Build Coastguard Worker# LICENSE
73*6a54128fSAndroid Build Coastguard Worker#
74*6a54128fSAndroid Build Coastguard Worker#   Copyright (c) 2008 Steven G. Johnson <[email protected]>
75*6a54128fSAndroid Build Coastguard Worker#   Copyright (c) 2011 Daniel Richard G. <[email protected]>
76*6a54128fSAndroid Build Coastguard Worker#   Copyright (c) 2019 Marc Stevens <[email protected]>
77*6a54128fSAndroid Build Coastguard Worker#
78*6a54128fSAndroid Build Coastguard Worker#   This program is free software: you can redistribute it and/or modify it
79*6a54128fSAndroid Build Coastguard Worker#   under the terms of the GNU General Public License as published by the
80*6a54128fSAndroid Build Coastguard Worker#   Free Software Foundation, either version 3 of the License, or (at your
81*6a54128fSAndroid Build Coastguard Worker#   option) any later version.
82*6a54128fSAndroid Build Coastguard Worker#
83*6a54128fSAndroid Build Coastguard Worker#   This program is distributed in the hope that it will be useful, but
84*6a54128fSAndroid Build Coastguard Worker#   WITHOUT ANY WARRANTY; without even the implied warranty of
85*6a54128fSAndroid Build Coastguard Worker#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
86*6a54128fSAndroid Build Coastguard Worker#   Public License for more details.
87*6a54128fSAndroid Build Coastguard Worker#
88*6a54128fSAndroid Build Coastguard Worker#   You should have received a copy of the GNU General Public License along
89*6a54128fSAndroid Build Coastguard Worker#   with this program. If not, see <https://www.gnu.org/licenses/>.
90*6a54128fSAndroid Build Coastguard Worker#
91*6a54128fSAndroid Build Coastguard Worker#   As a special exception, the respective Autoconf Macro's copyright owner
92*6a54128fSAndroid Build Coastguard Worker#   gives unlimited permission to copy, distribute and modify the configure
93*6a54128fSAndroid Build Coastguard Worker#   scripts that are the output of Autoconf when processing the Macro. You
94*6a54128fSAndroid Build Coastguard Worker#   need not follow the terms of the GNU General Public License when using
95*6a54128fSAndroid Build Coastguard Worker#   or distributing such scripts, even though portions of the text of the
96*6a54128fSAndroid Build Coastguard Worker#   Macro appear in them. The GNU General Public License (GPL) does govern
97*6a54128fSAndroid Build Coastguard Worker#   all other use of the material that constitutes the Autoconf Macro.
98*6a54128fSAndroid Build Coastguard Worker#
99*6a54128fSAndroid Build Coastguard Worker#   This special exception to the GPL applies to versions of the Autoconf
100*6a54128fSAndroid Build Coastguard Worker#   Macro released by the Autoconf Archive. When you make and distribute a
101*6a54128fSAndroid Build Coastguard Worker#   modified version of the Autoconf Macro, you may extend this special
102*6a54128fSAndroid Build Coastguard Worker#   exception to the GPL to apply to your modified version as well.
103*6a54128fSAndroid Build Coastguard Worker
104*6a54128fSAndroid Build Coastguard Worker#serial 31
105*6a54128fSAndroid Build Coastguard Worker
106*6a54128fSAndroid Build Coastguard WorkerAU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
107*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AX_PTHREAD], [
108*6a54128fSAndroid Build Coastguard WorkerAC_REQUIRE([AC_CANONICAL_HOST])
109*6a54128fSAndroid Build Coastguard WorkerAC_REQUIRE([AC_PROG_CC])
110*6a54128fSAndroid Build Coastguard WorkerAC_REQUIRE([AC_PROG_SED])
111*6a54128fSAndroid Build Coastguard WorkerAC_LANG_PUSH([C])
112*6a54128fSAndroid Build Coastguard Workerax_pthread_ok=no
113*6a54128fSAndroid Build Coastguard Worker
114*6a54128fSAndroid Build Coastguard Worker# We used to check for pthread.h first, but this fails if pthread.h
115*6a54128fSAndroid Build Coastguard Worker# requires special compiler flags (e.g. on Tru64 or Sequent).
116*6a54128fSAndroid Build Coastguard Worker# It gets checked for in the link test anyway.
117*6a54128fSAndroid Build Coastguard Worker
118*6a54128fSAndroid Build Coastguard Worker# First of all, check if the user has set any of the PTHREAD_LIBS,
119*6a54128fSAndroid Build Coastguard Worker# etcetera environment variables, and if threads linking works using
120*6a54128fSAndroid Build Coastguard Worker# them:
121*6a54128fSAndroid Build Coastguard Workerif test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
122*6a54128fSAndroid Build Coastguard Worker        ax_pthread_save_CC="$CC"
123*6a54128fSAndroid Build Coastguard Worker        ax_pthread_save_CFLAGS="$CFLAGS"
124*6a54128fSAndroid Build Coastguard Worker        ax_pthread_save_LIBS="$LIBS"
125*6a54128fSAndroid Build Coastguard Worker        AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
126*6a54128fSAndroid Build Coastguard Worker        AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"])
127*6a54128fSAndroid Build Coastguard Worker        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
128*6a54128fSAndroid Build Coastguard Worker        LIBS="$PTHREAD_LIBS $LIBS"
129*6a54128fSAndroid Build Coastguard Worker        AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
130*6a54128fSAndroid Build Coastguard Worker        AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
131*6a54128fSAndroid Build Coastguard Worker        AC_MSG_RESULT([$ax_pthread_ok])
132*6a54128fSAndroid Build Coastguard Worker        if test "x$ax_pthread_ok" = "xno"; then
133*6a54128fSAndroid Build Coastguard Worker                PTHREAD_LIBS=""
134*6a54128fSAndroid Build Coastguard Worker                PTHREAD_CFLAGS=""
135*6a54128fSAndroid Build Coastguard Worker        fi
136*6a54128fSAndroid Build Coastguard Worker        CC="$ax_pthread_save_CC"
137*6a54128fSAndroid Build Coastguard Worker        CFLAGS="$ax_pthread_save_CFLAGS"
138*6a54128fSAndroid Build Coastguard Worker        LIBS="$ax_pthread_save_LIBS"
139*6a54128fSAndroid Build Coastguard Workerfi
140*6a54128fSAndroid Build Coastguard Worker
141*6a54128fSAndroid Build Coastguard Worker# We must check for the threads library under a number of different
142*6a54128fSAndroid Build Coastguard Worker# names; the ordering is very important because some systems
143*6a54128fSAndroid Build Coastguard Worker# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
144*6a54128fSAndroid Build Coastguard Worker# libraries is broken (non-POSIX).
145*6a54128fSAndroid Build Coastguard Worker
146*6a54128fSAndroid Build Coastguard Worker# Create a list of thread flags to try. Items with a "," contain both
147*6a54128fSAndroid Build Coastguard Worker# C compiler flags (before ",") and linker flags (after ","). Other items
148*6a54128fSAndroid Build Coastguard Worker# starting with a "-" are C compiler flags, and remaining items are
149*6a54128fSAndroid Build Coastguard Worker# library names, except for "none" which indicates that we try without
150*6a54128fSAndroid Build Coastguard Worker# any flags at all, and "pthread-config" which is a program returning
151*6a54128fSAndroid Build Coastguard Worker# the flags for the Pth emulation library.
152*6a54128fSAndroid Build Coastguard Worker
153*6a54128fSAndroid Build Coastguard Workerax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
154*6a54128fSAndroid Build Coastguard Worker
155*6a54128fSAndroid Build Coastguard Worker# The ordering *is* (sometimes) important.  Some notes on the
156*6a54128fSAndroid Build Coastguard Worker# individual items follow:
157*6a54128fSAndroid Build Coastguard Worker
158*6a54128fSAndroid Build Coastguard Worker# pthreads: AIX (must check this before -lpthread)
159*6a54128fSAndroid Build Coastguard Worker# none: in case threads are in libc; should be tried before -Kthread and
160*6a54128fSAndroid Build Coastguard Worker#       other compiler flags to prevent continual compiler warnings
161*6a54128fSAndroid Build Coastguard Worker# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
162*6a54128fSAndroid Build Coastguard Worker# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
163*6a54128fSAndroid Build Coastguard Worker#           (Note: HP C rejects this with "bad form for `-t' option")
164*6a54128fSAndroid Build Coastguard Worker# -pthreads: Solaris/gcc (Note: HP C also rejects)
165*6a54128fSAndroid Build Coastguard Worker# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
166*6a54128fSAndroid Build Coastguard Worker#      doesn't hurt to check since this sometimes defines pthreads and
167*6a54128fSAndroid Build Coastguard Worker#      -D_REENTRANT too), HP C (must be checked before -lpthread, which
168*6a54128fSAndroid Build Coastguard Worker#      is present but should not be used directly; and before -mthreads,
169*6a54128fSAndroid Build Coastguard Worker#      because the compiler interprets this as "-mt" + "-hreads")
170*6a54128fSAndroid Build Coastguard Worker# -mthreads: Mingw32/gcc, Lynx/gcc
171*6a54128fSAndroid Build Coastguard Worker# pthread: Linux, etcetera
172*6a54128fSAndroid Build Coastguard Worker# --thread-safe: KAI C++
173*6a54128fSAndroid Build Coastguard Worker# pthread-config: use pthread-config program (for GNU Pth library)
174*6a54128fSAndroid Build Coastguard Worker
175*6a54128fSAndroid Build Coastguard Workercase $host_os in
176*6a54128fSAndroid Build Coastguard Worker
177*6a54128fSAndroid Build Coastguard Worker        freebsd*)
178*6a54128fSAndroid Build Coastguard Worker
179*6a54128fSAndroid Build Coastguard Worker        # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
180*6a54128fSAndroid Build Coastguard Worker        # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
181*6a54128fSAndroid Build Coastguard Worker
182*6a54128fSAndroid Build Coastguard Worker        ax_pthread_flags="-kthread lthread $ax_pthread_flags"
183*6a54128fSAndroid Build Coastguard Worker        ;;
184*6a54128fSAndroid Build Coastguard Worker
185*6a54128fSAndroid Build Coastguard Worker        hpux*)
186*6a54128fSAndroid Build Coastguard Worker
187*6a54128fSAndroid Build Coastguard Worker        # From the cc(1) man page: "[-mt] Sets various -D flags to enable
188*6a54128fSAndroid Build Coastguard Worker        # multi-threading and also sets -lpthread."
189*6a54128fSAndroid Build Coastguard Worker
190*6a54128fSAndroid Build Coastguard Worker        ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
191*6a54128fSAndroid Build Coastguard Worker        ;;
192*6a54128fSAndroid Build Coastguard Worker
193*6a54128fSAndroid Build Coastguard Worker        openedition*)
194*6a54128fSAndroid Build Coastguard Worker
195*6a54128fSAndroid Build Coastguard Worker        # IBM z/OS requires a feature-test macro to be defined in order to
196*6a54128fSAndroid Build Coastguard Worker        # enable POSIX threads at all, so give the user a hint if this is
197*6a54128fSAndroid Build Coastguard Worker        # not set. (We don't define these ourselves, as they can affect
198*6a54128fSAndroid Build Coastguard Worker        # other portions of the system API in unpredictable ways.)
199*6a54128fSAndroid Build Coastguard Worker
200*6a54128fSAndroid Build Coastguard Worker        AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
201*6a54128fSAndroid Build Coastguard Worker            [
202*6a54128fSAndroid Build Coastguard Worker#            if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
203*6a54128fSAndroid Build Coastguard Worker             AX_PTHREAD_ZOS_MISSING
204*6a54128fSAndroid Build Coastguard Worker#            endif
205*6a54128fSAndroid Build Coastguard Worker            ],
206*6a54128fSAndroid Build Coastguard Worker            [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
207*6a54128fSAndroid Build Coastguard Worker        ;;
208*6a54128fSAndroid Build Coastguard Worker
209*6a54128fSAndroid Build Coastguard Worker        solaris*)
210*6a54128fSAndroid Build Coastguard Worker
211*6a54128fSAndroid Build Coastguard Worker        # On Solaris (at least, for some versions), libc contains stubbed
212*6a54128fSAndroid Build Coastguard Worker        # (non-functional) versions of the pthreads routines, so link-based
213*6a54128fSAndroid Build Coastguard Worker        # tests will erroneously succeed. (N.B.: The stubs are missing
214*6a54128fSAndroid Build Coastguard Worker        # pthread_cleanup_push, or rather a function called by this macro,
215*6a54128fSAndroid Build Coastguard Worker        # so we could check for that, but who knows whether they'll stub
216*6a54128fSAndroid Build Coastguard Worker        # that too in a future libc.)  So we'll check first for the
217*6a54128fSAndroid Build Coastguard Worker        # standard Solaris way of linking pthreads (-mt -lpthread).
218*6a54128fSAndroid Build Coastguard Worker
219*6a54128fSAndroid Build Coastguard Worker        ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags"
220*6a54128fSAndroid Build Coastguard Worker        ;;
221*6a54128fSAndroid Build Coastguard Workeresac
222*6a54128fSAndroid Build Coastguard Worker
223*6a54128fSAndroid Build Coastguard Worker# Are we compiling with Clang?
224*6a54128fSAndroid Build Coastguard Worker
225*6a54128fSAndroid Build Coastguard WorkerAC_CACHE_CHECK([whether $CC is Clang],
226*6a54128fSAndroid Build Coastguard Worker    [ax_cv_PTHREAD_CLANG],
227*6a54128fSAndroid Build Coastguard Worker    [ax_cv_PTHREAD_CLANG=no
228*6a54128fSAndroid Build Coastguard Worker     # Note that Autoconf sets GCC=yes for Clang as well as GCC
229*6a54128fSAndroid Build Coastguard Worker     if test "x$GCC" = "xyes"; then
230*6a54128fSAndroid Build Coastguard Worker        AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
231*6a54128fSAndroid Build Coastguard Worker            [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
232*6a54128fSAndroid Build Coastguard Worker#            if defined(__clang__) && defined(__llvm__)
233*6a54128fSAndroid Build Coastguard Worker             AX_PTHREAD_CC_IS_CLANG
234*6a54128fSAndroid Build Coastguard Worker#            endif
235*6a54128fSAndroid Build Coastguard Worker            ],
236*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_CLANG=yes])
237*6a54128fSAndroid Build Coastguard Worker     fi
238*6a54128fSAndroid Build Coastguard Worker    ])
239*6a54128fSAndroid Build Coastguard Workerax_pthread_clang="$ax_cv_PTHREAD_CLANG"
240*6a54128fSAndroid Build Coastguard Worker
241*6a54128fSAndroid Build Coastguard Worker
242*6a54128fSAndroid Build Coastguard Worker# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
243*6a54128fSAndroid Build Coastguard Worker
244*6a54128fSAndroid Build Coastguard Worker# Note that for GCC and Clang -pthread generally implies -lpthread,
245*6a54128fSAndroid Build Coastguard Worker# except when -nostdlib is passed.
246*6a54128fSAndroid Build Coastguard Worker# This is problematic using libtool to build C++ shared libraries with pthread:
247*6a54128fSAndroid Build Coastguard Worker# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460
248*6a54128fSAndroid Build Coastguard Worker# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333
249*6a54128fSAndroid Build Coastguard Worker# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555
250*6a54128fSAndroid Build Coastguard Worker# To solve this, first try -pthread together with -lpthread for GCC
251*6a54128fSAndroid Build Coastguard Worker
252*6a54128fSAndroid Build Coastguard WorkerAS_IF([test "x$GCC" = "xyes"],
253*6a54128fSAndroid Build Coastguard Worker      [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"])
254*6a54128fSAndroid Build Coastguard Worker
255*6a54128fSAndroid Build Coastguard Worker# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first
256*6a54128fSAndroid Build Coastguard Worker
257*6a54128fSAndroid Build Coastguard WorkerAS_IF([test "x$ax_pthread_clang" = "xyes"],
258*6a54128fSAndroid Build Coastguard Worker      [ax_pthread_flags="-pthread,-lpthread -pthread"])
259*6a54128fSAndroid Build Coastguard Worker
260*6a54128fSAndroid Build Coastguard Worker
261*6a54128fSAndroid Build Coastguard Worker# The presence of a feature test macro requesting re-entrant function
262*6a54128fSAndroid Build Coastguard Worker# definitions is, on some systems, a strong hint that pthreads support is
263*6a54128fSAndroid Build Coastguard Worker# correctly enabled
264*6a54128fSAndroid Build Coastguard Worker
265*6a54128fSAndroid Build Coastguard Workercase $host_os in
266*6a54128fSAndroid Build Coastguard Worker        darwin* | hpux* | linux* | osf* | solaris*)
267*6a54128fSAndroid Build Coastguard Worker        ax_pthread_check_macro="_REENTRANT"
268*6a54128fSAndroid Build Coastguard Worker        ;;
269*6a54128fSAndroid Build Coastguard Worker
270*6a54128fSAndroid Build Coastguard Worker        aix*)
271*6a54128fSAndroid Build Coastguard Worker        ax_pthread_check_macro="_THREAD_SAFE"
272*6a54128fSAndroid Build Coastguard Worker        ;;
273*6a54128fSAndroid Build Coastguard Worker
274*6a54128fSAndroid Build Coastguard Worker        *)
275*6a54128fSAndroid Build Coastguard Worker        ax_pthread_check_macro="--"
276*6a54128fSAndroid Build Coastguard Worker        ;;
277*6a54128fSAndroid Build Coastguard Workeresac
278*6a54128fSAndroid Build Coastguard WorkerAS_IF([test "x$ax_pthread_check_macro" = "x--"],
279*6a54128fSAndroid Build Coastguard Worker      [ax_pthread_check_cond=0],
280*6a54128fSAndroid Build Coastguard Worker      [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
281*6a54128fSAndroid Build Coastguard Worker
282*6a54128fSAndroid Build Coastguard Worker
283*6a54128fSAndroid Build Coastguard Workerif test "x$ax_pthread_ok" = "xno"; then
284*6a54128fSAndroid Build Coastguard Workerfor ax_pthread_try_flag in $ax_pthread_flags; do
285*6a54128fSAndroid Build Coastguard Worker
286*6a54128fSAndroid Build Coastguard Worker        case $ax_pthread_try_flag in
287*6a54128fSAndroid Build Coastguard Worker                none)
288*6a54128fSAndroid Build Coastguard Worker                AC_MSG_CHECKING([whether pthreads work without any flags])
289*6a54128fSAndroid Build Coastguard Worker                ;;
290*6a54128fSAndroid Build Coastguard Worker
291*6a54128fSAndroid Build Coastguard Worker                *,*)
292*6a54128fSAndroid Build Coastguard Worker                PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
293*6a54128fSAndroid Build Coastguard Worker                PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
294*6a54128fSAndroid Build Coastguard Worker                AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
295*6a54128fSAndroid Build Coastguard Worker                ;;
296*6a54128fSAndroid Build Coastguard Worker
297*6a54128fSAndroid Build Coastguard Worker                -*)
298*6a54128fSAndroid Build Coastguard Worker                AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
299*6a54128fSAndroid Build Coastguard Worker                PTHREAD_CFLAGS="$ax_pthread_try_flag"
300*6a54128fSAndroid Build Coastguard Worker                ;;
301*6a54128fSAndroid Build Coastguard Worker
302*6a54128fSAndroid Build Coastguard Worker                pthread-config)
303*6a54128fSAndroid Build Coastguard Worker                AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
304*6a54128fSAndroid Build Coastguard Worker                AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
305*6a54128fSAndroid Build Coastguard Worker                PTHREAD_CFLAGS="`pthread-config --cflags`"
306*6a54128fSAndroid Build Coastguard Worker                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
307*6a54128fSAndroid Build Coastguard Worker                ;;
308*6a54128fSAndroid Build Coastguard Worker
309*6a54128fSAndroid Build Coastguard Worker                *)
310*6a54128fSAndroid Build Coastguard Worker                AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
311*6a54128fSAndroid Build Coastguard Worker                PTHREAD_LIBS="-l$ax_pthread_try_flag"
312*6a54128fSAndroid Build Coastguard Worker                ;;
313*6a54128fSAndroid Build Coastguard Worker        esac
314*6a54128fSAndroid Build Coastguard Worker
315*6a54128fSAndroid Build Coastguard Worker        ax_pthread_save_CFLAGS="$CFLAGS"
316*6a54128fSAndroid Build Coastguard Worker        ax_pthread_save_LIBS="$LIBS"
317*6a54128fSAndroid Build Coastguard Worker        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
318*6a54128fSAndroid Build Coastguard Worker        LIBS="$PTHREAD_LIBS $LIBS"
319*6a54128fSAndroid Build Coastguard Worker
320*6a54128fSAndroid Build Coastguard Worker        # Check for various functions.  We must include pthread.h,
321*6a54128fSAndroid Build Coastguard Worker        # since some functions may be macros.  (On the Sequent, we
322*6a54128fSAndroid Build Coastguard Worker        # need a special flag -Kthread to make this header compile.)
323*6a54128fSAndroid Build Coastguard Worker        # We check for pthread_join because it is in -lpthread on IRIX
324*6a54128fSAndroid Build Coastguard Worker        # while pthread_create is in libc.  We check for pthread_attr_init
325*6a54128fSAndroid Build Coastguard Worker        # due to DEC craziness with -lpthreads.  We check for
326*6a54128fSAndroid Build Coastguard Worker        # pthread_cleanup_push because it is one of the few pthread
327*6a54128fSAndroid Build Coastguard Worker        # functions on Solaris that doesn't have a non-functional libc stub.
328*6a54128fSAndroid Build Coastguard Worker        # We try pthread_create on general principles.
329*6a54128fSAndroid Build Coastguard Worker
330*6a54128fSAndroid Build Coastguard Worker        AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
331*6a54128fSAndroid Build Coastguard Worker#                       if $ax_pthread_check_cond
332*6a54128fSAndroid Build Coastguard Worker#                        error "$ax_pthread_check_macro must be defined"
333*6a54128fSAndroid Build Coastguard Worker#                       endif
334*6a54128fSAndroid Build Coastguard Worker                        static void *some_global = NULL;
335*6a54128fSAndroid Build Coastguard Worker                        static void routine(void *a)
336*6a54128fSAndroid Build Coastguard Worker                          {
337*6a54128fSAndroid Build Coastguard Worker                             /* To avoid any unused-parameter or
338*6a54128fSAndroid Build Coastguard Worker                                unused-but-set-parameter warning.  */
339*6a54128fSAndroid Build Coastguard Worker                             some_global = a;
340*6a54128fSAndroid Build Coastguard Worker                          }
341*6a54128fSAndroid Build Coastguard Worker                        static void *start_routine(void *a) { return a; }],
342*6a54128fSAndroid Build Coastguard Worker                       [pthread_t th; pthread_attr_t attr;
343*6a54128fSAndroid Build Coastguard Worker                        pthread_create(&th, 0, start_routine, 0);
344*6a54128fSAndroid Build Coastguard Worker                        pthread_join(th, 0);
345*6a54128fSAndroid Build Coastguard Worker                        pthread_attr_init(&attr);
346*6a54128fSAndroid Build Coastguard Worker                        pthread_cleanup_push(routine, 0);
347*6a54128fSAndroid Build Coastguard Worker                        pthread_cleanup_pop(0) /* ; */])],
348*6a54128fSAndroid Build Coastguard Worker            [ax_pthread_ok=yes],
349*6a54128fSAndroid Build Coastguard Worker            [])
350*6a54128fSAndroid Build Coastguard Worker
351*6a54128fSAndroid Build Coastguard Worker        CFLAGS="$ax_pthread_save_CFLAGS"
352*6a54128fSAndroid Build Coastguard Worker        LIBS="$ax_pthread_save_LIBS"
353*6a54128fSAndroid Build Coastguard Worker
354*6a54128fSAndroid Build Coastguard Worker        AC_MSG_RESULT([$ax_pthread_ok])
355*6a54128fSAndroid Build Coastguard Worker        AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
356*6a54128fSAndroid Build Coastguard Worker
357*6a54128fSAndroid Build Coastguard Worker        PTHREAD_LIBS=""
358*6a54128fSAndroid Build Coastguard Worker        PTHREAD_CFLAGS=""
359*6a54128fSAndroid Build Coastguard Workerdone
360*6a54128fSAndroid Build Coastguard Workerfi
361*6a54128fSAndroid Build Coastguard Worker
362*6a54128fSAndroid Build Coastguard Worker
363*6a54128fSAndroid Build Coastguard Worker# Clang needs special handling, because older versions handle the -pthread
364*6a54128fSAndroid Build Coastguard Worker# option in a rather... idiosyncratic way
365*6a54128fSAndroid Build Coastguard Worker
366*6a54128fSAndroid Build Coastguard Workerif test "x$ax_pthread_clang" = "xyes"; then
367*6a54128fSAndroid Build Coastguard Worker
368*6a54128fSAndroid Build Coastguard Worker        # Clang takes -pthread; it has never supported any other flag
369*6a54128fSAndroid Build Coastguard Worker
370*6a54128fSAndroid Build Coastguard Worker        # (Note 1: This will need to be revisited if a system that Clang
371*6a54128fSAndroid Build Coastguard Worker        # supports has POSIX threads in a separate library.  This tends not
372*6a54128fSAndroid Build Coastguard Worker        # to be the way of modern systems, but it's conceivable.)
373*6a54128fSAndroid Build Coastguard Worker
374*6a54128fSAndroid Build Coastguard Worker        # (Note 2: On some systems, notably Darwin, -pthread is not needed
375*6a54128fSAndroid Build Coastguard Worker        # to get POSIX threads support; the API is always present and
376*6a54128fSAndroid Build Coastguard Worker        # active.  We could reasonably leave PTHREAD_CFLAGS empty.  But
377*6a54128fSAndroid Build Coastguard Worker        # -pthread does define _REENTRANT, and while the Darwin headers
378*6a54128fSAndroid Build Coastguard Worker        # ignore this macro, third-party headers might not.)
379*6a54128fSAndroid Build Coastguard Worker
380*6a54128fSAndroid Build Coastguard Worker        # However, older versions of Clang make a point of warning the user
381*6a54128fSAndroid Build Coastguard Worker        # that, in an invocation where only linking and no compilation is
382*6a54128fSAndroid Build Coastguard Worker        # taking place, the -pthread option has no effect ("argument unused
383*6a54128fSAndroid Build Coastguard Worker        # during compilation").  They expect -pthread to be passed in only
384*6a54128fSAndroid Build Coastguard Worker        # when source code is being compiled.
385*6a54128fSAndroid Build Coastguard Worker        #
386*6a54128fSAndroid Build Coastguard Worker        # Problem is, this is at odds with the way Automake and most other
387*6a54128fSAndroid Build Coastguard Worker        # C build frameworks function, which is that the same flags used in
388*6a54128fSAndroid Build Coastguard Worker        # compilation (CFLAGS) are also used in linking.  Many systems
389*6a54128fSAndroid Build Coastguard Worker        # supported by AX_PTHREAD require exactly this for POSIX threads
390*6a54128fSAndroid Build Coastguard Worker        # support, and in fact it is often not straightforward to specify a
391*6a54128fSAndroid Build Coastguard Worker        # flag that is used only in the compilation phase and not in
392*6a54128fSAndroid Build Coastguard Worker        # linking.  Such a scenario is extremely rare in practice.
393*6a54128fSAndroid Build Coastguard Worker        #
394*6a54128fSAndroid Build Coastguard Worker        # Even though use of the -pthread flag in linking would only print
395*6a54128fSAndroid Build Coastguard Worker        # a warning, this can be a nuisance for well-run software projects
396*6a54128fSAndroid Build Coastguard Worker        # that build with -Werror.  So if the active version of Clang has
397*6a54128fSAndroid Build Coastguard Worker        # this misfeature, we search for an option to squash it.
398*6a54128fSAndroid Build Coastguard Worker
399*6a54128fSAndroid Build Coastguard Worker        AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
400*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
401*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
402*6a54128fSAndroid Build Coastguard Worker             # Create an alternate version of $ac_link that compiles and
403*6a54128fSAndroid Build Coastguard Worker             # links in two steps (.c -> .o, .o -> exe) instead of one
404*6a54128fSAndroid Build Coastguard Worker             # (.c -> exe), because the warning occurs only in the second
405*6a54128fSAndroid Build Coastguard Worker             # step
406*6a54128fSAndroid Build Coastguard Worker             ax_pthread_save_ac_link="$ac_link"
407*6a54128fSAndroid Build Coastguard Worker             ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
408*6a54128fSAndroid Build Coastguard Worker             ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"`
409*6a54128fSAndroid Build Coastguard Worker             ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
410*6a54128fSAndroid Build Coastguard Worker             ax_pthread_save_CFLAGS="$CFLAGS"
411*6a54128fSAndroid Build Coastguard Worker             for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
412*6a54128fSAndroid Build Coastguard Worker                AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
413*6a54128fSAndroid Build Coastguard Worker                CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
414*6a54128fSAndroid Build Coastguard Worker                ac_link="$ax_pthread_save_ac_link"
415*6a54128fSAndroid Build Coastguard Worker                AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
416*6a54128fSAndroid Build Coastguard Worker                    [ac_link="$ax_pthread_2step_ac_link"
417*6a54128fSAndroid Build Coastguard Worker                     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
418*6a54128fSAndroid Build Coastguard Worker                         [break])
419*6a54128fSAndroid Build Coastguard Worker                    ])
420*6a54128fSAndroid Build Coastguard Worker             done
421*6a54128fSAndroid Build Coastguard Worker             ac_link="$ax_pthread_save_ac_link"
422*6a54128fSAndroid Build Coastguard Worker             CFLAGS="$ax_pthread_save_CFLAGS"
423*6a54128fSAndroid Build Coastguard Worker             AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
424*6a54128fSAndroid Build Coastguard Worker             ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
425*6a54128fSAndroid Build Coastguard Worker            ])
426*6a54128fSAndroid Build Coastguard Worker
427*6a54128fSAndroid Build Coastguard Worker        case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
428*6a54128fSAndroid Build Coastguard Worker                no | unknown) ;;
429*6a54128fSAndroid Build Coastguard Worker                *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
430*6a54128fSAndroid Build Coastguard Worker        esac
431*6a54128fSAndroid Build Coastguard Worker
432*6a54128fSAndroid Build Coastguard Workerfi # $ax_pthread_clang = yes
433*6a54128fSAndroid Build Coastguard Worker
434*6a54128fSAndroid Build Coastguard Worker
435*6a54128fSAndroid Build Coastguard Worker
436*6a54128fSAndroid Build Coastguard Worker# Various other checks:
437*6a54128fSAndroid Build Coastguard Workerif test "x$ax_pthread_ok" = "xyes"; then
438*6a54128fSAndroid Build Coastguard Worker        ax_pthread_save_CFLAGS="$CFLAGS"
439*6a54128fSAndroid Build Coastguard Worker        ax_pthread_save_LIBS="$LIBS"
440*6a54128fSAndroid Build Coastguard Worker        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
441*6a54128fSAndroid Build Coastguard Worker        LIBS="$PTHREAD_LIBS $LIBS"
442*6a54128fSAndroid Build Coastguard Worker
443*6a54128fSAndroid Build Coastguard Worker        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
444*6a54128fSAndroid Build Coastguard Worker        AC_CACHE_CHECK([for joinable pthread attribute],
445*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_JOINABLE_ATTR],
446*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
447*6a54128fSAndroid Build Coastguard Worker             for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
448*6a54128fSAndroid Build Coastguard Worker                 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
449*6a54128fSAndroid Build Coastguard Worker                                                 [int attr = $ax_pthread_attr; return attr /* ; */])],
450*6a54128fSAndroid Build Coastguard Worker                                [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
451*6a54128fSAndroid Build Coastguard Worker                                [])
452*6a54128fSAndroid Build Coastguard Worker             done
453*6a54128fSAndroid Build Coastguard Worker            ])
454*6a54128fSAndroid Build Coastguard Worker        AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
455*6a54128fSAndroid Build Coastguard Worker               test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
456*6a54128fSAndroid Build Coastguard Worker               test "x$ax_pthread_joinable_attr_defined" != "xyes"],
457*6a54128fSAndroid Build Coastguard Worker              [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
458*6a54128fSAndroid Build Coastguard Worker                                  [$ax_cv_PTHREAD_JOINABLE_ATTR],
459*6a54128fSAndroid Build Coastguard Worker                                  [Define to necessary symbol if this constant
460*6a54128fSAndroid Build Coastguard Worker                                   uses a non-standard name on your system.])
461*6a54128fSAndroid Build Coastguard Worker               ax_pthread_joinable_attr_defined=yes
462*6a54128fSAndroid Build Coastguard Worker              ])
463*6a54128fSAndroid Build Coastguard Worker
464*6a54128fSAndroid Build Coastguard Worker        AC_CACHE_CHECK([whether more special flags are required for pthreads],
465*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_SPECIAL_FLAGS],
466*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_SPECIAL_FLAGS=no
467*6a54128fSAndroid Build Coastguard Worker             case $host_os in
468*6a54128fSAndroid Build Coastguard Worker             solaris*)
469*6a54128fSAndroid Build Coastguard Worker             ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
470*6a54128fSAndroid Build Coastguard Worker             ;;
471*6a54128fSAndroid Build Coastguard Worker             esac
472*6a54128fSAndroid Build Coastguard Worker            ])
473*6a54128fSAndroid Build Coastguard Worker        AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
474*6a54128fSAndroid Build Coastguard Worker               test "x$ax_pthread_special_flags_added" != "xyes"],
475*6a54128fSAndroid Build Coastguard Worker              [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
476*6a54128fSAndroid Build Coastguard Worker               ax_pthread_special_flags_added=yes])
477*6a54128fSAndroid Build Coastguard Worker
478*6a54128fSAndroid Build Coastguard Worker        AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
479*6a54128fSAndroid Build Coastguard Worker            [ax_cv_PTHREAD_PRIO_INHERIT],
480*6a54128fSAndroid Build Coastguard Worker            [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
481*6a54128fSAndroid Build Coastguard Worker                                             [[int i = PTHREAD_PRIO_INHERIT;
482*6a54128fSAndroid Build Coastguard Worker                                               return i;]])],
483*6a54128fSAndroid Build Coastguard Worker                            [ax_cv_PTHREAD_PRIO_INHERIT=yes],
484*6a54128fSAndroid Build Coastguard Worker                            [ax_cv_PTHREAD_PRIO_INHERIT=no])
485*6a54128fSAndroid Build Coastguard Worker            ])
486*6a54128fSAndroid Build Coastguard Worker        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
487*6a54128fSAndroid Build Coastguard Worker               test "x$ax_pthread_prio_inherit_defined" != "xyes"],
488*6a54128fSAndroid Build Coastguard Worker              [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
489*6a54128fSAndroid Build Coastguard Worker               ax_pthread_prio_inherit_defined=yes
490*6a54128fSAndroid Build Coastguard Worker              ])
491*6a54128fSAndroid Build Coastguard Worker
492*6a54128fSAndroid Build Coastguard Worker        CFLAGS="$ax_pthread_save_CFLAGS"
493*6a54128fSAndroid Build Coastguard Worker        LIBS="$ax_pthread_save_LIBS"
494*6a54128fSAndroid Build Coastguard Worker
495*6a54128fSAndroid Build Coastguard Worker        # More AIX lossage: compile with *_r variant
496*6a54128fSAndroid Build Coastguard Worker        if test "x$GCC" != "xyes"; then
497*6a54128fSAndroid Build Coastguard Worker            case $host_os in
498*6a54128fSAndroid Build Coastguard Worker                aix*)
499*6a54128fSAndroid Build Coastguard Worker                AS_CASE(["x/$CC"],
500*6a54128fSAndroid Build Coastguard Worker                    [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
501*6a54128fSAndroid Build Coastguard Worker                    [#handle absolute path differently from PATH based program lookup
502*6a54128fSAndroid Build Coastguard Worker                     AS_CASE(["x$CC"],
503*6a54128fSAndroid Build Coastguard Worker                         [x/*],
504*6a54128fSAndroid Build Coastguard Worker                         [
505*6a54128fSAndroid Build Coastguard Worker			   AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])
506*6a54128fSAndroid Build Coastguard Worker			   AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])])
507*6a54128fSAndroid Build Coastguard Worker			 ],
508*6a54128fSAndroid Build Coastguard Worker                         [
509*6a54128fSAndroid Build Coastguard Worker			   AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])
510*6a54128fSAndroid Build Coastguard Worker			   AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])])
511*6a54128fSAndroid Build Coastguard Worker			 ]
512*6a54128fSAndroid Build Coastguard Worker                     )
513*6a54128fSAndroid Build Coastguard Worker                    ])
514*6a54128fSAndroid Build Coastguard Worker                ;;
515*6a54128fSAndroid Build Coastguard Worker            esac
516*6a54128fSAndroid Build Coastguard Worker        fi
517*6a54128fSAndroid Build Coastguard Workerfi
518*6a54128fSAndroid Build Coastguard Worker
519*6a54128fSAndroid Build Coastguard Workertest -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
520*6a54128fSAndroid Build Coastguard Workertest -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"
521*6a54128fSAndroid Build Coastguard Worker
522*6a54128fSAndroid Build Coastguard WorkerAC_SUBST([PTHREAD_LIBS])
523*6a54128fSAndroid Build Coastguard WorkerAC_SUBST([PTHREAD_CFLAGS])
524*6a54128fSAndroid Build Coastguard WorkerAC_SUBST([PTHREAD_CC])
525*6a54128fSAndroid Build Coastguard WorkerAC_SUBST([PTHREAD_CXX])
526*6a54128fSAndroid Build Coastguard Worker
527*6a54128fSAndroid Build Coastguard Worker# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
528*6a54128fSAndroid Build Coastguard Workerif test "x$ax_pthread_ok" = "xyes"; then
529*6a54128fSAndroid Build Coastguard Worker        ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
530*6a54128fSAndroid Build Coastguard Worker        :
531*6a54128fSAndroid Build Coastguard Workerelse
532*6a54128fSAndroid Build Coastguard Worker        ax_pthread_ok=no
533*6a54128fSAndroid Build Coastguard Worker        $2
534*6a54128fSAndroid Build Coastguard Workerfi
535*6a54128fSAndroid Build Coastguard WorkerAC_LANG_POP
536*6a54128fSAndroid Build Coastguard Worker])dnl AX_PTHREAD
537*6a54128fSAndroid Build Coastguard Worker
538*6a54128fSAndroid Build Coastguard Worker# gettext.m4 serial 71 (gettext-0.20.2)
539*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc.
540*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
541*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
542*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
543*6a54128fSAndroid Build Coastguard Workerdnl
544*6a54128fSAndroid Build Coastguard Workerdnl This file can be used in projects which are not available under
545*6a54128fSAndroid Build Coastguard Workerdnl the GNU General Public License or the GNU Lesser General Public
546*6a54128fSAndroid Build Coastguard Workerdnl License but which still want to provide support for the GNU gettext
547*6a54128fSAndroid Build Coastguard Workerdnl functionality.
548*6a54128fSAndroid Build Coastguard Workerdnl Please note that the actual code of the GNU gettext library is covered
549*6a54128fSAndroid Build Coastguard Workerdnl by the GNU Lesser General Public License, and the rest of the GNU
550*6a54128fSAndroid Build Coastguard Workerdnl gettext package is covered by the GNU General Public License.
551*6a54128fSAndroid Build Coastguard Workerdnl They are *not* in the public domain.
552*6a54128fSAndroid Build Coastguard Worker
553*6a54128fSAndroid Build Coastguard Workerdnl Authors:
554*6a54128fSAndroid Build Coastguard Workerdnl   Ulrich Drepper <[email protected]>, 1995-2000.
555*6a54128fSAndroid Build Coastguard Workerdnl   Bruno Haible <[email protected]>, 2000-2006, 2008-2010.
556*6a54128fSAndroid Build Coastguard Worker
557*6a54128fSAndroid Build Coastguard Workerdnl Macro to add for using GNU gettext.
558*6a54128fSAndroid Build Coastguard Worker
559*6a54128fSAndroid Build Coastguard Workerdnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
560*6a54128fSAndroid Build Coastguard Workerdnl INTLSYMBOL must be one of 'external', 'use-libtool'.
561*6a54128fSAndroid Build Coastguard Workerdnl    INTLSYMBOL should be 'external' for packages other than GNU gettext, and
562*6a54128fSAndroid Build Coastguard Workerdnl    'use-libtool' for the packages 'gettext-runtime' and 'gettext-tools'.
563*6a54128fSAndroid Build Coastguard Workerdnl    If INTLSYMBOL is 'use-libtool', then a libtool library
564*6a54128fSAndroid Build Coastguard Workerdnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
565*6a54128fSAndroid Build Coastguard Workerdnl    depending on --{enable,disable}-{shared,static} and on the presence of
566*6a54128fSAndroid Build Coastguard Workerdnl    AM-DISABLE-SHARED).
567*6a54128fSAndroid Build Coastguard Workerdnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
568*6a54128fSAndroid Build Coastguard Workerdnl    implementations (in libc or libintl) without the ngettext() function
569*6a54128fSAndroid Build Coastguard Workerdnl    will be ignored.  If NEEDSYMBOL is specified and is
570*6a54128fSAndroid Build Coastguard Workerdnl    'need-formatstring-macros', then GNU gettext implementations that don't
571*6a54128fSAndroid Build Coastguard Workerdnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
572*6a54128fSAndroid Build Coastguard Workerdnl INTLDIR is used to find the intl libraries.  If empty,
573*6a54128fSAndroid Build Coastguard Workerdnl    the value '$(top_builddir)/intl/' is used.
574*6a54128fSAndroid Build Coastguard Workerdnl
575*6a54128fSAndroid Build Coastguard Workerdnl The result of the configuration is one of three cases:
576*6a54128fSAndroid Build Coastguard Workerdnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
577*6a54128fSAndroid Build Coastguard Workerdnl    and used.
578*6a54128fSAndroid Build Coastguard Workerdnl    Catalog format: GNU --> install in $(datadir)
579*6a54128fSAndroid Build Coastguard Workerdnl    Catalog extension: .mo after installation, .gmo in source tree
580*6a54128fSAndroid Build Coastguard Workerdnl 2) GNU gettext has been found in the system's C library.
581*6a54128fSAndroid Build Coastguard Workerdnl    Catalog format: GNU --> install in $(datadir)
582*6a54128fSAndroid Build Coastguard Workerdnl    Catalog extension: .mo after installation, .gmo in source tree
583*6a54128fSAndroid Build Coastguard Workerdnl 3) No internationalization, always use English msgid.
584*6a54128fSAndroid Build Coastguard Workerdnl    Catalog format: none
585*6a54128fSAndroid Build Coastguard Workerdnl    Catalog extension: none
586*6a54128fSAndroid Build Coastguard Workerdnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
587*6a54128fSAndroid Build Coastguard Workerdnl The use of .gmo is historical (it was needed to avoid overwriting the
588*6a54128fSAndroid Build Coastguard Workerdnl GNU format catalogs when building on a platform with an X/Open gettext),
589*6a54128fSAndroid Build Coastguard Workerdnl but we keep it in order not to force irrelevant filename changes on the
590*6a54128fSAndroid Build Coastguard Workerdnl maintainers.
591*6a54128fSAndroid Build Coastguard Workerdnl
592*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_GNU_GETTEXT],
593*6a54128fSAndroid Build Coastguard Worker[
594*6a54128fSAndroid Build Coastguard Worker  dnl Argument checking.
595*6a54128fSAndroid Build Coastguard Worker  ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [use-libtool], ,
596*6a54128fSAndroid Build Coastguard Worker    [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
597*6a54128fSAndroid Build Coastguard Worker])])])])
598*6a54128fSAndroid Build Coastguard Worker  ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
599*6a54128fSAndroid Build Coastguard Worker    [errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported.
600*6a54128fSAndroid Build Coastguard Worker])])
601*6a54128fSAndroid Build Coastguard Worker  ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
602*6a54128fSAndroid Build Coastguard Worker    [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
603*6a54128fSAndroid Build Coastguard Worker])])])])
604*6a54128fSAndroid Build Coastguard Worker  define([gt_included_intl],
605*6a54128fSAndroid Build Coastguard Worker    ifelse([$1], [external], [no], [yes]))
606*6a54128fSAndroid Build Coastguard Worker  gt_NEEDS_INIT
607*6a54128fSAndroid Build Coastguard Worker  AM_GNU_GETTEXT_NEED([$2])
608*6a54128fSAndroid Build Coastguard Worker
609*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AM_PO_SUBDIRS])dnl
610*6a54128fSAndroid Build Coastguard Worker  ifelse(gt_included_intl, yes, [
611*6a54128fSAndroid Build Coastguard Worker    AC_REQUIRE([AM_INTL_SUBDIR])dnl
612*6a54128fSAndroid Build Coastguard Worker  ])
613*6a54128fSAndroid Build Coastguard Worker
614*6a54128fSAndroid Build Coastguard Worker  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
615*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
616*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_RPATH])
617*6a54128fSAndroid Build Coastguard Worker
618*6a54128fSAndroid Build Coastguard Worker  dnl Sometimes libintl requires libiconv, so first search for libiconv.
619*6a54128fSAndroid Build Coastguard Worker  dnl Ideally we would do this search only after the
620*6a54128fSAndroid Build Coastguard Worker  dnl      if test "$USE_NLS" = "yes"; then
621*6a54128fSAndroid Build Coastguard Worker  dnl        if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
622*6a54128fSAndroid Build Coastguard Worker  dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
623*6a54128fSAndroid Build Coastguard Worker  dnl the configure script would need to contain the same shell code
624*6a54128fSAndroid Build Coastguard Worker  dnl again, outside any 'if'. There are two solutions:
625*6a54128fSAndroid Build Coastguard Worker  dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
626*6a54128fSAndroid Build Coastguard Worker  dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
627*6a54128fSAndroid Build Coastguard Worker  dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it.
628*6a54128fSAndroid Build Coastguard Worker  ifelse(gt_included_intl, yes, , [
629*6a54128fSAndroid Build Coastguard Worker    AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
630*6a54128fSAndroid Build Coastguard Worker  ])
631*6a54128fSAndroid Build Coastguard Worker
632*6a54128fSAndroid Build Coastguard Worker  dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
633*6a54128fSAndroid Build Coastguard Worker  gt_INTL_MACOSX
634*6a54128fSAndroid Build Coastguard Worker
635*6a54128fSAndroid Build Coastguard Worker  dnl Set USE_NLS.
636*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AM_NLS])
637*6a54128fSAndroid Build Coastguard Worker
638*6a54128fSAndroid Build Coastguard Worker  ifelse(gt_included_intl, yes, [
639*6a54128fSAndroid Build Coastguard Worker    BUILD_INCLUDED_LIBINTL=no
640*6a54128fSAndroid Build Coastguard Worker    USE_INCLUDED_LIBINTL=no
641*6a54128fSAndroid Build Coastguard Worker  ])
642*6a54128fSAndroid Build Coastguard Worker  LIBINTL=
643*6a54128fSAndroid Build Coastguard Worker  LTLIBINTL=
644*6a54128fSAndroid Build Coastguard Worker  POSUB=
645*6a54128fSAndroid Build Coastguard Worker
646*6a54128fSAndroid Build Coastguard Worker  dnl Add a version number to the cache macros.
647*6a54128fSAndroid Build Coastguard Worker  case " $gt_needs " in
648*6a54128fSAndroid Build Coastguard Worker    *" need-formatstring-macros "*) gt_api_version=3 ;;
649*6a54128fSAndroid Build Coastguard Worker    *" need-ngettext "*) gt_api_version=2 ;;
650*6a54128fSAndroid Build Coastguard Worker    *) gt_api_version=1 ;;
651*6a54128fSAndroid Build Coastguard Worker  esac
652*6a54128fSAndroid Build Coastguard Worker  gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
653*6a54128fSAndroid Build Coastguard Worker  gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
654*6a54128fSAndroid Build Coastguard Worker
655*6a54128fSAndroid Build Coastguard Worker  dnl If we use NLS figure out what method
656*6a54128fSAndroid Build Coastguard Worker  if test "$USE_NLS" = "yes"; then
657*6a54128fSAndroid Build Coastguard Worker    gt_use_preinstalled_gnugettext=no
658*6a54128fSAndroid Build Coastguard Worker    ifelse(gt_included_intl, yes, [
659*6a54128fSAndroid Build Coastguard Worker      AC_MSG_CHECKING([whether included gettext is requested])
660*6a54128fSAndroid Build Coastguard Worker      AC_ARG_WITH([included-gettext],
661*6a54128fSAndroid Build Coastguard Worker        [  --with-included-gettext use the GNU gettext library included here],
662*6a54128fSAndroid Build Coastguard Worker        nls_cv_force_use_gnu_gettext=$withval,
663*6a54128fSAndroid Build Coastguard Worker        nls_cv_force_use_gnu_gettext=no)
664*6a54128fSAndroid Build Coastguard Worker      AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
665*6a54128fSAndroid Build Coastguard Worker
666*6a54128fSAndroid Build Coastguard Worker      nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
667*6a54128fSAndroid Build Coastguard Worker      if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
668*6a54128fSAndroid Build Coastguard Worker    ])
669*6a54128fSAndroid Build Coastguard Worker        dnl User does not insist on using GNU NLS library.  Figure out what
670*6a54128fSAndroid Build Coastguard Worker        dnl to use.  If GNU gettext is available we use this.  Else we have
671*6a54128fSAndroid Build Coastguard Worker        dnl to fall back to GNU NLS library.
672*6a54128fSAndroid Build Coastguard Worker
673*6a54128fSAndroid Build Coastguard Worker        if test $gt_api_version -ge 3; then
674*6a54128fSAndroid Build Coastguard Worker          gt_revision_test_code='
675*6a54128fSAndroid Build Coastguard Worker#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
676*6a54128fSAndroid Build Coastguard Worker#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
677*6a54128fSAndroid Build Coastguard Worker#endif
678*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
679*6a54128fSAndroid Build Coastguard Workertypedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
680*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
681*6a54128fSAndroid Build Coastguard Worker'
682*6a54128fSAndroid Build Coastguard Worker        else
683*6a54128fSAndroid Build Coastguard Worker          gt_revision_test_code=
684*6a54128fSAndroid Build Coastguard Worker        fi
685*6a54128fSAndroid Build Coastguard Worker        if test $gt_api_version -ge 2; then
686*6a54128fSAndroid Build Coastguard Worker          gt_expression_test_code=' + * ngettext ("", "", 0)'
687*6a54128fSAndroid Build Coastguard Worker        else
688*6a54128fSAndroid Build Coastguard Worker          gt_expression_test_code=
689*6a54128fSAndroid Build Coastguard Worker        fi
690*6a54128fSAndroid Build Coastguard Worker
691*6a54128fSAndroid Build Coastguard Worker        AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
692*6a54128fSAndroid Build Coastguard Worker         [AC_LINK_IFELSE(
693*6a54128fSAndroid Build Coastguard Worker            [AC_LANG_PROGRAM(
694*6a54128fSAndroid Build Coastguard Worker               [[
695*6a54128fSAndroid Build Coastguard Worker#include <libintl.h>
696*6a54128fSAndroid Build Coastguard Worker#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
697*6a54128fSAndroid Build Coastguard Workerextern int _nl_msg_cat_cntr;
698*6a54128fSAndroid Build Coastguard Workerextern int *_nl_domain_bindings;
699*6a54128fSAndroid Build Coastguard Worker#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings)
700*6a54128fSAndroid Build Coastguard Worker#else
701*6a54128fSAndroid Build Coastguard Worker#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
702*6a54128fSAndroid Build Coastguard Worker#endif
703*6a54128fSAndroid Build Coastguard Worker$gt_revision_test_code
704*6a54128fSAndroid Build Coastguard Worker               ]],
705*6a54128fSAndroid Build Coastguard Worker               [[
706*6a54128fSAndroid Build Coastguard Workerbindtextdomain ("", "");
707*6a54128fSAndroid Build Coastguard Workerreturn * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
708*6a54128fSAndroid Build Coastguard Worker               ]])],
709*6a54128fSAndroid Build Coastguard Worker            [eval "$gt_func_gnugettext_libc=yes"],
710*6a54128fSAndroid Build Coastguard Worker            [eval "$gt_func_gnugettext_libc=no"])])
711*6a54128fSAndroid Build Coastguard Worker
712*6a54128fSAndroid Build Coastguard Worker        if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
713*6a54128fSAndroid Build Coastguard Worker          dnl Sometimes libintl requires libiconv, so first search for libiconv.
714*6a54128fSAndroid Build Coastguard Worker          ifelse(gt_included_intl, yes, , [
715*6a54128fSAndroid Build Coastguard Worker            AM_ICONV_LINK
716*6a54128fSAndroid Build Coastguard Worker          ])
717*6a54128fSAndroid Build Coastguard Worker          dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
718*6a54128fSAndroid Build Coastguard Worker          dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
719*6a54128fSAndroid Build Coastguard Worker          dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
720*6a54128fSAndroid Build Coastguard Worker          dnl even if libiconv doesn't exist.
721*6a54128fSAndroid Build Coastguard Worker          AC_LIB_LINKFLAGS_BODY([intl])
722*6a54128fSAndroid Build Coastguard Worker          AC_CACHE_CHECK([for GNU gettext in libintl],
723*6a54128fSAndroid Build Coastguard Worker            [$gt_func_gnugettext_libintl],
724*6a54128fSAndroid Build Coastguard Worker           [gt_save_CPPFLAGS="$CPPFLAGS"
725*6a54128fSAndroid Build Coastguard Worker            CPPFLAGS="$CPPFLAGS $INCINTL"
726*6a54128fSAndroid Build Coastguard Worker            gt_save_LIBS="$LIBS"
727*6a54128fSAndroid Build Coastguard Worker            LIBS="$LIBS $LIBINTL"
728*6a54128fSAndroid Build Coastguard Worker            dnl Now see whether libintl exists and does not depend on libiconv.
729*6a54128fSAndroid Build Coastguard Worker            AC_LINK_IFELSE(
730*6a54128fSAndroid Build Coastguard Worker              [AC_LANG_PROGRAM(
731*6a54128fSAndroid Build Coastguard Worker                 [[
732*6a54128fSAndroid Build Coastguard Worker#include <libintl.h>
733*6a54128fSAndroid Build Coastguard Worker#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
734*6a54128fSAndroid Build Coastguard Workerextern int _nl_msg_cat_cntr;
735*6a54128fSAndroid Build Coastguard Workerextern
736*6a54128fSAndroid Build Coastguard Worker#ifdef __cplusplus
737*6a54128fSAndroid Build Coastguard Worker"C"
738*6a54128fSAndroid Build Coastguard Worker#endif
739*6a54128fSAndroid Build Coastguard Workerconst char *_nl_expand_alias (const char *);
740*6a54128fSAndroid Build Coastguard Worker#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))
741*6a54128fSAndroid Build Coastguard Worker#else
742*6a54128fSAndroid Build Coastguard Worker#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
743*6a54128fSAndroid Build Coastguard Worker#endif
744*6a54128fSAndroid Build Coastguard Worker$gt_revision_test_code
745*6a54128fSAndroid Build Coastguard Worker                 ]],
746*6a54128fSAndroid Build Coastguard Worker                 [[
747*6a54128fSAndroid Build Coastguard Workerbindtextdomain ("", "");
748*6a54128fSAndroid Build Coastguard Workerreturn * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
749*6a54128fSAndroid Build Coastguard Worker                 ]])],
750*6a54128fSAndroid Build Coastguard Worker              [eval "$gt_func_gnugettext_libintl=yes"],
751*6a54128fSAndroid Build Coastguard Worker              [eval "$gt_func_gnugettext_libintl=no"])
752*6a54128fSAndroid Build Coastguard Worker            dnl Now see whether libintl exists and depends on libiconv.
753*6a54128fSAndroid Build Coastguard Worker            if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
754*6a54128fSAndroid Build Coastguard Worker              LIBS="$LIBS $LIBICONV"
755*6a54128fSAndroid Build Coastguard Worker              AC_LINK_IFELSE(
756*6a54128fSAndroid Build Coastguard Worker                [AC_LANG_PROGRAM(
757*6a54128fSAndroid Build Coastguard Worker                   [[
758*6a54128fSAndroid Build Coastguard Worker#include <libintl.h>
759*6a54128fSAndroid Build Coastguard Worker#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
760*6a54128fSAndroid Build Coastguard Workerextern int _nl_msg_cat_cntr;
761*6a54128fSAndroid Build Coastguard Workerextern
762*6a54128fSAndroid Build Coastguard Worker#ifdef __cplusplus
763*6a54128fSAndroid Build Coastguard Worker"C"
764*6a54128fSAndroid Build Coastguard Worker#endif
765*6a54128fSAndroid Build Coastguard Workerconst char *_nl_expand_alias (const char *);
766*6a54128fSAndroid Build Coastguard Worker#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))
767*6a54128fSAndroid Build Coastguard Worker#else
768*6a54128fSAndroid Build Coastguard Worker#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0
769*6a54128fSAndroid Build Coastguard Worker#endif
770*6a54128fSAndroid Build Coastguard Worker$gt_revision_test_code
771*6a54128fSAndroid Build Coastguard Worker                   ]],
772*6a54128fSAndroid Build Coastguard Worker                   [[
773*6a54128fSAndroid Build Coastguard Workerbindtextdomain ("", "");
774*6a54128fSAndroid Build Coastguard Workerreturn * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
775*6a54128fSAndroid Build Coastguard Worker                   ]])],
776*6a54128fSAndroid Build Coastguard Worker                [LIBINTL="$LIBINTL $LIBICONV"
777*6a54128fSAndroid Build Coastguard Worker                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
778*6a54128fSAndroid Build Coastguard Worker                 eval "$gt_func_gnugettext_libintl=yes"
779*6a54128fSAndroid Build Coastguard Worker                ])
780*6a54128fSAndroid Build Coastguard Worker            fi
781*6a54128fSAndroid Build Coastguard Worker            CPPFLAGS="$gt_save_CPPFLAGS"
782*6a54128fSAndroid Build Coastguard Worker            LIBS="$gt_save_LIBS"])
783*6a54128fSAndroid Build Coastguard Worker        fi
784*6a54128fSAndroid Build Coastguard Worker
785*6a54128fSAndroid Build Coastguard Worker        dnl If an already present or preinstalled GNU gettext() is found,
786*6a54128fSAndroid Build Coastguard Worker        dnl use it.  But if this macro is used in GNU gettext, and GNU
787*6a54128fSAndroid Build Coastguard Worker        dnl gettext is already preinstalled in libintl, we update this
788*6a54128fSAndroid Build Coastguard Worker        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
789*6a54128fSAndroid Build Coastguard Worker        if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
790*6a54128fSAndroid Build Coastguard Worker           || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
791*6a54128fSAndroid Build Coastguard Worker                && test "$PACKAGE" != gettext-runtime \
792*6a54128fSAndroid Build Coastguard Worker                && test "$PACKAGE" != gettext-tools; }; then
793*6a54128fSAndroid Build Coastguard Worker          gt_use_preinstalled_gnugettext=yes
794*6a54128fSAndroid Build Coastguard Worker        else
795*6a54128fSAndroid Build Coastguard Worker          dnl Reset the values set by searching for libintl.
796*6a54128fSAndroid Build Coastguard Worker          LIBINTL=
797*6a54128fSAndroid Build Coastguard Worker          LTLIBINTL=
798*6a54128fSAndroid Build Coastguard Worker          INCINTL=
799*6a54128fSAndroid Build Coastguard Worker        fi
800*6a54128fSAndroid Build Coastguard Worker
801*6a54128fSAndroid Build Coastguard Worker    ifelse(gt_included_intl, yes, [
802*6a54128fSAndroid Build Coastguard Worker        if test "$gt_use_preinstalled_gnugettext" != "yes"; then
803*6a54128fSAndroid Build Coastguard Worker          dnl GNU gettext is not found in the C library.
804*6a54128fSAndroid Build Coastguard Worker          dnl Fall back on included GNU gettext library.
805*6a54128fSAndroid Build Coastguard Worker          nls_cv_use_gnu_gettext=yes
806*6a54128fSAndroid Build Coastguard Worker        fi
807*6a54128fSAndroid Build Coastguard Worker      fi
808*6a54128fSAndroid Build Coastguard Worker
809*6a54128fSAndroid Build Coastguard Worker      if test "$nls_cv_use_gnu_gettext" = "yes"; then
810*6a54128fSAndroid Build Coastguard Worker        dnl Mark actions used to generate GNU NLS library.
811*6a54128fSAndroid Build Coastguard Worker        BUILD_INCLUDED_LIBINTL=yes
812*6a54128fSAndroid Build Coastguard Worker        USE_INCLUDED_LIBINTL=yes
813*6a54128fSAndroid Build Coastguard Worker        LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD"
814*6a54128fSAndroid Build Coastguard Worker        LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD"
815*6a54128fSAndroid Build Coastguard Worker        LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
816*6a54128fSAndroid Build Coastguard Worker      fi
817*6a54128fSAndroid Build Coastguard Worker
818*6a54128fSAndroid Build Coastguard Worker      CATOBJEXT=
819*6a54128fSAndroid Build Coastguard Worker      if test "$gt_use_preinstalled_gnugettext" = "yes" \
820*6a54128fSAndroid Build Coastguard Worker         || test "$nls_cv_use_gnu_gettext" = "yes"; then
821*6a54128fSAndroid Build Coastguard Worker        dnl Mark actions to use GNU gettext tools.
822*6a54128fSAndroid Build Coastguard Worker        CATOBJEXT=.gmo
823*6a54128fSAndroid Build Coastguard Worker      fi
824*6a54128fSAndroid Build Coastguard Worker    ])
825*6a54128fSAndroid Build Coastguard Worker
826*6a54128fSAndroid Build Coastguard Worker    if test -n "$INTL_MACOSX_LIBS"; then
827*6a54128fSAndroid Build Coastguard Worker      if test "$gt_use_preinstalled_gnugettext" = "yes" \
828*6a54128fSAndroid Build Coastguard Worker         || test "$nls_cv_use_gnu_gettext" = "yes"; then
829*6a54128fSAndroid Build Coastguard Worker        dnl Some extra flags are needed during linking.
830*6a54128fSAndroid Build Coastguard Worker        LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
831*6a54128fSAndroid Build Coastguard Worker        LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
832*6a54128fSAndroid Build Coastguard Worker      fi
833*6a54128fSAndroid Build Coastguard Worker    fi
834*6a54128fSAndroid Build Coastguard Worker
835*6a54128fSAndroid Build Coastguard Worker    if test "$gt_use_preinstalled_gnugettext" = "yes" \
836*6a54128fSAndroid Build Coastguard Worker       || test "$nls_cv_use_gnu_gettext" = "yes"; then
837*6a54128fSAndroid Build Coastguard Worker      AC_DEFINE([ENABLE_NLS], [1],
838*6a54128fSAndroid Build Coastguard Worker        [Define to 1 if translation of program messages to the user's native language
839*6a54128fSAndroid Build Coastguard Worker   is requested.])
840*6a54128fSAndroid Build Coastguard Worker    else
841*6a54128fSAndroid Build Coastguard Worker      USE_NLS=no
842*6a54128fSAndroid Build Coastguard Worker    fi
843*6a54128fSAndroid Build Coastguard Worker  fi
844*6a54128fSAndroid Build Coastguard Worker
845*6a54128fSAndroid Build Coastguard Worker  AC_MSG_CHECKING([whether to use NLS])
846*6a54128fSAndroid Build Coastguard Worker  AC_MSG_RESULT([$USE_NLS])
847*6a54128fSAndroid Build Coastguard Worker  if test "$USE_NLS" = "yes"; then
848*6a54128fSAndroid Build Coastguard Worker    AC_MSG_CHECKING([where the gettext function comes from])
849*6a54128fSAndroid Build Coastguard Worker    if test "$gt_use_preinstalled_gnugettext" = "yes"; then
850*6a54128fSAndroid Build Coastguard Worker      if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
851*6a54128fSAndroid Build Coastguard Worker        gt_source="external libintl"
852*6a54128fSAndroid Build Coastguard Worker      else
853*6a54128fSAndroid Build Coastguard Worker        gt_source="libc"
854*6a54128fSAndroid Build Coastguard Worker      fi
855*6a54128fSAndroid Build Coastguard Worker    else
856*6a54128fSAndroid Build Coastguard Worker      gt_source="included intl directory"
857*6a54128fSAndroid Build Coastguard Worker    fi
858*6a54128fSAndroid Build Coastguard Worker    AC_MSG_RESULT([$gt_source])
859*6a54128fSAndroid Build Coastguard Worker  fi
860*6a54128fSAndroid Build Coastguard Worker
861*6a54128fSAndroid Build Coastguard Worker  if test "$USE_NLS" = "yes"; then
862*6a54128fSAndroid Build Coastguard Worker
863*6a54128fSAndroid Build Coastguard Worker    if test "$gt_use_preinstalled_gnugettext" = "yes"; then
864*6a54128fSAndroid Build Coastguard Worker      if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
865*6a54128fSAndroid Build Coastguard Worker        AC_MSG_CHECKING([how to link with libintl])
866*6a54128fSAndroid Build Coastguard Worker        AC_MSG_RESULT([$LIBINTL])
867*6a54128fSAndroid Build Coastguard Worker        AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
868*6a54128fSAndroid Build Coastguard Worker      fi
869*6a54128fSAndroid Build Coastguard Worker
870*6a54128fSAndroid Build Coastguard Worker      dnl For backward compatibility. Some packages may be using this.
871*6a54128fSAndroid Build Coastguard Worker      AC_DEFINE([HAVE_GETTEXT], [1],
872*6a54128fSAndroid Build Coastguard Worker       [Define if the GNU gettext() function is already present or preinstalled.])
873*6a54128fSAndroid Build Coastguard Worker      AC_DEFINE([HAVE_DCGETTEXT], [1],
874*6a54128fSAndroid Build Coastguard Worker       [Define if the GNU dcgettext() function is already present or preinstalled.])
875*6a54128fSAndroid Build Coastguard Worker    fi
876*6a54128fSAndroid Build Coastguard Worker
877*6a54128fSAndroid Build Coastguard Worker    dnl We need to process the po/ directory.
878*6a54128fSAndroid Build Coastguard Worker    POSUB=po
879*6a54128fSAndroid Build Coastguard Worker  fi
880*6a54128fSAndroid Build Coastguard Worker
881*6a54128fSAndroid Build Coastguard Worker  ifelse(gt_included_intl, yes, [
882*6a54128fSAndroid Build Coastguard Worker    dnl In GNU gettext we have to set BUILD_INCLUDED_LIBINTL to 'yes'
883*6a54128fSAndroid Build Coastguard Worker    dnl because some of the testsuite requires it.
884*6a54128fSAndroid Build Coastguard Worker    BUILD_INCLUDED_LIBINTL=yes
885*6a54128fSAndroid Build Coastguard Worker
886*6a54128fSAndroid Build Coastguard Worker    dnl Make all variables we use known to autoconf.
887*6a54128fSAndroid Build Coastguard Worker    AC_SUBST([BUILD_INCLUDED_LIBINTL])
888*6a54128fSAndroid Build Coastguard Worker    AC_SUBST([USE_INCLUDED_LIBINTL])
889*6a54128fSAndroid Build Coastguard Worker    AC_SUBST([CATOBJEXT])
890*6a54128fSAndroid Build Coastguard Worker  ])
891*6a54128fSAndroid Build Coastguard Worker
892*6a54128fSAndroid Build Coastguard Worker  dnl For backward compatibility. Some Makefiles may be using this.
893*6a54128fSAndroid Build Coastguard Worker  INTLLIBS="$LIBINTL"
894*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([INTLLIBS])
895*6a54128fSAndroid Build Coastguard Worker
896*6a54128fSAndroid Build Coastguard Worker  dnl Make all documented variables known to autoconf.
897*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LIBINTL])
898*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LTLIBINTL])
899*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([POSUB])
900*6a54128fSAndroid Build Coastguard Worker])
901*6a54128fSAndroid Build Coastguard Worker
902*6a54128fSAndroid Build Coastguard Worker
903*6a54128fSAndroid Build Coastguard Workerdnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
904*6a54128fSAndroid Build Coastguard Workerm4_define([gt_NEEDS_INIT],
905*6a54128fSAndroid Build Coastguard Worker[
906*6a54128fSAndroid Build Coastguard Worker  m4_divert_text([DEFAULTS], [gt_needs=])
907*6a54128fSAndroid Build Coastguard Worker  m4_define([gt_NEEDS_INIT], [])
908*6a54128fSAndroid Build Coastguard Worker])
909*6a54128fSAndroid Build Coastguard Worker
910*6a54128fSAndroid Build Coastguard Worker
911*6a54128fSAndroid Build Coastguard Workerdnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
912*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_GNU_GETTEXT_NEED],
913*6a54128fSAndroid Build Coastguard Worker[
914*6a54128fSAndroid Build Coastguard Worker  m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
915*6a54128fSAndroid Build Coastguard Worker])
916*6a54128fSAndroid Build Coastguard Worker
917*6a54128fSAndroid Build Coastguard Worker
918*6a54128fSAndroid Build Coastguard Workerdnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
919*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
920*6a54128fSAndroid Build Coastguard Worker
921*6a54128fSAndroid Build Coastguard Worker
922*6a54128fSAndroid Build Coastguard Workerdnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version])
923*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], [])
924*6a54128fSAndroid Build Coastguard Worker
925*6a54128fSAndroid Build Coastguard Worker# host-cpu-c-abi.m4 serial 13
926*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 2002-2020 Free Software Foundation, Inc.
927*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
928*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
929*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
930*6a54128fSAndroid Build Coastguard Worker
931*6a54128fSAndroid Build Coastguard Workerdnl From Bruno Haible and Sam Steingold.
932*6a54128fSAndroid Build Coastguard Worker
933*6a54128fSAndroid Build Coastguard Workerdnl Sets the HOST_CPU variable to the canonical name of the CPU.
934*6a54128fSAndroid Build Coastguard Workerdnl Sets the HOST_CPU_C_ABI variable to the canonical name of the CPU with its
935*6a54128fSAndroid Build Coastguard Workerdnl C language ABI (application binary interface).
936*6a54128fSAndroid Build Coastguard Workerdnl Also defines __${HOST_CPU}__ and __${HOST_CPU_C_ABI}__ as C macros in
937*6a54128fSAndroid Build Coastguard Workerdnl config.h.
938*6a54128fSAndroid Build Coastguard Workerdnl
939*6a54128fSAndroid Build Coastguard Workerdnl This canonical name can be used to select a particular assembly language
940*6a54128fSAndroid Build Coastguard Workerdnl source file that will interoperate with C code on the given host.
941*6a54128fSAndroid Build Coastguard Workerdnl
942*6a54128fSAndroid Build Coastguard Workerdnl For example:
943*6a54128fSAndroid Build Coastguard Workerdnl * 'i386' and 'sparc' are different canonical names, because code for i386
944*6a54128fSAndroid Build Coastguard Workerdnl   will not run on SPARC CPUs and vice versa. They have different
945*6a54128fSAndroid Build Coastguard Workerdnl   instruction sets.
946*6a54128fSAndroid Build Coastguard Workerdnl * 'sparc' and 'sparc64' are different canonical names, because code for
947*6a54128fSAndroid Build Coastguard Workerdnl   'sparc' and code for 'sparc64' cannot be linked together: 'sparc' code
948*6a54128fSAndroid Build Coastguard Workerdnl   contains 32-bit instructions, whereas 'sparc64' code contains 64-bit
949*6a54128fSAndroid Build Coastguard Workerdnl   instructions. A process on a SPARC CPU can be in 32-bit mode or in 64-bit
950*6a54128fSAndroid Build Coastguard Workerdnl   mode, but not both.
951*6a54128fSAndroid Build Coastguard Workerdnl * 'mips' and 'mipsn32' are different canonical names, because they use
952*6a54128fSAndroid Build Coastguard Workerdnl   different argument passing and return conventions for C functions, and
953*6a54128fSAndroid Build Coastguard Workerdnl   although the instruction set of 'mips' is a large subset of the
954*6a54128fSAndroid Build Coastguard Workerdnl   instruction set of 'mipsn32'.
955*6a54128fSAndroid Build Coastguard Workerdnl * 'mipsn32' and 'mips64' are different canonical names, because they use
956*6a54128fSAndroid Build Coastguard Workerdnl   different sizes for the C types like 'int' and 'void *', and although
957*6a54128fSAndroid Build Coastguard Workerdnl   the instruction sets of 'mipsn32' and 'mips64' are the same.
958*6a54128fSAndroid Build Coastguard Workerdnl * The same canonical name is used for different endiannesses. You can
959*6a54128fSAndroid Build Coastguard Workerdnl   determine the endianness through preprocessor symbols:
960*6a54128fSAndroid Build Coastguard Workerdnl   - 'arm': test __ARMEL__.
961*6a54128fSAndroid Build Coastguard Workerdnl   - 'mips', 'mipsn32', 'mips64': test _MIPSEB vs. _MIPSEL.
962*6a54128fSAndroid Build Coastguard Workerdnl   - 'powerpc64': test _BIG_ENDIAN vs. _LITTLE_ENDIAN.
963*6a54128fSAndroid Build Coastguard Workerdnl * The same name 'i386' is used for CPUs of type i386, i486, i586
964*6a54128fSAndroid Build Coastguard Workerdnl   (Pentium), AMD K7, Pentium II, Pentium IV, etc., because
965*6a54128fSAndroid Build Coastguard Workerdnl   - Instructions that do not exist on all of these CPUs (cmpxchg,
966*6a54128fSAndroid Build Coastguard Workerdnl     MMX, SSE, SSE2, 3DNow! etc.) are not frequently used. If your
967*6a54128fSAndroid Build Coastguard Workerdnl     assembly language source files use such instructions, you will
968*6a54128fSAndroid Build Coastguard Workerdnl     need to make the distinction.
969*6a54128fSAndroid Build Coastguard Workerdnl   - Speed of execution of the common instruction set is reasonable across
970*6a54128fSAndroid Build Coastguard Workerdnl     the entire family of CPUs. If you have assembly language source files
971*6a54128fSAndroid Build Coastguard Workerdnl     that are optimized for particular CPU types (like GNU gmp has), you
972*6a54128fSAndroid Build Coastguard Workerdnl     will need to make the distinction.
973*6a54128fSAndroid Build Coastguard Workerdnl   See <https://en.wikipedia.org/wiki/X86_instruction_listings>.
974*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([gl_HOST_CPU_C_ABI],
975*6a54128fSAndroid Build Coastguard Worker[
976*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_CANONICAL_HOST])
977*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([gl_C_ASM])
978*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([host CPU and C ABI], [gl_cv_host_cpu_c_abi],
979*6a54128fSAndroid Build Coastguard Worker    [case "$host_cpu" in
980*6a54128fSAndroid Build Coastguard Worker
981*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
982*6a54128fSAndroid Build Coastguard Worker       i[34567]86 )
983*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
984*6a54128fSAndroid Build Coastguard Worker         gl_cv_host_cpu_c_abi=i386
985*6a54128fSAndroid Build Coastguard Worker         ;;
986*6a54128fSAndroid Build Coastguard Worker
987*6a54128fSAndroid Build Coastguard Worker       x86_64 )
988*6a54128fSAndroid Build Coastguard Worker         # On x86_64 systems, the C compiler may be generating code in one of
989*6a54128fSAndroid Build Coastguard Worker         # these ABIs:
990*6a54128fSAndroid Build Coastguard Worker         # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64.
991*6a54128fSAndroid Build Coastguard Worker         # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64
992*6a54128fSAndroid Build Coastguard Worker         #   with native Windows (mingw, MSVC).
993*6a54128fSAndroid Build Coastguard Worker         # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32.
994*6a54128fSAndroid Build Coastguard Worker         # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386.
995*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
996*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
997*6a54128fSAndroid Build Coastguard Worker              [[#if (defined __x86_64__ || defined __amd64__ \
998*6a54128fSAndroid Build Coastguard Worker                     || defined _M_X64 || defined _M_AMD64)
999*6a54128fSAndroid Build Coastguard Worker                 int ok;
1000*6a54128fSAndroid Build Coastguard Worker                #else
1001*6a54128fSAndroid Build Coastguard Worker                 error fail
1002*6a54128fSAndroid Build Coastguard Worker                #endif
1003*6a54128fSAndroid Build Coastguard Worker              ]])],
1004*6a54128fSAndroid Build Coastguard Worker           [AC_COMPILE_IFELSE(
1005*6a54128fSAndroid Build Coastguard Worker              [AC_LANG_SOURCE(
1006*6a54128fSAndroid Build Coastguard Worker                 [[#if defined __ILP32__ || defined _ILP32
1007*6a54128fSAndroid Build Coastguard Worker                    int ok;
1008*6a54128fSAndroid Build Coastguard Worker                   #else
1009*6a54128fSAndroid Build Coastguard Worker                    error fail
1010*6a54128fSAndroid Build Coastguard Worker                   #endif
1011*6a54128fSAndroid Build Coastguard Worker                 ]])],
1012*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=x86_64-x32],
1013*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=x86_64])],
1014*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=i386])
1015*6a54128fSAndroid Build Coastguard Worker         ;;
1016*6a54128fSAndroid Build Coastguard Worker
1017*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
1018*6a54128fSAndroid Build Coastguard Worker       alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
1019*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
1020*6a54128fSAndroid Build Coastguard Worker         gl_cv_host_cpu_c_abi=alpha
1021*6a54128fSAndroid Build Coastguard Worker         ;;
1022*6a54128fSAndroid Build Coastguard Worker
1023*6a54128fSAndroid Build Coastguard Worker       arm* | aarch64 )
1024*6a54128fSAndroid Build Coastguard Worker         # Assume arm with EABI.
1025*6a54128fSAndroid Build Coastguard Worker         # On arm64 systems, the C compiler may be generating code in one of
1026*6a54128fSAndroid Build Coastguard Worker         # these ABIs:
1027*6a54128fSAndroid Build Coastguard Worker         # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64.
1028*6a54128fSAndroid Build Coastguard Worker         # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32.
1029*6a54128fSAndroid Build Coastguard Worker         # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf.
1030*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1031*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1032*6a54128fSAndroid Build Coastguard Worker              [[#ifdef __aarch64__
1033*6a54128fSAndroid Build Coastguard Worker                 int ok;
1034*6a54128fSAndroid Build Coastguard Worker                #else
1035*6a54128fSAndroid Build Coastguard Worker                 error fail
1036*6a54128fSAndroid Build Coastguard Worker                #endif
1037*6a54128fSAndroid Build Coastguard Worker              ]])],
1038*6a54128fSAndroid Build Coastguard Worker           [AC_COMPILE_IFELSE(
1039*6a54128fSAndroid Build Coastguard Worker              [AC_LANG_SOURCE(
1040*6a54128fSAndroid Build Coastguard Worker                [[#if defined __ILP32__ || defined _ILP32
1041*6a54128fSAndroid Build Coastguard Worker                   int ok;
1042*6a54128fSAndroid Build Coastguard Worker                  #else
1043*6a54128fSAndroid Build Coastguard Worker                   error fail
1044*6a54128fSAndroid Build Coastguard Worker                  #endif
1045*6a54128fSAndroid Build Coastguard Worker                ]])],
1046*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=arm64-ilp32],
1047*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=arm64])],
1048*6a54128fSAndroid Build Coastguard Worker           [# Don't distinguish little-endian and big-endian arm, since they
1049*6a54128fSAndroid Build Coastguard Worker            # don't require different machine code for simple operations and
1050*6a54128fSAndroid Build Coastguard Worker            # since the user can distinguish them through the preprocessor
1051*6a54128fSAndroid Build Coastguard Worker            # defines __ARMEL__ vs. __ARMEB__.
1052*6a54128fSAndroid Build Coastguard Worker            # But distinguish arm which passes floating-point arguments and
1053*6a54128fSAndroid Build Coastguard Worker            # return values in integer registers (r0, r1, ...) - this is
1054*6a54128fSAndroid Build Coastguard Worker            # gcc -mfloat-abi=soft or gcc -mfloat-abi=softfp - from arm which
1055*6a54128fSAndroid Build Coastguard Worker            # passes them in float registers (s0, s1, ...) and double registers
1056*6a54128fSAndroid Build Coastguard Worker            # (d0, d1, ...) - this is gcc -mfloat-abi=hard. GCC 4.6 or newer
1057*6a54128fSAndroid Build Coastguard Worker            # sets the preprocessor defines __ARM_PCS (for the first case) and
1058*6a54128fSAndroid Build Coastguard Worker            # __ARM_PCS_VFP (for the second case), but older GCC does not.
1059*6a54128fSAndroid Build Coastguard Worker            echo 'double ddd; void func (double dd) { ddd = dd; }' > conftest.c
1060*6a54128fSAndroid Build Coastguard Worker            # Look for a reference to the register d0 in the .s file.
1061*6a54128fSAndroid Build Coastguard Worker            AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $gl_c_asm_opt conftest.c) >/dev/null 2>&1
1062*6a54128fSAndroid Build Coastguard Worker            if LC_ALL=C grep 'd0,' conftest.$gl_asmext >/dev/null; then
1063*6a54128fSAndroid Build Coastguard Worker              gl_cv_host_cpu_c_abi=armhf
1064*6a54128fSAndroid Build Coastguard Worker            else
1065*6a54128fSAndroid Build Coastguard Worker              gl_cv_host_cpu_c_abi=arm
1066*6a54128fSAndroid Build Coastguard Worker            fi
1067*6a54128fSAndroid Build Coastguard Worker            rm -f conftest*
1068*6a54128fSAndroid Build Coastguard Worker           ])
1069*6a54128fSAndroid Build Coastguard Worker         ;;
1070*6a54128fSAndroid Build Coastguard Worker
1071*6a54128fSAndroid Build Coastguard Worker       hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
1072*6a54128fSAndroid Build Coastguard Worker         # On hppa, the C compiler may be generating 32-bit code or 64-bit
1073*6a54128fSAndroid Build Coastguard Worker         # code. In the latter case, it defines _LP64 and __LP64__.
1074*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1075*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1076*6a54128fSAndroid Build Coastguard Worker              [[#ifdef __LP64__
1077*6a54128fSAndroid Build Coastguard Worker                 int ok;
1078*6a54128fSAndroid Build Coastguard Worker                #else
1079*6a54128fSAndroid Build Coastguard Worker                 error fail
1080*6a54128fSAndroid Build Coastguard Worker                #endif
1081*6a54128fSAndroid Build Coastguard Worker              ]])],
1082*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=hppa64],
1083*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=hppa])
1084*6a54128fSAndroid Build Coastguard Worker         ;;
1085*6a54128fSAndroid Build Coastguard Worker
1086*6a54128fSAndroid Build Coastguard Worker       ia64* )
1087*6a54128fSAndroid Build Coastguard Worker         # On ia64 on HP-UX, the C compiler may be generating 64-bit code or
1088*6a54128fSAndroid Build Coastguard Worker         # 32-bit code. In the latter case, it defines _ILP32.
1089*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1090*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1091*6a54128fSAndroid Build Coastguard Worker              [[#ifdef _ILP32
1092*6a54128fSAndroid Build Coastguard Worker                 int ok;
1093*6a54128fSAndroid Build Coastguard Worker                #else
1094*6a54128fSAndroid Build Coastguard Worker                 error fail
1095*6a54128fSAndroid Build Coastguard Worker                #endif
1096*6a54128fSAndroid Build Coastguard Worker              ]])],
1097*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=ia64-ilp32],
1098*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=ia64])
1099*6a54128fSAndroid Build Coastguard Worker         ;;
1100*6a54128fSAndroid Build Coastguard Worker
1101*6a54128fSAndroid Build Coastguard Worker       mips* )
1102*6a54128fSAndroid Build Coastguard Worker         # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this
1103*6a54128fSAndroid Build Coastguard Worker         # at 32.
1104*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1105*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1106*6a54128fSAndroid Build Coastguard Worker              [[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64)
1107*6a54128fSAndroid Build Coastguard Worker                 int ok;
1108*6a54128fSAndroid Build Coastguard Worker                #else
1109*6a54128fSAndroid Build Coastguard Worker                 error fail
1110*6a54128fSAndroid Build Coastguard Worker                #endif
1111*6a54128fSAndroid Build Coastguard Worker              ]])],
1112*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=mips64],
1113*6a54128fSAndroid Build Coastguard Worker           [# In the n32 ABI, _ABIN32 is defined, _ABIO32 is not defined (but
1114*6a54128fSAndroid Build Coastguard Worker            # may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIN32.
1115*6a54128fSAndroid Build Coastguard Worker            # In the 32 ABI, _ABIO32 is defined, _ABIN32 is not defined (but
1116*6a54128fSAndroid Build Coastguard Worker            # may later get defined by <sgidefs.h>), and _MIPS_SIM == _ABIO32.
1117*6a54128fSAndroid Build Coastguard Worker            AC_COMPILE_IFELSE(
1118*6a54128fSAndroid Build Coastguard Worker              [AC_LANG_SOURCE(
1119*6a54128fSAndroid Build Coastguard Worker                 [[#if (_MIPS_SIM == _ABIN32)
1120*6a54128fSAndroid Build Coastguard Worker                    int ok;
1121*6a54128fSAndroid Build Coastguard Worker                   #else
1122*6a54128fSAndroid Build Coastguard Worker                    error fail
1123*6a54128fSAndroid Build Coastguard Worker                   #endif
1124*6a54128fSAndroid Build Coastguard Worker                 ]])],
1125*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=mipsn32],
1126*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=mips])])
1127*6a54128fSAndroid Build Coastguard Worker         ;;
1128*6a54128fSAndroid Build Coastguard Worker
1129*6a54128fSAndroid Build Coastguard Worker       powerpc* )
1130*6a54128fSAndroid Build Coastguard Worker         # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD.
1131*6a54128fSAndroid Build Coastguard Worker         # No need to distinguish them here; the caller may distinguish
1132*6a54128fSAndroid Build Coastguard Worker         # them based on the OS.
1133*6a54128fSAndroid Build Coastguard Worker         # On powerpc64 systems, the C compiler may still be generating
1134*6a54128fSAndroid Build Coastguard Worker         # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may
1135*6a54128fSAndroid Build Coastguard Worker         # be generating 64-bit code.
1136*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1137*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1138*6a54128fSAndroid Build Coastguard Worker              [[#if defined __powerpc64__ || defined _ARCH_PPC64
1139*6a54128fSAndroid Build Coastguard Worker                 int ok;
1140*6a54128fSAndroid Build Coastguard Worker                #else
1141*6a54128fSAndroid Build Coastguard Worker                 error fail
1142*6a54128fSAndroid Build Coastguard Worker                #endif
1143*6a54128fSAndroid Build Coastguard Worker              ]])],
1144*6a54128fSAndroid Build Coastguard Worker           [# On powerpc64, there are two ABIs on Linux: The AIX compatible
1145*6a54128fSAndroid Build Coastguard Worker            # one and the ELFv2 one. The latter defines _CALL_ELF=2.
1146*6a54128fSAndroid Build Coastguard Worker            AC_COMPILE_IFELSE(
1147*6a54128fSAndroid Build Coastguard Worker              [AC_LANG_SOURCE(
1148*6a54128fSAndroid Build Coastguard Worker                 [[#if defined _CALL_ELF && _CALL_ELF == 2
1149*6a54128fSAndroid Build Coastguard Worker                    int ok;
1150*6a54128fSAndroid Build Coastguard Worker                   #else
1151*6a54128fSAndroid Build Coastguard Worker                    error fail
1152*6a54128fSAndroid Build Coastguard Worker                   #endif
1153*6a54128fSAndroid Build Coastguard Worker                 ]])],
1154*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=powerpc64-elfv2],
1155*6a54128fSAndroid Build Coastguard Worker              [gl_cv_host_cpu_c_abi=powerpc64])
1156*6a54128fSAndroid Build Coastguard Worker           ],
1157*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=powerpc])
1158*6a54128fSAndroid Build Coastguard Worker         ;;
1159*6a54128fSAndroid Build Coastguard Worker
1160*6a54128fSAndroid Build Coastguard Worker       rs6000 )
1161*6a54128fSAndroid Build Coastguard Worker         gl_cv_host_cpu_c_abi=powerpc
1162*6a54128fSAndroid Build Coastguard Worker         ;;
1163*6a54128fSAndroid Build Coastguard Worker
1164*6a54128fSAndroid Build Coastguard Worker       riscv32 | riscv64 )
1165*6a54128fSAndroid Build Coastguard Worker         # There are 2 architectures (with variants): rv32* and rv64*.
1166*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1167*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1168*6a54128fSAndroid Build Coastguard Worker              [[#if __riscv_xlen == 64
1169*6a54128fSAndroid Build Coastguard Worker                  int ok;
1170*6a54128fSAndroid Build Coastguard Worker                #else
1171*6a54128fSAndroid Build Coastguard Worker                  error fail
1172*6a54128fSAndroid Build Coastguard Worker                #endif
1173*6a54128fSAndroid Build Coastguard Worker              ]])],
1174*6a54128fSAndroid Build Coastguard Worker           [cpu=riscv64],
1175*6a54128fSAndroid Build Coastguard Worker           [cpu=riscv32])
1176*6a54128fSAndroid Build Coastguard Worker         # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d.
1177*6a54128fSAndroid Build Coastguard Worker         # Size of 'long' and 'void *':
1178*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1179*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1180*6a54128fSAndroid Build Coastguard Worker              [[#if defined __LP64__
1181*6a54128fSAndroid Build Coastguard Worker                  int ok;
1182*6a54128fSAndroid Build Coastguard Worker                #else
1183*6a54128fSAndroid Build Coastguard Worker                  error fail
1184*6a54128fSAndroid Build Coastguard Worker                #endif
1185*6a54128fSAndroid Build Coastguard Worker              ]])],
1186*6a54128fSAndroid Build Coastguard Worker           [main_abi=lp64],
1187*6a54128fSAndroid Build Coastguard Worker           [main_abi=ilp32])
1188*6a54128fSAndroid Build Coastguard Worker         # Float ABIs:
1189*6a54128fSAndroid Build Coastguard Worker         # __riscv_float_abi_double:
1190*6a54128fSAndroid Build Coastguard Worker         #   'float' and 'double' are passed in floating-point registers.
1191*6a54128fSAndroid Build Coastguard Worker         # __riscv_float_abi_single:
1192*6a54128fSAndroid Build Coastguard Worker         #   'float' are passed in floating-point registers.
1193*6a54128fSAndroid Build Coastguard Worker         # __riscv_float_abi_soft:
1194*6a54128fSAndroid Build Coastguard Worker         #   No values are passed in floating-point registers.
1195*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1196*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1197*6a54128fSAndroid Build Coastguard Worker              [[#if defined __riscv_float_abi_double
1198*6a54128fSAndroid Build Coastguard Worker                  int ok;
1199*6a54128fSAndroid Build Coastguard Worker                #else
1200*6a54128fSAndroid Build Coastguard Worker                  error fail
1201*6a54128fSAndroid Build Coastguard Worker                #endif
1202*6a54128fSAndroid Build Coastguard Worker              ]])],
1203*6a54128fSAndroid Build Coastguard Worker           [float_abi=d],
1204*6a54128fSAndroid Build Coastguard Worker           [AC_COMPILE_IFELSE(
1205*6a54128fSAndroid Build Coastguard Worker              [AC_LANG_SOURCE(
1206*6a54128fSAndroid Build Coastguard Worker                 [[#if defined __riscv_float_abi_single
1207*6a54128fSAndroid Build Coastguard Worker                     int ok;
1208*6a54128fSAndroid Build Coastguard Worker                   #else
1209*6a54128fSAndroid Build Coastguard Worker                     error fail
1210*6a54128fSAndroid Build Coastguard Worker                   #endif
1211*6a54128fSAndroid Build Coastguard Worker                 ]])],
1212*6a54128fSAndroid Build Coastguard Worker              [float_abi=f],
1213*6a54128fSAndroid Build Coastguard Worker              [float_abi=''])
1214*6a54128fSAndroid Build Coastguard Worker           ])
1215*6a54128fSAndroid Build Coastguard Worker         gl_cv_host_cpu_c_abi="${cpu}-${main_abi}${float_abi}"
1216*6a54128fSAndroid Build Coastguard Worker         ;;
1217*6a54128fSAndroid Build Coastguard Worker
1218*6a54128fSAndroid Build Coastguard Worker       s390* )
1219*6a54128fSAndroid Build Coastguard Worker         # On s390x, the C compiler may be generating 64-bit (= s390x) code
1220*6a54128fSAndroid Build Coastguard Worker         # or 31-bit (= s390) code.
1221*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1222*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1223*6a54128fSAndroid Build Coastguard Worker              [[#if defined __LP64__ || defined __s390x__
1224*6a54128fSAndroid Build Coastguard Worker                  int ok;
1225*6a54128fSAndroid Build Coastguard Worker                #else
1226*6a54128fSAndroid Build Coastguard Worker                  error fail
1227*6a54128fSAndroid Build Coastguard Worker                #endif
1228*6a54128fSAndroid Build Coastguard Worker              ]])],
1229*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=s390x],
1230*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=s390])
1231*6a54128fSAndroid Build Coastguard Worker         ;;
1232*6a54128fSAndroid Build Coastguard Worker
1233*6a54128fSAndroid Build Coastguard Worker       sparc | sparc64 )
1234*6a54128fSAndroid Build Coastguard Worker         # UltraSPARCs running Linux have `uname -m` = "sparc64", but the
1235*6a54128fSAndroid Build Coastguard Worker         # C compiler still generates 32-bit code.
1236*6a54128fSAndroid Build Coastguard Worker         AC_COMPILE_IFELSE(
1237*6a54128fSAndroid Build Coastguard Worker           [AC_LANG_SOURCE(
1238*6a54128fSAndroid Build Coastguard Worker              [[#if defined __sparcv9 || defined __arch64__
1239*6a54128fSAndroid Build Coastguard Worker                 int ok;
1240*6a54128fSAndroid Build Coastguard Worker                #else
1241*6a54128fSAndroid Build Coastguard Worker                 error fail
1242*6a54128fSAndroid Build Coastguard Worker                #endif
1243*6a54128fSAndroid Build Coastguard Worker              ]])],
1244*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=sparc64],
1245*6a54128fSAndroid Build Coastguard Worker           [gl_cv_host_cpu_c_abi=sparc])
1246*6a54128fSAndroid Build Coastguard Worker         ;;
1247*6a54128fSAndroid Build Coastguard Worker
1248*6a54128fSAndroid Build Coastguard Worker       *)
1249*6a54128fSAndroid Build Coastguard Worker         gl_cv_host_cpu_c_abi="$host_cpu"
1250*6a54128fSAndroid Build Coastguard Worker         ;;
1251*6a54128fSAndroid Build Coastguard Worker     esac
1252*6a54128fSAndroid Build Coastguard Worker    ])
1253*6a54128fSAndroid Build Coastguard Worker
1254*6a54128fSAndroid Build Coastguard Worker  dnl In most cases, $HOST_CPU and $HOST_CPU_C_ABI are the same.
1255*6a54128fSAndroid Build Coastguard Worker  HOST_CPU=`echo "$gl_cv_host_cpu_c_abi" | sed -e 's/-.*//'`
1256*6a54128fSAndroid Build Coastguard Worker  HOST_CPU_C_ABI="$gl_cv_host_cpu_c_abi"
1257*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([HOST_CPU])
1258*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([HOST_CPU_C_ABI])
1259*6a54128fSAndroid Build Coastguard Worker
1260*6a54128fSAndroid Build Coastguard Worker  # This was
1261*6a54128fSAndroid Build Coastguard Worker  #   AC_DEFINE_UNQUOTED([__${HOST_CPU}__])
1262*6a54128fSAndroid Build Coastguard Worker  #   AC_DEFINE_UNQUOTED([__${HOST_CPU_C_ABI}__])
1263*6a54128fSAndroid Build Coastguard Worker  # earlier, but KAI C++ 3.2d doesn't like this.
1264*6a54128fSAndroid Build Coastguard Worker  sed -e 's/-/_/g' >> confdefs.h <<EOF
1265*6a54128fSAndroid Build Coastguard Worker#ifndef __${HOST_CPU}__
1266*6a54128fSAndroid Build Coastguard Worker#define __${HOST_CPU}__ 1
1267*6a54128fSAndroid Build Coastguard Worker#endif
1268*6a54128fSAndroid Build Coastguard Worker#ifndef __${HOST_CPU_C_ABI}__
1269*6a54128fSAndroid Build Coastguard Worker#define __${HOST_CPU_C_ABI}__ 1
1270*6a54128fSAndroid Build Coastguard Worker#endif
1271*6a54128fSAndroid Build Coastguard WorkerEOF
1272*6a54128fSAndroid Build Coastguard Worker  AH_TOP([/* CPU and C ABI indicator */
1273*6a54128fSAndroid Build Coastguard Worker#ifndef __i386__
1274*6a54128fSAndroid Build Coastguard Worker#undef __i386__
1275*6a54128fSAndroid Build Coastguard Worker#endif
1276*6a54128fSAndroid Build Coastguard Worker#ifndef __x86_64_x32__
1277*6a54128fSAndroid Build Coastguard Worker#undef __x86_64_x32__
1278*6a54128fSAndroid Build Coastguard Worker#endif
1279*6a54128fSAndroid Build Coastguard Worker#ifndef __x86_64__
1280*6a54128fSAndroid Build Coastguard Worker#undef __x86_64__
1281*6a54128fSAndroid Build Coastguard Worker#endif
1282*6a54128fSAndroid Build Coastguard Worker#ifndef __alpha__
1283*6a54128fSAndroid Build Coastguard Worker#undef __alpha__
1284*6a54128fSAndroid Build Coastguard Worker#endif
1285*6a54128fSAndroid Build Coastguard Worker#ifndef __arm__
1286*6a54128fSAndroid Build Coastguard Worker#undef __arm__
1287*6a54128fSAndroid Build Coastguard Worker#endif
1288*6a54128fSAndroid Build Coastguard Worker#ifndef __armhf__
1289*6a54128fSAndroid Build Coastguard Worker#undef __armhf__
1290*6a54128fSAndroid Build Coastguard Worker#endif
1291*6a54128fSAndroid Build Coastguard Worker#ifndef __arm64_ilp32__
1292*6a54128fSAndroid Build Coastguard Worker#undef __arm64_ilp32__
1293*6a54128fSAndroid Build Coastguard Worker#endif
1294*6a54128fSAndroid Build Coastguard Worker#ifndef __arm64__
1295*6a54128fSAndroid Build Coastguard Worker#undef __arm64__
1296*6a54128fSAndroid Build Coastguard Worker#endif
1297*6a54128fSAndroid Build Coastguard Worker#ifndef __hppa__
1298*6a54128fSAndroid Build Coastguard Worker#undef __hppa__
1299*6a54128fSAndroid Build Coastguard Worker#endif
1300*6a54128fSAndroid Build Coastguard Worker#ifndef __hppa64__
1301*6a54128fSAndroid Build Coastguard Worker#undef __hppa64__
1302*6a54128fSAndroid Build Coastguard Worker#endif
1303*6a54128fSAndroid Build Coastguard Worker#ifndef __ia64_ilp32__
1304*6a54128fSAndroid Build Coastguard Worker#undef __ia64_ilp32__
1305*6a54128fSAndroid Build Coastguard Worker#endif
1306*6a54128fSAndroid Build Coastguard Worker#ifndef __ia64__
1307*6a54128fSAndroid Build Coastguard Worker#undef __ia64__
1308*6a54128fSAndroid Build Coastguard Worker#endif
1309*6a54128fSAndroid Build Coastguard Worker#ifndef __m68k__
1310*6a54128fSAndroid Build Coastguard Worker#undef __m68k__
1311*6a54128fSAndroid Build Coastguard Worker#endif
1312*6a54128fSAndroid Build Coastguard Worker#ifndef __mips__
1313*6a54128fSAndroid Build Coastguard Worker#undef __mips__
1314*6a54128fSAndroid Build Coastguard Worker#endif
1315*6a54128fSAndroid Build Coastguard Worker#ifndef __mipsn32__
1316*6a54128fSAndroid Build Coastguard Worker#undef __mipsn32__
1317*6a54128fSAndroid Build Coastguard Worker#endif
1318*6a54128fSAndroid Build Coastguard Worker#ifndef __mips64__
1319*6a54128fSAndroid Build Coastguard Worker#undef __mips64__
1320*6a54128fSAndroid Build Coastguard Worker#endif
1321*6a54128fSAndroid Build Coastguard Worker#ifndef __powerpc__
1322*6a54128fSAndroid Build Coastguard Worker#undef __powerpc__
1323*6a54128fSAndroid Build Coastguard Worker#endif
1324*6a54128fSAndroid Build Coastguard Worker#ifndef __powerpc64__
1325*6a54128fSAndroid Build Coastguard Worker#undef __powerpc64__
1326*6a54128fSAndroid Build Coastguard Worker#endif
1327*6a54128fSAndroid Build Coastguard Worker#ifndef __powerpc64_elfv2__
1328*6a54128fSAndroid Build Coastguard Worker#undef __powerpc64_elfv2__
1329*6a54128fSAndroid Build Coastguard Worker#endif
1330*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv32__
1331*6a54128fSAndroid Build Coastguard Worker#undef __riscv32__
1332*6a54128fSAndroid Build Coastguard Worker#endif
1333*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv64__
1334*6a54128fSAndroid Build Coastguard Worker#undef __riscv64__
1335*6a54128fSAndroid Build Coastguard Worker#endif
1336*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv32_ilp32__
1337*6a54128fSAndroid Build Coastguard Worker#undef __riscv32_ilp32__
1338*6a54128fSAndroid Build Coastguard Worker#endif
1339*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv32_ilp32f__
1340*6a54128fSAndroid Build Coastguard Worker#undef __riscv32_ilp32f__
1341*6a54128fSAndroid Build Coastguard Worker#endif
1342*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv32_ilp32d__
1343*6a54128fSAndroid Build Coastguard Worker#undef __riscv32_ilp32d__
1344*6a54128fSAndroid Build Coastguard Worker#endif
1345*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv64_ilp32__
1346*6a54128fSAndroid Build Coastguard Worker#undef __riscv64_ilp32__
1347*6a54128fSAndroid Build Coastguard Worker#endif
1348*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv64_ilp32f__
1349*6a54128fSAndroid Build Coastguard Worker#undef __riscv64_ilp32f__
1350*6a54128fSAndroid Build Coastguard Worker#endif
1351*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv64_ilp32d__
1352*6a54128fSAndroid Build Coastguard Worker#undef __riscv64_ilp32d__
1353*6a54128fSAndroid Build Coastguard Worker#endif
1354*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv64_lp64__
1355*6a54128fSAndroid Build Coastguard Worker#undef __riscv64_lp64__
1356*6a54128fSAndroid Build Coastguard Worker#endif
1357*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv64_lp64f__
1358*6a54128fSAndroid Build Coastguard Worker#undef __riscv64_lp64f__
1359*6a54128fSAndroid Build Coastguard Worker#endif
1360*6a54128fSAndroid Build Coastguard Worker#ifndef __riscv64_lp64d__
1361*6a54128fSAndroid Build Coastguard Worker#undef __riscv64_lp64d__
1362*6a54128fSAndroid Build Coastguard Worker#endif
1363*6a54128fSAndroid Build Coastguard Worker#ifndef __s390__
1364*6a54128fSAndroid Build Coastguard Worker#undef __s390__
1365*6a54128fSAndroid Build Coastguard Worker#endif
1366*6a54128fSAndroid Build Coastguard Worker#ifndef __s390x__
1367*6a54128fSAndroid Build Coastguard Worker#undef __s390x__
1368*6a54128fSAndroid Build Coastguard Worker#endif
1369*6a54128fSAndroid Build Coastguard Worker#ifndef __sh__
1370*6a54128fSAndroid Build Coastguard Worker#undef __sh__
1371*6a54128fSAndroid Build Coastguard Worker#endif
1372*6a54128fSAndroid Build Coastguard Worker#ifndef __sparc__
1373*6a54128fSAndroid Build Coastguard Worker#undef __sparc__
1374*6a54128fSAndroid Build Coastguard Worker#endif
1375*6a54128fSAndroid Build Coastguard Worker#ifndef __sparc64__
1376*6a54128fSAndroid Build Coastguard Worker#undef __sparc64__
1377*6a54128fSAndroid Build Coastguard Worker#endif
1378*6a54128fSAndroid Build Coastguard Worker])
1379*6a54128fSAndroid Build Coastguard Worker
1380*6a54128fSAndroid Build Coastguard Worker])
1381*6a54128fSAndroid Build Coastguard Worker
1382*6a54128fSAndroid Build Coastguard Worker
1383*6a54128fSAndroid Build Coastguard Workerdnl Sets the HOST_CPU_C_ABI_32BIT variable to 'yes' if the C language ABI
1384*6a54128fSAndroid Build Coastguard Workerdnl (application binary interface) is a 32-bit one, to 'no' if it is a 64-bit
1385*6a54128fSAndroid Build Coastguard Workerdnl one, or to 'unknown' if unknown.
1386*6a54128fSAndroid Build Coastguard Workerdnl This is a simplified variant of gl_HOST_CPU_C_ABI.
1387*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
1388*6a54128fSAndroid Build Coastguard Worker[
1389*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_CANONICAL_HOST])
1390*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([32-bit host C ABI], [gl_cv_host_cpu_c_abi_32bit],
1391*6a54128fSAndroid Build Coastguard Worker    [if test -n "$gl_cv_host_cpu_c_abi"; then
1392*6a54128fSAndroid Build Coastguard Worker       case "$gl_cv_host_cpu_c_abi" in
1393*6a54128fSAndroid Build Coastguard Worker         i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
1394*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=yes ;;
1395*6a54128fSAndroid Build Coastguard Worker         x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
1396*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=no ;;
1397*6a54128fSAndroid Build Coastguard Worker         *)
1398*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=unknown ;;
1399*6a54128fSAndroid Build Coastguard Worker       esac
1400*6a54128fSAndroid Build Coastguard Worker     else
1401*6a54128fSAndroid Build Coastguard Worker       case "$host_cpu" in
1402*6a54128fSAndroid Build Coastguard Worker
1403*6a54128fSAndroid Build Coastguard Worker         # CPUs that only support a 32-bit ABI.
1404*6a54128fSAndroid Build Coastguard Worker         arc \
1405*6a54128fSAndroid Build Coastguard Worker         | bfin \
1406*6a54128fSAndroid Build Coastguard Worker         | cris* \
1407*6a54128fSAndroid Build Coastguard Worker         | csky \
1408*6a54128fSAndroid Build Coastguard Worker         | epiphany \
1409*6a54128fSAndroid Build Coastguard Worker         | ft32 \
1410*6a54128fSAndroid Build Coastguard Worker         | h8300 \
1411*6a54128fSAndroid Build Coastguard Worker         | m68k \
1412*6a54128fSAndroid Build Coastguard Worker         | microblaze | microblazeel \
1413*6a54128fSAndroid Build Coastguard Worker         | nds32 | nds32le | nds32be \
1414*6a54128fSAndroid Build Coastguard Worker         | nios2 | nios2eb | nios2el \
1415*6a54128fSAndroid Build Coastguard Worker         | or1k* \
1416*6a54128fSAndroid Build Coastguard Worker         | or32 \
1417*6a54128fSAndroid Build Coastguard Worker         | sh | sh[1234] | sh[1234]e[lb] \
1418*6a54128fSAndroid Build Coastguard Worker         | tic6x \
1419*6a54128fSAndroid Build Coastguard Worker         | xtensa* )
1420*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=yes
1421*6a54128fSAndroid Build Coastguard Worker           ;;
1422*6a54128fSAndroid Build Coastguard Worker
1423*6a54128fSAndroid Build Coastguard Worker         # CPUs that only support a 64-bit ABI.
1424*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
1425*6a54128fSAndroid Build Coastguard Worker         alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
1426*6a54128fSAndroid Build Coastguard Worker         | mmix )
1427*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
1428*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=no
1429*6a54128fSAndroid Build Coastguard Worker           ;;
1430*6a54128fSAndroid Build Coastguard Worker
1431*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
1432*6a54128fSAndroid Build Coastguard Worker         i[34567]86 )
1433*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
1434*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=yes
1435*6a54128fSAndroid Build Coastguard Worker           ;;
1436*6a54128fSAndroid Build Coastguard Worker
1437*6a54128fSAndroid Build Coastguard Worker         x86_64 )
1438*6a54128fSAndroid Build Coastguard Worker           # On x86_64 systems, the C compiler may be generating code in one of
1439*6a54128fSAndroid Build Coastguard Worker           # these ABIs:
1440*6a54128fSAndroid Build Coastguard Worker           # - 64-bit instruction set, 64-bit pointers, 64-bit 'long': x86_64.
1441*6a54128fSAndroid Build Coastguard Worker           # - 64-bit instruction set, 64-bit pointers, 32-bit 'long': x86_64
1442*6a54128fSAndroid Build Coastguard Worker           #   with native Windows (mingw, MSVC).
1443*6a54128fSAndroid Build Coastguard Worker           # - 64-bit instruction set, 32-bit pointers, 32-bit 'long': x86_64-x32.
1444*6a54128fSAndroid Build Coastguard Worker           # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': i386.
1445*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1446*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1447*6a54128fSAndroid Build Coastguard Worker                [[#if (defined __x86_64__ || defined __amd64__ \
1448*6a54128fSAndroid Build Coastguard Worker                       || defined _M_X64 || defined _M_AMD64) \
1449*6a54128fSAndroid Build Coastguard Worker                      && !(defined __ILP32__ || defined _ILP32)
1450*6a54128fSAndroid Build Coastguard Worker                   int ok;
1451*6a54128fSAndroid Build Coastguard Worker                  #else
1452*6a54128fSAndroid Build Coastguard Worker                   error fail
1453*6a54128fSAndroid Build Coastguard Worker                  #endif
1454*6a54128fSAndroid Build Coastguard Worker                ]])],
1455*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1456*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1457*6a54128fSAndroid Build Coastguard Worker           ;;
1458*6a54128fSAndroid Build Coastguard Worker
1459*6a54128fSAndroid Build Coastguard Worker         arm* | aarch64 )
1460*6a54128fSAndroid Build Coastguard Worker           # Assume arm with EABI.
1461*6a54128fSAndroid Build Coastguard Worker           # On arm64 systems, the C compiler may be generating code in one of
1462*6a54128fSAndroid Build Coastguard Worker           # these ABIs:
1463*6a54128fSAndroid Build Coastguard Worker           # - aarch64 instruction set, 64-bit pointers, 64-bit 'long': arm64.
1464*6a54128fSAndroid Build Coastguard Worker           # - aarch64 instruction set, 32-bit pointers, 32-bit 'long': arm64-ilp32.
1465*6a54128fSAndroid Build Coastguard Worker           # - 32-bit instruction set, 32-bit pointers, 32-bit 'long': arm or armhf.
1466*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1467*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1468*6a54128fSAndroid Build Coastguard Worker                [[#if defined __aarch64__ && !(defined __ILP32__ || defined _ILP32)
1469*6a54128fSAndroid Build Coastguard Worker                   int ok;
1470*6a54128fSAndroid Build Coastguard Worker                  #else
1471*6a54128fSAndroid Build Coastguard Worker                   error fail
1472*6a54128fSAndroid Build Coastguard Worker                  #endif
1473*6a54128fSAndroid Build Coastguard Worker                ]])],
1474*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1475*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1476*6a54128fSAndroid Build Coastguard Worker           ;;
1477*6a54128fSAndroid Build Coastguard Worker
1478*6a54128fSAndroid Build Coastguard Worker         hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
1479*6a54128fSAndroid Build Coastguard Worker           # On hppa, the C compiler may be generating 32-bit code or 64-bit
1480*6a54128fSAndroid Build Coastguard Worker           # code. In the latter case, it defines _LP64 and __LP64__.
1481*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1482*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1483*6a54128fSAndroid Build Coastguard Worker                [[#ifdef __LP64__
1484*6a54128fSAndroid Build Coastguard Worker                   int ok;
1485*6a54128fSAndroid Build Coastguard Worker                  #else
1486*6a54128fSAndroid Build Coastguard Worker                   error fail
1487*6a54128fSAndroid Build Coastguard Worker                  #endif
1488*6a54128fSAndroid Build Coastguard Worker                ]])],
1489*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1490*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1491*6a54128fSAndroid Build Coastguard Worker           ;;
1492*6a54128fSAndroid Build Coastguard Worker
1493*6a54128fSAndroid Build Coastguard Worker         ia64* )
1494*6a54128fSAndroid Build Coastguard Worker           # On ia64 on HP-UX, the C compiler may be generating 64-bit code or
1495*6a54128fSAndroid Build Coastguard Worker           # 32-bit code. In the latter case, it defines _ILP32.
1496*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1497*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1498*6a54128fSAndroid Build Coastguard Worker                [[#ifdef _ILP32
1499*6a54128fSAndroid Build Coastguard Worker                   int ok;
1500*6a54128fSAndroid Build Coastguard Worker                  #else
1501*6a54128fSAndroid Build Coastguard Worker                   error fail
1502*6a54128fSAndroid Build Coastguard Worker                  #endif
1503*6a54128fSAndroid Build Coastguard Worker                ]])],
1504*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes],
1505*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no])
1506*6a54128fSAndroid Build Coastguard Worker           ;;
1507*6a54128fSAndroid Build Coastguard Worker
1508*6a54128fSAndroid Build Coastguard Worker         mips* )
1509*6a54128fSAndroid Build Coastguard Worker           # We should also check for (_MIPS_SZPTR == 64), but gcc keeps this
1510*6a54128fSAndroid Build Coastguard Worker           # at 32.
1511*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1512*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1513*6a54128fSAndroid Build Coastguard Worker                [[#if defined _MIPS_SZLONG && (_MIPS_SZLONG == 64)
1514*6a54128fSAndroid Build Coastguard Worker                   int ok;
1515*6a54128fSAndroid Build Coastguard Worker                  #else
1516*6a54128fSAndroid Build Coastguard Worker                   error fail
1517*6a54128fSAndroid Build Coastguard Worker                  #endif
1518*6a54128fSAndroid Build Coastguard Worker                ]])],
1519*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1520*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1521*6a54128fSAndroid Build Coastguard Worker           ;;
1522*6a54128fSAndroid Build Coastguard Worker
1523*6a54128fSAndroid Build Coastguard Worker         powerpc* )
1524*6a54128fSAndroid Build Coastguard Worker           # Different ABIs are in use on AIX vs. Mac OS X vs. Linux,*BSD.
1525*6a54128fSAndroid Build Coastguard Worker           # No need to distinguish them here; the caller may distinguish
1526*6a54128fSAndroid Build Coastguard Worker           # them based on the OS.
1527*6a54128fSAndroid Build Coastguard Worker           # On powerpc64 systems, the C compiler may still be generating
1528*6a54128fSAndroid Build Coastguard Worker           # 32-bit code. And on powerpc-ibm-aix systems, the C compiler may
1529*6a54128fSAndroid Build Coastguard Worker           # be generating 64-bit code.
1530*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1531*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1532*6a54128fSAndroid Build Coastguard Worker                [[#if defined __powerpc64__ || defined _ARCH_PPC64
1533*6a54128fSAndroid Build Coastguard Worker                   int ok;
1534*6a54128fSAndroid Build Coastguard Worker                  #else
1535*6a54128fSAndroid Build Coastguard Worker                   error fail
1536*6a54128fSAndroid Build Coastguard Worker                  #endif
1537*6a54128fSAndroid Build Coastguard Worker                ]])],
1538*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1539*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1540*6a54128fSAndroid Build Coastguard Worker           ;;
1541*6a54128fSAndroid Build Coastguard Worker
1542*6a54128fSAndroid Build Coastguard Worker         rs6000 )
1543*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=yes
1544*6a54128fSAndroid Build Coastguard Worker           ;;
1545*6a54128fSAndroid Build Coastguard Worker
1546*6a54128fSAndroid Build Coastguard Worker         riscv32 | riscv64 )
1547*6a54128fSAndroid Build Coastguard Worker           # There are 6 ABIs: ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d.
1548*6a54128fSAndroid Build Coastguard Worker           # Size of 'long' and 'void *':
1549*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1550*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1551*6a54128fSAndroid Build Coastguard Worker                [[#if defined __LP64__
1552*6a54128fSAndroid Build Coastguard Worker                    int ok;
1553*6a54128fSAndroid Build Coastguard Worker                  #else
1554*6a54128fSAndroid Build Coastguard Worker                    error fail
1555*6a54128fSAndroid Build Coastguard Worker                  #endif
1556*6a54128fSAndroid Build Coastguard Worker                ]])],
1557*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1558*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1559*6a54128fSAndroid Build Coastguard Worker           ;;
1560*6a54128fSAndroid Build Coastguard Worker
1561*6a54128fSAndroid Build Coastguard Worker         s390* )
1562*6a54128fSAndroid Build Coastguard Worker           # On s390x, the C compiler may be generating 64-bit (= s390x) code
1563*6a54128fSAndroid Build Coastguard Worker           # or 31-bit (= s390) code.
1564*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1565*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1566*6a54128fSAndroid Build Coastguard Worker                [[#if defined __LP64__ || defined __s390x__
1567*6a54128fSAndroid Build Coastguard Worker                    int ok;
1568*6a54128fSAndroid Build Coastguard Worker                  #else
1569*6a54128fSAndroid Build Coastguard Worker                    error fail
1570*6a54128fSAndroid Build Coastguard Worker                  #endif
1571*6a54128fSAndroid Build Coastguard Worker                ]])],
1572*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1573*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1574*6a54128fSAndroid Build Coastguard Worker           ;;
1575*6a54128fSAndroid Build Coastguard Worker
1576*6a54128fSAndroid Build Coastguard Worker         sparc | sparc64 )
1577*6a54128fSAndroid Build Coastguard Worker           # UltraSPARCs running Linux have `uname -m` = "sparc64", but the
1578*6a54128fSAndroid Build Coastguard Worker           # C compiler still generates 32-bit code.
1579*6a54128fSAndroid Build Coastguard Worker           AC_COMPILE_IFELSE(
1580*6a54128fSAndroid Build Coastguard Worker             [AC_LANG_SOURCE(
1581*6a54128fSAndroid Build Coastguard Worker                [[#if defined __sparcv9 || defined __arch64__
1582*6a54128fSAndroid Build Coastguard Worker                   int ok;
1583*6a54128fSAndroid Build Coastguard Worker                  #else
1584*6a54128fSAndroid Build Coastguard Worker                   error fail
1585*6a54128fSAndroid Build Coastguard Worker                  #endif
1586*6a54128fSAndroid Build Coastguard Worker                ]])],
1587*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=no],
1588*6a54128fSAndroid Build Coastguard Worker             [gl_cv_host_cpu_c_abi_32bit=yes])
1589*6a54128fSAndroid Build Coastguard Worker           ;;
1590*6a54128fSAndroid Build Coastguard Worker
1591*6a54128fSAndroid Build Coastguard Worker         *)
1592*6a54128fSAndroid Build Coastguard Worker           gl_cv_host_cpu_c_abi_32bit=unknown
1593*6a54128fSAndroid Build Coastguard Worker           ;;
1594*6a54128fSAndroid Build Coastguard Worker       esac
1595*6a54128fSAndroid Build Coastguard Worker     fi
1596*6a54128fSAndroid Build Coastguard Worker    ])
1597*6a54128fSAndroid Build Coastguard Worker
1598*6a54128fSAndroid Build Coastguard Worker  HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit"
1599*6a54128fSAndroid Build Coastguard Worker])
1600*6a54128fSAndroid Build Coastguard Worker
1601*6a54128fSAndroid Build Coastguard Worker# iconv.m4 serial 21
1602*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 2000-2002, 2007-2014, 2016-2020 Free Software Foundation,
1603*6a54128fSAndroid Build Coastguard Workerdnl Inc.
1604*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
1605*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
1606*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
1607*6a54128fSAndroid Build Coastguard Worker
1608*6a54128fSAndroid Build Coastguard Workerdnl From Bruno Haible.
1609*6a54128fSAndroid Build Coastguard Worker
1610*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
1611*6a54128fSAndroid Build Coastguard Worker[
1612*6a54128fSAndroid Build Coastguard Worker  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
1613*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
1614*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_RPATH])
1615*6a54128fSAndroid Build Coastguard Worker
1616*6a54128fSAndroid Build Coastguard Worker  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
1617*6a54128fSAndroid Build Coastguard Worker  dnl accordingly.
1618*6a54128fSAndroid Build Coastguard Worker  AC_LIB_LINKFLAGS_BODY([iconv])
1619*6a54128fSAndroid Build Coastguard Worker])
1620*6a54128fSAndroid Build Coastguard Worker
1621*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_ICONV_LINK],
1622*6a54128fSAndroid Build Coastguard Worker[
1623*6a54128fSAndroid Build Coastguard Worker  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
1624*6a54128fSAndroid Build Coastguard Worker  dnl those with the standalone portable GNU libiconv installed).
1625*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1626*6a54128fSAndroid Build Coastguard Worker
1627*6a54128fSAndroid Build Coastguard Worker  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
1628*6a54128fSAndroid Build Coastguard Worker  dnl accordingly.
1629*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
1630*6a54128fSAndroid Build Coastguard Worker
1631*6a54128fSAndroid Build Coastguard Worker  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
1632*6a54128fSAndroid Build Coastguard Worker  dnl because if the user has installed libiconv and not disabled its use
1633*6a54128fSAndroid Build Coastguard Worker  dnl via --without-libiconv-prefix, he wants to use it. The first
1634*6a54128fSAndroid Build Coastguard Worker  dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
1635*6a54128fSAndroid Build Coastguard Worker  am_save_CPPFLAGS="$CPPFLAGS"
1636*6a54128fSAndroid Build Coastguard Worker  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
1637*6a54128fSAndroid Build Coastguard Worker
1638*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
1639*6a54128fSAndroid Build Coastguard Worker    am_cv_func_iconv="no, consider installing GNU libiconv"
1640*6a54128fSAndroid Build Coastguard Worker    am_cv_lib_iconv=no
1641*6a54128fSAndroid Build Coastguard Worker    AC_LINK_IFELSE(
1642*6a54128fSAndroid Build Coastguard Worker      [AC_LANG_PROGRAM(
1643*6a54128fSAndroid Build Coastguard Worker         [[
1644*6a54128fSAndroid Build Coastguard Worker#include <stdlib.h>
1645*6a54128fSAndroid Build Coastguard Worker#include <iconv.h>
1646*6a54128fSAndroid Build Coastguard Worker         ]],
1647*6a54128fSAndroid Build Coastguard Worker         [[iconv_t cd = iconv_open("","");
1648*6a54128fSAndroid Build Coastguard Worker           iconv(cd,NULL,NULL,NULL,NULL);
1649*6a54128fSAndroid Build Coastguard Worker           iconv_close(cd);]])],
1650*6a54128fSAndroid Build Coastguard Worker      [am_cv_func_iconv=yes])
1651*6a54128fSAndroid Build Coastguard Worker    if test "$am_cv_func_iconv" != yes; then
1652*6a54128fSAndroid Build Coastguard Worker      am_save_LIBS="$LIBS"
1653*6a54128fSAndroid Build Coastguard Worker      LIBS="$LIBS $LIBICONV"
1654*6a54128fSAndroid Build Coastguard Worker      AC_LINK_IFELSE(
1655*6a54128fSAndroid Build Coastguard Worker        [AC_LANG_PROGRAM(
1656*6a54128fSAndroid Build Coastguard Worker           [[
1657*6a54128fSAndroid Build Coastguard Worker#include <stdlib.h>
1658*6a54128fSAndroid Build Coastguard Worker#include <iconv.h>
1659*6a54128fSAndroid Build Coastguard Worker           ]],
1660*6a54128fSAndroid Build Coastguard Worker           [[iconv_t cd = iconv_open("","");
1661*6a54128fSAndroid Build Coastguard Worker             iconv(cd,NULL,NULL,NULL,NULL);
1662*6a54128fSAndroid Build Coastguard Worker             iconv_close(cd);]])],
1663*6a54128fSAndroid Build Coastguard Worker        [am_cv_lib_iconv=yes]
1664*6a54128fSAndroid Build Coastguard Worker        [am_cv_func_iconv=yes])
1665*6a54128fSAndroid Build Coastguard Worker      LIBS="$am_save_LIBS"
1666*6a54128fSAndroid Build Coastguard Worker    fi
1667*6a54128fSAndroid Build Coastguard Worker  ])
1668*6a54128fSAndroid Build Coastguard Worker  if test "$am_cv_func_iconv" = yes; then
1669*6a54128fSAndroid Build Coastguard Worker    AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
1670*6a54128fSAndroid Build Coastguard Worker      dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
1671*6a54128fSAndroid Build Coastguard Worker      dnl Solaris 10.
1672*6a54128fSAndroid Build Coastguard Worker      am_save_LIBS="$LIBS"
1673*6a54128fSAndroid Build Coastguard Worker      if test $am_cv_lib_iconv = yes; then
1674*6a54128fSAndroid Build Coastguard Worker        LIBS="$LIBS $LIBICONV"
1675*6a54128fSAndroid Build Coastguard Worker      fi
1676*6a54128fSAndroid Build Coastguard Worker      am_cv_func_iconv_works=no
1677*6a54128fSAndroid Build Coastguard Worker      for ac_iconv_const in '' 'const'; do
1678*6a54128fSAndroid Build Coastguard Worker        AC_RUN_IFELSE(
1679*6a54128fSAndroid Build Coastguard Worker          [AC_LANG_PROGRAM(
1680*6a54128fSAndroid Build Coastguard Worker             [[
1681*6a54128fSAndroid Build Coastguard Worker#include <iconv.h>
1682*6a54128fSAndroid Build Coastguard Worker#include <string.h>
1683*6a54128fSAndroid Build Coastguard Worker
1684*6a54128fSAndroid Build Coastguard Worker#ifndef ICONV_CONST
1685*6a54128fSAndroid Build Coastguard Worker# define ICONV_CONST $ac_iconv_const
1686*6a54128fSAndroid Build Coastguard Worker#endif
1687*6a54128fSAndroid Build Coastguard Worker             ]],
1688*6a54128fSAndroid Build Coastguard Worker             [[int result = 0;
1689*6a54128fSAndroid Build Coastguard Worker  /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
1690*6a54128fSAndroid Build Coastguard Worker     returns.  */
1691*6a54128fSAndroid Build Coastguard Worker  {
1692*6a54128fSAndroid Build Coastguard Worker    iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
1693*6a54128fSAndroid Build Coastguard Worker    if (cd_utf8_to_88591 != (iconv_t)(-1))
1694*6a54128fSAndroid Build Coastguard Worker      {
1695*6a54128fSAndroid Build Coastguard Worker        static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
1696*6a54128fSAndroid Build Coastguard Worker        char buf[10];
1697*6a54128fSAndroid Build Coastguard Worker        ICONV_CONST char *inptr = input;
1698*6a54128fSAndroid Build Coastguard Worker        size_t inbytesleft = strlen (input);
1699*6a54128fSAndroid Build Coastguard Worker        char *outptr = buf;
1700*6a54128fSAndroid Build Coastguard Worker        size_t outbytesleft = sizeof (buf);
1701*6a54128fSAndroid Build Coastguard Worker        size_t res = iconv (cd_utf8_to_88591,
1702*6a54128fSAndroid Build Coastguard Worker                            &inptr, &inbytesleft,
1703*6a54128fSAndroid Build Coastguard Worker                            &outptr, &outbytesleft);
1704*6a54128fSAndroid Build Coastguard Worker        if (res == 0)
1705*6a54128fSAndroid Build Coastguard Worker          result |= 1;
1706*6a54128fSAndroid Build Coastguard Worker        iconv_close (cd_utf8_to_88591);
1707*6a54128fSAndroid Build Coastguard Worker      }
1708*6a54128fSAndroid Build Coastguard Worker  }
1709*6a54128fSAndroid Build Coastguard Worker  /* Test against Solaris 10 bug: Failures are not distinguishable from
1710*6a54128fSAndroid Build Coastguard Worker     successful returns.  */
1711*6a54128fSAndroid Build Coastguard Worker  {
1712*6a54128fSAndroid Build Coastguard Worker    iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
1713*6a54128fSAndroid Build Coastguard Worker    if (cd_ascii_to_88591 != (iconv_t)(-1))
1714*6a54128fSAndroid Build Coastguard Worker      {
1715*6a54128fSAndroid Build Coastguard Worker        static ICONV_CONST char input[] = "\263";
1716*6a54128fSAndroid Build Coastguard Worker        char buf[10];
1717*6a54128fSAndroid Build Coastguard Worker        ICONV_CONST char *inptr = input;
1718*6a54128fSAndroid Build Coastguard Worker        size_t inbytesleft = strlen (input);
1719*6a54128fSAndroid Build Coastguard Worker        char *outptr = buf;
1720*6a54128fSAndroid Build Coastguard Worker        size_t outbytesleft = sizeof (buf);
1721*6a54128fSAndroid Build Coastguard Worker        size_t res = iconv (cd_ascii_to_88591,
1722*6a54128fSAndroid Build Coastguard Worker                            &inptr, &inbytesleft,
1723*6a54128fSAndroid Build Coastguard Worker                            &outptr, &outbytesleft);
1724*6a54128fSAndroid Build Coastguard Worker        if (res == 0)
1725*6a54128fSAndroid Build Coastguard Worker          result |= 2;
1726*6a54128fSAndroid Build Coastguard Worker        iconv_close (cd_ascii_to_88591);
1727*6a54128fSAndroid Build Coastguard Worker      }
1728*6a54128fSAndroid Build Coastguard Worker  }
1729*6a54128fSAndroid Build Coastguard Worker  /* Test against AIX 6.1..7.1 bug: Buffer overrun.  */
1730*6a54128fSAndroid Build Coastguard Worker  {
1731*6a54128fSAndroid Build Coastguard Worker    iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
1732*6a54128fSAndroid Build Coastguard Worker    if (cd_88591_to_utf8 != (iconv_t)(-1))
1733*6a54128fSAndroid Build Coastguard Worker      {
1734*6a54128fSAndroid Build Coastguard Worker        static ICONV_CONST char input[] = "\304";
1735*6a54128fSAndroid Build Coastguard Worker        static char buf[2] = { (char)0xDE, (char)0xAD };
1736*6a54128fSAndroid Build Coastguard Worker        ICONV_CONST char *inptr = input;
1737*6a54128fSAndroid Build Coastguard Worker        size_t inbytesleft = 1;
1738*6a54128fSAndroid Build Coastguard Worker        char *outptr = buf;
1739*6a54128fSAndroid Build Coastguard Worker        size_t outbytesleft = 1;
1740*6a54128fSAndroid Build Coastguard Worker        size_t res = iconv (cd_88591_to_utf8,
1741*6a54128fSAndroid Build Coastguard Worker                            &inptr, &inbytesleft,
1742*6a54128fSAndroid Build Coastguard Worker                            &outptr, &outbytesleft);
1743*6a54128fSAndroid Build Coastguard Worker        if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
1744*6a54128fSAndroid Build Coastguard Worker          result |= 4;
1745*6a54128fSAndroid Build Coastguard Worker        iconv_close (cd_88591_to_utf8);
1746*6a54128fSAndroid Build Coastguard Worker      }
1747*6a54128fSAndroid Build Coastguard Worker  }
1748*6a54128fSAndroid Build Coastguard Worker#if 0 /* This bug could be worked around by the caller.  */
1749*6a54128fSAndroid Build Coastguard Worker  /* Test against HP-UX 11.11 bug: Positive return value instead of 0.  */
1750*6a54128fSAndroid Build Coastguard Worker  {
1751*6a54128fSAndroid Build Coastguard Worker    iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
1752*6a54128fSAndroid Build Coastguard Worker    if (cd_88591_to_utf8 != (iconv_t)(-1))
1753*6a54128fSAndroid Build Coastguard Worker      {
1754*6a54128fSAndroid Build Coastguard Worker        static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
1755*6a54128fSAndroid Build Coastguard Worker        char buf[50];
1756*6a54128fSAndroid Build Coastguard Worker        ICONV_CONST char *inptr = input;
1757*6a54128fSAndroid Build Coastguard Worker        size_t inbytesleft = strlen (input);
1758*6a54128fSAndroid Build Coastguard Worker        char *outptr = buf;
1759*6a54128fSAndroid Build Coastguard Worker        size_t outbytesleft = sizeof (buf);
1760*6a54128fSAndroid Build Coastguard Worker        size_t res = iconv (cd_88591_to_utf8,
1761*6a54128fSAndroid Build Coastguard Worker                            &inptr, &inbytesleft,
1762*6a54128fSAndroid Build Coastguard Worker                            &outptr, &outbytesleft);
1763*6a54128fSAndroid Build Coastguard Worker        if ((int)res > 0)
1764*6a54128fSAndroid Build Coastguard Worker          result |= 8;
1765*6a54128fSAndroid Build Coastguard Worker        iconv_close (cd_88591_to_utf8);
1766*6a54128fSAndroid Build Coastguard Worker      }
1767*6a54128fSAndroid Build Coastguard Worker  }
1768*6a54128fSAndroid Build Coastguard Worker#endif
1769*6a54128fSAndroid Build Coastguard Worker  /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
1770*6a54128fSAndroid Build Coastguard Worker     provided.  */
1771*6a54128fSAndroid Build Coastguard Worker  {
1772*6a54128fSAndroid Build Coastguard Worker    /* Try standardized names.  */
1773*6a54128fSAndroid Build Coastguard Worker    iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
1774*6a54128fSAndroid Build Coastguard Worker    /* Try IRIX, OSF/1 names.  */
1775*6a54128fSAndroid Build Coastguard Worker    iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
1776*6a54128fSAndroid Build Coastguard Worker    /* Try AIX names.  */
1777*6a54128fSAndroid Build Coastguard Worker    iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
1778*6a54128fSAndroid Build Coastguard Worker    /* Try HP-UX names.  */
1779*6a54128fSAndroid Build Coastguard Worker    iconv_t cd4 = iconv_open ("utf8", "eucJP");
1780*6a54128fSAndroid Build Coastguard Worker    if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
1781*6a54128fSAndroid Build Coastguard Worker        && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
1782*6a54128fSAndroid Build Coastguard Worker      result |= 16;
1783*6a54128fSAndroid Build Coastguard Worker    if (cd1 != (iconv_t)(-1))
1784*6a54128fSAndroid Build Coastguard Worker      iconv_close (cd1);
1785*6a54128fSAndroid Build Coastguard Worker    if (cd2 != (iconv_t)(-1))
1786*6a54128fSAndroid Build Coastguard Worker      iconv_close (cd2);
1787*6a54128fSAndroid Build Coastguard Worker    if (cd3 != (iconv_t)(-1))
1788*6a54128fSAndroid Build Coastguard Worker      iconv_close (cd3);
1789*6a54128fSAndroid Build Coastguard Worker    if (cd4 != (iconv_t)(-1))
1790*6a54128fSAndroid Build Coastguard Worker      iconv_close (cd4);
1791*6a54128fSAndroid Build Coastguard Worker  }
1792*6a54128fSAndroid Build Coastguard Worker  return result;
1793*6a54128fSAndroid Build Coastguard Worker]])],
1794*6a54128fSAndroid Build Coastguard Worker          [am_cv_func_iconv_works=yes], ,
1795*6a54128fSAndroid Build Coastguard Worker          [case "$host_os" in
1796*6a54128fSAndroid Build Coastguard Worker             aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
1797*6a54128fSAndroid Build Coastguard Worker             *)            am_cv_func_iconv_works="guessing yes" ;;
1798*6a54128fSAndroid Build Coastguard Worker           esac])
1799*6a54128fSAndroid Build Coastguard Worker        test "$am_cv_func_iconv_works" = no || break
1800*6a54128fSAndroid Build Coastguard Worker      done
1801*6a54128fSAndroid Build Coastguard Worker      LIBS="$am_save_LIBS"
1802*6a54128fSAndroid Build Coastguard Worker    ])
1803*6a54128fSAndroid Build Coastguard Worker    case "$am_cv_func_iconv_works" in
1804*6a54128fSAndroid Build Coastguard Worker      *no) am_func_iconv=no am_cv_lib_iconv=no ;;
1805*6a54128fSAndroid Build Coastguard Worker      *)   am_func_iconv=yes ;;
1806*6a54128fSAndroid Build Coastguard Worker    esac
1807*6a54128fSAndroid Build Coastguard Worker  else
1808*6a54128fSAndroid Build Coastguard Worker    am_func_iconv=no am_cv_lib_iconv=no
1809*6a54128fSAndroid Build Coastguard Worker  fi
1810*6a54128fSAndroid Build Coastguard Worker  if test "$am_func_iconv" = yes; then
1811*6a54128fSAndroid Build Coastguard Worker    AC_DEFINE([HAVE_ICONV], [1],
1812*6a54128fSAndroid Build Coastguard Worker      [Define if you have the iconv() function and it works.])
1813*6a54128fSAndroid Build Coastguard Worker  fi
1814*6a54128fSAndroid Build Coastguard Worker  if test "$am_cv_lib_iconv" = yes; then
1815*6a54128fSAndroid Build Coastguard Worker    AC_MSG_CHECKING([how to link with libiconv])
1816*6a54128fSAndroid Build Coastguard Worker    AC_MSG_RESULT([$LIBICONV])
1817*6a54128fSAndroid Build Coastguard Worker  else
1818*6a54128fSAndroid Build Coastguard Worker    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
1819*6a54128fSAndroid Build Coastguard Worker    dnl either.
1820*6a54128fSAndroid Build Coastguard Worker    CPPFLAGS="$am_save_CPPFLAGS"
1821*6a54128fSAndroid Build Coastguard Worker    LIBICONV=
1822*6a54128fSAndroid Build Coastguard Worker    LTLIBICONV=
1823*6a54128fSAndroid Build Coastguard Worker  fi
1824*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LIBICONV])
1825*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LTLIBICONV])
1826*6a54128fSAndroid Build Coastguard Worker])
1827*6a54128fSAndroid Build Coastguard Worker
1828*6a54128fSAndroid Build Coastguard Workerdnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
1829*6a54128fSAndroid Build Coastguard Workerdnl avoid warnings like
1830*6a54128fSAndroid Build Coastguard Workerdnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
1831*6a54128fSAndroid Build Coastguard Workerdnl This is tricky because of the way 'aclocal' is implemented:
1832*6a54128fSAndroid Build Coastguard Workerdnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
1833*6a54128fSAndroid Build Coastguard Workerdnl   Otherwise aclocal's initial scan pass would miss the macro definition.
1834*6a54128fSAndroid Build Coastguard Workerdnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
1835*6a54128fSAndroid Build Coastguard Workerdnl   Otherwise aclocal would emit many "Use of uninitialized value $1"
1836*6a54128fSAndroid Build Coastguard Workerdnl   warnings.
1837*6a54128fSAndroid Build Coastguard Workerm4_define([gl_iconv_AC_DEFUN],
1838*6a54128fSAndroid Build Coastguard Worker  m4_version_prereq([2.64],
1839*6a54128fSAndroid Build Coastguard Worker    [[AC_DEFUN_ONCE(
1840*6a54128fSAndroid Build Coastguard Worker        [$1], [$2])]],
1841*6a54128fSAndroid Build Coastguard Worker    [m4_ifdef([gl_00GNULIB],
1842*6a54128fSAndroid Build Coastguard Worker       [[AC_DEFUN_ONCE(
1843*6a54128fSAndroid Build Coastguard Worker           [$1], [$2])]],
1844*6a54128fSAndroid Build Coastguard Worker       [[AC_DEFUN(
1845*6a54128fSAndroid Build Coastguard Worker           [$1], [$2])]])]))
1846*6a54128fSAndroid Build Coastguard Workergl_iconv_AC_DEFUN([AM_ICONV],
1847*6a54128fSAndroid Build Coastguard Worker[
1848*6a54128fSAndroid Build Coastguard Worker  AM_ICONV_LINK
1849*6a54128fSAndroid Build Coastguard Worker  if test "$am_cv_func_iconv" = yes; then
1850*6a54128fSAndroid Build Coastguard Worker    AC_MSG_CHECKING([for iconv declaration])
1851*6a54128fSAndroid Build Coastguard Worker    AC_CACHE_VAL([am_cv_proto_iconv], [
1852*6a54128fSAndroid Build Coastguard Worker      AC_COMPILE_IFELSE(
1853*6a54128fSAndroid Build Coastguard Worker        [AC_LANG_PROGRAM(
1854*6a54128fSAndroid Build Coastguard Worker           [[
1855*6a54128fSAndroid Build Coastguard Worker#include <stdlib.h>
1856*6a54128fSAndroid Build Coastguard Worker#include <iconv.h>
1857*6a54128fSAndroid Build Coastguard Workerextern
1858*6a54128fSAndroid Build Coastguard Worker#ifdef __cplusplus
1859*6a54128fSAndroid Build Coastguard Worker"C"
1860*6a54128fSAndroid Build Coastguard Worker#endif
1861*6a54128fSAndroid Build Coastguard Worker#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
1862*6a54128fSAndroid Build Coastguard Workersize_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
1863*6a54128fSAndroid Build Coastguard Worker#else
1864*6a54128fSAndroid Build Coastguard Workersize_t iconv();
1865*6a54128fSAndroid Build Coastguard Worker#endif
1866*6a54128fSAndroid Build Coastguard Worker           ]],
1867*6a54128fSAndroid Build Coastguard Worker           [[]])],
1868*6a54128fSAndroid Build Coastguard Worker        [am_cv_proto_iconv_arg1=""],
1869*6a54128fSAndroid Build Coastguard Worker        [am_cv_proto_iconv_arg1="const"])
1870*6a54128fSAndroid Build Coastguard Worker      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
1871*6a54128fSAndroid Build Coastguard Worker    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
1872*6a54128fSAndroid Build Coastguard Worker    AC_MSG_RESULT([
1873*6a54128fSAndroid Build Coastguard Worker         $am_cv_proto_iconv])
1874*6a54128fSAndroid Build Coastguard Worker  else
1875*6a54128fSAndroid Build Coastguard Worker    dnl When compiling GNU libiconv on a system that does not have iconv yet,
1876*6a54128fSAndroid Build Coastguard Worker    dnl pick the POSIX compliant declaration without 'const'.
1877*6a54128fSAndroid Build Coastguard Worker    am_cv_proto_iconv_arg1=""
1878*6a54128fSAndroid Build Coastguard Worker  fi
1879*6a54128fSAndroid Build Coastguard Worker  AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
1880*6a54128fSAndroid Build Coastguard Worker    [Define as const if the declaration of iconv() needs const.])
1881*6a54128fSAndroid Build Coastguard Worker  dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
1882*6a54128fSAndroid Build Coastguard Worker  m4_ifdef([gl_ICONV_H_DEFAULTS],
1883*6a54128fSAndroid Build Coastguard Worker    [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
1884*6a54128fSAndroid Build Coastguard Worker     if test -n "$am_cv_proto_iconv_arg1"; then
1885*6a54128fSAndroid Build Coastguard Worker       ICONV_CONST="const"
1886*6a54128fSAndroid Build Coastguard Worker     fi
1887*6a54128fSAndroid Build Coastguard Worker    ])
1888*6a54128fSAndroid Build Coastguard Worker])
1889*6a54128fSAndroid Build Coastguard Worker
1890*6a54128fSAndroid Build Coastguard Worker# intlmacosx.m4 serial 8 (gettext-0.20.2)
1891*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 2004-2014, 2016, 2019-2020 Free Software Foundation, Inc.
1892*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
1893*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
1894*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
1895*6a54128fSAndroid Build Coastguard Workerdnl
1896*6a54128fSAndroid Build Coastguard Workerdnl This file can be used in projects which are not available under
1897*6a54128fSAndroid Build Coastguard Workerdnl the GNU General Public License or the GNU Lesser General Public
1898*6a54128fSAndroid Build Coastguard Workerdnl License but which still want to provide support for the GNU gettext
1899*6a54128fSAndroid Build Coastguard Workerdnl functionality.
1900*6a54128fSAndroid Build Coastguard Workerdnl Please note that the actual code of the GNU gettext library is covered
1901*6a54128fSAndroid Build Coastguard Workerdnl by the GNU Lesser General Public License, and the rest of the GNU
1902*6a54128fSAndroid Build Coastguard Workerdnl gettext package is covered by the GNU General Public License.
1903*6a54128fSAndroid Build Coastguard Workerdnl They are *not* in the public domain.
1904*6a54128fSAndroid Build Coastguard Worker
1905*6a54128fSAndroid Build Coastguard Workerdnl Checks for special options needed on Mac OS X.
1906*6a54128fSAndroid Build Coastguard Workerdnl Defines INTL_MACOSX_LIBS.
1907*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([gt_INTL_MACOSX],
1908*6a54128fSAndroid Build Coastguard Worker[
1909*6a54128fSAndroid Build Coastguard Worker  dnl Check for API introduced in Mac OS X 10.4.
1910*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
1911*6a54128fSAndroid Build Coastguard Worker    [gt_cv_func_CFPreferencesCopyAppValue],
1912*6a54128fSAndroid Build Coastguard Worker    [gt_save_LIBS="$LIBS"
1913*6a54128fSAndroid Build Coastguard Worker     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
1914*6a54128fSAndroid Build Coastguard Worker     AC_LINK_IFELSE(
1915*6a54128fSAndroid Build Coastguard Worker       [AC_LANG_PROGRAM(
1916*6a54128fSAndroid Build Coastguard Worker          [[#include <CoreFoundation/CFPreferences.h>]],
1917*6a54128fSAndroid Build Coastguard Worker          [[CFPreferencesCopyAppValue(NULL, NULL)]])],
1918*6a54128fSAndroid Build Coastguard Worker       [gt_cv_func_CFPreferencesCopyAppValue=yes],
1919*6a54128fSAndroid Build Coastguard Worker       [gt_cv_func_CFPreferencesCopyAppValue=no])
1920*6a54128fSAndroid Build Coastguard Worker     LIBS="$gt_save_LIBS"])
1921*6a54128fSAndroid Build Coastguard Worker  if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
1922*6a54128fSAndroid Build Coastguard Worker    AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
1923*6a54128fSAndroid Build Coastguard Worker      [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
1924*6a54128fSAndroid Build Coastguard Worker  fi
1925*6a54128fSAndroid Build Coastguard Worker  dnl Don't check for the API introduced in Mac OS X 10.5, CFLocaleCopyCurrent,
1926*6a54128fSAndroid Build Coastguard Worker  dnl because in macOS 10.13.4 it has the following behaviour:
1927*6a54128fSAndroid Build Coastguard Worker  dnl When two or more languages are specified in the
1928*6a54128fSAndroid Build Coastguard Worker  dnl "System Preferences > Language & Region > Preferred Languages" panel,
1929*6a54128fSAndroid Build Coastguard Worker  dnl it returns en_CC where CC is the territory (even when English is not among
1930*6a54128fSAndroid Build Coastguard Worker  dnl the preferred languages!).  What we want instead is what
1931*6a54128fSAndroid Build Coastguard Worker  dnl CFLocaleCopyCurrent returned in earlier macOS releases and what
1932*6a54128fSAndroid Build Coastguard Worker  dnl CFPreferencesCopyAppValue still returns, namely ll_CC where ll is the
1933*6a54128fSAndroid Build Coastguard Worker  dnl first among the preferred languages and CC is the territory.
1934*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([for CFLocaleCopyPreferredLanguages], [gt_cv_func_CFLocaleCopyPreferredLanguages],
1935*6a54128fSAndroid Build Coastguard Worker    [gt_save_LIBS="$LIBS"
1936*6a54128fSAndroid Build Coastguard Worker     LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
1937*6a54128fSAndroid Build Coastguard Worker     AC_LINK_IFELSE(
1938*6a54128fSAndroid Build Coastguard Worker       [AC_LANG_PROGRAM(
1939*6a54128fSAndroid Build Coastguard Worker          [[#include <CoreFoundation/CFLocale.h>]],
1940*6a54128fSAndroid Build Coastguard Worker          [[CFLocaleCopyPreferredLanguages();]])],
1941*6a54128fSAndroid Build Coastguard Worker       [gt_cv_func_CFLocaleCopyPreferredLanguages=yes],
1942*6a54128fSAndroid Build Coastguard Worker       [gt_cv_func_CFLocaleCopyPreferredLanguages=no])
1943*6a54128fSAndroid Build Coastguard Worker     LIBS="$gt_save_LIBS"])
1944*6a54128fSAndroid Build Coastguard Worker  if test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
1945*6a54128fSAndroid Build Coastguard Worker    AC_DEFINE([HAVE_CFLOCALECOPYPREFERREDLANGUAGES], [1],
1946*6a54128fSAndroid Build Coastguard Worker      [Define to 1 if you have the Mac OS X function CFLocaleCopyPreferredLanguages in the CoreFoundation framework.])
1947*6a54128fSAndroid Build Coastguard Worker  fi
1948*6a54128fSAndroid Build Coastguard Worker  INTL_MACOSX_LIBS=
1949*6a54128fSAndroid Build Coastguard Worker  if test $gt_cv_func_CFPreferencesCopyAppValue = yes \
1950*6a54128fSAndroid Build Coastguard Worker     || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
1951*6a54128fSAndroid Build Coastguard Worker    INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
1952*6a54128fSAndroid Build Coastguard Worker  fi
1953*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([INTL_MACOSX_LIBS])
1954*6a54128fSAndroid Build Coastguard Worker])
1955*6a54128fSAndroid Build Coastguard Worker
1956*6a54128fSAndroid Build Coastguard Worker# lib-ld.m4 serial 9
1957*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc.
1958*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
1959*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
1960*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
1961*6a54128fSAndroid Build Coastguard Worker
1962*6a54128fSAndroid Build Coastguard Workerdnl Subroutines of libtool.m4,
1963*6a54128fSAndroid Build Coastguard Workerdnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
1964*6a54128fSAndroid Build Coastguard Workerdnl collision with libtool.m4.
1965*6a54128fSAndroid Build Coastguard Worker
1966*6a54128fSAndroid Build Coastguard Workerdnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
1967*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_PROG_LD_GNU],
1968*6a54128fSAndroid Build Coastguard Worker[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
1969*6a54128fSAndroid Build Coastguard Worker[# I'd rather use --version here, but apparently some GNU lds only accept -v.
1970*6a54128fSAndroid Build Coastguard Workercase `$LD -v 2>&1 </dev/null` in
1971*6a54128fSAndroid Build Coastguard Worker*GNU* | *'with BFD'*)
1972*6a54128fSAndroid Build Coastguard Worker  acl_cv_prog_gnu_ld=yes
1973*6a54128fSAndroid Build Coastguard Worker  ;;
1974*6a54128fSAndroid Build Coastguard Worker*)
1975*6a54128fSAndroid Build Coastguard Worker  acl_cv_prog_gnu_ld=no
1976*6a54128fSAndroid Build Coastguard Worker  ;;
1977*6a54128fSAndroid Build Coastguard Workeresac])
1978*6a54128fSAndroid Build Coastguard Workerwith_gnu_ld=$acl_cv_prog_gnu_ld
1979*6a54128fSAndroid Build Coastguard Worker])
1980*6a54128fSAndroid Build Coastguard Worker
1981*6a54128fSAndroid Build Coastguard Workerdnl From libtool-2.4. Sets the variable LD.
1982*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_PROG_LD],
1983*6a54128fSAndroid Build Coastguard Worker[AC_REQUIRE([AC_PROG_CC])dnl
1984*6a54128fSAndroid Build Coastguard WorkerAC_REQUIRE([AC_CANONICAL_HOST])dnl
1985*6a54128fSAndroid Build Coastguard Worker
1986*6a54128fSAndroid Build Coastguard WorkerAC_ARG_WITH([gnu-ld],
1987*6a54128fSAndroid Build Coastguard Worker    [AS_HELP_STRING([--with-gnu-ld],
1988*6a54128fSAndroid Build Coastguard Worker        [assume the C compiler uses GNU ld [default=no]])],
1989*6a54128fSAndroid Build Coastguard Worker    [test "$withval" = no || with_gnu_ld=yes],
1990*6a54128fSAndroid Build Coastguard Worker    [with_gnu_ld=no])dnl
1991*6a54128fSAndroid Build Coastguard Worker
1992*6a54128fSAndroid Build Coastguard Worker# Prepare PATH_SEPARATOR.
1993*6a54128fSAndroid Build Coastguard Worker# The user is always right.
1994*6a54128fSAndroid Build Coastguard Workerif test "${PATH_SEPARATOR+set}" != set; then
1995*6a54128fSAndroid Build Coastguard Worker  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
1996*6a54128fSAndroid Build Coastguard Worker  # contains only /bin. Note that ksh looks also at the FPATH variable,
1997*6a54128fSAndroid Build Coastguard Worker  # so we have to set that as well for the test.
1998*6a54128fSAndroid Build Coastguard Worker  PATH_SEPARATOR=:
1999*6a54128fSAndroid Build Coastguard Worker  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
2000*6a54128fSAndroid Build Coastguard Worker    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
2001*6a54128fSAndroid Build Coastguard Worker           || PATH_SEPARATOR=';'
2002*6a54128fSAndroid Build Coastguard Worker       }
2003*6a54128fSAndroid Build Coastguard Workerfi
2004*6a54128fSAndroid Build Coastguard Worker
2005*6a54128fSAndroid Build Coastguard Workerif test -n "$LD"; then
2006*6a54128fSAndroid Build Coastguard Worker  AC_MSG_CHECKING([for ld])
2007*6a54128fSAndroid Build Coastguard Workerelif test "$GCC" = yes; then
2008*6a54128fSAndroid Build Coastguard Worker  AC_MSG_CHECKING([for ld used by $CC])
2009*6a54128fSAndroid Build Coastguard Workerelif test "$with_gnu_ld" = yes; then
2010*6a54128fSAndroid Build Coastguard Worker  AC_MSG_CHECKING([for GNU ld])
2011*6a54128fSAndroid Build Coastguard Workerelse
2012*6a54128fSAndroid Build Coastguard Worker  AC_MSG_CHECKING([for non-GNU ld])
2013*6a54128fSAndroid Build Coastguard Workerfi
2014*6a54128fSAndroid Build Coastguard Workerif test -n "$LD"; then
2015*6a54128fSAndroid Build Coastguard Worker  # Let the user override the test with a path.
2016*6a54128fSAndroid Build Coastguard Worker  :
2017*6a54128fSAndroid Build Coastguard Workerelse
2018*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_VAL([acl_cv_path_LD],
2019*6a54128fSAndroid Build Coastguard Worker  [
2020*6a54128fSAndroid Build Coastguard Worker    acl_cv_path_LD= # Final result of this test
2021*6a54128fSAndroid Build Coastguard Worker    ac_prog=ld # Program to search in $PATH
2022*6a54128fSAndroid Build Coastguard Worker    if test "$GCC" = yes; then
2023*6a54128fSAndroid Build Coastguard Worker      # Check if gcc -print-prog-name=ld gives a path.
2024*6a54128fSAndroid Build Coastguard Worker      case $host in
2025*6a54128fSAndroid Build Coastguard Worker        *-*-mingw*)
2026*6a54128fSAndroid Build Coastguard Worker          # gcc leaves a trailing carriage return which upsets mingw
2027*6a54128fSAndroid Build Coastguard Worker          acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
2028*6a54128fSAndroid Build Coastguard Worker        *)
2029*6a54128fSAndroid Build Coastguard Worker          acl_output=`($CC -print-prog-name=ld) 2>&5` ;;
2030*6a54128fSAndroid Build Coastguard Worker      esac
2031*6a54128fSAndroid Build Coastguard Worker      case $acl_output in
2032*6a54128fSAndroid Build Coastguard Worker        # Accept absolute paths.
2033*6a54128fSAndroid Build Coastguard Worker        [[\\/]]* | ?:[[\\/]]*)
2034*6a54128fSAndroid Build Coastguard Worker          re_direlt='/[[^/]][[^/]]*/\.\./'
2035*6a54128fSAndroid Build Coastguard Worker          # Canonicalize the pathname of ld
2036*6a54128fSAndroid Build Coastguard Worker          acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'`
2037*6a54128fSAndroid Build Coastguard Worker          while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do
2038*6a54128fSAndroid Build Coastguard Worker            acl_output=`echo $acl_output | sed "s%$re_direlt%/%"`
2039*6a54128fSAndroid Build Coastguard Worker          done
2040*6a54128fSAndroid Build Coastguard Worker          # Got the pathname. No search in PATH is needed.
2041*6a54128fSAndroid Build Coastguard Worker          acl_cv_path_LD="$acl_output"
2042*6a54128fSAndroid Build Coastguard Worker          ac_prog=
2043*6a54128fSAndroid Build Coastguard Worker          ;;
2044*6a54128fSAndroid Build Coastguard Worker        "")
2045*6a54128fSAndroid Build Coastguard Worker          # If it fails, then pretend we aren't using GCC.
2046*6a54128fSAndroid Build Coastguard Worker          ;;
2047*6a54128fSAndroid Build Coastguard Worker        *)
2048*6a54128fSAndroid Build Coastguard Worker          # If it is relative, then search for the first ld in PATH.
2049*6a54128fSAndroid Build Coastguard Worker          with_gnu_ld=unknown
2050*6a54128fSAndroid Build Coastguard Worker          ;;
2051*6a54128fSAndroid Build Coastguard Worker      esac
2052*6a54128fSAndroid Build Coastguard Worker    fi
2053*6a54128fSAndroid Build Coastguard Worker    if test -n "$ac_prog"; then
2054*6a54128fSAndroid Build Coastguard Worker      # Search for $ac_prog in $PATH.
2055*6a54128fSAndroid Build Coastguard Worker      acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
2056*6a54128fSAndroid Build Coastguard Worker      for ac_dir in $PATH; do
2057*6a54128fSAndroid Build Coastguard Worker        IFS="$acl_save_ifs"
2058*6a54128fSAndroid Build Coastguard Worker        test -z "$ac_dir" && ac_dir=.
2059*6a54128fSAndroid Build Coastguard Worker        if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
2060*6a54128fSAndroid Build Coastguard Worker          acl_cv_path_LD="$ac_dir/$ac_prog"
2061*6a54128fSAndroid Build Coastguard Worker          # Check to see if the program is GNU ld.  I'd rather use --version,
2062*6a54128fSAndroid Build Coastguard Worker          # but apparently some variants of GNU ld only accept -v.
2063*6a54128fSAndroid Build Coastguard Worker          # Break only if it was the GNU/non-GNU ld that we prefer.
2064*6a54128fSAndroid Build Coastguard Worker          case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
2065*6a54128fSAndroid Build Coastguard Worker            *GNU* | *'with BFD'*)
2066*6a54128fSAndroid Build Coastguard Worker              test "$with_gnu_ld" != no && break
2067*6a54128fSAndroid Build Coastguard Worker              ;;
2068*6a54128fSAndroid Build Coastguard Worker            *)
2069*6a54128fSAndroid Build Coastguard Worker              test "$with_gnu_ld" != yes && break
2070*6a54128fSAndroid Build Coastguard Worker              ;;
2071*6a54128fSAndroid Build Coastguard Worker          esac
2072*6a54128fSAndroid Build Coastguard Worker        fi
2073*6a54128fSAndroid Build Coastguard Worker      done
2074*6a54128fSAndroid Build Coastguard Worker      IFS="$acl_save_ifs"
2075*6a54128fSAndroid Build Coastguard Worker    fi
2076*6a54128fSAndroid Build Coastguard Worker    case $host in
2077*6a54128fSAndroid Build Coastguard Worker      *-*-aix*)
2078*6a54128fSAndroid Build Coastguard Worker        AC_COMPILE_IFELSE(
2079*6a54128fSAndroid Build Coastguard Worker          [AC_LANG_SOURCE(
2080*6a54128fSAndroid Build Coastguard Worker             [[#if defined __powerpc64__ || defined _ARCH_PPC64
2081*6a54128fSAndroid Build Coastguard Worker                int ok;
2082*6a54128fSAndroid Build Coastguard Worker               #else
2083*6a54128fSAndroid Build Coastguard Worker                error fail
2084*6a54128fSAndroid Build Coastguard Worker               #endif
2085*6a54128fSAndroid Build Coastguard Worker             ]])],
2086*6a54128fSAndroid Build Coastguard Worker          [# The compiler produces 64-bit code. Add option '-b64' so that the
2087*6a54128fSAndroid Build Coastguard Worker           # linker groks 64-bit object files.
2088*6a54128fSAndroid Build Coastguard Worker           case "$acl_cv_path_LD " in
2089*6a54128fSAndroid Build Coastguard Worker             *" -b64 "*) ;;
2090*6a54128fSAndroid Build Coastguard Worker             *) acl_cv_path_LD="$acl_cv_path_LD -b64" ;;
2091*6a54128fSAndroid Build Coastguard Worker           esac
2092*6a54128fSAndroid Build Coastguard Worker          ], [])
2093*6a54128fSAndroid Build Coastguard Worker        ;;
2094*6a54128fSAndroid Build Coastguard Worker      sparc64-*-netbsd*)
2095*6a54128fSAndroid Build Coastguard Worker        AC_COMPILE_IFELSE(
2096*6a54128fSAndroid Build Coastguard Worker          [AC_LANG_SOURCE(
2097*6a54128fSAndroid Build Coastguard Worker             [[#if defined __sparcv9 || defined __arch64__
2098*6a54128fSAndroid Build Coastguard Worker                int ok;
2099*6a54128fSAndroid Build Coastguard Worker               #else
2100*6a54128fSAndroid Build Coastguard Worker                error fail
2101*6a54128fSAndroid Build Coastguard Worker               #endif
2102*6a54128fSAndroid Build Coastguard Worker             ]])],
2103*6a54128fSAndroid Build Coastguard Worker          [],
2104*6a54128fSAndroid Build Coastguard Worker          [# The compiler produces 32-bit code. Add option '-m elf32_sparc'
2105*6a54128fSAndroid Build Coastguard Worker           # so that the linker groks 32-bit object files.
2106*6a54128fSAndroid Build Coastguard Worker           case "$acl_cv_path_LD " in
2107*6a54128fSAndroid Build Coastguard Worker             *" -m elf32_sparc "*) ;;
2108*6a54128fSAndroid Build Coastguard Worker             *) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;;
2109*6a54128fSAndroid Build Coastguard Worker           esac
2110*6a54128fSAndroid Build Coastguard Worker          ])
2111*6a54128fSAndroid Build Coastguard Worker        ;;
2112*6a54128fSAndroid Build Coastguard Worker    esac
2113*6a54128fSAndroid Build Coastguard Worker  ])
2114*6a54128fSAndroid Build Coastguard Worker  LD="$acl_cv_path_LD"
2115*6a54128fSAndroid Build Coastguard Workerfi
2116*6a54128fSAndroid Build Coastguard Workerif test -n "$LD"; then
2117*6a54128fSAndroid Build Coastguard Worker  AC_MSG_RESULT([$LD])
2118*6a54128fSAndroid Build Coastguard Workerelse
2119*6a54128fSAndroid Build Coastguard Worker  AC_MSG_RESULT([no])
2120*6a54128fSAndroid Build Coastguard Worker  AC_MSG_ERROR([no acceptable ld found in \$PATH])
2121*6a54128fSAndroid Build Coastguard Workerfi
2122*6a54128fSAndroid Build Coastguard WorkerAC_LIB_PROG_LD_GNU
2123*6a54128fSAndroid Build Coastguard Worker])
2124*6a54128fSAndroid Build Coastguard Worker
2125*6a54128fSAndroid Build Coastguard Worker# lib-link.m4 serial 31
2126*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 2001-2020 Free Software Foundation, Inc.
2127*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
2128*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
2129*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
2130*6a54128fSAndroid Build Coastguard Worker
2131*6a54128fSAndroid Build Coastguard Workerdnl From Bruno Haible.
2132*6a54128fSAndroid Build Coastguard Worker
2133*6a54128fSAndroid Build Coastguard WorkerAC_PREREQ([2.61])
2134*6a54128fSAndroid Build Coastguard Worker
2135*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
2136*6a54128fSAndroid Build Coastguard Workerdnl the libraries corresponding to explicit and implicit dependencies.
2137*6a54128fSAndroid Build Coastguard Workerdnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
2138*6a54128fSAndroid Build Coastguard Workerdnl augments the CPPFLAGS variable.
2139*6a54128fSAndroid Build Coastguard Workerdnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
2140*6a54128fSAndroid Build Coastguard Workerdnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
2141*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_LINKFLAGS],
2142*6a54128fSAndroid Build Coastguard Worker[
2143*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2144*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_RPATH])
2145*6a54128fSAndroid Build Coastguard Worker  pushdef([Name],[m4_translit([$1],[./+-], [____])])
2146*6a54128fSAndroid Build Coastguard Worker  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2147*6a54128fSAndroid Build Coastguard Worker                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2148*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
2149*6a54128fSAndroid Build Coastguard Worker    AC_LIB_LINKFLAGS_BODY([$1], [$2])
2150*6a54128fSAndroid Build Coastguard Worker    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
2151*6a54128fSAndroid Build Coastguard Worker    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
2152*6a54128fSAndroid Build Coastguard Worker    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
2153*6a54128fSAndroid Build Coastguard Worker    ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
2154*6a54128fSAndroid Build Coastguard Worker  ])
2155*6a54128fSAndroid Build Coastguard Worker  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
2156*6a54128fSAndroid Build Coastguard Worker  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
2157*6a54128fSAndroid Build Coastguard Worker  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
2158*6a54128fSAndroid Build Coastguard Worker  LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
2159*6a54128fSAndroid Build Coastguard Worker  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2160*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LIB]NAME)
2161*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LTLIB]NAME)
2162*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LIB]NAME[_PREFIX])
2163*6a54128fSAndroid Build Coastguard Worker  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
2164*6a54128fSAndroid Build Coastguard Worker  dnl results of this search when this library appears as a dependency.
2165*6a54128fSAndroid Build Coastguard Worker  HAVE_LIB[]NAME=yes
2166*6a54128fSAndroid Build Coastguard Worker  popdef([NAME])
2167*6a54128fSAndroid Build Coastguard Worker  popdef([Name])
2168*6a54128fSAndroid Build Coastguard Worker])
2169*6a54128fSAndroid Build Coastguard Worker
2170*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
2171*6a54128fSAndroid Build Coastguard Workerdnl searches for libname and the libraries corresponding to explicit and
2172*6a54128fSAndroid Build Coastguard Workerdnl implicit dependencies, together with the specified include files and
2173*6a54128fSAndroid Build Coastguard Workerdnl the ability to compile and link the specified testcode. The missing-message
2174*6a54128fSAndroid Build Coastguard Workerdnl defaults to 'no' and may contain additional hints for the user.
2175*6a54128fSAndroid Build Coastguard Workerdnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
2176*6a54128fSAndroid Build Coastguard Workerdnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
2177*6a54128fSAndroid Build Coastguard Workerdnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
2178*6a54128fSAndroid Build Coastguard Workerdnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
2179*6a54128fSAndroid Build Coastguard Workerdnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
2180*6a54128fSAndroid Build Coastguard Workerdnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
2181*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
2182*6a54128fSAndroid Build Coastguard Worker[
2183*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2184*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_RPATH])
2185*6a54128fSAndroid Build Coastguard Worker  pushdef([Name],[m4_translit([$1],[./+-], [____])])
2186*6a54128fSAndroid Build Coastguard Worker  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2187*6a54128fSAndroid Build Coastguard Worker                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2188*6a54128fSAndroid Build Coastguard Worker
2189*6a54128fSAndroid Build Coastguard Worker  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
2190*6a54128fSAndroid Build Coastguard Worker  dnl accordingly.
2191*6a54128fSAndroid Build Coastguard Worker  AC_LIB_LINKFLAGS_BODY([$1], [$2])
2192*6a54128fSAndroid Build Coastguard Worker
2193*6a54128fSAndroid Build Coastguard Worker  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
2194*6a54128fSAndroid Build Coastguard Worker  dnl because if the user has installed lib[]Name and not disabled its use
2195*6a54128fSAndroid Build Coastguard Worker  dnl via --without-lib[]Name-prefix, he wants to use it.
2196*6a54128fSAndroid Build Coastguard Worker  ac_save_CPPFLAGS="$CPPFLAGS"
2197*6a54128fSAndroid Build Coastguard Worker  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
2198*6a54128fSAndroid Build Coastguard Worker
2199*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
2200*6a54128fSAndroid Build Coastguard Worker    ac_save_LIBS="$LIBS"
2201*6a54128fSAndroid Build Coastguard Worker    dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
2202*6a54128fSAndroid Build Coastguard Worker    dnl because these -l options might require -L options that are present in
2203*6a54128fSAndroid Build Coastguard Worker    dnl LIBS. -l options benefit only from the -L options listed before it.
2204*6a54128fSAndroid Build Coastguard Worker    dnl Otherwise, add it to the front of LIBS, because it may be a static
2205*6a54128fSAndroid Build Coastguard Worker    dnl library that depends on another static library that is present in LIBS.
2206*6a54128fSAndroid Build Coastguard Worker    dnl Static libraries benefit only from the static libraries listed after
2207*6a54128fSAndroid Build Coastguard Worker    dnl it.
2208*6a54128fSAndroid Build Coastguard Worker    case " $LIB[]NAME" in
2209*6a54128fSAndroid Build Coastguard Worker      *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
2210*6a54128fSAndroid Build Coastguard Worker      *)       LIBS="$LIB[]NAME $LIBS" ;;
2211*6a54128fSAndroid Build Coastguard Worker    esac
2212*6a54128fSAndroid Build Coastguard Worker    AC_LINK_IFELSE(
2213*6a54128fSAndroid Build Coastguard Worker      [AC_LANG_PROGRAM([[$3]], [[$4]])],
2214*6a54128fSAndroid Build Coastguard Worker      [ac_cv_lib[]Name=yes],
2215*6a54128fSAndroid Build Coastguard Worker      [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
2216*6a54128fSAndroid Build Coastguard Worker    LIBS="$ac_save_LIBS"
2217*6a54128fSAndroid Build Coastguard Worker  ])
2218*6a54128fSAndroid Build Coastguard Worker  if test "$ac_cv_lib[]Name" = yes; then
2219*6a54128fSAndroid Build Coastguard Worker    HAVE_LIB[]NAME=yes
2220*6a54128fSAndroid Build Coastguard Worker    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
2221*6a54128fSAndroid Build Coastguard Worker    AC_MSG_CHECKING([how to link with lib[]$1])
2222*6a54128fSAndroid Build Coastguard Worker    AC_MSG_RESULT([$LIB[]NAME])
2223*6a54128fSAndroid Build Coastguard Worker  else
2224*6a54128fSAndroid Build Coastguard Worker    HAVE_LIB[]NAME=no
2225*6a54128fSAndroid Build Coastguard Worker    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
2226*6a54128fSAndroid Build Coastguard Worker    dnl $INC[]NAME either.
2227*6a54128fSAndroid Build Coastguard Worker    CPPFLAGS="$ac_save_CPPFLAGS"
2228*6a54128fSAndroid Build Coastguard Worker    LIB[]NAME=
2229*6a54128fSAndroid Build Coastguard Worker    LTLIB[]NAME=
2230*6a54128fSAndroid Build Coastguard Worker    LIB[]NAME[]_PREFIX=
2231*6a54128fSAndroid Build Coastguard Worker  fi
2232*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([HAVE_LIB]NAME)
2233*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LIB]NAME)
2234*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LTLIB]NAME)
2235*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([LIB]NAME[_PREFIX])
2236*6a54128fSAndroid Build Coastguard Worker  popdef([NAME])
2237*6a54128fSAndroid Build Coastguard Worker  popdef([Name])
2238*6a54128fSAndroid Build Coastguard Worker])
2239*6a54128fSAndroid Build Coastguard Worker
2240*6a54128fSAndroid Build Coastguard Workerdnl Determine the platform dependent parameters needed to use rpath:
2241*6a54128fSAndroid Build Coastguard Workerdnl   acl_libext,
2242*6a54128fSAndroid Build Coastguard Workerdnl   acl_shlibext,
2243*6a54128fSAndroid Build Coastguard Workerdnl   acl_libname_spec,
2244*6a54128fSAndroid Build Coastguard Workerdnl   acl_library_names_spec,
2245*6a54128fSAndroid Build Coastguard Workerdnl   acl_hardcode_libdir_flag_spec,
2246*6a54128fSAndroid Build Coastguard Workerdnl   acl_hardcode_libdir_separator,
2247*6a54128fSAndroid Build Coastguard Workerdnl   acl_hardcode_direct,
2248*6a54128fSAndroid Build Coastguard Workerdnl   acl_hardcode_minus_L.
2249*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_RPATH],
2250*6a54128fSAndroid Build Coastguard Worker[
2251*6a54128fSAndroid Build Coastguard Worker  dnl Complain if config.rpath is missing.
2252*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE_AUX_FILE([config.rpath])
2253*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
2254*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
2255*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
2256*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
2257*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
2258*6a54128fSAndroid Build Coastguard Worker    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
2259*6a54128fSAndroid Build Coastguard Worker    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
2260*6a54128fSAndroid Build Coastguard Worker    . ./conftest.sh
2261*6a54128fSAndroid Build Coastguard Worker    rm -f ./conftest.sh
2262*6a54128fSAndroid Build Coastguard Worker    acl_cv_rpath=done
2263*6a54128fSAndroid Build Coastguard Worker  ])
2264*6a54128fSAndroid Build Coastguard Worker  wl="$acl_cv_wl"
2265*6a54128fSAndroid Build Coastguard Worker  acl_libext="$acl_cv_libext"
2266*6a54128fSAndroid Build Coastguard Worker  acl_shlibext="$acl_cv_shlibext"
2267*6a54128fSAndroid Build Coastguard Worker  acl_libname_spec="$acl_cv_libname_spec"
2268*6a54128fSAndroid Build Coastguard Worker  acl_library_names_spec="$acl_cv_library_names_spec"
2269*6a54128fSAndroid Build Coastguard Worker  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
2270*6a54128fSAndroid Build Coastguard Worker  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
2271*6a54128fSAndroid Build Coastguard Worker  acl_hardcode_direct="$acl_cv_hardcode_direct"
2272*6a54128fSAndroid Build Coastguard Worker  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
2273*6a54128fSAndroid Build Coastguard Worker  dnl Determine whether the user wants rpath handling at all.
2274*6a54128fSAndroid Build Coastguard Worker  AC_ARG_ENABLE([rpath],
2275*6a54128fSAndroid Build Coastguard Worker    [  --disable-rpath         do not hardcode runtime library paths],
2276*6a54128fSAndroid Build Coastguard Worker    :, enable_rpath=yes)
2277*6a54128fSAndroid Build Coastguard Worker])
2278*6a54128fSAndroid Build Coastguard Worker
2279*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_FROMPACKAGE(name, package)
2280*6a54128fSAndroid Build Coastguard Workerdnl declares that libname comes from the given package. The configure file
2281*6a54128fSAndroid Build Coastguard Workerdnl will then not have a --with-libname-prefix option but a
2282*6a54128fSAndroid Build Coastguard Workerdnl --with-package-prefix option. Several libraries can come from the same
2283*6a54128fSAndroid Build Coastguard Workerdnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
2284*6a54128fSAndroid Build Coastguard Workerdnl macro call that searches for libname.
2285*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_FROMPACKAGE],
2286*6a54128fSAndroid Build Coastguard Worker[
2287*6a54128fSAndroid Build Coastguard Worker  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2288*6a54128fSAndroid Build Coastguard Worker                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2289*6a54128fSAndroid Build Coastguard Worker  define([acl_frompackage_]NAME, [$2])
2290*6a54128fSAndroid Build Coastguard Worker  popdef([NAME])
2291*6a54128fSAndroid Build Coastguard Worker  pushdef([PACK],[$2])
2292*6a54128fSAndroid Build Coastguard Worker  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
2293*6a54128fSAndroid Build Coastguard Worker                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2294*6a54128fSAndroid Build Coastguard Worker  define([acl_libsinpackage_]PACKUP,
2295*6a54128fSAndroid Build Coastguard Worker    m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
2296*6a54128fSAndroid Build Coastguard Worker  popdef([PACKUP])
2297*6a54128fSAndroid Build Coastguard Worker  popdef([PACK])
2298*6a54128fSAndroid Build Coastguard Worker])
2299*6a54128fSAndroid Build Coastguard Worker
2300*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
2301*6a54128fSAndroid Build Coastguard Workerdnl the libraries corresponding to explicit and implicit dependencies.
2302*6a54128fSAndroid Build Coastguard Workerdnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
2303*6a54128fSAndroid Build Coastguard Workerdnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
2304*6a54128fSAndroid Build Coastguard Workerdnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
2305*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_LINKFLAGS_BODY],
2306*6a54128fSAndroid Build Coastguard Worker[
2307*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
2308*6a54128fSAndroid Build Coastguard Worker  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
2309*6a54128fSAndroid Build Coastguard Worker                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2310*6a54128fSAndroid Build Coastguard Worker  pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
2311*6a54128fSAndroid Build Coastguard Worker  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
2312*6a54128fSAndroid Build Coastguard Worker                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
2313*6a54128fSAndroid Build Coastguard Worker  pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
2314*6a54128fSAndroid Build Coastguard Worker  dnl By default, look in $includedir and $libdir.
2315*6a54128fSAndroid Build Coastguard Worker  use_additional=yes
2316*6a54128fSAndroid Build Coastguard Worker  AC_LIB_WITH_FINAL_PREFIX([
2317*6a54128fSAndroid Build Coastguard Worker    eval additional_includedir=\"$includedir\"
2318*6a54128fSAndroid Build Coastguard Worker    eval additional_libdir=\"$libdir\"
2319*6a54128fSAndroid Build Coastguard Worker    eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
2320*6a54128fSAndroid Build Coastguard Worker    eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
2321*6a54128fSAndroid Build Coastguard Worker  ])
2322*6a54128fSAndroid Build Coastguard Worker  AC_ARG_WITH(PACK[-prefix],
2323*6a54128fSAndroid Build Coastguard Worker[[  --with-]]PACK[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
2324*6a54128fSAndroid Build Coastguard Worker  --without-]]PACK[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
2325*6a54128fSAndroid Build Coastguard Worker[
2326*6a54128fSAndroid Build Coastguard Worker    if test "X$withval" = "Xno"; then
2327*6a54128fSAndroid Build Coastguard Worker      use_additional=no
2328*6a54128fSAndroid Build Coastguard Worker    else
2329*6a54128fSAndroid Build Coastguard Worker      if test "X$withval" = "X"; then
2330*6a54128fSAndroid Build Coastguard Worker        AC_LIB_WITH_FINAL_PREFIX([
2331*6a54128fSAndroid Build Coastguard Worker          eval additional_includedir=\"$includedir\"
2332*6a54128fSAndroid Build Coastguard Worker          eval additional_libdir=\"$libdir\"
2333*6a54128fSAndroid Build Coastguard Worker          eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
2334*6a54128fSAndroid Build Coastguard Worker          eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
2335*6a54128fSAndroid Build Coastguard Worker        ])
2336*6a54128fSAndroid Build Coastguard Worker      else
2337*6a54128fSAndroid Build Coastguard Worker        additional_includedir="$withval/include"
2338*6a54128fSAndroid Build Coastguard Worker        additional_libdir="$withval/$acl_libdirstem"
2339*6a54128fSAndroid Build Coastguard Worker        additional_libdir2="$withval/$acl_libdirstem2"
2340*6a54128fSAndroid Build Coastguard Worker        additional_libdir3="$withval/$acl_libdirstem3"
2341*6a54128fSAndroid Build Coastguard Worker      fi
2342*6a54128fSAndroid Build Coastguard Worker    fi
2343*6a54128fSAndroid Build Coastguard Worker])
2344*6a54128fSAndroid Build Coastguard Worker  if test "X$additional_libdir2" = "X$additional_libdir"; then
2345*6a54128fSAndroid Build Coastguard Worker    additional_libdir2=
2346*6a54128fSAndroid Build Coastguard Worker  fi
2347*6a54128fSAndroid Build Coastguard Worker  if test "X$additional_libdir3" = "X$additional_libdir"; then
2348*6a54128fSAndroid Build Coastguard Worker    additional_libdir3=
2349*6a54128fSAndroid Build Coastguard Worker  fi
2350*6a54128fSAndroid Build Coastguard Worker  dnl Search the library and its dependencies in $additional_libdir and
2351*6a54128fSAndroid Build Coastguard Worker  dnl $LDFLAGS. Using breadth-first-seach.
2352*6a54128fSAndroid Build Coastguard Worker  LIB[]NAME=
2353*6a54128fSAndroid Build Coastguard Worker  LTLIB[]NAME=
2354*6a54128fSAndroid Build Coastguard Worker  INC[]NAME=
2355*6a54128fSAndroid Build Coastguard Worker  LIB[]NAME[]_PREFIX=
2356*6a54128fSAndroid Build Coastguard Worker  dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
2357*6a54128fSAndroid Build Coastguard Worker  dnl computed. So it has to be reset here.
2358*6a54128fSAndroid Build Coastguard Worker  HAVE_LIB[]NAME=
2359*6a54128fSAndroid Build Coastguard Worker  rpathdirs=
2360*6a54128fSAndroid Build Coastguard Worker  ltrpathdirs=
2361*6a54128fSAndroid Build Coastguard Worker  names_already_handled=
2362*6a54128fSAndroid Build Coastguard Worker  names_next_round='$1 $2'
2363*6a54128fSAndroid Build Coastguard Worker  while test -n "$names_next_round"; do
2364*6a54128fSAndroid Build Coastguard Worker    names_this_round="$names_next_round"
2365*6a54128fSAndroid Build Coastguard Worker    names_next_round=
2366*6a54128fSAndroid Build Coastguard Worker    for name in $names_this_round; do
2367*6a54128fSAndroid Build Coastguard Worker      already_handled=
2368*6a54128fSAndroid Build Coastguard Worker      for n in $names_already_handled; do
2369*6a54128fSAndroid Build Coastguard Worker        if test "$n" = "$name"; then
2370*6a54128fSAndroid Build Coastguard Worker          already_handled=yes
2371*6a54128fSAndroid Build Coastguard Worker          break
2372*6a54128fSAndroid Build Coastguard Worker        fi
2373*6a54128fSAndroid Build Coastguard Worker      done
2374*6a54128fSAndroid Build Coastguard Worker      if test -z "$already_handled"; then
2375*6a54128fSAndroid Build Coastguard Worker        names_already_handled="$names_already_handled $name"
2376*6a54128fSAndroid Build Coastguard Worker        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
2377*6a54128fSAndroid Build Coastguard Worker        dnl or AC_LIB_HAVE_LINKFLAGS call.
2378*6a54128fSAndroid Build Coastguard Worker        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
2379*6a54128fSAndroid Build Coastguard Worker        eval value=\"\$HAVE_LIB$uppername\"
2380*6a54128fSAndroid Build Coastguard Worker        if test -n "$value"; then
2381*6a54128fSAndroid Build Coastguard Worker          if test "$value" = yes; then
2382*6a54128fSAndroid Build Coastguard Worker            eval value=\"\$LIB$uppername\"
2383*6a54128fSAndroid Build Coastguard Worker            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
2384*6a54128fSAndroid Build Coastguard Worker            eval value=\"\$LTLIB$uppername\"
2385*6a54128fSAndroid Build Coastguard Worker            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
2386*6a54128fSAndroid Build Coastguard Worker          else
2387*6a54128fSAndroid Build Coastguard Worker            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
2388*6a54128fSAndroid Build Coastguard Worker            dnl that this library doesn't exist. So just drop it.
2389*6a54128fSAndroid Build Coastguard Worker            :
2390*6a54128fSAndroid Build Coastguard Worker          fi
2391*6a54128fSAndroid Build Coastguard Worker        else
2392*6a54128fSAndroid Build Coastguard Worker          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
2393*6a54128fSAndroid Build Coastguard Worker          dnl and the already constructed $LIBNAME/$LTLIBNAME.
2394*6a54128fSAndroid Build Coastguard Worker          found_dir=
2395*6a54128fSAndroid Build Coastguard Worker          found_la=
2396*6a54128fSAndroid Build Coastguard Worker          found_so=
2397*6a54128fSAndroid Build Coastguard Worker          found_a=
2398*6a54128fSAndroid Build Coastguard Worker          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
2399*6a54128fSAndroid Build Coastguard Worker          if test -n "$acl_shlibext"; then
2400*6a54128fSAndroid Build Coastguard Worker            shrext=".$acl_shlibext"             # typically: shrext=.so
2401*6a54128fSAndroid Build Coastguard Worker          else
2402*6a54128fSAndroid Build Coastguard Worker            shrext=
2403*6a54128fSAndroid Build Coastguard Worker          fi
2404*6a54128fSAndroid Build Coastguard Worker          if test $use_additional = yes; then
2405*6a54128fSAndroid Build Coastguard Worker            for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do
2406*6a54128fSAndroid Build Coastguard Worker              if test "X$found_dir" = "X"; then
2407*6a54128fSAndroid Build Coastguard Worker                eval dir=\$$additional_libdir_variable
2408*6a54128fSAndroid Build Coastguard Worker                if test -n "$dir"; then
2409*6a54128fSAndroid Build Coastguard Worker                  dnl The same code as in the loop below:
2410*6a54128fSAndroid Build Coastguard Worker                  dnl First look for a shared library.
2411*6a54128fSAndroid Build Coastguard Worker                  if test -n "$acl_shlibext"; then
2412*6a54128fSAndroid Build Coastguard Worker                    if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
2413*6a54128fSAndroid Build Coastguard Worker                      found_dir="$dir"
2414*6a54128fSAndroid Build Coastguard Worker                      found_so="$dir/$libname$shrext"
2415*6a54128fSAndroid Build Coastguard Worker                    else
2416*6a54128fSAndroid Build Coastguard Worker                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
2417*6a54128fSAndroid Build Coastguard Worker                        ver=`(cd "$dir" && \
2418*6a54128fSAndroid Build Coastguard Worker                              for f in "$libname$shrext".*; do echo "$f"; done \
2419*6a54128fSAndroid Build Coastguard Worker                              | sed -e "s,^$libname$shrext\\\\.,," \
2420*6a54128fSAndroid Build Coastguard Worker                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
2421*6a54128fSAndroid Build Coastguard Worker                              | sed 1q ) 2>/dev/null`
2422*6a54128fSAndroid Build Coastguard Worker                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
2423*6a54128fSAndroid Build Coastguard Worker                          found_dir="$dir"
2424*6a54128fSAndroid Build Coastguard Worker                          found_so="$dir/$libname$shrext.$ver"
2425*6a54128fSAndroid Build Coastguard Worker                        fi
2426*6a54128fSAndroid Build Coastguard Worker                      else
2427*6a54128fSAndroid Build Coastguard Worker                        eval library_names=\"$acl_library_names_spec\"
2428*6a54128fSAndroid Build Coastguard Worker                        for f in $library_names; do
2429*6a54128fSAndroid Build Coastguard Worker                          if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
2430*6a54128fSAndroid Build Coastguard Worker                            found_dir="$dir"
2431*6a54128fSAndroid Build Coastguard Worker                            found_so="$dir/$f"
2432*6a54128fSAndroid Build Coastguard Worker                            break
2433*6a54128fSAndroid Build Coastguard Worker                          fi
2434*6a54128fSAndroid Build Coastguard Worker                        done
2435*6a54128fSAndroid Build Coastguard Worker                      fi
2436*6a54128fSAndroid Build Coastguard Worker                    fi
2437*6a54128fSAndroid Build Coastguard Worker                  fi
2438*6a54128fSAndroid Build Coastguard Worker                  dnl Then look for a static library.
2439*6a54128fSAndroid Build Coastguard Worker                  if test "X$found_dir" = "X"; then
2440*6a54128fSAndroid Build Coastguard Worker                    if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
2441*6a54128fSAndroid Build Coastguard Worker                      found_dir="$dir"
2442*6a54128fSAndroid Build Coastguard Worker                      found_a="$dir/$libname.$acl_libext"
2443*6a54128fSAndroid Build Coastguard Worker                    fi
2444*6a54128fSAndroid Build Coastguard Worker                  fi
2445*6a54128fSAndroid Build Coastguard Worker                  if test "X$found_dir" != "X"; then
2446*6a54128fSAndroid Build Coastguard Worker                    if test -f "$dir/$libname.la"; then
2447*6a54128fSAndroid Build Coastguard Worker                      found_la="$dir/$libname.la"
2448*6a54128fSAndroid Build Coastguard Worker                    fi
2449*6a54128fSAndroid Build Coastguard Worker                  fi
2450*6a54128fSAndroid Build Coastguard Worker                fi
2451*6a54128fSAndroid Build Coastguard Worker              fi
2452*6a54128fSAndroid Build Coastguard Worker            done
2453*6a54128fSAndroid Build Coastguard Worker          fi
2454*6a54128fSAndroid Build Coastguard Worker          if test "X$found_dir" = "X"; then
2455*6a54128fSAndroid Build Coastguard Worker            for x in $LDFLAGS $LTLIB[]NAME; do
2456*6a54128fSAndroid Build Coastguard Worker              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2457*6a54128fSAndroid Build Coastguard Worker              case "$x" in
2458*6a54128fSAndroid Build Coastguard Worker                -L*)
2459*6a54128fSAndroid Build Coastguard Worker                  dir=`echo "X$x" | sed -e 's/^X-L//'`
2460*6a54128fSAndroid Build Coastguard Worker                  dnl First look for a shared library.
2461*6a54128fSAndroid Build Coastguard Worker                  if test -n "$acl_shlibext"; then
2462*6a54128fSAndroid Build Coastguard Worker                    if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
2463*6a54128fSAndroid Build Coastguard Worker                      found_dir="$dir"
2464*6a54128fSAndroid Build Coastguard Worker                      found_so="$dir/$libname$shrext"
2465*6a54128fSAndroid Build Coastguard Worker                    else
2466*6a54128fSAndroid Build Coastguard Worker                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
2467*6a54128fSAndroid Build Coastguard Worker                        ver=`(cd "$dir" && \
2468*6a54128fSAndroid Build Coastguard Worker                              for f in "$libname$shrext".*; do echo "$f"; done \
2469*6a54128fSAndroid Build Coastguard Worker                              | sed -e "s,^$libname$shrext\\\\.,," \
2470*6a54128fSAndroid Build Coastguard Worker                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
2471*6a54128fSAndroid Build Coastguard Worker                              | sed 1q ) 2>/dev/null`
2472*6a54128fSAndroid Build Coastguard Worker                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
2473*6a54128fSAndroid Build Coastguard Worker                          found_dir="$dir"
2474*6a54128fSAndroid Build Coastguard Worker                          found_so="$dir/$libname$shrext.$ver"
2475*6a54128fSAndroid Build Coastguard Worker                        fi
2476*6a54128fSAndroid Build Coastguard Worker                      else
2477*6a54128fSAndroid Build Coastguard Worker                        eval library_names=\"$acl_library_names_spec\"
2478*6a54128fSAndroid Build Coastguard Worker                        for f in $library_names; do
2479*6a54128fSAndroid Build Coastguard Worker                          if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
2480*6a54128fSAndroid Build Coastguard Worker                            found_dir="$dir"
2481*6a54128fSAndroid Build Coastguard Worker                            found_so="$dir/$f"
2482*6a54128fSAndroid Build Coastguard Worker                            break
2483*6a54128fSAndroid Build Coastguard Worker                          fi
2484*6a54128fSAndroid Build Coastguard Worker                        done
2485*6a54128fSAndroid Build Coastguard Worker                      fi
2486*6a54128fSAndroid Build Coastguard Worker                    fi
2487*6a54128fSAndroid Build Coastguard Worker                  fi
2488*6a54128fSAndroid Build Coastguard Worker                  dnl Then look for a static library.
2489*6a54128fSAndroid Build Coastguard Worker                  if test "X$found_dir" = "X"; then
2490*6a54128fSAndroid Build Coastguard Worker                    if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
2491*6a54128fSAndroid Build Coastguard Worker                      found_dir="$dir"
2492*6a54128fSAndroid Build Coastguard Worker                      found_a="$dir/$libname.$acl_libext"
2493*6a54128fSAndroid Build Coastguard Worker                    fi
2494*6a54128fSAndroid Build Coastguard Worker                  fi
2495*6a54128fSAndroid Build Coastguard Worker                  if test "X$found_dir" != "X"; then
2496*6a54128fSAndroid Build Coastguard Worker                    if test -f "$dir/$libname.la"; then
2497*6a54128fSAndroid Build Coastguard Worker                      found_la="$dir/$libname.la"
2498*6a54128fSAndroid Build Coastguard Worker                    fi
2499*6a54128fSAndroid Build Coastguard Worker                  fi
2500*6a54128fSAndroid Build Coastguard Worker                  ;;
2501*6a54128fSAndroid Build Coastguard Worker              esac
2502*6a54128fSAndroid Build Coastguard Worker              if test "X$found_dir" != "X"; then
2503*6a54128fSAndroid Build Coastguard Worker                break
2504*6a54128fSAndroid Build Coastguard Worker              fi
2505*6a54128fSAndroid Build Coastguard Worker            done
2506*6a54128fSAndroid Build Coastguard Worker          fi
2507*6a54128fSAndroid Build Coastguard Worker          if test "X$found_dir" != "X"; then
2508*6a54128fSAndroid Build Coastguard Worker            dnl Found the library.
2509*6a54128fSAndroid Build Coastguard Worker            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
2510*6a54128fSAndroid Build Coastguard Worker            if test "X$found_so" != "X"; then
2511*6a54128fSAndroid Build Coastguard Worker              dnl Linking with a shared library. We attempt to hardcode its
2512*6a54128fSAndroid Build Coastguard Worker              dnl directory into the executable's runpath, unless it's the
2513*6a54128fSAndroid Build Coastguard Worker              dnl standard /usr/lib.
2514*6a54128fSAndroid Build Coastguard Worker              if test "$enable_rpath" = no \
2515*6a54128fSAndroid Build Coastguard Worker                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
2516*6a54128fSAndroid Build Coastguard Worker                 || test "X$found_dir" = "X/usr/$acl_libdirstem2" \
2517*6a54128fSAndroid Build Coastguard Worker                 || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then
2518*6a54128fSAndroid Build Coastguard Worker                dnl No hardcoding is needed.
2519*6a54128fSAndroid Build Coastguard Worker                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2520*6a54128fSAndroid Build Coastguard Worker              else
2521*6a54128fSAndroid Build Coastguard Worker                dnl Use an explicit option to hardcode DIR into the resulting
2522*6a54128fSAndroid Build Coastguard Worker                dnl binary.
2523*6a54128fSAndroid Build Coastguard Worker                dnl Potentially add DIR to ltrpathdirs.
2524*6a54128fSAndroid Build Coastguard Worker                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
2525*6a54128fSAndroid Build Coastguard Worker                haveit=
2526*6a54128fSAndroid Build Coastguard Worker                for x in $ltrpathdirs; do
2527*6a54128fSAndroid Build Coastguard Worker                  if test "X$x" = "X$found_dir"; then
2528*6a54128fSAndroid Build Coastguard Worker                    haveit=yes
2529*6a54128fSAndroid Build Coastguard Worker                    break
2530*6a54128fSAndroid Build Coastguard Worker                  fi
2531*6a54128fSAndroid Build Coastguard Worker                done
2532*6a54128fSAndroid Build Coastguard Worker                if test -z "$haveit"; then
2533*6a54128fSAndroid Build Coastguard Worker                  ltrpathdirs="$ltrpathdirs $found_dir"
2534*6a54128fSAndroid Build Coastguard Worker                fi
2535*6a54128fSAndroid Build Coastguard Worker                dnl The hardcoding into $LIBNAME is system dependent.
2536*6a54128fSAndroid Build Coastguard Worker                if test "$acl_hardcode_direct" = yes; then
2537*6a54128fSAndroid Build Coastguard Worker                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
2538*6a54128fSAndroid Build Coastguard Worker                  dnl resulting binary.
2539*6a54128fSAndroid Build Coastguard Worker                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2540*6a54128fSAndroid Build Coastguard Worker                else
2541*6a54128fSAndroid Build Coastguard Worker                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
2542*6a54128fSAndroid Build Coastguard Worker                    dnl Use an explicit option to hardcode DIR into the resulting
2543*6a54128fSAndroid Build Coastguard Worker                    dnl binary.
2544*6a54128fSAndroid Build Coastguard Worker                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2545*6a54128fSAndroid Build Coastguard Worker                    dnl Potentially add DIR to rpathdirs.
2546*6a54128fSAndroid Build Coastguard Worker                    dnl The rpathdirs will be appended to $LIBNAME at the end.
2547*6a54128fSAndroid Build Coastguard Worker                    haveit=
2548*6a54128fSAndroid Build Coastguard Worker                    for x in $rpathdirs; do
2549*6a54128fSAndroid Build Coastguard Worker                      if test "X$x" = "X$found_dir"; then
2550*6a54128fSAndroid Build Coastguard Worker                        haveit=yes
2551*6a54128fSAndroid Build Coastguard Worker                        break
2552*6a54128fSAndroid Build Coastguard Worker                      fi
2553*6a54128fSAndroid Build Coastguard Worker                    done
2554*6a54128fSAndroid Build Coastguard Worker                    if test -z "$haveit"; then
2555*6a54128fSAndroid Build Coastguard Worker                      rpathdirs="$rpathdirs $found_dir"
2556*6a54128fSAndroid Build Coastguard Worker                    fi
2557*6a54128fSAndroid Build Coastguard Worker                  else
2558*6a54128fSAndroid Build Coastguard Worker                    dnl Rely on "-L$found_dir".
2559*6a54128fSAndroid Build Coastguard Worker                    dnl But don't add it if it's already contained in the LDFLAGS
2560*6a54128fSAndroid Build Coastguard Worker                    dnl or the already constructed $LIBNAME
2561*6a54128fSAndroid Build Coastguard Worker                    haveit=
2562*6a54128fSAndroid Build Coastguard Worker                    for x in $LDFLAGS $LIB[]NAME; do
2563*6a54128fSAndroid Build Coastguard Worker                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2564*6a54128fSAndroid Build Coastguard Worker                      if test "X$x" = "X-L$found_dir"; then
2565*6a54128fSAndroid Build Coastguard Worker                        haveit=yes
2566*6a54128fSAndroid Build Coastguard Worker                        break
2567*6a54128fSAndroid Build Coastguard Worker                      fi
2568*6a54128fSAndroid Build Coastguard Worker                    done
2569*6a54128fSAndroid Build Coastguard Worker                    if test -z "$haveit"; then
2570*6a54128fSAndroid Build Coastguard Worker                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
2571*6a54128fSAndroid Build Coastguard Worker                    fi
2572*6a54128fSAndroid Build Coastguard Worker                    if test "$acl_hardcode_minus_L" != no; then
2573*6a54128fSAndroid Build Coastguard Worker                      dnl FIXME: Not sure whether we should use
2574*6a54128fSAndroid Build Coastguard Worker                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
2575*6a54128fSAndroid Build Coastguard Worker                      dnl here.
2576*6a54128fSAndroid Build Coastguard Worker                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
2577*6a54128fSAndroid Build Coastguard Worker                    else
2578*6a54128fSAndroid Build Coastguard Worker                      dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
2579*6a54128fSAndroid Build Coastguard Worker                      dnl here, because this doesn't fit in flags passed to the
2580*6a54128fSAndroid Build Coastguard Worker                      dnl compiler. So give up. No hardcoding. This affects only
2581*6a54128fSAndroid Build Coastguard Worker                      dnl very old systems.
2582*6a54128fSAndroid Build Coastguard Worker                      dnl FIXME: Not sure whether we should use
2583*6a54128fSAndroid Build Coastguard Worker                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
2584*6a54128fSAndroid Build Coastguard Worker                      dnl here.
2585*6a54128fSAndroid Build Coastguard Worker                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
2586*6a54128fSAndroid Build Coastguard Worker                    fi
2587*6a54128fSAndroid Build Coastguard Worker                  fi
2588*6a54128fSAndroid Build Coastguard Worker                fi
2589*6a54128fSAndroid Build Coastguard Worker              fi
2590*6a54128fSAndroid Build Coastguard Worker            else
2591*6a54128fSAndroid Build Coastguard Worker              if test "X$found_a" != "X"; then
2592*6a54128fSAndroid Build Coastguard Worker                dnl Linking with a static library.
2593*6a54128fSAndroid Build Coastguard Worker                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
2594*6a54128fSAndroid Build Coastguard Worker              else
2595*6a54128fSAndroid Build Coastguard Worker                dnl We shouldn't come here, but anyway it's good to have a
2596*6a54128fSAndroid Build Coastguard Worker                dnl fallback.
2597*6a54128fSAndroid Build Coastguard Worker                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
2598*6a54128fSAndroid Build Coastguard Worker              fi
2599*6a54128fSAndroid Build Coastguard Worker            fi
2600*6a54128fSAndroid Build Coastguard Worker            dnl Assume the include files are nearby.
2601*6a54128fSAndroid Build Coastguard Worker            additional_includedir=
2602*6a54128fSAndroid Build Coastguard Worker            case "$found_dir" in
2603*6a54128fSAndroid Build Coastguard Worker              */$acl_libdirstem | */$acl_libdirstem/)
2604*6a54128fSAndroid Build Coastguard Worker                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
2605*6a54128fSAndroid Build Coastguard Worker                if test "$name" = '$1'; then
2606*6a54128fSAndroid Build Coastguard Worker                  LIB[]NAME[]_PREFIX="$basedir"
2607*6a54128fSAndroid Build Coastguard Worker                fi
2608*6a54128fSAndroid Build Coastguard Worker                additional_includedir="$basedir/include"
2609*6a54128fSAndroid Build Coastguard Worker                ;;
2610*6a54128fSAndroid Build Coastguard Worker              */$acl_libdirstem2 | */$acl_libdirstem2/)
2611*6a54128fSAndroid Build Coastguard Worker                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
2612*6a54128fSAndroid Build Coastguard Worker                if test "$name" = '$1'; then
2613*6a54128fSAndroid Build Coastguard Worker                  LIB[]NAME[]_PREFIX="$basedir"
2614*6a54128fSAndroid Build Coastguard Worker                fi
2615*6a54128fSAndroid Build Coastguard Worker                additional_includedir="$basedir/include"
2616*6a54128fSAndroid Build Coastguard Worker                ;;
2617*6a54128fSAndroid Build Coastguard Worker              */$acl_libdirstem3 | */$acl_libdirstem3/)
2618*6a54128fSAndroid Build Coastguard Worker                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'`
2619*6a54128fSAndroid Build Coastguard Worker                if test "$name" = '$1'; then
2620*6a54128fSAndroid Build Coastguard Worker                  LIB[]NAME[]_PREFIX="$basedir"
2621*6a54128fSAndroid Build Coastguard Worker                fi
2622*6a54128fSAndroid Build Coastguard Worker                additional_includedir="$basedir/include"
2623*6a54128fSAndroid Build Coastguard Worker                ;;
2624*6a54128fSAndroid Build Coastguard Worker            esac
2625*6a54128fSAndroid Build Coastguard Worker            if test "X$additional_includedir" != "X"; then
2626*6a54128fSAndroid Build Coastguard Worker              dnl Potentially add $additional_includedir to $INCNAME.
2627*6a54128fSAndroid Build Coastguard Worker              dnl But don't add it
2628*6a54128fSAndroid Build Coastguard Worker              dnl   1. if it's the standard /usr/include,
2629*6a54128fSAndroid Build Coastguard Worker              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
2630*6a54128fSAndroid Build Coastguard Worker              dnl   3. if it's already present in $CPPFLAGS or the already
2631*6a54128fSAndroid Build Coastguard Worker              dnl      constructed $INCNAME,
2632*6a54128fSAndroid Build Coastguard Worker              dnl   4. if it doesn't exist as a directory.
2633*6a54128fSAndroid Build Coastguard Worker              if test "X$additional_includedir" != "X/usr/include"; then
2634*6a54128fSAndroid Build Coastguard Worker                haveit=
2635*6a54128fSAndroid Build Coastguard Worker                if test "X$additional_includedir" = "X/usr/local/include"; then
2636*6a54128fSAndroid Build Coastguard Worker                  if test -n "$GCC"; then
2637*6a54128fSAndroid Build Coastguard Worker                    case $host_os in
2638*6a54128fSAndroid Build Coastguard Worker                      linux* | gnu* | k*bsd*-gnu) haveit=yes;;
2639*6a54128fSAndroid Build Coastguard Worker                    esac
2640*6a54128fSAndroid Build Coastguard Worker                  fi
2641*6a54128fSAndroid Build Coastguard Worker                fi
2642*6a54128fSAndroid Build Coastguard Worker                if test -z "$haveit"; then
2643*6a54128fSAndroid Build Coastguard Worker                  for x in $CPPFLAGS $INC[]NAME; do
2644*6a54128fSAndroid Build Coastguard Worker                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2645*6a54128fSAndroid Build Coastguard Worker                    if test "X$x" = "X-I$additional_includedir"; then
2646*6a54128fSAndroid Build Coastguard Worker                      haveit=yes
2647*6a54128fSAndroid Build Coastguard Worker                      break
2648*6a54128fSAndroid Build Coastguard Worker                    fi
2649*6a54128fSAndroid Build Coastguard Worker                  done
2650*6a54128fSAndroid Build Coastguard Worker                  if test -z "$haveit"; then
2651*6a54128fSAndroid Build Coastguard Worker                    if test -d "$additional_includedir"; then
2652*6a54128fSAndroid Build Coastguard Worker                      dnl Really add $additional_includedir to $INCNAME.
2653*6a54128fSAndroid Build Coastguard Worker                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
2654*6a54128fSAndroid Build Coastguard Worker                    fi
2655*6a54128fSAndroid Build Coastguard Worker                  fi
2656*6a54128fSAndroid Build Coastguard Worker                fi
2657*6a54128fSAndroid Build Coastguard Worker              fi
2658*6a54128fSAndroid Build Coastguard Worker            fi
2659*6a54128fSAndroid Build Coastguard Worker            dnl Look for dependencies.
2660*6a54128fSAndroid Build Coastguard Worker            if test -n "$found_la"; then
2661*6a54128fSAndroid Build Coastguard Worker              dnl Read the .la file. It defines the variables
2662*6a54128fSAndroid Build Coastguard Worker              dnl dlname, library_names, old_library, dependency_libs, current,
2663*6a54128fSAndroid Build Coastguard Worker              dnl age, revision, installed, dlopen, dlpreopen, libdir.
2664*6a54128fSAndroid Build Coastguard Worker              save_libdir="$libdir"
2665*6a54128fSAndroid Build Coastguard Worker              case "$found_la" in
2666*6a54128fSAndroid Build Coastguard Worker                */* | *\\*) . "$found_la" ;;
2667*6a54128fSAndroid Build Coastguard Worker                *) . "./$found_la" ;;
2668*6a54128fSAndroid Build Coastguard Worker              esac
2669*6a54128fSAndroid Build Coastguard Worker              libdir="$save_libdir"
2670*6a54128fSAndroid Build Coastguard Worker              dnl We use only dependency_libs.
2671*6a54128fSAndroid Build Coastguard Worker              for dep in $dependency_libs; do
2672*6a54128fSAndroid Build Coastguard Worker                case "$dep" in
2673*6a54128fSAndroid Build Coastguard Worker                  -L*)
2674*6a54128fSAndroid Build Coastguard Worker                    dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
2675*6a54128fSAndroid Build Coastguard Worker                    dnl Potentially add $dependency_libdir to $LIBNAME and $LTLIBNAME.
2676*6a54128fSAndroid Build Coastguard Worker                    dnl But don't add it
2677*6a54128fSAndroid Build Coastguard Worker                    dnl   1. if it's the standard /usr/lib,
2678*6a54128fSAndroid Build Coastguard Worker                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
2679*6a54128fSAndroid Build Coastguard Worker                    dnl   3. if it's already present in $LDFLAGS or the already
2680*6a54128fSAndroid Build Coastguard Worker                    dnl      constructed $LIBNAME,
2681*6a54128fSAndroid Build Coastguard Worker                    dnl   4. if it doesn't exist as a directory.
2682*6a54128fSAndroid Build Coastguard Worker                    if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \
2683*6a54128fSAndroid Build Coastguard Worker                       && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \
2684*6a54128fSAndroid Build Coastguard Worker                       && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then
2685*6a54128fSAndroid Build Coastguard Worker                      haveit=
2686*6a54128fSAndroid Build Coastguard Worker                      if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \
2687*6a54128fSAndroid Build Coastguard Worker                         || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \
2688*6a54128fSAndroid Build Coastguard Worker                         || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then
2689*6a54128fSAndroid Build Coastguard Worker                        if test -n "$GCC"; then
2690*6a54128fSAndroid Build Coastguard Worker                          case $host_os in
2691*6a54128fSAndroid Build Coastguard Worker                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
2692*6a54128fSAndroid Build Coastguard Worker                          esac
2693*6a54128fSAndroid Build Coastguard Worker                        fi
2694*6a54128fSAndroid Build Coastguard Worker                      fi
2695*6a54128fSAndroid Build Coastguard Worker                      if test -z "$haveit"; then
2696*6a54128fSAndroid Build Coastguard Worker                        haveit=
2697*6a54128fSAndroid Build Coastguard Worker                        for x in $LDFLAGS $LIB[]NAME; do
2698*6a54128fSAndroid Build Coastguard Worker                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2699*6a54128fSAndroid Build Coastguard Worker                          if test "X$x" = "X-L$dependency_libdir"; then
2700*6a54128fSAndroid Build Coastguard Worker                            haveit=yes
2701*6a54128fSAndroid Build Coastguard Worker                            break
2702*6a54128fSAndroid Build Coastguard Worker                          fi
2703*6a54128fSAndroid Build Coastguard Worker                        done
2704*6a54128fSAndroid Build Coastguard Worker                        if test -z "$haveit"; then
2705*6a54128fSAndroid Build Coastguard Worker                          if test -d "$dependency_libdir"; then
2706*6a54128fSAndroid Build Coastguard Worker                            dnl Really add $dependency_libdir to $LIBNAME.
2707*6a54128fSAndroid Build Coastguard Worker                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$dependency_libdir"
2708*6a54128fSAndroid Build Coastguard Worker                          fi
2709*6a54128fSAndroid Build Coastguard Worker                        fi
2710*6a54128fSAndroid Build Coastguard Worker                        haveit=
2711*6a54128fSAndroid Build Coastguard Worker                        for x in $LDFLAGS $LTLIB[]NAME; do
2712*6a54128fSAndroid Build Coastguard Worker                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2713*6a54128fSAndroid Build Coastguard Worker                          if test "X$x" = "X-L$dependency_libdir"; then
2714*6a54128fSAndroid Build Coastguard Worker                            haveit=yes
2715*6a54128fSAndroid Build Coastguard Worker                            break
2716*6a54128fSAndroid Build Coastguard Worker                          fi
2717*6a54128fSAndroid Build Coastguard Worker                        done
2718*6a54128fSAndroid Build Coastguard Worker                        if test -z "$haveit"; then
2719*6a54128fSAndroid Build Coastguard Worker                          if test -d "$dependency_libdir"; then
2720*6a54128fSAndroid Build Coastguard Worker                            dnl Really add $dependency_libdir to $LTLIBNAME.
2721*6a54128fSAndroid Build Coastguard Worker                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$dependency_libdir"
2722*6a54128fSAndroid Build Coastguard Worker                          fi
2723*6a54128fSAndroid Build Coastguard Worker                        fi
2724*6a54128fSAndroid Build Coastguard Worker                      fi
2725*6a54128fSAndroid Build Coastguard Worker                    fi
2726*6a54128fSAndroid Build Coastguard Worker                    ;;
2727*6a54128fSAndroid Build Coastguard Worker                  -R*)
2728*6a54128fSAndroid Build Coastguard Worker                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
2729*6a54128fSAndroid Build Coastguard Worker                    if test "$enable_rpath" != no; then
2730*6a54128fSAndroid Build Coastguard Worker                      dnl Potentially add DIR to rpathdirs.
2731*6a54128fSAndroid Build Coastguard Worker                      dnl The rpathdirs will be appended to $LIBNAME at the end.
2732*6a54128fSAndroid Build Coastguard Worker                      haveit=
2733*6a54128fSAndroid Build Coastguard Worker                      for x in $rpathdirs; do
2734*6a54128fSAndroid Build Coastguard Worker                        if test "X$x" = "X$dir"; then
2735*6a54128fSAndroid Build Coastguard Worker                          haveit=yes
2736*6a54128fSAndroid Build Coastguard Worker                          break
2737*6a54128fSAndroid Build Coastguard Worker                        fi
2738*6a54128fSAndroid Build Coastguard Worker                      done
2739*6a54128fSAndroid Build Coastguard Worker                      if test -z "$haveit"; then
2740*6a54128fSAndroid Build Coastguard Worker                        rpathdirs="$rpathdirs $dir"
2741*6a54128fSAndroid Build Coastguard Worker                      fi
2742*6a54128fSAndroid Build Coastguard Worker                      dnl Potentially add DIR to ltrpathdirs.
2743*6a54128fSAndroid Build Coastguard Worker                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
2744*6a54128fSAndroid Build Coastguard Worker                      haveit=
2745*6a54128fSAndroid Build Coastguard Worker                      for x in $ltrpathdirs; do
2746*6a54128fSAndroid Build Coastguard Worker                        if test "X$x" = "X$dir"; then
2747*6a54128fSAndroid Build Coastguard Worker                          haveit=yes
2748*6a54128fSAndroid Build Coastguard Worker                          break
2749*6a54128fSAndroid Build Coastguard Worker                        fi
2750*6a54128fSAndroid Build Coastguard Worker                      done
2751*6a54128fSAndroid Build Coastguard Worker                      if test -z "$haveit"; then
2752*6a54128fSAndroid Build Coastguard Worker                        ltrpathdirs="$ltrpathdirs $dir"
2753*6a54128fSAndroid Build Coastguard Worker                      fi
2754*6a54128fSAndroid Build Coastguard Worker                    fi
2755*6a54128fSAndroid Build Coastguard Worker                    ;;
2756*6a54128fSAndroid Build Coastguard Worker                  -l*)
2757*6a54128fSAndroid Build Coastguard Worker                    dnl Handle this in the next round.
2758*6a54128fSAndroid Build Coastguard Worker                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
2759*6a54128fSAndroid Build Coastguard Worker                    ;;
2760*6a54128fSAndroid Build Coastguard Worker                  *.la)
2761*6a54128fSAndroid Build Coastguard Worker                    dnl Handle this in the next round. Throw away the .la's
2762*6a54128fSAndroid Build Coastguard Worker                    dnl directory; it is already contained in a preceding -L
2763*6a54128fSAndroid Build Coastguard Worker                    dnl option.
2764*6a54128fSAndroid Build Coastguard Worker                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
2765*6a54128fSAndroid Build Coastguard Worker                    ;;
2766*6a54128fSAndroid Build Coastguard Worker                  *)
2767*6a54128fSAndroid Build Coastguard Worker                    dnl Most likely an immediate library name.
2768*6a54128fSAndroid Build Coastguard Worker                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
2769*6a54128fSAndroid Build Coastguard Worker                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
2770*6a54128fSAndroid Build Coastguard Worker                    ;;
2771*6a54128fSAndroid Build Coastguard Worker                esac
2772*6a54128fSAndroid Build Coastguard Worker              done
2773*6a54128fSAndroid Build Coastguard Worker            fi
2774*6a54128fSAndroid Build Coastguard Worker          else
2775*6a54128fSAndroid Build Coastguard Worker            dnl Didn't find the library; assume it is in the system directories
2776*6a54128fSAndroid Build Coastguard Worker            dnl known to the linker and runtime loader. (All the system
2777*6a54128fSAndroid Build Coastguard Worker            dnl directories known to the linker should also be known to the
2778*6a54128fSAndroid Build Coastguard Worker            dnl runtime loader, otherwise the system is severely misconfigured.)
2779*6a54128fSAndroid Build Coastguard Worker            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
2780*6a54128fSAndroid Build Coastguard Worker            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
2781*6a54128fSAndroid Build Coastguard Worker          fi
2782*6a54128fSAndroid Build Coastguard Worker        fi
2783*6a54128fSAndroid Build Coastguard Worker      fi
2784*6a54128fSAndroid Build Coastguard Worker    done
2785*6a54128fSAndroid Build Coastguard Worker  done
2786*6a54128fSAndroid Build Coastguard Worker  if test "X$rpathdirs" != "X"; then
2787*6a54128fSAndroid Build Coastguard Worker    if test -n "$acl_hardcode_libdir_separator"; then
2788*6a54128fSAndroid Build Coastguard Worker      dnl Weird platform: only the last -rpath option counts, the user must
2789*6a54128fSAndroid Build Coastguard Worker      dnl pass all path elements in one option. We can arrange that for a
2790*6a54128fSAndroid Build Coastguard Worker      dnl single library, but not when more than one $LIBNAMEs are used.
2791*6a54128fSAndroid Build Coastguard Worker      alldirs=
2792*6a54128fSAndroid Build Coastguard Worker      for found_dir in $rpathdirs; do
2793*6a54128fSAndroid Build Coastguard Worker        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
2794*6a54128fSAndroid Build Coastguard Worker      done
2795*6a54128fSAndroid Build Coastguard Worker      dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
2796*6a54128fSAndroid Build Coastguard Worker      acl_save_libdir="$libdir"
2797*6a54128fSAndroid Build Coastguard Worker      libdir="$alldirs"
2798*6a54128fSAndroid Build Coastguard Worker      eval flag=\"$acl_hardcode_libdir_flag_spec\"
2799*6a54128fSAndroid Build Coastguard Worker      libdir="$acl_save_libdir"
2800*6a54128fSAndroid Build Coastguard Worker      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
2801*6a54128fSAndroid Build Coastguard Worker    else
2802*6a54128fSAndroid Build Coastguard Worker      dnl The -rpath options are cumulative.
2803*6a54128fSAndroid Build Coastguard Worker      for found_dir in $rpathdirs; do
2804*6a54128fSAndroid Build Coastguard Worker        acl_save_libdir="$libdir"
2805*6a54128fSAndroid Build Coastguard Worker        libdir="$found_dir"
2806*6a54128fSAndroid Build Coastguard Worker        eval flag=\"$acl_hardcode_libdir_flag_spec\"
2807*6a54128fSAndroid Build Coastguard Worker        libdir="$acl_save_libdir"
2808*6a54128fSAndroid Build Coastguard Worker        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
2809*6a54128fSAndroid Build Coastguard Worker      done
2810*6a54128fSAndroid Build Coastguard Worker    fi
2811*6a54128fSAndroid Build Coastguard Worker  fi
2812*6a54128fSAndroid Build Coastguard Worker  if test "X$ltrpathdirs" != "X"; then
2813*6a54128fSAndroid Build Coastguard Worker    dnl When using libtool, the option that works for both libraries and
2814*6a54128fSAndroid Build Coastguard Worker    dnl executables is -R. The -R options are cumulative.
2815*6a54128fSAndroid Build Coastguard Worker    for found_dir in $ltrpathdirs; do
2816*6a54128fSAndroid Build Coastguard Worker      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
2817*6a54128fSAndroid Build Coastguard Worker    done
2818*6a54128fSAndroid Build Coastguard Worker  fi
2819*6a54128fSAndroid Build Coastguard Worker  popdef([PACKLIBS])
2820*6a54128fSAndroid Build Coastguard Worker  popdef([PACKUP])
2821*6a54128fSAndroid Build Coastguard Worker  popdef([PACK])
2822*6a54128fSAndroid Build Coastguard Worker  popdef([NAME])
2823*6a54128fSAndroid Build Coastguard Worker])
2824*6a54128fSAndroid Build Coastguard Worker
2825*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
2826*6a54128fSAndroid Build Coastguard Workerdnl unless already present in VAR.
2827*6a54128fSAndroid Build Coastguard Workerdnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
2828*6a54128fSAndroid Build Coastguard Workerdnl contains two or three consecutive elements that belong together.
2829*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_APPENDTOVAR],
2830*6a54128fSAndroid Build Coastguard Worker[
2831*6a54128fSAndroid Build Coastguard Worker  for element in [$2]; do
2832*6a54128fSAndroid Build Coastguard Worker    haveit=
2833*6a54128fSAndroid Build Coastguard Worker    for x in $[$1]; do
2834*6a54128fSAndroid Build Coastguard Worker      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2835*6a54128fSAndroid Build Coastguard Worker      if test "X$x" = "X$element"; then
2836*6a54128fSAndroid Build Coastguard Worker        haveit=yes
2837*6a54128fSAndroid Build Coastguard Worker        break
2838*6a54128fSAndroid Build Coastguard Worker      fi
2839*6a54128fSAndroid Build Coastguard Worker    done
2840*6a54128fSAndroid Build Coastguard Worker    if test -z "$haveit"; then
2841*6a54128fSAndroid Build Coastguard Worker      [$1]="${[$1]}${[$1]:+ }$element"
2842*6a54128fSAndroid Build Coastguard Worker    fi
2843*6a54128fSAndroid Build Coastguard Worker  done
2844*6a54128fSAndroid Build Coastguard Worker])
2845*6a54128fSAndroid Build Coastguard Worker
2846*6a54128fSAndroid Build Coastguard Workerdnl For those cases where a variable contains several -L and -l options
2847*6a54128fSAndroid Build Coastguard Workerdnl referring to unknown libraries and directories, this macro determines the
2848*6a54128fSAndroid Build Coastguard Workerdnl necessary additional linker options for the runtime path.
2849*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
2850*6a54128fSAndroid Build Coastguard Workerdnl sets LDADDVAR to linker options needed together with LIBSVALUE.
2851*6a54128fSAndroid Build Coastguard Workerdnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
2852*6a54128fSAndroid Build Coastguard Workerdnl otherwise linking without libtool is assumed.
2853*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
2854*6a54128fSAndroid Build Coastguard Worker[
2855*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_RPATH])
2856*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
2857*6a54128fSAndroid Build Coastguard Worker  $1=
2858*6a54128fSAndroid Build Coastguard Worker  if test "$enable_rpath" != no; then
2859*6a54128fSAndroid Build Coastguard Worker    if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
2860*6a54128fSAndroid Build Coastguard Worker      dnl Use an explicit option to hardcode directories into the resulting
2861*6a54128fSAndroid Build Coastguard Worker      dnl binary.
2862*6a54128fSAndroid Build Coastguard Worker      rpathdirs=
2863*6a54128fSAndroid Build Coastguard Worker      next=
2864*6a54128fSAndroid Build Coastguard Worker      for opt in $2; do
2865*6a54128fSAndroid Build Coastguard Worker        if test -n "$next"; then
2866*6a54128fSAndroid Build Coastguard Worker          dir="$next"
2867*6a54128fSAndroid Build Coastguard Worker          dnl No need to hardcode the standard /usr/lib.
2868*6a54128fSAndroid Build Coastguard Worker          if test "X$dir" != "X/usr/$acl_libdirstem" \
2869*6a54128fSAndroid Build Coastguard Worker             && test "X$dir" != "X/usr/$acl_libdirstem2" \
2870*6a54128fSAndroid Build Coastguard Worker             && test "X$dir" != "X/usr/$acl_libdirstem3"; then
2871*6a54128fSAndroid Build Coastguard Worker            rpathdirs="$rpathdirs $dir"
2872*6a54128fSAndroid Build Coastguard Worker          fi
2873*6a54128fSAndroid Build Coastguard Worker          next=
2874*6a54128fSAndroid Build Coastguard Worker        else
2875*6a54128fSAndroid Build Coastguard Worker          case $opt in
2876*6a54128fSAndroid Build Coastguard Worker            -L) next=yes ;;
2877*6a54128fSAndroid Build Coastguard Worker            -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
2878*6a54128fSAndroid Build Coastguard Worker                 dnl No need to hardcode the standard /usr/lib.
2879*6a54128fSAndroid Build Coastguard Worker                 if test "X$dir" != "X/usr/$acl_libdirstem" \
2880*6a54128fSAndroid Build Coastguard Worker                    && test "X$dir" != "X/usr/$acl_libdirstem2" \
2881*6a54128fSAndroid Build Coastguard Worker                    && test "X$dir" != "X/usr/$acl_libdirstem3"; then
2882*6a54128fSAndroid Build Coastguard Worker                   rpathdirs="$rpathdirs $dir"
2883*6a54128fSAndroid Build Coastguard Worker                 fi
2884*6a54128fSAndroid Build Coastguard Worker                 next= ;;
2885*6a54128fSAndroid Build Coastguard Worker            *) next= ;;
2886*6a54128fSAndroid Build Coastguard Worker          esac
2887*6a54128fSAndroid Build Coastguard Worker        fi
2888*6a54128fSAndroid Build Coastguard Worker      done
2889*6a54128fSAndroid Build Coastguard Worker      if test "X$rpathdirs" != "X"; then
2890*6a54128fSAndroid Build Coastguard Worker        if test -n ""$3""; then
2891*6a54128fSAndroid Build Coastguard Worker          dnl libtool is used for linking. Use -R options.
2892*6a54128fSAndroid Build Coastguard Worker          for dir in $rpathdirs; do
2893*6a54128fSAndroid Build Coastguard Worker            $1="${$1}${$1:+ }-R$dir"
2894*6a54128fSAndroid Build Coastguard Worker          done
2895*6a54128fSAndroid Build Coastguard Worker        else
2896*6a54128fSAndroid Build Coastguard Worker          dnl The linker is used for linking directly.
2897*6a54128fSAndroid Build Coastguard Worker          if test -n "$acl_hardcode_libdir_separator"; then
2898*6a54128fSAndroid Build Coastguard Worker            dnl Weird platform: only the last -rpath option counts, the user
2899*6a54128fSAndroid Build Coastguard Worker            dnl must pass all path elements in one option.
2900*6a54128fSAndroid Build Coastguard Worker            alldirs=
2901*6a54128fSAndroid Build Coastguard Worker            for dir in $rpathdirs; do
2902*6a54128fSAndroid Build Coastguard Worker              alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
2903*6a54128fSAndroid Build Coastguard Worker            done
2904*6a54128fSAndroid Build Coastguard Worker            acl_save_libdir="$libdir"
2905*6a54128fSAndroid Build Coastguard Worker            libdir="$alldirs"
2906*6a54128fSAndroid Build Coastguard Worker            eval flag=\"$acl_hardcode_libdir_flag_spec\"
2907*6a54128fSAndroid Build Coastguard Worker            libdir="$acl_save_libdir"
2908*6a54128fSAndroid Build Coastguard Worker            $1="$flag"
2909*6a54128fSAndroid Build Coastguard Worker          else
2910*6a54128fSAndroid Build Coastguard Worker            dnl The -rpath options are cumulative.
2911*6a54128fSAndroid Build Coastguard Worker            for dir in $rpathdirs; do
2912*6a54128fSAndroid Build Coastguard Worker              acl_save_libdir="$libdir"
2913*6a54128fSAndroid Build Coastguard Worker              libdir="$dir"
2914*6a54128fSAndroid Build Coastguard Worker              eval flag=\"$acl_hardcode_libdir_flag_spec\"
2915*6a54128fSAndroid Build Coastguard Worker              libdir="$acl_save_libdir"
2916*6a54128fSAndroid Build Coastguard Worker              $1="${$1}${$1:+ }$flag"
2917*6a54128fSAndroid Build Coastguard Worker            done
2918*6a54128fSAndroid Build Coastguard Worker          fi
2919*6a54128fSAndroid Build Coastguard Worker        fi
2920*6a54128fSAndroid Build Coastguard Worker      fi
2921*6a54128fSAndroid Build Coastguard Worker    fi
2922*6a54128fSAndroid Build Coastguard Worker  fi
2923*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([$1])
2924*6a54128fSAndroid Build Coastguard Worker])
2925*6a54128fSAndroid Build Coastguard Worker
2926*6a54128fSAndroid Build Coastguard Worker# lib-prefix.m4 serial 17
2927*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc.
2928*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
2929*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
2930*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
2931*6a54128fSAndroid Build Coastguard Worker
2932*6a54128fSAndroid Build Coastguard Workerdnl From Bruno Haible.
2933*6a54128fSAndroid Build Coastguard Worker
2934*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
2935*6a54128fSAndroid Build Coastguard Workerdnl to access previously installed libraries. The basic assumption is that
2936*6a54128fSAndroid Build Coastguard Workerdnl a user will want packages to use other packages he previously installed
2937*6a54128fSAndroid Build Coastguard Workerdnl with the same --prefix option.
2938*6a54128fSAndroid Build Coastguard Workerdnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
2939*6a54128fSAndroid Build Coastguard Workerdnl libraries, but is otherwise very convenient.
2940*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_PREFIX],
2941*6a54128fSAndroid Build Coastguard Worker[
2942*6a54128fSAndroid Build Coastguard Worker  AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
2943*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_PROG_CC])
2944*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_CANONICAL_HOST])
2945*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
2946*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
2947*6a54128fSAndroid Build Coastguard Worker  dnl By default, look in $includedir and $libdir.
2948*6a54128fSAndroid Build Coastguard Worker  use_additional=yes
2949*6a54128fSAndroid Build Coastguard Worker  AC_LIB_WITH_FINAL_PREFIX([
2950*6a54128fSAndroid Build Coastguard Worker    eval additional_includedir=\"$includedir\"
2951*6a54128fSAndroid Build Coastguard Worker    eval additional_libdir=\"$libdir\"
2952*6a54128fSAndroid Build Coastguard Worker  ])
2953*6a54128fSAndroid Build Coastguard Worker  AC_ARG_WITH([lib-prefix],
2954*6a54128fSAndroid Build Coastguard Worker[[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
2955*6a54128fSAndroid Build Coastguard Worker  --without-lib-prefix    don't search for libraries in includedir and libdir]],
2956*6a54128fSAndroid Build Coastguard Worker[
2957*6a54128fSAndroid Build Coastguard Worker    if test "X$withval" = "Xno"; then
2958*6a54128fSAndroid Build Coastguard Worker      use_additional=no
2959*6a54128fSAndroid Build Coastguard Worker    else
2960*6a54128fSAndroid Build Coastguard Worker      if test "X$withval" = "X"; then
2961*6a54128fSAndroid Build Coastguard Worker        AC_LIB_WITH_FINAL_PREFIX([
2962*6a54128fSAndroid Build Coastguard Worker          eval additional_includedir=\"$includedir\"
2963*6a54128fSAndroid Build Coastguard Worker          eval additional_libdir=\"$libdir\"
2964*6a54128fSAndroid Build Coastguard Worker        ])
2965*6a54128fSAndroid Build Coastguard Worker      else
2966*6a54128fSAndroid Build Coastguard Worker        additional_includedir="$withval/include"
2967*6a54128fSAndroid Build Coastguard Worker        additional_libdir="$withval/$acl_libdirstem"
2968*6a54128fSAndroid Build Coastguard Worker      fi
2969*6a54128fSAndroid Build Coastguard Worker    fi
2970*6a54128fSAndroid Build Coastguard Worker])
2971*6a54128fSAndroid Build Coastguard Worker  if test $use_additional = yes; then
2972*6a54128fSAndroid Build Coastguard Worker    dnl Potentially add $additional_includedir to $CPPFLAGS.
2973*6a54128fSAndroid Build Coastguard Worker    dnl But don't add it
2974*6a54128fSAndroid Build Coastguard Worker    dnl   1. if it's the standard /usr/include,
2975*6a54128fSAndroid Build Coastguard Worker    dnl   2. if it's already present in $CPPFLAGS,
2976*6a54128fSAndroid Build Coastguard Worker    dnl   3. if it's /usr/local/include and we are using GCC on Linux,
2977*6a54128fSAndroid Build Coastguard Worker    dnl   4. if it doesn't exist as a directory.
2978*6a54128fSAndroid Build Coastguard Worker    if test "X$additional_includedir" != "X/usr/include"; then
2979*6a54128fSAndroid Build Coastguard Worker      haveit=
2980*6a54128fSAndroid Build Coastguard Worker      for x in $CPPFLAGS; do
2981*6a54128fSAndroid Build Coastguard Worker        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
2982*6a54128fSAndroid Build Coastguard Worker        if test "X$x" = "X-I$additional_includedir"; then
2983*6a54128fSAndroid Build Coastguard Worker          haveit=yes
2984*6a54128fSAndroid Build Coastguard Worker          break
2985*6a54128fSAndroid Build Coastguard Worker        fi
2986*6a54128fSAndroid Build Coastguard Worker      done
2987*6a54128fSAndroid Build Coastguard Worker      if test -z "$haveit"; then
2988*6a54128fSAndroid Build Coastguard Worker        if test "X$additional_includedir" = "X/usr/local/include"; then
2989*6a54128fSAndroid Build Coastguard Worker          if test -n "$GCC"; then
2990*6a54128fSAndroid Build Coastguard Worker            case $host_os in
2991*6a54128fSAndroid Build Coastguard Worker              linux* | gnu* | k*bsd*-gnu) haveit=yes;;
2992*6a54128fSAndroid Build Coastguard Worker            esac
2993*6a54128fSAndroid Build Coastguard Worker          fi
2994*6a54128fSAndroid Build Coastguard Worker        fi
2995*6a54128fSAndroid Build Coastguard Worker        if test -z "$haveit"; then
2996*6a54128fSAndroid Build Coastguard Worker          if test -d "$additional_includedir"; then
2997*6a54128fSAndroid Build Coastguard Worker            dnl Really add $additional_includedir to $CPPFLAGS.
2998*6a54128fSAndroid Build Coastguard Worker            CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
2999*6a54128fSAndroid Build Coastguard Worker          fi
3000*6a54128fSAndroid Build Coastguard Worker        fi
3001*6a54128fSAndroid Build Coastguard Worker      fi
3002*6a54128fSAndroid Build Coastguard Worker    fi
3003*6a54128fSAndroid Build Coastguard Worker    dnl Potentially add $additional_libdir to $LDFLAGS.
3004*6a54128fSAndroid Build Coastguard Worker    dnl But don't add it
3005*6a54128fSAndroid Build Coastguard Worker    dnl   1. if it's the standard /usr/lib,
3006*6a54128fSAndroid Build Coastguard Worker    dnl   2. if it's already present in $LDFLAGS,
3007*6a54128fSAndroid Build Coastguard Worker    dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
3008*6a54128fSAndroid Build Coastguard Worker    dnl   4. if it doesn't exist as a directory.
3009*6a54128fSAndroid Build Coastguard Worker    if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
3010*6a54128fSAndroid Build Coastguard Worker      haveit=
3011*6a54128fSAndroid Build Coastguard Worker      for x in $LDFLAGS; do
3012*6a54128fSAndroid Build Coastguard Worker        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
3013*6a54128fSAndroid Build Coastguard Worker        if test "X$x" = "X-L$additional_libdir"; then
3014*6a54128fSAndroid Build Coastguard Worker          haveit=yes
3015*6a54128fSAndroid Build Coastguard Worker          break
3016*6a54128fSAndroid Build Coastguard Worker        fi
3017*6a54128fSAndroid Build Coastguard Worker      done
3018*6a54128fSAndroid Build Coastguard Worker      if test -z "$haveit"; then
3019*6a54128fSAndroid Build Coastguard Worker        if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
3020*6a54128fSAndroid Build Coastguard Worker          if test -n "$GCC"; then
3021*6a54128fSAndroid Build Coastguard Worker            case $host_os in
3022*6a54128fSAndroid Build Coastguard Worker              linux*) haveit=yes;;
3023*6a54128fSAndroid Build Coastguard Worker            esac
3024*6a54128fSAndroid Build Coastguard Worker          fi
3025*6a54128fSAndroid Build Coastguard Worker        fi
3026*6a54128fSAndroid Build Coastguard Worker        if test -z "$haveit"; then
3027*6a54128fSAndroid Build Coastguard Worker          if test -d "$additional_libdir"; then
3028*6a54128fSAndroid Build Coastguard Worker            dnl Really add $additional_libdir to $LDFLAGS.
3029*6a54128fSAndroid Build Coastguard Worker            LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
3030*6a54128fSAndroid Build Coastguard Worker          fi
3031*6a54128fSAndroid Build Coastguard Worker        fi
3032*6a54128fSAndroid Build Coastguard Worker      fi
3033*6a54128fSAndroid Build Coastguard Worker    fi
3034*6a54128fSAndroid Build Coastguard Worker  fi
3035*6a54128fSAndroid Build Coastguard Worker])
3036*6a54128fSAndroid Build Coastguard Worker
3037*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
3038*6a54128fSAndroid Build Coastguard Workerdnl acl_final_exec_prefix, containing the values to which $prefix and
3039*6a54128fSAndroid Build Coastguard Workerdnl $exec_prefix will expand at the end of the configure script.
3040*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_PREPARE_PREFIX],
3041*6a54128fSAndroid Build Coastguard Worker[
3042*6a54128fSAndroid Build Coastguard Worker  dnl Unfortunately, prefix and exec_prefix get only finally determined
3043*6a54128fSAndroid Build Coastguard Worker  dnl at the end of configure.
3044*6a54128fSAndroid Build Coastguard Worker  if test "X$prefix" = "XNONE"; then
3045*6a54128fSAndroid Build Coastguard Worker    acl_final_prefix="$ac_default_prefix"
3046*6a54128fSAndroid Build Coastguard Worker  else
3047*6a54128fSAndroid Build Coastguard Worker    acl_final_prefix="$prefix"
3048*6a54128fSAndroid Build Coastguard Worker  fi
3049*6a54128fSAndroid Build Coastguard Worker  if test "X$exec_prefix" = "XNONE"; then
3050*6a54128fSAndroid Build Coastguard Worker    acl_final_exec_prefix='${prefix}'
3051*6a54128fSAndroid Build Coastguard Worker  else
3052*6a54128fSAndroid Build Coastguard Worker    acl_final_exec_prefix="$exec_prefix"
3053*6a54128fSAndroid Build Coastguard Worker  fi
3054*6a54128fSAndroid Build Coastguard Worker  acl_save_prefix="$prefix"
3055*6a54128fSAndroid Build Coastguard Worker  prefix="$acl_final_prefix"
3056*6a54128fSAndroid Build Coastguard Worker  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
3057*6a54128fSAndroid Build Coastguard Worker  prefix="$acl_save_prefix"
3058*6a54128fSAndroid Build Coastguard Worker])
3059*6a54128fSAndroid Build Coastguard Worker
3060*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
3061*6a54128fSAndroid Build Coastguard Workerdnl variables prefix and exec_prefix bound to the values they will have
3062*6a54128fSAndroid Build Coastguard Workerdnl at the end of the configure script.
3063*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
3064*6a54128fSAndroid Build Coastguard Worker[
3065*6a54128fSAndroid Build Coastguard Worker  acl_save_prefix="$prefix"
3066*6a54128fSAndroid Build Coastguard Worker  prefix="$acl_final_prefix"
3067*6a54128fSAndroid Build Coastguard Worker  acl_save_exec_prefix="$exec_prefix"
3068*6a54128fSAndroid Build Coastguard Worker  exec_prefix="$acl_final_exec_prefix"
3069*6a54128fSAndroid Build Coastguard Worker  $1
3070*6a54128fSAndroid Build Coastguard Worker  exec_prefix="$acl_save_exec_prefix"
3071*6a54128fSAndroid Build Coastguard Worker  prefix="$acl_save_prefix"
3072*6a54128fSAndroid Build Coastguard Worker])
3073*6a54128fSAndroid Build Coastguard Worker
3074*6a54128fSAndroid Build Coastguard Workerdnl AC_LIB_PREPARE_MULTILIB creates
3075*6a54128fSAndroid Build Coastguard Workerdnl - a function acl_is_expected_elfclass, that tests whether standard input
3076*6a54128fSAndroid Build Coastguard Workerdn;   has a 32-bit or 64-bit ELF header, depending on the host CPU ABI,
3077*6a54128fSAndroid Build Coastguard Workerdnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing
3078*6a54128fSAndroid Build Coastguard Workerdnl   the basename of the libdir to try in turn, either "lib" or "lib64" or
3079*6a54128fSAndroid Build Coastguard Workerdnl   "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar.
3080*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AC_LIB_PREPARE_MULTILIB],
3081*6a54128fSAndroid Build Coastguard Worker[
3082*6a54128fSAndroid Build Coastguard Worker  dnl There is no formal standard regarding lib, lib32, and lib64.
3083*6a54128fSAndroid Build Coastguard Worker  dnl On most glibc systems, the current practice is that on a system supporting
3084*6a54128fSAndroid Build Coastguard Worker  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
3085*6a54128fSAndroid Build Coastguard Worker  dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on
3086*6a54128fSAndroid Build Coastguard Worker  dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go
3087*6a54128fSAndroid Build Coastguard Worker  dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib.
3088*6a54128fSAndroid Build Coastguard Worker  dnl We determine the compiler's default mode by looking at the compiler's
3089*6a54128fSAndroid Build Coastguard Worker  dnl library search path. If at least one of its elements ends in /lib64 or
3090*6a54128fSAndroid Build Coastguard Worker  dnl points to a directory whose absolute pathname ends in /lib64, we use that
3091*6a54128fSAndroid Build Coastguard Worker  dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default,
3092*6a54128fSAndroid Build Coastguard Worker  dnl namely "lib".
3093*6a54128fSAndroid Build Coastguard Worker  dnl On Solaris systems, the current practice is that on a system supporting
3094*6a54128fSAndroid Build Coastguard Worker  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
3095*6a54128fSAndroid Build Coastguard Worker  dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
3096*6a54128fSAndroid Build Coastguard Worker  dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
3097*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_CANONICAL_HOST])
3098*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT])
3099*6a54128fSAndroid Build Coastguard Worker
3100*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
3101*6a54128fSAndroid Build Coastguard Worker    [AC_EGREP_CPP([Extensible Linking Format],
3102*6a54128fSAndroid Build Coastguard Worker       [#ifdef __ELF__
3103*6a54128fSAndroid Build Coastguard Worker        Extensible Linking Format
3104*6a54128fSAndroid Build Coastguard Worker        #endif
3105*6a54128fSAndroid Build Coastguard Worker       ],
3106*6a54128fSAndroid Build Coastguard Worker       [gl_cv_elf=yes],
3107*6a54128fSAndroid Build Coastguard Worker       [gl_cv_elf=no])
3108*6a54128fSAndroid Build Coastguard Worker     ])
3109*6a54128fSAndroid Build Coastguard Worker  if test $gl_cv_elf; then
3110*6a54128fSAndroid Build Coastguard Worker    # Extract the ELF class of a file (5th byte) in decimal.
3111*6a54128fSAndroid Build Coastguard Worker    # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
3112*6a54128fSAndroid Build Coastguard Worker    if od -A x < /dev/null >/dev/null 2>/dev/null; then
3113*6a54128fSAndroid Build Coastguard Worker      # Use POSIX od.
3114*6a54128fSAndroid Build Coastguard Worker      func_elfclass ()
3115*6a54128fSAndroid Build Coastguard Worker      {
3116*6a54128fSAndroid Build Coastguard Worker        od -A n -t d1 -j 4 -N 1
3117*6a54128fSAndroid Build Coastguard Worker      }
3118*6a54128fSAndroid Build Coastguard Worker    else
3119*6a54128fSAndroid Build Coastguard Worker      # Use BSD hexdump.
3120*6a54128fSAndroid Build Coastguard Worker      func_elfclass ()
3121*6a54128fSAndroid Build Coastguard Worker      {
3122*6a54128fSAndroid Build Coastguard Worker        dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'
3123*6a54128fSAndroid Build Coastguard Worker        echo
3124*6a54128fSAndroid Build Coastguard Worker      }
3125*6a54128fSAndroid Build Coastguard Worker    fi
3126*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
3127*6a54128fSAndroid Build Coastguard Worker    case $HOST_CPU_C_ABI_32BIT in
3128*6a54128fSAndroid Build Coastguard Worker      yes)
3129*6a54128fSAndroid Build Coastguard Worker        # 32-bit ABI.
3130*6a54128fSAndroid Build Coastguard Worker        acl_is_expected_elfclass ()
3131*6a54128fSAndroid Build Coastguard Worker        {
3132*6a54128fSAndroid Build Coastguard Worker          test "`func_elfclass | sed -e 's/[ 	]//g'`" = 1
3133*6a54128fSAndroid Build Coastguard Worker        }
3134*6a54128fSAndroid Build Coastguard Worker        ;;
3135*6a54128fSAndroid Build Coastguard Worker      no)
3136*6a54128fSAndroid Build Coastguard Worker        # 64-bit ABI.
3137*6a54128fSAndroid Build Coastguard Worker        acl_is_expected_elfclass ()
3138*6a54128fSAndroid Build Coastguard Worker        {
3139*6a54128fSAndroid Build Coastguard Worker          test "`func_elfclass | sed -e 's/[ 	]//g'`" = 2
3140*6a54128fSAndroid Build Coastguard Worker        }
3141*6a54128fSAndroid Build Coastguard Worker        ;;
3142*6a54128fSAndroid Build Coastguard Worker      *)
3143*6a54128fSAndroid Build Coastguard Worker        # Unknown.
3144*6a54128fSAndroid Build Coastguard Worker        acl_is_expected_elfclass ()
3145*6a54128fSAndroid Build Coastguard Worker        {
3146*6a54128fSAndroid Build Coastguard Worker          :
3147*6a54128fSAndroid Build Coastguard Worker        }
3148*6a54128fSAndroid Build Coastguard Worker        ;;
3149*6a54128fSAndroid Build Coastguard Worker    esac
3150*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
3151*6a54128fSAndroid Build Coastguard Worker  else
3152*6a54128fSAndroid Build Coastguard Worker    acl_is_expected_elfclass ()
3153*6a54128fSAndroid Build Coastguard Worker    {
3154*6a54128fSAndroid Build Coastguard Worker      :
3155*6a54128fSAndroid Build Coastguard Worker    }
3156*6a54128fSAndroid Build Coastguard Worker  fi
3157*6a54128fSAndroid Build Coastguard Worker
3158*6a54128fSAndroid Build Coastguard Worker  dnl Allow the user to override the result by setting acl_cv_libdirstems.
3159*6a54128fSAndroid Build Coastguard Worker  AC_CACHE_CHECK([for the common suffixes of directories in the library search path],
3160*6a54128fSAndroid Build Coastguard Worker    [acl_cv_libdirstems],
3161*6a54128fSAndroid Build Coastguard Worker    [dnl Try 'lib' first, because that's the default for libdir in GNU, see
3162*6a54128fSAndroid Build Coastguard Worker     dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.
3163*6a54128fSAndroid Build Coastguard Worker     acl_libdirstem=lib
3164*6a54128fSAndroid Build Coastguard Worker     acl_libdirstem2=
3165*6a54128fSAndroid Build Coastguard Worker     acl_libdirstem3=
3166*6a54128fSAndroid Build Coastguard Worker     case "$host_os" in
3167*6a54128fSAndroid Build Coastguard Worker       solaris*)
3168*6a54128fSAndroid Build Coastguard Worker         dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
3169*6a54128fSAndroid Build Coastguard Worker         dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>.
3170*6a54128fSAndroid Build Coastguard Worker         dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
3171*6a54128fSAndroid Build Coastguard Worker         dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
3172*6a54128fSAndroid Build Coastguard Worker         dnl symlink is missing, so we set acl_libdirstem2 too.
3173*6a54128fSAndroid Build Coastguard Worker         if test $HOST_CPU_C_ABI_32BIT = no; then
3174*6a54128fSAndroid Build Coastguard Worker           acl_libdirstem2=lib/64
3175*6a54128fSAndroid Build Coastguard Worker           case "$host_cpu" in
3176*6a54128fSAndroid Build Coastguard Worker             sparc*)        acl_libdirstem3=lib/sparcv9 ;;
3177*6a54128fSAndroid Build Coastguard Worker             i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;
3178*6a54128fSAndroid Build Coastguard Worker           esac
3179*6a54128fSAndroid Build Coastguard Worker         fi
3180*6a54128fSAndroid Build Coastguard Worker         ;;
3181*6a54128fSAndroid Build Coastguard Worker       *)
3182*6a54128fSAndroid Build Coastguard Worker         dnl If $CC generates code for a 32-bit ABI, the libraries are
3183*6a54128fSAndroid Build Coastguard Worker         dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64.
3184*6a54128fSAndroid Build Coastguard Worker         dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries
3185*6a54128fSAndroid Build Coastguard Worker         dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32.
3186*6a54128fSAndroid Build Coastguard Worker         dnl Find the compiler's search path. However, non-system compilers
3187*6a54128fSAndroid Build Coastguard Worker         dnl sometimes have odd library search paths. But we can't simply invoke
3188*6a54128fSAndroid Build Coastguard Worker         dnl '/usr/bin/gcc -print-search-dirs' because that would not take into
3189*6a54128fSAndroid Build Coastguard Worker         dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS.
3190*6a54128fSAndroid Build Coastguard Worker         searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \
3191*6a54128fSAndroid Build Coastguard Worker                     | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
3192*6a54128fSAndroid Build Coastguard Worker         if test $HOST_CPU_C_ABI_32BIT != no; then
3193*6a54128fSAndroid Build Coastguard Worker           # 32-bit or unknown ABI.
3194*6a54128fSAndroid Build Coastguard Worker           if test -d /usr/lib32; then
3195*6a54128fSAndroid Build Coastguard Worker             acl_libdirstem2=lib32
3196*6a54128fSAndroid Build Coastguard Worker           fi
3197*6a54128fSAndroid Build Coastguard Worker         fi
3198*6a54128fSAndroid Build Coastguard Worker         if test $HOST_CPU_C_ABI_32BIT != yes; then
3199*6a54128fSAndroid Build Coastguard Worker           # 64-bit or unknown ABI.
3200*6a54128fSAndroid Build Coastguard Worker           if test -d /usr/lib64; then
3201*6a54128fSAndroid Build Coastguard Worker             acl_libdirstem3=lib64
3202*6a54128fSAndroid Build Coastguard Worker           fi
3203*6a54128fSAndroid Build Coastguard Worker         fi
3204*6a54128fSAndroid Build Coastguard Worker         if test -n "$searchpath"; then
3205*6a54128fSAndroid Build Coastguard Worker           acl_save_IFS="${IFS= 	}"; IFS=":"
3206*6a54128fSAndroid Build Coastguard Worker           for searchdir in $searchpath; do
3207*6a54128fSAndroid Build Coastguard Worker             if test -d "$searchdir"; then
3208*6a54128fSAndroid Build Coastguard Worker               case "$searchdir" in
3209*6a54128fSAndroid Build Coastguard Worker                 */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;
3210*6a54128fSAndroid Build Coastguard Worker                 */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;
3211*6a54128fSAndroid Build Coastguard Worker                 */../ | */.. )
3212*6a54128fSAndroid Build Coastguard Worker                   # Better ignore directories of this form. They are misleading.
3213*6a54128fSAndroid Build Coastguard Worker                   ;;
3214*6a54128fSAndroid Build Coastguard Worker                 *) searchdir=`cd "$searchdir" && pwd`
3215*6a54128fSAndroid Build Coastguard Worker                    case "$searchdir" in
3216*6a54128fSAndroid Build Coastguard Worker                      */lib32 ) acl_libdirstem2=lib32 ;;
3217*6a54128fSAndroid Build Coastguard Worker                      */lib64 ) acl_libdirstem3=lib64 ;;
3218*6a54128fSAndroid Build Coastguard Worker                    esac ;;
3219*6a54128fSAndroid Build Coastguard Worker               esac
3220*6a54128fSAndroid Build Coastguard Worker             fi
3221*6a54128fSAndroid Build Coastguard Worker           done
3222*6a54128fSAndroid Build Coastguard Worker           IFS="$acl_save_IFS"
3223*6a54128fSAndroid Build Coastguard Worker           if test $HOST_CPU_C_ABI_32BIT = yes; then
3224*6a54128fSAndroid Build Coastguard Worker             # 32-bit ABI.
3225*6a54128fSAndroid Build Coastguard Worker             acl_libdirstem3=
3226*6a54128fSAndroid Build Coastguard Worker           fi
3227*6a54128fSAndroid Build Coastguard Worker           if test $HOST_CPU_C_ABI_32BIT = no; then
3228*6a54128fSAndroid Build Coastguard Worker             # 64-bit ABI.
3229*6a54128fSAndroid Build Coastguard Worker             acl_libdirstem2=
3230*6a54128fSAndroid Build Coastguard Worker           fi
3231*6a54128fSAndroid Build Coastguard Worker         fi
3232*6a54128fSAndroid Build Coastguard Worker         ;;
3233*6a54128fSAndroid Build Coastguard Worker     esac
3234*6a54128fSAndroid Build Coastguard Worker     test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
3235*6a54128fSAndroid Build Coastguard Worker     test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"
3236*6a54128fSAndroid Build Coastguard Worker     acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"
3237*6a54128fSAndroid Build Coastguard Worker    ])
3238*6a54128fSAndroid Build Coastguard Worker  dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and
3239*6a54128fSAndroid Build Coastguard Worker  dnl acl_libdirstem3.
3240*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
3241*6a54128fSAndroid Build Coastguard Worker  acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
3242*6a54128fSAndroid Build Coastguard Worker  acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`
3243*6a54128fSAndroid Build Coastguard Worker  acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`
3244*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
3245*6a54128fSAndroid Build Coastguard Worker])
3246*6a54128fSAndroid Build Coastguard Worker
3247*6a54128fSAndroid Build Coastguard Worker# nls.m4 serial 6 (gettext-0.20.2)
3248*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016, 2019-2020 Free
3249*6a54128fSAndroid Build Coastguard Workerdnl Software Foundation, Inc.
3250*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
3251*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
3252*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
3253*6a54128fSAndroid Build Coastguard Workerdnl
3254*6a54128fSAndroid Build Coastguard Workerdnl This file can be used in projects which are not available under
3255*6a54128fSAndroid Build Coastguard Workerdnl the GNU General Public License or the GNU Lesser General Public
3256*6a54128fSAndroid Build Coastguard Workerdnl License but which still want to provide support for the GNU gettext
3257*6a54128fSAndroid Build Coastguard Workerdnl functionality.
3258*6a54128fSAndroid Build Coastguard Workerdnl Please note that the actual code of the GNU gettext library is covered
3259*6a54128fSAndroid Build Coastguard Workerdnl by the GNU Lesser General Public License, and the rest of the GNU
3260*6a54128fSAndroid Build Coastguard Workerdnl gettext package is covered by the GNU General Public License.
3261*6a54128fSAndroid Build Coastguard Workerdnl They are *not* in the public domain.
3262*6a54128fSAndroid Build Coastguard Worker
3263*6a54128fSAndroid Build Coastguard Workerdnl Authors:
3264*6a54128fSAndroid Build Coastguard Workerdnl   Ulrich Drepper <[email protected]>, 1995-2000.
3265*6a54128fSAndroid Build Coastguard Workerdnl   Bruno Haible <[email protected]>, 2000-2003.
3266*6a54128fSAndroid Build Coastguard Worker
3267*6a54128fSAndroid Build Coastguard WorkerAC_PREREQ([2.50])
3268*6a54128fSAndroid Build Coastguard Worker
3269*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_NLS],
3270*6a54128fSAndroid Build Coastguard Worker[
3271*6a54128fSAndroid Build Coastguard Worker  AC_MSG_CHECKING([whether NLS is requested])
3272*6a54128fSAndroid Build Coastguard Worker  dnl Default is enabled NLS
3273*6a54128fSAndroid Build Coastguard Worker  AC_ARG_ENABLE([nls],
3274*6a54128fSAndroid Build Coastguard Worker    [  --disable-nls           do not use Native Language Support],
3275*6a54128fSAndroid Build Coastguard Worker    USE_NLS=$enableval, USE_NLS=yes)
3276*6a54128fSAndroid Build Coastguard Worker  AC_MSG_RESULT([$USE_NLS])
3277*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([USE_NLS])
3278*6a54128fSAndroid Build Coastguard Worker])
3279*6a54128fSAndroid Build Coastguard Worker
3280*6a54128fSAndroid Build Coastguard Worker# pkg.m4 - Macros to locate and use pkg-config.   -*- Autoconf -*-
3281*6a54128fSAndroid Build Coastguard Worker# serial 12 (pkg-config-0.29.2)
3282*6a54128fSAndroid Build Coastguard Worker
3283*6a54128fSAndroid Build Coastguard Workerdnl Copyright © 2004 Scott James Remnant <[email protected]>.
3284*6a54128fSAndroid Build Coastguard Workerdnl Copyright © 2012-2015 Dan Nicholson <[email protected]>
3285*6a54128fSAndroid Build Coastguard Workerdnl
3286*6a54128fSAndroid Build Coastguard Workerdnl This program is free software; you can redistribute it and/or modify
3287*6a54128fSAndroid Build Coastguard Workerdnl it under the terms of the GNU General Public License as published by
3288*6a54128fSAndroid Build Coastguard Workerdnl the Free Software Foundation; either version 2 of the License, or
3289*6a54128fSAndroid Build Coastguard Workerdnl (at your option) any later version.
3290*6a54128fSAndroid Build Coastguard Workerdnl
3291*6a54128fSAndroid Build Coastguard Workerdnl This program is distributed in the hope that it will be useful, but
3292*6a54128fSAndroid Build Coastguard Workerdnl WITHOUT ANY WARRANTY; without even the implied warranty of
3293*6a54128fSAndroid Build Coastguard Workerdnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3294*6a54128fSAndroid Build Coastguard Workerdnl General Public License for more details.
3295*6a54128fSAndroid Build Coastguard Workerdnl
3296*6a54128fSAndroid Build Coastguard Workerdnl You should have received a copy of the GNU General Public License
3297*6a54128fSAndroid Build Coastguard Workerdnl along with this program; if not, write to the Free Software
3298*6a54128fSAndroid Build Coastguard Workerdnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3299*6a54128fSAndroid Build Coastguard Workerdnl 02111-1307, USA.
3300*6a54128fSAndroid Build Coastguard Workerdnl
3301*6a54128fSAndroid Build Coastguard Workerdnl As a special exception to the GNU General Public License, if you
3302*6a54128fSAndroid Build Coastguard Workerdnl distribute this file as part of a program that contains a
3303*6a54128fSAndroid Build Coastguard Workerdnl configuration script generated by Autoconf, you may include it under
3304*6a54128fSAndroid Build Coastguard Workerdnl the same distribution terms that you use for the rest of that
3305*6a54128fSAndroid Build Coastguard Workerdnl program.
3306*6a54128fSAndroid Build Coastguard Worker
3307*6a54128fSAndroid Build Coastguard Workerdnl PKG_PREREQ(MIN-VERSION)
3308*6a54128fSAndroid Build Coastguard Workerdnl -----------------------
3309*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.29
3310*6a54128fSAndroid Build Coastguard Workerdnl
3311*6a54128fSAndroid Build Coastguard Workerdnl Verify that the version of the pkg-config macros are at least
3312*6a54128fSAndroid Build Coastguard Workerdnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
3313*6a54128fSAndroid Build Coastguard Workerdnl installed version of pkg-config, this checks the developer's version
3314*6a54128fSAndroid Build Coastguard Workerdnl of pkg.m4 when generating configure.
3315*6a54128fSAndroid Build Coastguard Workerdnl
3316*6a54128fSAndroid Build Coastguard Workerdnl To ensure that this macro is defined, also add:
3317*6a54128fSAndroid Build Coastguard Workerdnl m4_ifndef([PKG_PREREQ],
3318*6a54128fSAndroid Build Coastguard Workerdnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
3319*6a54128fSAndroid Build Coastguard Workerdnl
3320*6a54128fSAndroid Build Coastguard Workerdnl See the "Since" comment for each macro you use to see what version
3321*6a54128fSAndroid Build Coastguard Workerdnl of the macros you require.
3322*6a54128fSAndroid Build Coastguard Workerm4_defun([PKG_PREREQ],
3323*6a54128fSAndroid Build Coastguard Worker[m4_define([PKG_MACROS_VERSION], [0.29.2])
3324*6a54128fSAndroid Build Coastguard Workerm4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
3325*6a54128fSAndroid Build Coastguard Worker    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
3326*6a54128fSAndroid Build Coastguard Worker])dnl PKG_PREREQ
3327*6a54128fSAndroid Build Coastguard Worker
3328*6a54128fSAndroid Build Coastguard Workerdnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
3329*6a54128fSAndroid Build Coastguard Workerdnl ----------------------------------
3330*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.16
3331*6a54128fSAndroid Build Coastguard Workerdnl
3332*6a54128fSAndroid Build Coastguard Workerdnl Search for the pkg-config tool and set the PKG_CONFIG variable to
3333*6a54128fSAndroid Build Coastguard Workerdnl first found in the path. Checks that the version of pkg-config found
3334*6a54128fSAndroid Build Coastguard Workerdnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
3335*6a54128fSAndroid Build Coastguard Workerdnl used since that's the first version where most current features of
3336*6a54128fSAndroid Build Coastguard Workerdnl pkg-config existed.
3337*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_PROG_PKG_CONFIG],
3338*6a54128fSAndroid Build Coastguard Worker[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
3339*6a54128fSAndroid Build Coastguard Workerm4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
3340*6a54128fSAndroid Build Coastguard Workerm4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
3341*6a54128fSAndroid Build Coastguard WorkerAC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
3342*6a54128fSAndroid Build Coastguard WorkerAC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
3343*6a54128fSAndroid Build Coastguard WorkerAC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
3344*6a54128fSAndroid Build Coastguard Worker
3345*6a54128fSAndroid Build Coastguard Workerif test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
3346*6a54128fSAndroid Build Coastguard Worker	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
3347*6a54128fSAndroid Build Coastguard Workerfi
3348*6a54128fSAndroid Build Coastguard Workerif test -n "$PKG_CONFIG"; then
3349*6a54128fSAndroid Build Coastguard Worker	_pkg_min_version=m4_default([$1], [0.9.0])
3350*6a54128fSAndroid Build Coastguard Worker	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
3351*6a54128fSAndroid Build Coastguard Worker	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
3352*6a54128fSAndroid Build Coastguard Worker		AC_MSG_RESULT([yes])
3353*6a54128fSAndroid Build Coastguard Worker	else
3354*6a54128fSAndroid Build Coastguard Worker		AC_MSG_RESULT([no])
3355*6a54128fSAndroid Build Coastguard Worker		PKG_CONFIG=""
3356*6a54128fSAndroid Build Coastguard Worker	fi
3357*6a54128fSAndroid Build Coastguard Workerfi[]dnl
3358*6a54128fSAndroid Build Coastguard Worker])dnl PKG_PROG_PKG_CONFIG
3359*6a54128fSAndroid Build Coastguard Worker
3360*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3361*6a54128fSAndroid Build Coastguard Workerdnl -------------------------------------------------------------------
3362*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.18
3363*6a54128fSAndroid Build Coastguard Workerdnl
3364*6a54128fSAndroid Build Coastguard Workerdnl Check to see whether a particular set of modules exists. Similar to
3365*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_MODULES(), but does not set variables or print errors.
3366*6a54128fSAndroid Build Coastguard Workerdnl
3367*6a54128fSAndroid Build Coastguard Workerdnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
3368*6a54128fSAndroid Build Coastguard Workerdnl only at the first occurrence in configure.ac, so if the first place
3369*6a54128fSAndroid Build Coastguard Workerdnl it's called might be skipped (such as if it is within an "if", you
3370*6a54128fSAndroid Build Coastguard Workerdnl have to call PKG_CHECK_EXISTS manually
3371*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_CHECK_EXISTS],
3372*6a54128fSAndroid Build Coastguard Worker[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
3373*6a54128fSAndroid Build Coastguard Workerif test -n "$PKG_CONFIG" && \
3374*6a54128fSAndroid Build Coastguard Worker    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
3375*6a54128fSAndroid Build Coastguard Worker  m4_default([$2], [:])
3376*6a54128fSAndroid Build Coastguard Workerm4_ifvaln([$3], [else
3377*6a54128fSAndroid Build Coastguard Worker  $3])dnl
3378*6a54128fSAndroid Build Coastguard Workerfi])
3379*6a54128fSAndroid Build Coastguard Worker
3380*6a54128fSAndroid Build Coastguard Workerdnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
3381*6a54128fSAndroid Build Coastguard Workerdnl ---------------------------------------------
3382*6a54128fSAndroid Build Coastguard Workerdnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
3383*6a54128fSAndroid Build Coastguard Workerdnl pkg_failed based on the result.
3384*6a54128fSAndroid Build Coastguard Workerm4_define([_PKG_CONFIG],
3385*6a54128fSAndroid Build Coastguard Worker[if test -n "$$1"; then
3386*6a54128fSAndroid Build Coastguard Worker    pkg_cv_[]$1="$$1"
3387*6a54128fSAndroid Build Coastguard Worker elif test -n "$PKG_CONFIG"; then
3388*6a54128fSAndroid Build Coastguard Worker    PKG_CHECK_EXISTS([$3],
3389*6a54128fSAndroid Build Coastguard Worker                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
3390*6a54128fSAndroid Build Coastguard Worker		      test "x$?" != "x0" && pkg_failed=yes ],
3391*6a54128fSAndroid Build Coastguard Worker		     [pkg_failed=yes])
3392*6a54128fSAndroid Build Coastguard Worker else
3393*6a54128fSAndroid Build Coastguard Worker    pkg_failed=untried
3394*6a54128fSAndroid Build Coastguard Workerfi[]dnl
3395*6a54128fSAndroid Build Coastguard Worker])dnl _PKG_CONFIG
3396*6a54128fSAndroid Build Coastguard Worker
3397*6a54128fSAndroid Build Coastguard Workerdnl _PKG_SHORT_ERRORS_SUPPORTED
3398*6a54128fSAndroid Build Coastguard Workerdnl ---------------------------
3399*6a54128fSAndroid Build Coastguard Workerdnl Internal check to see if pkg-config supports short errors.
3400*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
3401*6a54128fSAndroid Build Coastguard Worker[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
3402*6a54128fSAndroid Build Coastguard Workerif $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
3403*6a54128fSAndroid Build Coastguard Worker        _pkg_short_errors_supported=yes
3404*6a54128fSAndroid Build Coastguard Workerelse
3405*6a54128fSAndroid Build Coastguard Worker        _pkg_short_errors_supported=no
3406*6a54128fSAndroid Build Coastguard Workerfi[]dnl
3407*6a54128fSAndroid Build Coastguard Worker])dnl _PKG_SHORT_ERRORS_SUPPORTED
3408*6a54128fSAndroid Build Coastguard Worker
3409*6a54128fSAndroid Build Coastguard Worker
3410*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
3411*6a54128fSAndroid Build Coastguard Workerdnl   [ACTION-IF-NOT-FOUND])
3412*6a54128fSAndroid Build Coastguard Workerdnl --------------------------------------------------------------
3413*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.4.0
3414*6a54128fSAndroid Build Coastguard Workerdnl
3415*6a54128fSAndroid Build Coastguard Workerdnl Note that if there is a possibility the first call to
3416*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_MODULES might not happen, you should be sure to include an
3417*6a54128fSAndroid Build Coastguard Workerdnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
3418*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_CHECK_MODULES],
3419*6a54128fSAndroid Build Coastguard Worker[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
3420*6a54128fSAndroid Build Coastguard WorkerAC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
3421*6a54128fSAndroid Build Coastguard WorkerAC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
3422*6a54128fSAndroid Build Coastguard Worker
3423*6a54128fSAndroid Build Coastguard Workerpkg_failed=no
3424*6a54128fSAndroid Build Coastguard WorkerAC_MSG_CHECKING([for $2])
3425*6a54128fSAndroid Build Coastguard Worker
3426*6a54128fSAndroid Build Coastguard Worker_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
3427*6a54128fSAndroid Build Coastguard Worker_PKG_CONFIG([$1][_LIBS], [libs], [$2])
3428*6a54128fSAndroid Build Coastguard Worker
3429*6a54128fSAndroid Build Coastguard Workerm4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
3430*6a54128fSAndroid Build Coastguard Workerand $1[]_LIBS to avoid the need to call pkg-config.
3431*6a54128fSAndroid Build Coastguard WorkerSee the pkg-config man page for more details.])
3432*6a54128fSAndroid Build Coastguard Worker
3433*6a54128fSAndroid Build Coastguard Workerif test $pkg_failed = yes; then
3434*6a54128fSAndroid Build Coastguard Worker        AC_MSG_RESULT([no])
3435*6a54128fSAndroid Build Coastguard Worker        _PKG_SHORT_ERRORS_SUPPORTED
3436*6a54128fSAndroid Build Coastguard Worker        if test $_pkg_short_errors_supported = yes; then
3437*6a54128fSAndroid Build Coastguard Worker                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
3438*6a54128fSAndroid Build Coastguard Worker        else
3439*6a54128fSAndroid Build Coastguard Worker                $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
3440*6a54128fSAndroid Build Coastguard Worker        fi
3441*6a54128fSAndroid Build Coastguard Worker        # Put the nasty error message in config.log where it belongs
3442*6a54128fSAndroid Build Coastguard Worker        echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
3443*6a54128fSAndroid Build Coastguard Worker
3444*6a54128fSAndroid Build Coastguard Worker        m4_default([$4], [AC_MSG_ERROR(
3445*6a54128fSAndroid Build Coastguard Worker[Package requirements ($2) were not met:
3446*6a54128fSAndroid Build Coastguard Worker
3447*6a54128fSAndroid Build Coastguard Worker$$1_PKG_ERRORS
3448*6a54128fSAndroid Build Coastguard Worker
3449*6a54128fSAndroid Build Coastguard WorkerConsider adjusting the PKG_CONFIG_PATH environment variable if you
3450*6a54128fSAndroid Build Coastguard Workerinstalled software in a non-standard prefix.
3451*6a54128fSAndroid Build Coastguard Worker
3452*6a54128fSAndroid Build Coastguard Worker_PKG_TEXT])[]dnl
3453*6a54128fSAndroid Build Coastguard Worker        ])
3454*6a54128fSAndroid Build Coastguard Workerelif test $pkg_failed = untried; then
3455*6a54128fSAndroid Build Coastguard Worker        AC_MSG_RESULT([no])
3456*6a54128fSAndroid Build Coastguard Worker        m4_default([$4], [AC_MSG_FAILURE(
3457*6a54128fSAndroid Build Coastguard Worker[The pkg-config script could not be found or is too old.  Make sure it
3458*6a54128fSAndroid Build Coastguard Workeris in your PATH or set the PKG_CONFIG environment variable to the full
3459*6a54128fSAndroid Build Coastguard Workerpath to pkg-config.
3460*6a54128fSAndroid Build Coastguard Worker
3461*6a54128fSAndroid Build Coastguard Worker_PKG_TEXT
3462*6a54128fSAndroid Build Coastguard Worker
3463*6a54128fSAndroid Build Coastguard WorkerTo get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
3464*6a54128fSAndroid Build Coastguard Worker        ])
3465*6a54128fSAndroid Build Coastguard Workerelse
3466*6a54128fSAndroid Build Coastguard Worker        $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
3467*6a54128fSAndroid Build Coastguard Worker        $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
3468*6a54128fSAndroid Build Coastguard Worker        AC_MSG_RESULT([yes])
3469*6a54128fSAndroid Build Coastguard Worker        $3
3470*6a54128fSAndroid Build Coastguard Workerfi[]dnl
3471*6a54128fSAndroid Build Coastguard Worker])dnl PKG_CHECK_MODULES
3472*6a54128fSAndroid Build Coastguard Worker
3473*6a54128fSAndroid Build Coastguard Worker
3474*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
3475*6a54128fSAndroid Build Coastguard Workerdnl   [ACTION-IF-NOT-FOUND])
3476*6a54128fSAndroid Build Coastguard Workerdnl ---------------------------------------------------------------------
3477*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.29
3478*6a54128fSAndroid Build Coastguard Workerdnl
3479*6a54128fSAndroid Build Coastguard Workerdnl Checks for existence of MODULES and gathers its build flags with
3480*6a54128fSAndroid Build Coastguard Workerdnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
3481*6a54128fSAndroid Build Coastguard Workerdnl and VARIABLE-PREFIX_LIBS from --libs.
3482*6a54128fSAndroid Build Coastguard Workerdnl
3483*6a54128fSAndroid Build Coastguard Workerdnl Note that if there is a possibility the first call to
3484*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
3485*6a54128fSAndroid Build Coastguard Workerdnl include an explicit call to PKG_PROG_PKG_CONFIG in your
3486*6a54128fSAndroid Build Coastguard Workerdnl configure.ac.
3487*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_CHECK_MODULES_STATIC],
3488*6a54128fSAndroid Build Coastguard Worker[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
3489*6a54128fSAndroid Build Coastguard Worker_save_PKG_CONFIG=$PKG_CONFIG
3490*6a54128fSAndroid Build Coastguard WorkerPKG_CONFIG="$PKG_CONFIG --static"
3491*6a54128fSAndroid Build Coastguard WorkerPKG_CHECK_MODULES($@)
3492*6a54128fSAndroid Build Coastguard WorkerPKG_CONFIG=$_save_PKG_CONFIG[]dnl
3493*6a54128fSAndroid Build Coastguard Worker])dnl PKG_CHECK_MODULES_STATIC
3494*6a54128fSAndroid Build Coastguard Worker
3495*6a54128fSAndroid Build Coastguard Worker
3496*6a54128fSAndroid Build Coastguard Workerdnl PKG_INSTALLDIR([DIRECTORY])
3497*6a54128fSAndroid Build Coastguard Workerdnl -------------------------
3498*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.27
3499*6a54128fSAndroid Build Coastguard Workerdnl
3500*6a54128fSAndroid Build Coastguard Workerdnl Substitutes the variable pkgconfigdir as the location where a module
3501*6a54128fSAndroid Build Coastguard Workerdnl should install pkg-config .pc files. By default the directory is
3502*6a54128fSAndroid Build Coastguard Workerdnl $libdir/pkgconfig, but the default can be changed by passing
3503*6a54128fSAndroid Build Coastguard Workerdnl DIRECTORY. The user can override through the --with-pkgconfigdir
3504*6a54128fSAndroid Build Coastguard Workerdnl parameter.
3505*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_INSTALLDIR],
3506*6a54128fSAndroid Build Coastguard Worker[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
3507*6a54128fSAndroid Build Coastguard Workerm4_pushdef([pkg_description],
3508*6a54128fSAndroid Build Coastguard Worker    [pkg-config installation directory @<:@]pkg_default[@:>@])
3509*6a54128fSAndroid Build Coastguard WorkerAC_ARG_WITH([pkgconfigdir],
3510*6a54128fSAndroid Build Coastguard Worker    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
3511*6a54128fSAndroid Build Coastguard Worker    [with_pkgconfigdir=]pkg_default)
3512*6a54128fSAndroid Build Coastguard WorkerAC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
3513*6a54128fSAndroid Build Coastguard Workerm4_popdef([pkg_default])
3514*6a54128fSAndroid Build Coastguard Workerm4_popdef([pkg_description])
3515*6a54128fSAndroid Build Coastguard Worker])dnl PKG_INSTALLDIR
3516*6a54128fSAndroid Build Coastguard Worker
3517*6a54128fSAndroid Build Coastguard Worker
3518*6a54128fSAndroid Build Coastguard Workerdnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
3519*6a54128fSAndroid Build Coastguard Workerdnl --------------------------------
3520*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.27
3521*6a54128fSAndroid Build Coastguard Workerdnl
3522*6a54128fSAndroid Build Coastguard Workerdnl Substitutes the variable noarch_pkgconfigdir as the location where a
3523*6a54128fSAndroid Build Coastguard Workerdnl module should install arch-independent pkg-config .pc files. By
3524*6a54128fSAndroid Build Coastguard Workerdnl default the directory is $datadir/pkgconfig, but the default can be
3525*6a54128fSAndroid Build Coastguard Workerdnl changed by passing DIRECTORY. The user can override through the
3526*6a54128fSAndroid Build Coastguard Workerdnl --with-noarch-pkgconfigdir parameter.
3527*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_NOARCH_INSTALLDIR],
3528*6a54128fSAndroid Build Coastguard Worker[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
3529*6a54128fSAndroid Build Coastguard Workerm4_pushdef([pkg_description],
3530*6a54128fSAndroid Build Coastguard Worker    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
3531*6a54128fSAndroid Build Coastguard WorkerAC_ARG_WITH([noarch-pkgconfigdir],
3532*6a54128fSAndroid Build Coastguard Worker    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
3533*6a54128fSAndroid Build Coastguard Worker    [with_noarch_pkgconfigdir=]pkg_default)
3534*6a54128fSAndroid Build Coastguard WorkerAC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
3535*6a54128fSAndroid Build Coastguard Workerm4_popdef([pkg_default])
3536*6a54128fSAndroid Build Coastguard Workerm4_popdef([pkg_description])
3537*6a54128fSAndroid Build Coastguard Worker])dnl PKG_NOARCH_INSTALLDIR
3538*6a54128fSAndroid Build Coastguard Worker
3539*6a54128fSAndroid Build Coastguard Worker
3540*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
3541*6a54128fSAndroid Build Coastguard Workerdnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3542*6a54128fSAndroid Build Coastguard Workerdnl -------------------------------------------
3543*6a54128fSAndroid Build Coastguard Workerdnl Since: 0.28
3544*6a54128fSAndroid Build Coastguard Workerdnl
3545*6a54128fSAndroid Build Coastguard Workerdnl Retrieves the value of the pkg-config variable for the given module.
3546*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_CHECK_VAR],
3547*6a54128fSAndroid Build Coastguard Worker[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
3548*6a54128fSAndroid Build Coastguard WorkerAC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
3549*6a54128fSAndroid Build Coastguard Worker
3550*6a54128fSAndroid Build Coastguard Worker_PKG_CONFIG([$1], [variable="][$3]["], [$2])
3551*6a54128fSAndroid Build Coastguard WorkerAS_VAR_COPY([$1], [pkg_cv_][$1])
3552*6a54128fSAndroid Build Coastguard Worker
3553*6a54128fSAndroid Build Coastguard WorkerAS_VAR_IF([$1], [""], [$5], [$4])dnl
3554*6a54128fSAndroid Build Coastguard Worker])dnl PKG_CHECK_VAR
3555*6a54128fSAndroid Build Coastguard Worker
3556*6a54128fSAndroid Build Coastguard Workerdnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
3557*6a54128fSAndroid Build Coastguard Workerdnl   [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
3558*6a54128fSAndroid Build Coastguard Workerdnl   [DESCRIPTION], [DEFAULT])
3559*6a54128fSAndroid Build Coastguard Workerdnl ------------------------------------------
3560*6a54128fSAndroid Build Coastguard Workerdnl
3561*6a54128fSAndroid Build Coastguard Workerdnl Prepare a "--with-" configure option using the lowercase
3562*6a54128fSAndroid Build Coastguard Workerdnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
3563*6a54128fSAndroid Build Coastguard Workerdnl PKG_CHECK_MODULES in a single macro.
3564*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_WITH_MODULES],
3565*6a54128fSAndroid Build Coastguard Worker[
3566*6a54128fSAndroid Build Coastguard Workerm4_pushdef([with_arg], m4_tolower([$1]))
3567*6a54128fSAndroid Build Coastguard Worker
3568*6a54128fSAndroid Build Coastguard Workerm4_pushdef([description],
3569*6a54128fSAndroid Build Coastguard Worker           [m4_default([$5], [build with ]with_arg[ support])])
3570*6a54128fSAndroid Build Coastguard Worker
3571*6a54128fSAndroid Build Coastguard Workerm4_pushdef([def_arg], [m4_default([$6], [auto])])
3572*6a54128fSAndroid Build Coastguard Workerm4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
3573*6a54128fSAndroid Build Coastguard Workerm4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
3574*6a54128fSAndroid Build Coastguard Worker
3575*6a54128fSAndroid Build Coastguard Workerm4_case(def_arg,
3576*6a54128fSAndroid Build Coastguard Worker            [yes],[m4_pushdef([with_without], [--without-]with_arg)],
3577*6a54128fSAndroid Build Coastguard Worker            [m4_pushdef([with_without],[--with-]with_arg)])
3578*6a54128fSAndroid Build Coastguard Worker
3579*6a54128fSAndroid Build Coastguard WorkerAC_ARG_WITH(with_arg,
3580*6a54128fSAndroid Build Coastguard Worker     AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
3581*6a54128fSAndroid Build Coastguard Worker    [AS_TR_SH([with_]with_arg)=def_arg])
3582*6a54128fSAndroid Build Coastguard Worker
3583*6a54128fSAndroid Build Coastguard WorkerAS_CASE([$AS_TR_SH([with_]with_arg)],
3584*6a54128fSAndroid Build Coastguard Worker            [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
3585*6a54128fSAndroid Build Coastguard Worker            [auto],[PKG_CHECK_MODULES([$1],[$2],
3586*6a54128fSAndroid Build Coastguard Worker                                        [m4_n([def_action_if_found]) $3],
3587*6a54128fSAndroid Build Coastguard Worker                                        [m4_n([def_action_if_not_found]) $4])])
3588*6a54128fSAndroid Build Coastguard Worker
3589*6a54128fSAndroid Build Coastguard Workerm4_popdef([with_arg])
3590*6a54128fSAndroid Build Coastguard Workerm4_popdef([description])
3591*6a54128fSAndroid Build Coastguard Workerm4_popdef([def_arg])
3592*6a54128fSAndroid Build Coastguard Worker
3593*6a54128fSAndroid Build Coastguard Worker])dnl PKG_WITH_MODULES
3594*6a54128fSAndroid Build Coastguard Worker
3595*6a54128fSAndroid Build Coastguard Workerdnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
3596*6a54128fSAndroid Build Coastguard Workerdnl   [DESCRIPTION], [DEFAULT])
3597*6a54128fSAndroid Build Coastguard Workerdnl -----------------------------------------------
3598*6a54128fSAndroid Build Coastguard Workerdnl
3599*6a54128fSAndroid Build Coastguard Workerdnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
3600*6a54128fSAndroid Build Coastguard Workerdnl check._[VARIABLE-PREFIX] is exported as make variable.
3601*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_HAVE_WITH_MODULES],
3602*6a54128fSAndroid Build Coastguard Worker[
3603*6a54128fSAndroid Build Coastguard WorkerPKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
3604*6a54128fSAndroid Build Coastguard Worker
3605*6a54128fSAndroid Build Coastguard WorkerAM_CONDITIONAL([HAVE_][$1],
3606*6a54128fSAndroid Build Coastguard Worker               [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
3607*6a54128fSAndroid Build Coastguard Worker])dnl PKG_HAVE_WITH_MODULES
3608*6a54128fSAndroid Build Coastguard Worker
3609*6a54128fSAndroid Build Coastguard Workerdnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
3610*6a54128fSAndroid Build Coastguard Workerdnl   [DESCRIPTION], [DEFAULT])
3611*6a54128fSAndroid Build Coastguard Workerdnl ------------------------------------------------------
3612*6a54128fSAndroid Build Coastguard Workerdnl
3613*6a54128fSAndroid Build Coastguard Workerdnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
3614*6a54128fSAndroid Build Coastguard Workerdnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
3615*6a54128fSAndroid Build Coastguard Workerdnl and preprocessor variable.
3616*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
3617*6a54128fSAndroid Build Coastguard Worker[
3618*6a54128fSAndroid Build Coastguard WorkerPKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
3619*6a54128fSAndroid Build Coastguard Worker
3620*6a54128fSAndroid Build Coastguard WorkerAS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
3621*6a54128fSAndroid Build Coastguard Worker        [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
3622*6a54128fSAndroid Build Coastguard Worker])dnl PKG_HAVE_DEFINE_WITH_MODULES
3623*6a54128fSAndroid Build Coastguard Worker
3624*6a54128fSAndroid Build Coastguard Worker# po.m4 serial 31 (gettext-0.20.2)
3625*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc.
3626*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
3627*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
3628*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
3629*6a54128fSAndroid Build Coastguard Workerdnl
3630*6a54128fSAndroid Build Coastguard Workerdnl This file can be used in projects which are not available under
3631*6a54128fSAndroid Build Coastguard Workerdnl the GNU General Public License or the GNU Lesser General Public
3632*6a54128fSAndroid Build Coastguard Workerdnl License but which still want to provide support for the GNU gettext
3633*6a54128fSAndroid Build Coastguard Workerdnl functionality.
3634*6a54128fSAndroid Build Coastguard Workerdnl Please note that the actual code of the GNU gettext library is covered
3635*6a54128fSAndroid Build Coastguard Workerdnl by the GNU Lesser General Public License, and the rest of the GNU
3636*6a54128fSAndroid Build Coastguard Workerdnl gettext package is covered by the GNU General Public License.
3637*6a54128fSAndroid Build Coastguard Workerdnl They are *not* in the public domain.
3638*6a54128fSAndroid Build Coastguard Worker
3639*6a54128fSAndroid Build Coastguard Workerdnl Authors:
3640*6a54128fSAndroid Build Coastguard Workerdnl   Ulrich Drepper <[email protected]>, 1995-2000.
3641*6a54128fSAndroid Build Coastguard Workerdnl   Bruno Haible <[email protected]>, 2000-2003.
3642*6a54128fSAndroid Build Coastguard Worker
3643*6a54128fSAndroid Build Coastguard WorkerAC_PREREQ([2.60])
3644*6a54128fSAndroid Build Coastguard Worker
3645*6a54128fSAndroid Build Coastguard Workerdnl Checks for all prerequisites of the po subdirectory.
3646*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_PO_SUBDIRS],
3647*6a54128fSAndroid Build Coastguard Worker[
3648*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_PROG_MAKE_SET])dnl
3649*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_PROG_INSTALL])dnl
3650*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_PROG_MKDIR_P])dnl
3651*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AC_PROG_SED])dnl
3652*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AM_NLS])dnl
3653*6a54128fSAndroid Build Coastguard Worker
3654*6a54128fSAndroid Build Coastguard Worker  dnl Release version of the gettext macros. This is used to ensure that
3655*6a54128fSAndroid Build Coastguard Worker  dnl the gettext macros and po/Makefile.in.in are in sync.
3656*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([GETTEXT_MACRO_VERSION], [0.20])
3657*6a54128fSAndroid Build Coastguard Worker
3658*6a54128fSAndroid Build Coastguard Worker  dnl Perform the following tests also if --disable-nls has been given,
3659*6a54128fSAndroid Build Coastguard Worker  dnl because they are needed for "make dist" to work.
3660*6a54128fSAndroid Build Coastguard Worker
3661*6a54128fSAndroid Build Coastguard Worker  dnl Search for GNU msgfmt in the PATH.
3662*6a54128fSAndroid Build Coastguard Worker  dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
3663*6a54128fSAndroid Build Coastguard Worker  dnl The second test excludes FreeBSD msgfmt.
3664*6a54128fSAndroid Build Coastguard Worker  AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
3665*6a54128fSAndroid Build Coastguard Worker    [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
3666*6a54128fSAndroid Build Coastguard Worker     (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
3667*6a54128fSAndroid Build Coastguard Worker    :)
3668*6a54128fSAndroid Build Coastguard Worker  AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
3669*6a54128fSAndroid Build Coastguard Worker
3670*6a54128fSAndroid Build Coastguard Worker  dnl Test whether it is GNU msgfmt >= 0.15.
3671*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
3672*6a54128fSAndroid Build Coastguard Worker  case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
3673*6a54128fSAndroid Build Coastguard Worker    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
3674*6a54128fSAndroid Build Coastguard Worker    *) GMSGFMT_015=$GMSGFMT ;;
3675*6a54128fSAndroid Build Coastguard Worker  esac
3676*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
3677*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([GMSGFMT_015])
3678*6a54128fSAndroid Build Coastguard Worker
3679*6a54128fSAndroid Build Coastguard Worker  dnl Search for GNU xgettext 0.12 or newer in the PATH.
3680*6a54128fSAndroid Build Coastguard Worker  dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
3681*6a54128fSAndroid Build Coastguard Worker  dnl The second test excludes FreeBSD xgettext.
3682*6a54128fSAndroid Build Coastguard Worker  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
3683*6a54128fSAndroid Build Coastguard Worker    [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
3684*6a54128fSAndroid Build Coastguard Worker     (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
3685*6a54128fSAndroid Build Coastguard Worker    :)
3686*6a54128fSAndroid Build Coastguard Worker  dnl Remove leftover from FreeBSD xgettext call.
3687*6a54128fSAndroid Build Coastguard Worker  rm -f messages.po
3688*6a54128fSAndroid Build Coastguard Worker
3689*6a54128fSAndroid Build Coastguard Worker  dnl Test whether it is GNU xgettext >= 0.15.
3690*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
3691*6a54128fSAndroid Build Coastguard Worker  case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
3692*6a54128fSAndroid Build Coastguard Worker    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
3693*6a54128fSAndroid Build Coastguard Worker    *) XGETTEXT_015=$XGETTEXT ;;
3694*6a54128fSAndroid Build Coastguard Worker  esac
3695*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
3696*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([XGETTEXT_015])
3697*6a54128fSAndroid Build Coastguard Worker
3698*6a54128fSAndroid Build Coastguard Worker  dnl Search for GNU msgmerge 0.11 or newer in the PATH.
3699*6a54128fSAndroid Build Coastguard Worker  AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
3700*6a54128fSAndroid Build Coastguard Worker    [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
3701*6a54128fSAndroid Build Coastguard Worker
3702*6a54128fSAndroid Build Coastguard Worker  dnl Test whether it is GNU msgmerge >= 0.20.
3703*6a54128fSAndroid Build Coastguard Worker  if LC_ALL=C $MSGMERGE --help | grep ' --for-msgfmt ' >/dev/null; then
3704*6a54128fSAndroid Build Coastguard Worker    MSGMERGE_FOR_MSGFMT_OPTION='--for-msgfmt'
3705*6a54128fSAndroid Build Coastguard Worker  else
3706*6a54128fSAndroid Build Coastguard Worker    dnl Test whether it is GNU msgmerge >= 0.12.
3707*6a54128fSAndroid Build Coastguard Worker    if LC_ALL=C $MSGMERGE --help | grep ' --no-fuzzy-matching ' >/dev/null; then
3708*6a54128fSAndroid Build Coastguard Worker      MSGMERGE_FOR_MSGFMT_OPTION='--no-fuzzy-matching --no-location --quiet'
3709*6a54128fSAndroid Build Coastguard Worker    else
3710*6a54128fSAndroid Build Coastguard Worker      dnl With these old versions, $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) is
3711*6a54128fSAndroid Build Coastguard Worker      dnl slow. But this is not a big problem, as such old gettext versions are
3712*6a54128fSAndroid Build Coastguard Worker      dnl hardly in use any more.
3713*6a54128fSAndroid Build Coastguard Worker      MSGMERGE_FOR_MSGFMT_OPTION='--no-location --quiet'
3714*6a54128fSAndroid Build Coastguard Worker    fi
3715*6a54128fSAndroid Build Coastguard Worker  fi
3716*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([MSGMERGE_FOR_MSGFMT_OPTION])
3717*6a54128fSAndroid Build Coastguard Worker
3718*6a54128fSAndroid Build Coastguard Worker  dnl Support for AM_XGETTEXT_OPTION.
3719*6a54128fSAndroid Build Coastguard Worker  test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
3720*6a54128fSAndroid Build Coastguard Worker  AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
3721*6a54128fSAndroid Build Coastguard Worker
3722*6a54128fSAndroid Build Coastguard Worker  AC_CONFIG_COMMANDS([po-directories], [[
3723*6a54128fSAndroid Build Coastguard Worker    for ac_file in $CONFIG_FILES; do
3724*6a54128fSAndroid Build Coastguard Worker      # Support "outfile[:infile[:infile...]]"
3725*6a54128fSAndroid Build Coastguard Worker      case "$ac_file" in
3726*6a54128fSAndroid Build Coastguard Worker        *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
3727*6a54128fSAndroid Build Coastguard Worker      esac
3728*6a54128fSAndroid Build Coastguard Worker      # PO directories have a Makefile.in generated from Makefile.in.in.
3729*6a54128fSAndroid Build Coastguard Worker      case "$ac_file" in */Makefile.in)
3730*6a54128fSAndroid Build Coastguard Worker        # Adjust a relative srcdir.
3731*6a54128fSAndroid Build Coastguard Worker        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
3732*6a54128fSAndroid Build Coastguard Worker        ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
3733*6a54128fSAndroid Build Coastguard Worker        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
3734*6a54128fSAndroid Build Coastguard Worker        # In autoconf-2.13 it is called $ac_given_srcdir.
3735*6a54128fSAndroid Build Coastguard Worker        # In autoconf-2.50 it is called $srcdir.
3736*6a54128fSAndroid Build Coastguard Worker        test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
3737*6a54128fSAndroid Build Coastguard Worker        case "$ac_given_srcdir" in
3738*6a54128fSAndroid Build Coastguard Worker          .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
3739*6a54128fSAndroid Build Coastguard Worker          /*) top_srcdir="$ac_given_srcdir" ;;
3740*6a54128fSAndroid Build Coastguard Worker          *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
3741*6a54128fSAndroid Build Coastguard Worker        esac
3742*6a54128fSAndroid Build Coastguard Worker        # Treat a directory as a PO directory if and only if it has a
3743*6a54128fSAndroid Build Coastguard Worker        # POTFILES.in file. This allows packages to have multiple PO
3744*6a54128fSAndroid Build Coastguard Worker        # directories under different names or in different locations.
3745*6a54128fSAndroid Build Coastguard Worker        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
3746*6a54128fSAndroid Build Coastguard Worker          rm -f "$ac_dir/POTFILES"
3747*6a54128fSAndroid Build Coastguard Worker          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
3748*6a54128fSAndroid Build Coastguard Worker          gt_tab=`printf '\t'`
3749*6a54128fSAndroid Build Coastguard Worker          cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
3750*6a54128fSAndroid Build Coastguard Worker          POMAKEFILEDEPS="POTFILES.in"
3751*6a54128fSAndroid Build Coastguard Worker          # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
3752*6a54128fSAndroid Build Coastguard Worker          # on $ac_dir but don't depend on user-specified configuration
3753*6a54128fSAndroid Build Coastguard Worker          # parameters.
3754*6a54128fSAndroid Build Coastguard Worker          if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
3755*6a54128fSAndroid Build Coastguard Worker            # The LINGUAS file contains the set of available languages.
3756*6a54128fSAndroid Build Coastguard Worker            if test -n "$OBSOLETE_ALL_LINGUAS"; then
3757*6a54128fSAndroid Build Coastguard Worker              test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
3758*6a54128fSAndroid Build Coastguard Worker            fi
3759*6a54128fSAndroid Build Coastguard Worker            ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
3760*6a54128fSAndroid Build Coastguard Worker            POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
3761*6a54128fSAndroid Build Coastguard Worker          else
3762*6a54128fSAndroid Build Coastguard Worker            # The set of available languages was given in configure.in.
3763*6a54128fSAndroid Build Coastguard Worker            ALL_LINGUAS=$OBSOLETE_ALL_LINGUAS
3764*6a54128fSAndroid Build Coastguard Worker          fi
3765*6a54128fSAndroid Build Coastguard Worker          # Compute POFILES
3766*6a54128fSAndroid Build Coastguard Worker          # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
3767*6a54128fSAndroid Build Coastguard Worker          # Compute UPDATEPOFILES
3768*6a54128fSAndroid Build Coastguard Worker          # as      $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
3769*6a54128fSAndroid Build Coastguard Worker          # Compute DUMMYPOFILES
3770*6a54128fSAndroid Build Coastguard Worker          # as      $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
3771*6a54128fSAndroid Build Coastguard Worker          # Compute GMOFILES
3772*6a54128fSAndroid Build Coastguard Worker          # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
3773*6a54128fSAndroid Build Coastguard Worker          case "$ac_given_srcdir" in
3774*6a54128fSAndroid Build Coastguard Worker            .) srcdirpre= ;;
3775*6a54128fSAndroid Build Coastguard Worker            *) srcdirpre='$(srcdir)/' ;;
3776*6a54128fSAndroid Build Coastguard Worker          esac
3777*6a54128fSAndroid Build Coastguard Worker          POFILES=
3778*6a54128fSAndroid Build Coastguard Worker          UPDATEPOFILES=
3779*6a54128fSAndroid Build Coastguard Worker          DUMMYPOFILES=
3780*6a54128fSAndroid Build Coastguard Worker          GMOFILES=
3781*6a54128fSAndroid Build Coastguard Worker          for lang in $ALL_LINGUAS; do
3782*6a54128fSAndroid Build Coastguard Worker            POFILES="$POFILES $srcdirpre$lang.po"
3783*6a54128fSAndroid Build Coastguard Worker            UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
3784*6a54128fSAndroid Build Coastguard Worker            DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
3785*6a54128fSAndroid Build Coastguard Worker            GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
3786*6a54128fSAndroid Build Coastguard Worker          done
3787*6a54128fSAndroid Build Coastguard Worker          # CATALOGS depends on both $ac_dir and the user's LINGUAS
3788*6a54128fSAndroid Build Coastguard Worker          # environment variable.
3789*6a54128fSAndroid Build Coastguard Worker          INST_LINGUAS=
3790*6a54128fSAndroid Build Coastguard Worker          if test -n "$ALL_LINGUAS"; then
3791*6a54128fSAndroid Build Coastguard Worker            for presentlang in $ALL_LINGUAS; do
3792*6a54128fSAndroid Build Coastguard Worker              useit=no
3793*6a54128fSAndroid Build Coastguard Worker              if test "%UNSET%" != "$LINGUAS"; then
3794*6a54128fSAndroid Build Coastguard Worker                desiredlanguages="$LINGUAS"
3795*6a54128fSAndroid Build Coastguard Worker              else
3796*6a54128fSAndroid Build Coastguard Worker                desiredlanguages="$ALL_LINGUAS"
3797*6a54128fSAndroid Build Coastguard Worker              fi
3798*6a54128fSAndroid Build Coastguard Worker              for desiredlang in $desiredlanguages; do
3799*6a54128fSAndroid Build Coastguard Worker                # Use the presentlang catalog if desiredlang is
3800*6a54128fSAndroid Build Coastguard Worker                #   a. equal to presentlang, or
3801*6a54128fSAndroid Build Coastguard Worker                #   b. a variant of presentlang (because in this case,
3802*6a54128fSAndroid Build Coastguard Worker                #      presentlang can be used as a fallback for messages
3803*6a54128fSAndroid Build Coastguard Worker                #      which are not translated in the desiredlang catalog).
3804*6a54128fSAndroid Build Coastguard Worker                case "$desiredlang" in
3805*6a54128fSAndroid Build Coastguard Worker                  "$presentlang"*) useit=yes;;
3806*6a54128fSAndroid Build Coastguard Worker                esac
3807*6a54128fSAndroid Build Coastguard Worker              done
3808*6a54128fSAndroid Build Coastguard Worker              if test $useit = yes; then
3809*6a54128fSAndroid Build Coastguard Worker                INST_LINGUAS="$INST_LINGUAS $presentlang"
3810*6a54128fSAndroid Build Coastguard Worker              fi
3811*6a54128fSAndroid Build Coastguard Worker            done
3812*6a54128fSAndroid Build Coastguard Worker          fi
3813*6a54128fSAndroid Build Coastguard Worker          CATALOGS=
3814*6a54128fSAndroid Build Coastguard Worker          if test -n "$INST_LINGUAS"; then
3815*6a54128fSAndroid Build Coastguard Worker            for lang in $INST_LINGUAS; do
3816*6a54128fSAndroid Build Coastguard Worker              CATALOGS="$CATALOGS $lang.gmo"
3817*6a54128fSAndroid Build Coastguard Worker            done
3818*6a54128fSAndroid Build Coastguard Worker          fi
3819*6a54128fSAndroid Build Coastguard Worker          test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
3820*6a54128fSAndroid Build Coastguard Worker          sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
3821*6a54128fSAndroid Build Coastguard Worker          for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
3822*6a54128fSAndroid Build Coastguard Worker            if test -f "$f"; then
3823*6a54128fSAndroid Build Coastguard Worker              case "$f" in
3824*6a54128fSAndroid Build Coastguard Worker                *.orig | *.bak | *~) ;;
3825*6a54128fSAndroid Build Coastguard Worker                *) cat "$f" >> "$ac_dir/Makefile" ;;
3826*6a54128fSAndroid Build Coastguard Worker              esac
3827*6a54128fSAndroid Build Coastguard Worker            fi
3828*6a54128fSAndroid Build Coastguard Worker          done
3829*6a54128fSAndroid Build Coastguard Worker        fi
3830*6a54128fSAndroid Build Coastguard Worker        ;;
3831*6a54128fSAndroid Build Coastguard Worker      esac
3832*6a54128fSAndroid Build Coastguard Worker    done]],
3833*6a54128fSAndroid Build Coastguard Worker   [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
3834*6a54128fSAndroid Build Coastguard Worker    # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS.
3835*6a54128fSAndroid Build Coastguard Worker    OBSOLETE_ALL_LINGUAS="$ALL_LINGUAS"
3836*6a54128fSAndroid Build Coastguard Worker    # Capture the value of LINGUAS because we need it to compute CATALOGS.
3837*6a54128fSAndroid Build Coastguard Worker    LINGUAS="${LINGUAS-%UNSET%}"
3838*6a54128fSAndroid Build Coastguard Worker   ])
3839*6a54128fSAndroid Build Coastguard Worker])
3840*6a54128fSAndroid Build Coastguard Worker
3841*6a54128fSAndroid Build Coastguard Workerdnl Postprocesses a Makefile in a directory containing PO files.
3842*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
3843*6a54128fSAndroid Build Coastguard Worker[
3844*6a54128fSAndroid Build Coastguard Worker  # When this code is run, in config.status, two variables have already been
3845*6a54128fSAndroid Build Coastguard Worker  # set:
3846*6a54128fSAndroid Build Coastguard Worker  # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
3847*6a54128fSAndroid Build Coastguard Worker  # - LINGUAS is the value of the environment variable LINGUAS at configure
3848*6a54128fSAndroid Build Coastguard Worker  #   time.
3849*6a54128fSAndroid Build Coastguard Worker
3850*6a54128fSAndroid Build Coastguard Workerchangequote(,)dnl
3851*6a54128fSAndroid Build Coastguard Worker  # Adjust a relative srcdir.
3852*6a54128fSAndroid Build Coastguard Worker  ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
3853*6a54128fSAndroid Build Coastguard Worker  ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
3854*6a54128fSAndroid Build Coastguard Worker  ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
3855*6a54128fSAndroid Build Coastguard Worker  # In autoconf-2.13 it is called $ac_given_srcdir.
3856*6a54128fSAndroid Build Coastguard Worker  # In autoconf-2.50 it is called $srcdir.
3857*6a54128fSAndroid Build Coastguard Worker  test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
3858*6a54128fSAndroid Build Coastguard Worker  case "$ac_given_srcdir" in
3859*6a54128fSAndroid Build Coastguard Worker    .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
3860*6a54128fSAndroid Build Coastguard Worker    /*) top_srcdir="$ac_given_srcdir" ;;
3861*6a54128fSAndroid Build Coastguard Worker    *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
3862*6a54128fSAndroid Build Coastguard Worker  esac
3863*6a54128fSAndroid Build Coastguard Worker
3864*6a54128fSAndroid Build Coastguard Worker  # Find a way to echo strings without interpreting backslash.
3865*6a54128fSAndroid Build Coastguard Worker  if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
3866*6a54128fSAndroid Build Coastguard Worker    gt_echo='echo'
3867*6a54128fSAndroid Build Coastguard Worker  else
3868*6a54128fSAndroid Build Coastguard Worker    if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
3869*6a54128fSAndroid Build Coastguard Worker      gt_echo='printf %s\n'
3870*6a54128fSAndroid Build Coastguard Worker    else
3871*6a54128fSAndroid Build Coastguard Worker      echo_func () {
3872*6a54128fSAndroid Build Coastguard Worker        cat <<EOT
3873*6a54128fSAndroid Build Coastguard Worker$*
3874*6a54128fSAndroid Build Coastguard WorkerEOT
3875*6a54128fSAndroid Build Coastguard Worker      }
3876*6a54128fSAndroid Build Coastguard Worker      gt_echo='echo_func'
3877*6a54128fSAndroid Build Coastguard Worker    fi
3878*6a54128fSAndroid Build Coastguard Worker  fi
3879*6a54128fSAndroid Build Coastguard Worker
3880*6a54128fSAndroid Build Coastguard Worker  # A sed script that extracts the value of VARIABLE from a Makefile.
3881*6a54128fSAndroid Build Coastguard Worker  tab=`printf '\t'`
3882*6a54128fSAndroid Build Coastguard Worker  sed_x_variable='
3883*6a54128fSAndroid Build Coastguard Worker# Test if the hold space is empty.
3884*6a54128fSAndroid Build Coastguard Workerx
3885*6a54128fSAndroid Build Coastguard Workers/P/P/
3886*6a54128fSAndroid Build Coastguard Workerx
3887*6a54128fSAndroid Build Coastguard Workerta
3888*6a54128fSAndroid Build Coastguard Worker# Yes it was empty. Look if we have the expected variable definition.
3889*6a54128fSAndroid Build Coastguard Worker/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{
3890*6a54128fSAndroid Build Coastguard Worker  # Seen the first line of the variable definition.
3891*6a54128fSAndroid Build Coastguard Worker  s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=//
3892*6a54128fSAndroid Build Coastguard Worker  ba
3893*6a54128fSAndroid Build Coastguard Worker}
3894*6a54128fSAndroid Build Coastguard Workerbd
3895*6a54128fSAndroid Build Coastguard Worker:a
3896*6a54128fSAndroid Build Coastguard Worker# Here we are processing a line from the variable definition.
3897*6a54128fSAndroid Build Coastguard Worker# Remove comment, more precisely replace it with a space.
3898*6a54128fSAndroid Build Coastguard Workers/#.*$/ /
3899*6a54128fSAndroid Build Coastguard Worker# See if the line ends in a backslash.
3900*6a54128fSAndroid Build Coastguard Workertb
3901*6a54128fSAndroid Build Coastguard Worker:b
3902*6a54128fSAndroid Build Coastguard Workers/\\$//
3903*6a54128fSAndroid Build Coastguard Worker# Print the line, without the trailing backslash.
3904*6a54128fSAndroid Build Coastguard Workerp
3905*6a54128fSAndroid Build Coastguard Workertc
3906*6a54128fSAndroid Build Coastguard Worker# There was no trailing backslash. The end of the variable definition is
3907*6a54128fSAndroid Build Coastguard Worker# reached. Clear the hold space.
3908*6a54128fSAndroid Build Coastguard Workers/^.*$//
3909*6a54128fSAndroid Build Coastguard Workerx
3910*6a54128fSAndroid Build Coastguard Workerbd
3911*6a54128fSAndroid Build Coastguard Worker:c
3912*6a54128fSAndroid Build Coastguard Worker# A trailing backslash means that the variable definition continues in the
3913*6a54128fSAndroid Build Coastguard Worker# next line. Put a nonempty string into the hold space to indicate this.
3914*6a54128fSAndroid Build Coastguard Workers/^.*$/P/
3915*6a54128fSAndroid Build Coastguard Workerx
3916*6a54128fSAndroid Build Coastguard Worker:d
3917*6a54128fSAndroid Build Coastguard Worker'
3918*6a54128fSAndroid Build Coastguard Workerchangequote([,])dnl
3919*6a54128fSAndroid Build Coastguard Worker
3920*6a54128fSAndroid Build Coastguard Worker  # Set POTFILES to the value of the Makefile variable POTFILES.
3921*6a54128fSAndroid Build Coastguard Worker  sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
3922*6a54128fSAndroid Build Coastguard Worker  POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
3923*6a54128fSAndroid Build Coastguard Worker  # Compute POTFILES_DEPS as
3924*6a54128fSAndroid Build Coastguard Worker  #   $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
3925*6a54128fSAndroid Build Coastguard Worker  POTFILES_DEPS=
3926*6a54128fSAndroid Build Coastguard Worker  for file in $POTFILES; do
3927*6a54128fSAndroid Build Coastguard Worker    POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
3928*6a54128fSAndroid Build Coastguard Worker  done
3929*6a54128fSAndroid Build Coastguard Worker  POMAKEFILEDEPS=""
3930*6a54128fSAndroid Build Coastguard Worker
3931*6a54128fSAndroid Build Coastguard Worker  if test -n "$OBSOLETE_ALL_LINGUAS"; then
3932*6a54128fSAndroid Build Coastguard Worker    test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
3933*6a54128fSAndroid Build Coastguard Worker  fi
3934*6a54128fSAndroid Build Coastguard Worker  if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
3935*6a54128fSAndroid Build Coastguard Worker    # The LINGUAS file contains the set of available languages.
3936*6a54128fSAndroid Build Coastguard Worker    ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
3937*6a54128fSAndroid Build Coastguard Worker    POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
3938*6a54128fSAndroid Build Coastguard Worker  else
3939*6a54128fSAndroid Build Coastguard Worker    # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
3940*6a54128fSAndroid Build Coastguard Worker    sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
3941*6a54128fSAndroid Build Coastguard Worker    ALL_LINGUAS=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
3942*6a54128fSAndroid Build Coastguard Worker  fi
3943*6a54128fSAndroid Build Coastguard Worker  # Compute POFILES
3944*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
3945*6a54128fSAndroid Build Coastguard Worker  # Compute UPDATEPOFILES
3946*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
3947*6a54128fSAndroid Build Coastguard Worker  # Compute DUMMYPOFILES
3948*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
3949*6a54128fSAndroid Build Coastguard Worker  # Compute GMOFILES
3950*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
3951*6a54128fSAndroid Build Coastguard Worker  # Compute PROPERTIESFILES
3952*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(DOMAIN)_$(lang).properties)
3953*6a54128fSAndroid Build Coastguard Worker  # Compute CLASSFILES
3954*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(DOMAIN)_$(lang).class)
3955*6a54128fSAndroid Build Coastguard Worker  # Compute QMFILES
3956*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
3957*6a54128fSAndroid Build Coastguard Worker  # Compute MSGFILES
3958*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
3959*6a54128fSAndroid Build Coastguard Worker  # Compute RESOURCESDLLFILES
3960*6a54128fSAndroid Build Coastguard Worker  # as      $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
3961*6a54128fSAndroid Build Coastguard Worker  case "$ac_given_srcdir" in
3962*6a54128fSAndroid Build Coastguard Worker    .) srcdirpre= ;;
3963*6a54128fSAndroid Build Coastguard Worker    *) srcdirpre='$(srcdir)/' ;;
3964*6a54128fSAndroid Build Coastguard Worker  esac
3965*6a54128fSAndroid Build Coastguard Worker  POFILES=
3966*6a54128fSAndroid Build Coastguard Worker  UPDATEPOFILES=
3967*6a54128fSAndroid Build Coastguard Worker  DUMMYPOFILES=
3968*6a54128fSAndroid Build Coastguard Worker  GMOFILES=
3969*6a54128fSAndroid Build Coastguard Worker  PROPERTIESFILES=
3970*6a54128fSAndroid Build Coastguard Worker  CLASSFILES=
3971*6a54128fSAndroid Build Coastguard Worker  QMFILES=
3972*6a54128fSAndroid Build Coastguard Worker  MSGFILES=
3973*6a54128fSAndroid Build Coastguard Worker  RESOURCESDLLFILES=
3974*6a54128fSAndroid Build Coastguard Worker  for lang in $ALL_LINGUAS; do
3975*6a54128fSAndroid Build Coastguard Worker    POFILES="$POFILES $srcdirpre$lang.po"
3976*6a54128fSAndroid Build Coastguard Worker    UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
3977*6a54128fSAndroid Build Coastguard Worker    DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
3978*6a54128fSAndroid Build Coastguard Worker    GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
3979*6a54128fSAndroid Build Coastguard Worker    PROPERTIESFILES="$PROPERTIESFILES \$(srcdir)/\$(DOMAIN)_$lang.properties"
3980*6a54128fSAndroid Build Coastguard Worker    CLASSFILES="$CLASSFILES \$(srcdir)/\$(DOMAIN)_$lang.class"
3981*6a54128fSAndroid Build Coastguard Worker    QMFILES="$QMFILES $srcdirpre$lang.qm"
3982*6a54128fSAndroid Build Coastguard Worker    frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
3983*6a54128fSAndroid Build Coastguard Worker    MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
3984*6a54128fSAndroid Build Coastguard Worker    frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
3985*6a54128fSAndroid Build Coastguard Worker    RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
3986*6a54128fSAndroid Build Coastguard Worker  done
3987*6a54128fSAndroid Build Coastguard Worker  # CATALOGS depends on both $ac_dir and the user's LINGUAS
3988*6a54128fSAndroid Build Coastguard Worker  # environment variable.
3989*6a54128fSAndroid Build Coastguard Worker  INST_LINGUAS=
3990*6a54128fSAndroid Build Coastguard Worker  if test -n "$ALL_LINGUAS"; then
3991*6a54128fSAndroid Build Coastguard Worker    for presentlang in $ALL_LINGUAS; do
3992*6a54128fSAndroid Build Coastguard Worker      useit=no
3993*6a54128fSAndroid Build Coastguard Worker      if test "%UNSET%" != "$LINGUAS"; then
3994*6a54128fSAndroid Build Coastguard Worker        desiredlanguages="$LINGUAS"
3995*6a54128fSAndroid Build Coastguard Worker      else
3996*6a54128fSAndroid Build Coastguard Worker        desiredlanguages="$ALL_LINGUAS"
3997*6a54128fSAndroid Build Coastguard Worker      fi
3998*6a54128fSAndroid Build Coastguard Worker      for desiredlang in $desiredlanguages; do
3999*6a54128fSAndroid Build Coastguard Worker        # Use the presentlang catalog if desiredlang is
4000*6a54128fSAndroid Build Coastguard Worker        #   a. equal to presentlang, or
4001*6a54128fSAndroid Build Coastguard Worker        #   b. a variant of presentlang (because in this case,
4002*6a54128fSAndroid Build Coastguard Worker        #      presentlang can be used as a fallback for messages
4003*6a54128fSAndroid Build Coastguard Worker        #      which are not translated in the desiredlang catalog).
4004*6a54128fSAndroid Build Coastguard Worker        case "$desiredlang" in
4005*6a54128fSAndroid Build Coastguard Worker          "$presentlang"*) useit=yes;;
4006*6a54128fSAndroid Build Coastguard Worker        esac
4007*6a54128fSAndroid Build Coastguard Worker      done
4008*6a54128fSAndroid Build Coastguard Worker      if test $useit = yes; then
4009*6a54128fSAndroid Build Coastguard Worker        INST_LINGUAS="$INST_LINGUAS $presentlang"
4010*6a54128fSAndroid Build Coastguard Worker      fi
4011*6a54128fSAndroid Build Coastguard Worker    done
4012*6a54128fSAndroid Build Coastguard Worker  fi
4013*6a54128fSAndroid Build Coastguard Worker  CATALOGS=
4014*6a54128fSAndroid Build Coastguard Worker  JAVACATALOGS=
4015*6a54128fSAndroid Build Coastguard Worker  QTCATALOGS=
4016*6a54128fSAndroid Build Coastguard Worker  TCLCATALOGS=
4017*6a54128fSAndroid Build Coastguard Worker  CSHARPCATALOGS=
4018*6a54128fSAndroid Build Coastguard Worker  if test -n "$INST_LINGUAS"; then
4019*6a54128fSAndroid Build Coastguard Worker    for lang in $INST_LINGUAS; do
4020*6a54128fSAndroid Build Coastguard Worker      CATALOGS="$CATALOGS $lang.gmo"
4021*6a54128fSAndroid Build Coastguard Worker      JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
4022*6a54128fSAndroid Build Coastguard Worker      QTCATALOGS="$QTCATALOGS $lang.qm"
4023*6a54128fSAndroid Build Coastguard Worker      frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
4024*6a54128fSAndroid Build Coastguard Worker      TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
4025*6a54128fSAndroid Build Coastguard Worker      frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
4026*6a54128fSAndroid Build Coastguard Worker      CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
4027*6a54128fSAndroid Build Coastguard Worker    done
4028*6a54128fSAndroid Build Coastguard Worker  fi
4029*6a54128fSAndroid Build Coastguard Worker
4030*6a54128fSAndroid Build Coastguard Worker  sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
4031*6a54128fSAndroid Build Coastguard Worker  tab=`printf '\t'`
4032*6a54128fSAndroid Build Coastguard Worker  if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
4033*6a54128fSAndroid Build Coastguard Worker    # Add dependencies that cannot be formulated as a simple suffix rule.
4034*6a54128fSAndroid Build Coastguard Worker    for lang in $ALL_LINGUAS; do
4035*6a54128fSAndroid Build Coastguard Worker      frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
4036*6a54128fSAndroid Build Coastguard Worker      cat >> "$ac_file.tmp" <<EOF
4037*6a54128fSAndroid Build Coastguard Worker$frobbedlang.msg: $lang.po
4038*6a54128fSAndroid Build Coastguard Worker${tab}@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
4039*6a54128fSAndroid Build Coastguard Worker${tab}\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
4040*6a54128fSAndroid Build Coastguard WorkerEOF
4041*6a54128fSAndroid Build Coastguard Worker    done
4042*6a54128fSAndroid Build Coastguard Worker  fi
4043*6a54128fSAndroid Build Coastguard Worker  if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
4044*6a54128fSAndroid Build Coastguard Worker    # Add dependencies that cannot be formulated as a simple suffix rule.
4045*6a54128fSAndroid Build Coastguard Worker    for lang in $ALL_LINGUAS; do
4046*6a54128fSAndroid Build Coastguard Worker      frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
4047*6a54128fSAndroid Build Coastguard Worker      cat >> "$ac_file.tmp" <<EOF
4048*6a54128fSAndroid Build Coastguard Worker$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
4049*6a54128fSAndroid Build Coastguard Worker${tab}@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
4050*6a54128fSAndroid Build Coastguard Worker${tab}\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
4051*6a54128fSAndroid Build Coastguard WorkerEOF
4052*6a54128fSAndroid Build Coastguard Worker    done
4053*6a54128fSAndroid Build Coastguard Worker  fi
4054*6a54128fSAndroid Build Coastguard Worker  if test -n "$POMAKEFILEDEPS"; then
4055*6a54128fSAndroid Build Coastguard Worker    cat >> "$ac_file.tmp" <<EOF
4056*6a54128fSAndroid Build Coastguard WorkerMakefile: $POMAKEFILEDEPS
4057*6a54128fSAndroid Build Coastguard WorkerEOF
4058*6a54128fSAndroid Build Coastguard Worker  fi
4059*6a54128fSAndroid Build Coastguard Worker  mv "$ac_file.tmp" "$ac_file"
4060*6a54128fSAndroid Build Coastguard Worker])
4061*6a54128fSAndroid Build Coastguard Worker
4062*6a54128fSAndroid Build Coastguard Workerdnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
4063*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_XGETTEXT_OPTION_INIT],
4064*6a54128fSAndroid Build Coastguard Worker[
4065*6a54128fSAndroid Build Coastguard Worker  XGETTEXT_EXTRA_OPTIONS=
4066*6a54128fSAndroid Build Coastguard Worker])
4067*6a54128fSAndroid Build Coastguard Worker
4068*6a54128fSAndroid Build Coastguard Workerdnl Registers an option to be passed to xgettext in the po subdirectory.
4069*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_XGETTEXT_OPTION],
4070*6a54128fSAndroid Build Coastguard Worker[
4071*6a54128fSAndroid Build Coastguard Worker  AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
4072*6a54128fSAndroid Build Coastguard Worker  XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
4073*6a54128fSAndroid Build Coastguard Worker])
4074*6a54128fSAndroid Build Coastguard Worker
4075*6a54128fSAndroid Build Coastguard Worker# progtest.m4 serial 8 (gettext-0.20.2)
4076*6a54128fSAndroid Build Coastguard Workerdnl Copyright (C) 1996-2003, 2005, 2008-2020 Free Software Foundation, Inc.
4077*6a54128fSAndroid Build Coastguard Workerdnl This file is free software; the Free Software Foundation
4078*6a54128fSAndroid Build Coastguard Workerdnl gives unlimited permission to copy and/or distribute it,
4079*6a54128fSAndroid Build Coastguard Workerdnl with or without modifications, as long as this notice is preserved.
4080*6a54128fSAndroid Build Coastguard Workerdnl
4081*6a54128fSAndroid Build Coastguard Workerdnl This file can be used in projects which are not available under
4082*6a54128fSAndroid Build Coastguard Workerdnl the GNU General Public License or the GNU Lesser General Public
4083*6a54128fSAndroid Build Coastguard Workerdnl License but which still want to provide support for the GNU gettext
4084*6a54128fSAndroid Build Coastguard Workerdnl functionality.
4085*6a54128fSAndroid Build Coastguard Workerdnl Please note that the actual code of the GNU gettext library is covered
4086*6a54128fSAndroid Build Coastguard Workerdnl by the GNU Lesser General Public License, and the rest of the GNU
4087*6a54128fSAndroid Build Coastguard Workerdnl gettext package is covered by the GNU General Public License.
4088*6a54128fSAndroid Build Coastguard Workerdnl They are *not* in the public domain.
4089*6a54128fSAndroid Build Coastguard Worker
4090*6a54128fSAndroid Build Coastguard Workerdnl Authors:
4091*6a54128fSAndroid Build Coastguard Workerdnl   Ulrich Drepper <[email protected]>, 1996.
4092*6a54128fSAndroid Build Coastguard Worker
4093*6a54128fSAndroid Build Coastguard WorkerAC_PREREQ([2.50])
4094*6a54128fSAndroid Build Coastguard Worker
4095*6a54128fSAndroid Build Coastguard Worker# Search path for a program which passes the given test.
4096*6a54128fSAndroid Build Coastguard Worker
4097*6a54128fSAndroid Build Coastguard Workerdnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
4098*6a54128fSAndroid Build Coastguard Workerdnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
4099*6a54128fSAndroid Build Coastguard WorkerAC_DEFUN([AM_PATH_PROG_WITH_TEST],
4100*6a54128fSAndroid Build Coastguard Worker[
4101*6a54128fSAndroid Build Coastguard Worker# Prepare PATH_SEPARATOR.
4102*6a54128fSAndroid Build Coastguard Worker# The user is always right.
4103*6a54128fSAndroid Build Coastguard Workerif test "${PATH_SEPARATOR+set}" != set; then
4104*6a54128fSAndroid Build Coastguard Worker  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
4105*6a54128fSAndroid Build Coastguard Worker  # contains only /bin. Note that ksh looks also at the FPATH variable,
4106*6a54128fSAndroid Build Coastguard Worker  # so we have to set that as well for the test.
4107*6a54128fSAndroid Build Coastguard Worker  PATH_SEPARATOR=:
4108*6a54128fSAndroid Build Coastguard Worker  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
4109*6a54128fSAndroid Build Coastguard Worker    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
4110*6a54128fSAndroid Build Coastguard Worker           || PATH_SEPARATOR=';'
4111*6a54128fSAndroid Build Coastguard Worker       }
4112*6a54128fSAndroid Build Coastguard Workerfi
4113*6a54128fSAndroid Build Coastguard Worker
4114*6a54128fSAndroid Build Coastguard Worker# Find out how to test for executable files. Don't use a zero-byte file,
4115*6a54128fSAndroid Build Coastguard Worker# as systems may use methods other than mode bits to determine executability.
4116*6a54128fSAndroid Build Coastguard Workercat >conf$$.file <<_ASEOF
4117*6a54128fSAndroid Build Coastguard Worker#! /bin/sh
4118*6a54128fSAndroid Build Coastguard Workerexit 0
4119*6a54128fSAndroid Build Coastguard Worker_ASEOF
4120*6a54128fSAndroid Build Coastguard Workerchmod +x conf$$.file
4121*6a54128fSAndroid Build Coastguard Workerif test -x conf$$.file >/dev/null 2>&1; then
4122*6a54128fSAndroid Build Coastguard Worker  ac_executable_p="test -x"
4123*6a54128fSAndroid Build Coastguard Workerelse
4124*6a54128fSAndroid Build Coastguard Worker  ac_executable_p="test -f"
4125*6a54128fSAndroid Build Coastguard Workerfi
4126*6a54128fSAndroid Build Coastguard Workerrm -f conf$$.file
4127*6a54128fSAndroid Build Coastguard Worker
4128*6a54128fSAndroid Build Coastguard Worker# Extract the first word of "$2", so it can be a program name with args.
4129*6a54128fSAndroid Build Coastguard Workerset dummy $2; ac_word=[$]2
4130*6a54128fSAndroid Build Coastguard WorkerAC_MSG_CHECKING([for $ac_word])
4131*6a54128fSAndroid Build Coastguard WorkerAC_CACHE_VAL([ac_cv_path_$1],
4132*6a54128fSAndroid Build Coastguard Worker[case "[$]$1" in
4133*6a54128fSAndroid Build Coastguard Worker  [[\\/]]* | ?:[[\\/]]*)
4134*6a54128fSAndroid Build Coastguard Worker    ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
4135*6a54128fSAndroid Build Coastguard Worker    ;;
4136*6a54128fSAndroid Build Coastguard Worker  *)
4137*6a54128fSAndroid Build Coastguard Worker    ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
4138*6a54128fSAndroid Build Coastguard Worker    for ac_dir in ifelse([$5], , $PATH, [$5]); do
4139*6a54128fSAndroid Build Coastguard Worker      IFS="$ac_save_IFS"
4140*6a54128fSAndroid Build Coastguard Worker      test -z "$ac_dir" && ac_dir=.
4141*6a54128fSAndroid Build Coastguard Worker      for ac_exec_ext in '' $ac_executable_extensions; do
4142*6a54128fSAndroid Build Coastguard Worker        if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
4143*6a54128fSAndroid Build Coastguard Worker          echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD
4144*6a54128fSAndroid Build Coastguard Worker          if [$3]; then
4145*6a54128fSAndroid Build Coastguard Worker            ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
4146*6a54128fSAndroid Build Coastguard Worker            break 2
4147*6a54128fSAndroid Build Coastguard Worker          fi
4148*6a54128fSAndroid Build Coastguard Worker        fi
4149*6a54128fSAndroid Build Coastguard Worker      done
4150*6a54128fSAndroid Build Coastguard Worker    done
4151*6a54128fSAndroid Build Coastguard Worker    IFS="$ac_save_IFS"
4152*6a54128fSAndroid Build Coastguard Workerdnl If no 4th arg is given, leave the cache variable unset,
4153*6a54128fSAndroid Build Coastguard Workerdnl so AC_PATH_PROGS will keep looking.
4154*6a54128fSAndroid Build Coastguard Workerifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
4155*6a54128fSAndroid Build Coastguard Worker])dnl
4156*6a54128fSAndroid Build Coastguard Worker    ;;
4157*6a54128fSAndroid Build Coastguard Workeresac])dnl
4158*6a54128fSAndroid Build Coastguard Worker$1="$ac_cv_path_$1"
4159*6a54128fSAndroid Build Coastguard Workerif test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
4160*6a54128fSAndroid Build Coastguard Worker  AC_MSG_RESULT([$][$1])
4161*6a54128fSAndroid Build Coastguard Workerelse
4162*6a54128fSAndroid Build Coastguard Worker  AC_MSG_RESULT([no])
4163*6a54128fSAndroid Build Coastguard Workerfi
4164*6a54128fSAndroid Build Coastguard WorkerAC_SUBST([$1])dnl
4165*6a54128fSAndroid Build Coastguard Worker])
4166*6a54128fSAndroid Build Coastguard Worker
4167*6a54128fSAndroid Build Coastguard Workerm4_include([acinclude.m4])
4168