xref: /aosp_15_r20/external/libpng/configure.ac (revision a67afe4df73cf47866eedc69947994b8ff839aba)
1*a67afe4dSAndroid Build Coastguard Worker# configure.ac
2*a67afe4dSAndroid Build Coastguard Worker
3*a67afe4dSAndroid Build Coastguard Worker# Copyright (c) 2018-2024 Cosmin Truta
4*a67afe4dSAndroid Build Coastguard Worker# Copyright (c) 2004-2016 Glenn Randers-Pehrson
5*a67afe4dSAndroid Build Coastguard Worker
6*a67afe4dSAndroid Build Coastguard Worker# This code is released under the libpng license.
7*a67afe4dSAndroid Build Coastguard Worker# For conditions of distribution and use, see the disclaimer
8*a67afe4dSAndroid Build Coastguard Worker# and license in png.h
9*a67afe4dSAndroid Build Coastguard Worker
10*a67afe4dSAndroid Build Coastguard Workerdnl Process this file with autoconf to produce a configure script.
11*a67afe4dSAndroid Build Coastguard Workerdnl
12*a67afe4dSAndroid Build Coastguard Workerdnl Minor upgrades (compatible ABI): increment the package version
13*a67afe4dSAndroid Build Coastguard Workerdnl (third field in two places below) and set the PNGLIB_RELEASE
14*a67afe4dSAndroid Build Coastguard Workerdnl variable.
15*a67afe4dSAndroid Build Coastguard Workerdnl
16*a67afe4dSAndroid Build Coastguard Workerdnl Major upgrades (incompatible ABI): increment the package major
17*a67afe4dSAndroid Build Coastguard Workerdnl version (second field, or first if desired), set the minor
18*a67afe4dSAndroid Build Coastguard Workerdnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
19*a67afe4dSAndroid Build Coastguard Workerdnl Makefile.am to upgrade the package name.
20*a67afe4dSAndroid Build Coastguard Worker
21*a67afe4dSAndroid Build Coastguard Workerdnl This is here to prevent earlier autoconf from being used, it
22*a67afe4dSAndroid Build Coastguard Workerdnl should not be necessary to regenerate configure if the time
23*a67afe4dSAndroid Build Coastguard Workerdnl stamps are correct
24*a67afe4dSAndroid Build Coastguard WorkerAC_PREREQ([2.68])
25*a67afe4dSAndroid Build Coastguard Worker
26*a67afe4dSAndroid Build Coastguard Workerdnl Version number stuff here:
27*a67afe4dSAndroid Build Coastguard Worker
28*a67afe4dSAndroid Build Coastguard WorkerAC_INIT([libpng],[1.6.44],[[email protected]])
29*a67afe4dSAndroid Build Coastguard WorkerAC_CONFIG_MACRO_DIR([scripts/autoconf])
30*a67afe4dSAndroid Build Coastguard Worker
31*a67afe4dSAndroid Build Coastguard Worker# libpng does not follow GNU file name conventions (hence 'foreign')
32*a67afe4dSAndroid Build Coastguard Worker# color-tests requires automake 1.11 or later
33*a67afe4dSAndroid Build Coastguard Worker# silent-rules requires automake 1.11 or later
34*a67afe4dSAndroid Build Coastguard Worker# dist-xz requires automake 1.11 or later
35*a67afe4dSAndroid Build Coastguard Worker# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
36*a67afe4dSAndroid Build Coastguard Worker# 1.13 is required for parallel tests
37*a67afe4dSAndroid Build Coastguard WorkerAM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
38*a67afe4dSAndroid Build Coastguard Worker# The following line causes --disable-maintainer-mode to be the default to
39*a67afe4dSAndroid Build Coastguard Worker# configure. This is necessary because libpng distributions cannot rely on the
40*a67afe4dSAndroid Build Coastguard Worker# time stamps of the autotools generated files being correct
41*a67afe4dSAndroid Build Coastguard WorkerAM_MAINTAINER_MODE
42*a67afe4dSAndroid Build Coastguard Worker
43*a67afe4dSAndroid Build Coastguard Workerdnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
44*a67afe4dSAndroid Build Coastguard Workerdnl version; aclocal.m4 will generate a failure if you use a prior version of
45*a67afe4dSAndroid Build Coastguard Workerdnl automake, so the following is not necessary (and is not defined anyway):
46*a67afe4dSAndroid Build Coastguard Workerdnl AM_PREREQ([1.11.2])
47*a67afe4dSAndroid Build Coastguard Workerdnl stop configure from automagically running automake
48*a67afe4dSAndroid Build Coastguard Worker
49*a67afe4dSAndroid Build Coastguard WorkerPNGLIB_VERSION=1.6.44
50*a67afe4dSAndroid Build Coastguard WorkerPNGLIB_MAJOR=1
51*a67afe4dSAndroid Build Coastguard WorkerPNGLIB_MINOR=6
52*a67afe4dSAndroid Build Coastguard WorkerPNGLIB_RELEASE=44
53*a67afe4dSAndroid Build Coastguard Worker
54*a67afe4dSAndroid Build Coastguard Workerdnl End of version number stuff
55*a67afe4dSAndroid Build Coastguard Worker
56*a67afe4dSAndroid Build Coastguard WorkerAC_CONFIG_SRCDIR([pngget.c])
57*a67afe4dSAndroid Build Coastguard WorkerAC_CONFIG_HEADERS([config.h])
58*a67afe4dSAndroid Build Coastguard Worker
59*a67afe4dSAndroid Build Coastguard Worker# Check the basic programs.
60*a67afe4dSAndroid Build Coastguard WorkerAC_LANG([C])
61*a67afe4dSAndroid Build Coastguard WorkerAC_PROG_CC
62*a67afe4dSAndroid Build Coastguard WorkerAM_PROG_AS
63*a67afe4dSAndroid Build Coastguard WorkerLT_PATH_LD
64*a67afe4dSAndroid Build Coastguard WorkerAC_PROG_CPP
65*a67afe4dSAndroid Build Coastguard WorkerAC_PROG_AWK
66*a67afe4dSAndroid Build Coastguard WorkerAC_PROG_INSTALL
67*a67afe4dSAndroid Build Coastguard WorkerAC_PROG_LN_S
68*a67afe4dSAndroid Build Coastguard WorkerAC_PROG_MAKE_SET
69*a67afe4dSAndroid Build Coastguard Worker
70*a67afe4dSAndroid Build Coastguard Workerdnl libtool/libtoolize; version 2.4.2 is the tested version. This or any
71*a67afe4dSAndroid Build Coastguard Workerdnl compatible later version may be used
72*a67afe4dSAndroid Build Coastguard WorkerLT_INIT([win32-dll])
73*a67afe4dSAndroid Build Coastguard WorkerLT_PREREQ([2.4.2])
74*a67afe4dSAndroid Build Coastguard Worker
75*a67afe4dSAndroid Build Coastguard Workerdnl Declare the AWK variable.
76*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_VAR(AWK, [AWK language processor])
77*a67afe4dSAndroid Build Coastguard Worker
78*a67afe4dSAndroid Build Coastguard Worker# Some awk implementations crash when confronted with pnglibconf.dfa.
79*a67afe4dSAndroid Build Coastguard Worker# Run a test now, to make sure this doesn't happen.
80*a67afe4dSAndroid Build Coastguard WorkerAC_MSG_CHECKING([if awk ($AWK) works])
81*a67afe4dSAndroid Build Coastguard Workerif ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
82*a67afe4dSAndroid Build Coastguard Worker   ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
83*a67afe4dSAndroid Build Coastguard Worker   ${srcdir}/pngusr.dfa 1>&2
84*a67afe4dSAndroid Build Coastguard Workerthen
85*a67afe4dSAndroid Build Coastguard Worker   AC_MSG_RESULT([yes])
86*a67afe4dSAndroid Build Coastguard Workerelse
87*a67afe4dSAndroid Build Coastguard Worker   AC_MSG_FAILURE([no], 1)
88*a67afe4dSAndroid Build Coastguard Workerfi
89*a67afe4dSAndroid Build Coastguard Worker
90*a67afe4dSAndroid Build Coastguard Worker# This is a remnant of the old cc -E validation, where it may have been
91*a67afe4dSAndroid Build Coastguard Worker# necessary to use a different preprocessor for .dfn files
92*a67afe4dSAndroid Build Coastguard WorkerDFNCPP="$CPP"
93*a67afe4dSAndroid Build Coastguard WorkerAC_SUBST(DFNCPP)
94*a67afe4dSAndroid Build Coastguard Worker
95*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([tests],
96*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([--disable-tests],
97*a67afe4dSAndroid Build Coastguard Worker      [do not build the test programs (default is to build)]),
98*a67afe4dSAndroid Build Coastguard Worker      [enable_tests="$enableval"],
99*a67afe4dSAndroid Build Coastguard Worker      [enable_tests=yes])
100*a67afe4dSAndroid Build Coastguard Worker
101*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([ENABLE_TESTS],
102*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_tests" != "no"])
103*a67afe4dSAndroid Build Coastguard Worker
104*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([tools],
105*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([--disable-tools],
106*a67afe4dSAndroid Build Coastguard Worker      [do not build the auxiliary tools (default is to build)]),
107*a67afe4dSAndroid Build Coastguard Worker      [enable_tools="$enableval"],
108*a67afe4dSAndroid Build Coastguard Worker      [enable_tools=yes])
109*a67afe4dSAndroid Build Coastguard Worker
110*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([ENABLE_TOOLS],
111*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_tools" != "no"])
112*a67afe4dSAndroid Build Coastguard Worker
113*a67afe4dSAndroid Build Coastguard Worker# -Werror cannot be passed to GCC in CFLAGS because configure will fail
114*a67afe4dSAndroid Build Coastguard Worker# (it checks the compiler with a program that generates a warning).
115*a67afe4dSAndroid Build Coastguard Worker# Add the following option to deal with this:
116*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_VAR(PNG_COPTS,
117*a67afe4dSAndroid Build Coastguard Worker   [additional flags for the C compiler, to be used for options that would]
118*a67afe4dSAndroid Build Coastguard Worker   [cause configure itself to fail])
119*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE(werror,
120*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-werror[=OPT]]]],
121*a67afe4dSAndroid Build Coastguard Worker      [Pass -Werror or the given argument to the compiler if it is supported]),
122*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_werror" = "yes" && enable_werror="-Werror"
123*a67afe4dSAndroid Build Coastguard Worker    if test "$enable_werror" != "no"; then
124*a67afe4dSAndroid Build Coastguard Worker      sav_CFLAGS="$CFLAGS"
125*a67afe4dSAndroid Build Coastguard Worker      CFLAGS="$enable_werror $CFLAGS"
126*a67afe4dSAndroid Build Coastguard Worker      AC_MSG_CHECKING([if the compiler allows $enable_werror])
127*a67afe4dSAndroid Build Coastguard Worker      AC_COMPILE_IFELSE(
128*a67afe4dSAndroid Build Coastguard Worker         [AC_LANG_SOURCE([
129*a67afe4dSAndroid Build Coastguard Worker            [int main(int argc, char **argv){]
130*a67afe4dSAndroid Build Coastguard Worker            [return argv[argc-1][0];]
131*a67afe4dSAndroid Build Coastguard Worker            [}]])],
132*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_RESULT(yes)
133*a67afe4dSAndroid Build Coastguard Worker         PNG_COPTS="$PNG_COPTS $enable_werror",
134*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_RESULT(no))
135*a67afe4dSAndroid Build Coastguard Worker      CFLAGS="$sav_CFLAGS"
136*a67afe4dSAndroid Build Coastguard Worker    fi],)
137*a67afe4dSAndroid Build Coastguard Worker
138*a67afe4dSAndroid Build Coastguard Worker# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89.
139*a67afe4dSAndroid Build Coastguard Worker# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining
140*a67afe4dSAndroid Build Coastguard Worker# _POSIX_SOURCE to 1. This is incompatible with the new default mode, so
141*a67afe4dSAndroid Build Coastguard Worker# we test for that and force the "-std=c89" compiler option:
142*a67afe4dSAndroid Build Coastguard WorkerAC_MSG_CHECKING([if we need to force back C standard to C89])
143*a67afe4dSAndroid Build Coastguard WorkerAC_COMPILE_IFELSE(
144*a67afe4dSAndroid Build Coastguard Worker   [AC_LANG_PROGRAM([
145*a67afe4dSAndroid Build Coastguard Worker      [#define _POSIX_SOURCE 1]
146*a67afe4dSAndroid Build Coastguard Worker      [#include <stdio.h>]
147*a67afe4dSAndroid Build Coastguard Worker   ])],
148*a67afe4dSAndroid Build Coastguard Worker   AC_MSG_RESULT(no),[
149*a67afe4dSAndroid Build Coastguard Worker      if test "x$GCC" != "xyes"; then
150*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_ERROR(
151*a67afe4dSAndroid Build Coastguard Worker            [Forcing back to C89 is required but the flags are only known for GCC])
152*a67afe4dSAndroid Build Coastguard Worker      fi
153*a67afe4dSAndroid Build Coastguard Worker   AC_MSG_RESULT(yes)
154*a67afe4dSAndroid Build Coastguard Worker   CFLAGS="$CFLAGS -std=c89"
155*a67afe4dSAndroid Build Coastguard Worker])
156*a67afe4dSAndroid Build Coastguard Worker
157*a67afe4dSAndroid Build Coastguard Worker# Checks for structures and compiler characteristics.
158*a67afe4dSAndroid Build Coastguard WorkerAC_STRUCT_TM
159*a67afe4dSAndroid Build Coastguard WorkerAC_C_RESTRICT
160*a67afe4dSAndroid Build Coastguard Worker
161*a67afe4dSAndroid Build Coastguard Worker# Checks for library functions.
162*a67afe4dSAndroid Build Coastguard WorkerAC_CHECK_FUNCS([pow], ,
163*a67afe4dSAndroid Build Coastguard Worker  [AC_CHECK_LIB([m], [pow], , [AC_MSG_ERROR([cannot find pow])])])
164*a67afe4dSAndroid Build Coastguard Worker
165*a67afe4dSAndroid Build Coastguard Worker# Some later POSIX 1003.1 functions are required for test programs, failure
166*a67afe4dSAndroid Build Coastguard Worker# here is soft (the corresponding test program is not built).
167*a67afe4dSAndroid Build Coastguard WorkerAC_CHECK_FUNC([clock_gettime], , [AC_MSG_WARN([not building timepng])])
168*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
169*a67afe4dSAndroid Build Coastguard Worker
170*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_WITH(zlib-prefix,
171*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--with-zlib-prefix]]],
172*a67afe4dSAndroid Build Coastguard Worker      [prefix that may have been used in installed zlib]),
173*a67afe4dSAndroid Build Coastguard Worker      [ZPREFIX=${withval}],
174*a67afe4dSAndroid Build Coastguard Worker      [ZPREFIX='z_'])
175*a67afe4dSAndroid Build Coastguard WorkerAC_CHECK_LIB([z], [zlibVersion], ,
176*a67afe4dSAndroid Build Coastguard Worker  [AC_CHECK_LIB([z], [${ZPREFIX}zlibVersion], ,
177*a67afe4dSAndroid Build Coastguard Worker     [AC_MSG_ERROR([zlib not installed])])])
178*a67afe4dSAndroid Build Coastguard Worker
179*a67afe4dSAndroid Build Coastguard Worker# The following is for pngvalid, to ensure it catches FP errors even on
180*a67afe4dSAndroid Build Coastguard Worker# platforms that don't enable FP exceptions, the function appears in the math
181*a67afe4dSAndroid Build Coastguard Worker# library (typically), it's not an error if it is not found.
182*a67afe4dSAndroid Build Coastguard WorkerAC_CHECK_LIB([m], [feenableexcept])
183*a67afe4dSAndroid Build Coastguard WorkerAC_CHECK_FUNCS([feenableexcept])
184*a67afe4dSAndroid Build Coastguard Worker
185*a67afe4dSAndroid Build Coastguard WorkerAC_MSG_CHECKING([if using Solaris linker])
186*a67afe4dSAndroid Build Coastguard WorkerSLD=`$LD --version 2>&1 | grep Solaris`
187*a67afe4dSAndroid Build Coastguard Workerif test "$SLD"; then
188*a67afe4dSAndroid Build Coastguard Worker    have_solaris_ld=yes
189*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_RESULT(yes)
190*a67afe4dSAndroid Build Coastguard Workerelse
191*a67afe4dSAndroid Build Coastguard Worker    have_solaris_ld=no
192*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_RESULT(no)
193*a67afe4dSAndroid Build Coastguard Workerfi
194*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
195*a67afe4dSAndroid Build Coastguard Worker
196*a67afe4dSAndroid Build Coastguard WorkerAC_MSG_CHECKING([if libraries can be versioned])
197*a67afe4dSAndroid Build Coastguard Worker# Special case for PE/COFF platforms: ld reports
198*a67afe4dSAndroid Build Coastguard Worker# support for version-script, but doesn't actually
199*a67afe4dSAndroid Build Coastguard Worker# DO anything with it.
200*a67afe4dSAndroid Build Coastguard Workercase $host in
201*a67afe4dSAndroid Build Coastguard Worker*cygwin* | *mingw32* | *interix* )
202*a67afe4dSAndroid Build Coastguard Worker    have_ld_version_script=no
203*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_RESULT(no)
204*a67afe4dSAndroid Build Coastguard Worker;;
205*a67afe4dSAndroid Build Coastguard Worker* )
206*a67afe4dSAndroid Build Coastguard Worker
207*a67afe4dSAndroid Build Coastguard Workerif test "$have_solaris_ld" = "yes"; then
208*a67afe4dSAndroid Build Coastguard Worker    GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
209*a67afe4dSAndroid Build Coastguard Workerelse
210*a67afe4dSAndroid Build Coastguard Worker    GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
211*a67afe4dSAndroid Build Coastguard Workerfi
212*a67afe4dSAndroid Build Coastguard Worker
213*a67afe4dSAndroid Build Coastguard Workerif test "$GLD"; then
214*a67afe4dSAndroid Build Coastguard Worker    have_ld_version_script=yes
215*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_RESULT(yes)
216*a67afe4dSAndroid Build Coastguard Workerelse
217*a67afe4dSAndroid Build Coastguard Worker    have_ld_version_script=no
218*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_RESULT(no)
219*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_WARN(*** You have not enabled versioned symbols.)
220*a67afe4dSAndroid Build Coastguard Workerfi
221*a67afe4dSAndroid Build Coastguard Worker;;
222*a67afe4dSAndroid Build Coastguard Workeresac
223*a67afe4dSAndroid Build Coastguard Worker
224*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
225*a67afe4dSAndroid Build Coastguard Worker
226*a67afe4dSAndroid Build Coastguard Workerif test "$have_ld_version_script" = "yes"; then
227*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_CHECKING([for symbol prefix])
228*a67afe4dSAndroid Build Coastguard Worker    SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
229*a67afe4dSAndroid Build Coastguard Worker                  | ${CPP:-${CC:-gcc} -E} - 2>&1 \
230*a67afe4dSAndroid Build Coastguard Worker                  | ${EGREP:-grep} "^PREFIX=" \
231*a67afe4dSAndroid Build Coastguard Worker                  | ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
232*a67afe4dSAndroid Build Coastguard Worker    AC_SUBST(SYMBOL_PREFIX)
233*a67afe4dSAndroid Build Coastguard Worker    AC_MSG_RESULT($SYMBOL_PREFIX)
234*a67afe4dSAndroid Build Coastguard Workerfi
235*a67afe4dSAndroid Build Coastguard Worker
236*a67afe4dSAndroid Build Coastguard Worker# Substitutions for .in files
237*a67afe4dSAndroid Build Coastguard WorkerAC_SUBST(PNGLIB_VERSION)
238*a67afe4dSAndroid Build Coastguard WorkerAC_SUBST(PNGLIB_MAJOR)
239*a67afe4dSAndroid Build Coastguard WorkerAC_SUBST(PNGLIB_MINOR)
240*a67afe4dSAndroid Build Coastguard WorkerAC_SUBST(PNGLIB_RELEASE)
241*a67afe4dSAndroid Build Coastguard Worker
242*a67afe4dSAndroid Build Coastguard Worker# Additional arguments (and substitutions)
243*a67afe4dSAndroid Build Coastguard Worker# Allow the pkg-config directory to be set
244*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_WITH(pkgconfigdir,
245*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--with-pkgconfigdir]]],
246*a67afe4dSAndroid Build Coastguard Worker      [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
247*a67afe4dSAndroid Build Coastguard Worker   [pkgconfigdir=${withval}],
248*a67afe4dSAndroid Build Coastguard Worker   [pkgconfigdir='${libdir}/pkgconfig'])
249*a67afe4dSAndroid Build Coastguard Worker
250*a67afe4dSAndroid Build Coastguard WorkerAC_SUBST([pkgconfigdir])
251*a67afe4dSAndroid Build Coastguard WorkerAC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
252*a67afe4dSAndroid Build Coastguard Worker
253*a67afe4dSAndroid Build Coastguard Worker# Make the *-config binary config scripts optional
254*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_WITH(binconfigs,
255*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--with-binconfigs]]],
256*a67afe4dSAndroid Build Coastguard Worker      [Generate shell libpng-config scripts as well as pkg-config data]
257*a67afe4dSAndroid Build Coastguard Worker      [@<:@default=yes@:>@]),
258*a67afe4dSAndroid Build Coastguard Worker   [if test "${withval}" = no; then
259*a67afe4dSAndroid Build Coastguard Worker      binconfigs=
260*a67afe4dSAndroid Build Coastguard Worker      AC_MSG_NOTICE([[libpng-config scripts will not be built]])
261*a67afe4dSAndroid Build Coastguard Worker    else
262*a67afe4dSAndroid Build Coastguard Worker      binconfigs='${binconfigs}'
263*a67afe4dSAndroid Build Coastguard Worker    fi],
264*a67afe4dSAndroid Build Coastguard Worker   [binconfigs='${binconfigs}'])
265*a67afe4dSAndroid Build Coastguard WorkerAC_SUBST([binconfigs])
266*a67afe4dSAndroid Build Coastguard Worker
267*a67afe4dSAndroid Build Coastguard Worker# Support for prefixes to the API function names; this will generate defines
268*a67afe4dSAndroid Build Coastguard Worker# at the start of the build to rename exported library functions
269*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_WITH(libpng-prefix,
270*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--with-libpng-prefix]]],
271*a67afe4dSAndroid Build Coastguard Worker      [prefix libpng exported function (API) names with the given value]),
272*a67afe4dSAndroid Build Coastguard Worker   [if test "${withval:-no}" != "no"; then
273*a67afe4dSAndroid Build Coastguard Worker      AC_SUBST([PNG_PREFIX], [${withval}])
274*a67afe4dSAndroid Build Coastguard Worker    fi])
275*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
276*a67afe4dSAndroid Build Coastguard Worker
277*a67afe4dSAndroid Build Coastguard Worker# Control over what links are made for installed files.  Versioned files are
278*a67afe4dSAndroid Build Coastguard Worker# always installed, when the following options are turned on corresponding
279*a67afe4dSAndroid Build Coastguard Worker# unversioned links are also created (normally as symbolic links):
280*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([unversioned-links],
281*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-unversioned-links]]],
282*a67afe4dSAndroid Build Coastguard Worker      [Installed libpng header files are placed in a versioned subdirectory]
283*a67afe4dSAndroid Build Coastguard Worker      [and installed libpng library (including DLL) files are versioned.]
284*a67afe4dSAndroid Build Coastguard Worker      [If this option is enabled unversioned links will be created pointing to]
285*a67afe4dSAndroid Build Coastguard Worker      [the corresponding installed files.  If you use libpng.pc or]
286*a67afe4dSAndroid Build Coastguard Worker      [libpng-config for all builds you do not need these links, but if you]
287*a67afe4dSAndroid Build Coastguard Worker      [compile programs directly they will typically #include <png.h> and]
288*a67afe4dSAndroid Build Coastguard Worker      [link with -lpng; in that case you need the links.]
289*a67afe4dSAndroid Build Coastguard Worker      [The links can be installed manually using 'make install-header-links']
290*a67afe4dSAndroid Build Coastguard Worker      [and 'make install-library-links' and can be removed using the]
291*a67afe4dSAndroid Build Coastguard Worker      [corresponding uninstall- targets.  If you do enable this option every]
292*a67afe4dSAndroid Build Coastguard Worker      [libpng 'make install' will recreate the links to point to the just]
293*a67afe4dSAndroid Build Coastguard Worker      [installed version of libpng.  The default is to create the links;]
294*a67afe4dSAndroid Build Coastguard Worker      [use --disable-unversioned-links to change this]))
295*a67afe4dSAndroid Build Coastguard Worker
296*a67afe4dSAndroid Build Coastguard Worker# The AM_CONDITIONAL test is written so that the default is enabled;
297*a67afe4dSAndroid Build Coastguard Worker# --disable-unversioned-links must be given to turn the option off.
298*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
299*a67afe4dSAndroid Build Coastguard Worker
300*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([unversioned-libpng-pc],
301*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
302*a67afe4dSAndroid Build Coastguard Worker      [Install the configuration file 'libpng.pc' as a link to the versioned]
303*a67afe4dSAndroid Build Coastguard Worker      [version.  This is done by default - use --disable-unversioned-libpng-pc]
304*a67afe4dSAndroid Build Coastguard Worker      [to change this.]))
305*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
306*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_unversioned_libpng_pc" != "no"])
307*a67afe4dSAndroid Build Coastguard Worker
308*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([unversioned-libpng-config],
309*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
310*a67afe4dSAndroid Build Coastguard Worker      [Install the configuration file 'libpng-config' as a link to the]
311*a67afe4dSAndroid Build Coastguard Worker      [versioned version.  This is done by default - use]
312*a67afe4dSAndroid Build Coastguard Worker      [--disable-unversioned-libpng-config to change this.]))
313*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
314*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_unversioned_libpng_config" != "no"])
315*a67afe4dSAndroid Build Coastguard Worker
316*a67afe4dSAndroid Build Coastguard Worker# HOST-SPECIFIC OPTIONS
317*a67afe4dSAndroid Build Coastguard Worker# =====================
318*a67afe4dSAndroid Build Coastguard Worker#
319*a67afe4dSAndroid Build Coastguard Worker# DEFAULT
320*a67afe4dSAndroid Build Coastguard Worker# =======
321*a67afe4dSAndroid Build Coastguard Worker#
322*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([hardware-optimizations],
323*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-hardware-optimizations]]],
324*a67afe4dSAndroid Build Coastguard Worker      [Enable hardware optimizations: =no/off, yes/on.]),
325*a67afe4dSAndroid Build Coastguard Worker   [case "$enableval" in
326*a67afe4dSAndroid Build Coastguard Worker      no|off)
327*a67afe4dSAndroid Build Coastguard Worker         # disable hardware optimization on all systems:
328*a67afe4dSAndroid Build Coastguard Worker         enable_arm_neon=no
329*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_ARM_NEON_OPT], [0],
330*a67afe4dSAndroid Build Coastguard Worker           [Disable ARM_NEON optimizations])
331*a67afe4dSAndroid Build Coastguard Worker         enable_mips_msa=no
332*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
333*a67afe4dSAndroid Build Coastguard Worker           [Disable MIPS_MSA optimizations])
334*a67afe4dSAndroid Build Coastguard Worker         enable_mips_mmi=no
335*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
336*a67afe4dSAndroid Build Coastguard Worker           [Disable MIPS_MMI optimizations])
337*a67afe4dSAndroid Build Coastguard Worker         enable_powerpc_vsx=no
338*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
339*a67afe4dSAndroid Build Coastguard Worker           [Disable POWERPC VSX optimizations])
340*a67afe4dSAndroid Build Coastguard Worker         enable_intel_sse=no
341*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
342*a67afe4dSAndroid Build Coastguard Worker           [Disable INTEL_SSE optimizations])
343*a67afe4dSAndroid Build Coastguard Worker         enable_loongarch_lsx=no
344*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
345*a67afe4dSAndroid Build Coastguard Worker           [Disable LOONGARCH_LSX optimizations])
346*a67afe4dSAndroid Build Coastguard Worker         ;;
347*a67afe4dSAndroid Build Coastguard Worker      *)
348*a67afe4dSAndroid Build Coastguard Worker         # allow enabling hardware optimization on any system:
349*a67afe4dSAndroid Build Coastguard Worker         case "$host_cpu" in
350*a67afe4dSAndroid Build Coastguard Worker            arm*|aarch64*)
351*a67afe4dSAndroid Build Coastguard Worker              enable_arm_neon=yes
352*a67afe4dSAndroid Build Coastguard Worker              AC_DEFINE([PNG_ARM_NEON_OPT], [2],
353*a67afe4dSAndroid Build Coastguard Worker                [Enable ARM_NEON optimizations])
354*a67afe4dSAndroid Build Coastguard Worker              ;;
355*a67afe4dSAndroid Build Coastguard Worker            mipsel*|mips64el*)
356*a67afe4dSAndroid Build Coastguard Worker              enable_mips_mmi=yes
357*a67afe4dSAndroid Build Coastguard Worker              enable_mips_msa=yes
358*a67afe4dSAndroid Build Coastguard Worker              AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
359*a67afe4dSAndroid Build Coastguard Worker                [Enable MIPS_MMI optimizations])
360*a67afe4dSAndroid Build Coastguard Worker              AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
361*a67afe4dSAndroid Build Coastguard Worker                [Enable MIPS_MSA optimizations])
362*a67afe4dSAndroid Build Coastguard Worker              ;;
363*a67afe4dSAndroid Build Coastguard Worker            i?86|x86_64)
364*a67afe4dSAndroid Build Coastguard Worker              enable_intel_sse=yes
365*a67afe4dSAndroid Build Coastguard Worker              AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
366*a67afe4dSAndroid Build Coastguard Worker                [Enable Intel SSE optimizations])
367*a67afe4dSAndroid Build Coastguard Worker              ;;
368*a67afe4dSAndroid Build Coastguard Worker            powerpc*|ppc64*)
369*a67afe4dSAndroid Build Coastguard Worker              enable_powerpc_vsx=yes
370*a67afe4dSAndroid Build Coastguard Worker              AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
371*a67afe4dSAndroid Build Coastguard Worker                [Enable POWERPC VSX optimizations])
372*a67afe4dSAndroid Build Coastguard Worker              ;;
373*a67afe4dSAndroid Build Coastguard Worker            loongarch*)
374*a67afe4dSAndroid Build Coastguard Worker              enable_loongarch_lsx=yes
375*a67afe4dSAndroid Build Coastguard Worker              AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
376*a67afe4dSAndroid Build Coastguard Worker                [Enable LOONGARCH_LSX optimizations])
377*a67afe4dSAndroid Build Coastguard Worker              ;;
378*a67afe4dSAndroid Build Coastguard Worker         esac
379*a67afe4dSAndroid Build Coastguard Worker         ;;
380*a67afe4dSAndroid Build Coastguard Worker   esac])
381*a67afe4dSAndroid Build Coastguard Worker
382*a67afe4dSAndroid Build Coastguard Worker# ARM NEON
383*a67afe4dSAndroid Build Coastguard Worker# ========
384*a67afe4dSAndroid Build Coastguard Worker
385*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([arm-neon],
386*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-arm-neon]]],
387*a67afe4dSAndroid Build Coastguard Worker      [Enable ARM NEON optimizations: =no/off, check, api, yes/on.]
388*a67afe4dSAndroid Build Coastguard Worker      [no/off: disable the optimizations;]
389*a67afe4dSAndroid Build Coastguard Worker      [check: use internal checking code (deprecated and poorly supported);]
390*a67afe4dSAndroid Build Coastguard Worker      [api: disable by default, enable by a call to png_set_option;]
391*a67afe4dSAndroid Build Coastguard Worker      [yes/on: turn on unconditionally.]
392*a67afe4dSAndroid Build Coastguard Worker      [If not specified: determined by the compiler.]),
393*a67afe4dSAndroid Build Coastguard Worker   [case "$enableval" in
394*a67afe4dSAndroid Build Coastguard Worker      no|off)
395*a67afe4dSAndroid Build Coastguard Worker         # disable the default enabling on __ARM_NEON__ systems:
396*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_ARM_NEON_OPT], [0],
397*a67afe4dSAndroid Build Coastguard Worker                   [Disable ARM Neon optimizations])
398*a67afe4dSAndroid Build Coastguard Worker         # Prevent inclusion of the assembler files below:
399*a67afe4dSAndroid Build Coastguard Worker         enable_arm_neon=no ;;
400*a67afe4dSAndroid Build Coastguard Worker      check)
401*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
402*a67afe4dSAndroid Build Coastguard Worker                   [Check for ARM Neon support at run-time]);;
403*a67afe4dSAndroid Build Coastguard Worker      api)
404*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
405*a67afe4dSAndroid Build Coastguard Worker                   [Turn on ARM Neon optimizations at run-time]);;
406*a67afe4dSAndroid Build Coastguard Worker      yes|on)
407*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_ARM_NEON_OPT], [2],
408*a67afe4dSAndroid Build Coastguard Worker                   [Enable ARM Neon optimizations])
409*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api';]
410*a67afe4dSAndroid Build Coastguard Worker            [if you want the optimizations unconditionally,]
411*a67afe4dSAndroid Build Coastguard Worker            [pass '-mfpu=neon' to the compiler.]);;
412*a67afe4dSAndroid Build Coastguard Worker      *)
413*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}:]
414*a67afe4dSAndroid Build Coastguard Worker                      [invalid argument])
415*a67afe4dSAndroid Build Coastguard Worker   esac])
416*a67afe4dSAndroid Build Coastguard Worker
417*a67afe4dSAndroid Build Coastguard Worker# Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or
418*a67afe4dSAndroid Build Coastguard Worker# where ARM optimizations were explicitly requested. (This allows a fallback
419*a67afe4dSAndroid Build Coastguard Worker# if a future host CPU does not match 'arm*'.)
420*a67afe4dSAndroid Build Coastguard Worker
421*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([PNG_ARM_NEON],
422*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_arm_neon" != 'no' &&
423*a67afe4dSAndroid Build Coastguard Worker    case "$host_cpu" in
424*a67afe4dSAndroid Build Coastguard Worker      arm*|aarch64*) : ;;
425*a67afe4dSAndroid Build Coastguard Worker      *)    test "$enable_arm_neon" != '' ;;
426*a67afe4dSAndroid Build Coastguard Worker    esac])
427*a67afe4dSAndroid Build Coastguard Worker
428*a67afe4dSAndroid Build Coastguard Worker# MIPS MSA
429*a67afe4dSAndroid Build Coastguard Worker# ========
430*a67afe4dSAndroid Build Coastguard Worker
431*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([mips-msa],
432*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-mips-msa]]],
433*a67afe4dSAndroid Build Coastguard Worker      [Enable MIPS MSA optimizations: =no/off, check, api, yes/on.]
434*a67afe4dSAndroid Build Coastguard Worker      [no/off: disable the optimizations;]
435*a67afe4dSAndroid Build Coastguard Worker      [check: use internal checking code (deprecated and poorly supported);]
436*a67afe4dSAndroid Build Coastguard Worker      [api: disable by default, enable by a call to png_set_option;]
437*a67afe4dSAndroid Build Coastguard Worker      [yes/on: turn on unconditionally.]
438*a67afe4dSAndroid Build Coastguard Worker      [If not specified: determined by the compiler.]),
439*a67afe4dSAndroid Build Coastguard Worker   [case "$enableval" in
440*a67afe4dSAndroid Build Coastguard Worker      no|off)
441*a67afe4dSAndroid Build Coastguard Worker         # disable the default enabling on __mips_msa systems:
442*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
443*a67afe4dSAndroid Build Coastguard Worker                   [Disable MIPS MSA optimizations])
444*a67afe4dSAndroid Build Coastguard Worker         # Prevent inclusion of the assembler files below:
445*a67afe4dSAndroid Build Coastguard Worker         enable_mips_msa=no ;;
446*a67afe4dSAndroid Build Coastguard Worker      check)
447*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
448*a67afe4dSAndroid Build Coastguard Worker                   [Check for MIPS MSA support at run-time]);;
449*a67afe4dSAndroid Build Coastguard Worker      api)
450*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [],
451*a67afe4dSAndroid Build Coastguard Worker                   [Turn on MIPS MSA optimizations at run-time]);;
452*a67afe4dSAndroid Build Coastguard Worker      yes|on)
453*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
454*a67afe4dSAndroid Build Coastguard Worker                   [Enable MIPS MSA optimizations])
455*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api';]
456*a67afe4dSAndroid Build Coastguard Worker            [if you want the optimizations unconditionally,]
457*a67afe4dSAndroid Build Coastguard Worker            [pass '-mmsa -mfp64' to the compiler.]);;
458*a67afe4dSAndroid Build Coastguard Worker      *)
459*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}:]
460*a67afe4dSAndroid Build Coastguard Worker                      [invalid argument])
461*a67afe4dSAndroid Build Coastguard Worker   esac])
462*a67afe4dSAndroid Build Coastguard Worker
463*a67afe4dSAndroid Build Coastguard Worker# Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or
464*a67afe4dSAndroid Build Coastguard Worker# where MIPS optimizations were explicitly requested. (This allows a fallback
465*a67afe4dSAndroid Build Coastguard Worker# if a future host CPU does not match 'mips*'.)
466*a67afe4dSAndroid Build Coastguard Worker
467*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([PNG_MIPS_MSA],
468*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_mips_msa" != 'no' &&
469*a67afe4dSAndroid Build Coastguard Worker    case "$host_cpu" in
470*a67afe4dSAndroid Build Coastguard Worker      mipsel*|mips64el*) : ;;
471*a67afe4dSAndroid Build Coastguard Worker    esac])
472*a67afe4dSAndroid Build Coastguard Worker
473*a67afe4dSAndroid Build Coastguard Worker# MIPS MMI
474*a67afe4dSAndroid Build Coastguard Worker# ========
475*a67afe4dSAndroid Build Coastguard Worker
476*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([mips-mmi],
477*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-mips-mmi]]],
478*a67afe4dSAndroid Build Coastguard Worker      [Enable MIPS MMI optimizations: =no/off, check, api, yes/on.]
479*a67afe4dSAndroid Build Coastguard Worker      [no/off: disable the optimizations;]
480*a67afe4dSAndroid Build Coastguard Worker      [check: use internal checking code (deprecated and poorly supported);]
481*a67afe4dSAndroid Build Coastguard Worker      [api: disable by default, enable by a call to png_set_option;]
482*a67afe4dSAndroid Build Coastguard Worker      [yes/on: turn on unconditionally.]
483*a67afe4dSAndroid Build Coastguard Worker      [If not specified: determined by the compiler.]),
484*a67afe4dSAndroid Build Coastguard Worker   [case "$enableval" in
485*a67afe4dSAndroid Build Coastguard Worker      no|off)
486*a67afe4dSAndroid Build Coastguard Worker         # disable the default enabling on __mips_mmi systems:
487*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
488*a67afe4dSAndroid Build Coastguard Worker                   [Disable MIPS MMI optimizations])
489*a67afe4dSAndroid Build Coastguard Worker         # Prevent inclusion of the assembler files below:
490*a67afe4dSAndroid Build Coastguard Worker         enable_mips_mmi=no;;
491*a67afe4dSAndroid Build Coastguard Worker      check)
492*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MMI_CHECK_SUPPORTED], [],
493*a67afe4dSAndroid Build Coastguard Worker                   [Check for MIPS MMI support at run-time]);;
494*a67afe4dSAndroid Build Coastguard Worker      api)
495*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MMI_API_SUPPORTED], [],
496*a67afe4dSAndroid Build Coastguard Worker                   [Turn on MIPS MMI optimizations at run-time]);;
497*a67afe4dSAndroid Build Coastguard Worker      yes|on)
498*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
499*a67afe4dSAndroid Build Coastguard Worker                   [Enable MIPS MMI optimizations])
500*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api';]
501*a67afe4dSAndroid Build Coastguard Worker            [if you want the optimizations unconditionally]
502*a67afe4dSAndroid Build Coastguard Worker            [pass '-mloongson-mmi -march=loongson3a' to the compiler.]);;
503*a67afe4dSAndroid Build Coastguard Worker      *)
504*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}:]
505*a67afe4dSAndroid Build Coastguard Worker                      [invalid argument])
506*a67afe4dSAndroid Build Coastguard Worker   esac])
507*a67afe4dSAndroid Build Coastguard Worker
508*a67afe4dSAndroid Build Coastguard Worker# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
509*a67afe4dSAndroid Build Coastguard Worker# where MIPS optimizations were explicitly requested. (This allows a fallback
510*a67afe4dSAndroid Build Coastguard Worker# if a future host CPU does not match 'mips*'.)
511*a67afe4dSAndroid Build Coastguard Worker
512*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([PNG_MIPS_MMI],
513*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_mips_mmi" != 'no' &&
514*a67afe4dSAndroid Build Coastguard Worker    case "$host_cpu" in
515*a67afe4dSAndroid Build Coastguard Worker      mipsel*|mips64el*) : ;;
516*a67afe4dSAndroid Build Coastguard Worker    esac])
517*a67afe4dSAndroid Build Coastguard Worker
518*a67afe4dSAndroid Build Coastguard Worker# INTEL SSE
519*a67afe4dSAndroid Build Coastguard Worker# =========
520*a67afe4dSAndroid Build Coastguard Worker
521*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([intel-sse],
522*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-intel-sse]]],
523*a67afe4dSAndroid Build Coastguard Worker      [Enable Intel SSE optimizations: =no/off, yes/on.]
524*a67afe4dSAndroid Build Coastguard Worker      [no/off: disable the optimizations;]
525*a67afe4dSAndroid Build Coastguard Worker      [yes/on: enable the optimizations.]
526*a67afe4dSAndroid Build Coastguard Worker      [If not specified: determined by the compiler.]),
527*a67afe4dSAndroid Build Coastguard Worker   [case "$enableval" in
528*a67afe4dSAndroid Build Coastguard Worker      no|off)
529*a67afe4dSAndroid Build Coastguard Worker         # disable the default enabling:
530*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
531*a67afe4dSAndroid Build Coastguard Worker                   [Disable Intel SSE optimizations])
532*a67afe4dSAndroid Build Coastguard Worker         # Prevent inclusion of the assembler files below:
533*a67afe4dSAndroid Build Coastguard Worker         enable_intel_sse=no ;;
534*a67afe4dSAndroid Build Coastguard Worker      yes|on)
535*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
536*a67afe4dSAndroid Build Coastguard Worker                   [Enable Intel SSE optimizations]);;
537*a67afe4dSAndroid Build Coastguard Worker      *)
538*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}:]
539*a67afe4dSAndroid Build Coastguard Worker                      [invalid argument])
540*a67afe4dSAndroid Build Coastguard Worker   esac])
541*a67afe4dSAndroid Build Coastguard Worker
542*a67afe4dSAndroid Build Coastguard Worker# Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or
543*a67afe4dSAndroid Build Coastguard Worker# where Intel optimizations were explicitly requested. (This allows a fallback
544*a67afe4dSAndroid Build Coastguard Worker# if a future host CPU does not match 'x86*'.)
545*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([PNG_INTEL_SSE],
546*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_intel_sse" != 'no' &&
547*a67afe4dSAndroid Build Coastguard Worker    case "$host_cpu" in
548*a67afe4dSAndroid Build Coastguard Worker      i?86|x86_64) : ;;
549*a67afe4dSAndroid Build Coastguard Worker      *)    test "$enable_intel_sse" != '' ;;
550*a67afe4dSAndroid Build Coastguard Worker    esac])
551*a67afe4dSAndroid Build Coastguard Worker
552*a67afe4dSAndroid Build Coastguard Worker# POWERPC VSX
553*a67afe4dSAndroid Build Coastguard Worker# ===========
554*a67afe4dSAndroid Build Coastguard Worker
555*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([powerpc-vsx],
556*a67afe4dSAndroid Build Coastguard WorkerAS_HELP_STRING([[[--enable-powerpc-vsx]]],
557*a67afe4dSAndroid Build Coastguard Worker      [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on.]
558*a67afe4dSAndroid Build Coastguard Worker      [no/off: disable the optimizations;]
559*a67afe4dSAndroid Build Coastguard Worker      [check: use internal checking code;]
560*a67afe4dSAndroid Build Coastguard Worker      [api: disable by default, enable by a call to png_set_option;]
561*a67afe4dSAndroid Build Coastguard Worker      [yes/on: turn on unconditionally.]
562*a67afe4dSAndroid Build Coastguard Worker      [If not specified: determined by the compiler.]),
563*a67afe4dSAndroid Build Coastguard Worker   [case "$enableval" in
564*a67afe4dSAndroid Build Coastguard Worker      no|off)
565*a67afe4dSAndroid Build Coastguard Worker         # disable the default enabling on __ppc64__ systems:
566*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
567*a67afe4dSAndroid Build Coastguard Worker                   [Disable POWERPC VSX optimizations])
568*a67afe4dSAndroid Build Coastguard Worker         # Prevent inclusion of the platform-specific files below:
569*a67afe4dSAndroid Build Coastguard Worker         enable_powerpc_vsx=no ;;
570*a67afe4dSAndroid Build Coastguard Worker      check)
571*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
572*a67afe4dSAndroid Build Coastguard Worker                   [Check for POWERPC VSX support at run-time])
573*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_WARN([--enable-powerpc-vsx: please see contrib/powerpc/README]
574*a67afe4dSAndroid Build Coastguard Worker                     [for the list of supported systems.]);;
575*a67afe4dSAndroid Build Coastguard Worker      api)
576*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
577*a67afe4dSAndroid Build Coastguard Worker                   [Turn on POWERPC VSX optimizations at run-time]);;
578*a67afe4dSAndroid Build Coastguard Worker      yes|on)
579*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
580*a67afe4dSAndroid Build Coastguard Worker                   [Enable POWERPC VSX optimizations])
581*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api';]
582*a67afe4dSAndroid Build Coastguard Worker            [if you want the optimizations unconditionally,]
583*a67afe4dSAndroid Build Coastguard Worker            [pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler.]);;
584*a67afe4dSAndroid Build Coastguard Worker      *)
585*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}:]
586*a67afe4dSAndroid Build Coastguard Worker                      [invalid argument])
587*a67afe4dSAndroid Build Coastguard Worker   esac])
588*a67afe4dSAndroid Build Coastguard Worker
589*a67afe4dSAndroid Build Coastguard Worker# Add PowerPC-specific files to all builds where $host_cpu is powerpc
590*a67afe4dSAndroid Build Coastguard Worker# ('powerpc*') or where PowerPC optimizations were explicitly requested.
591*a67afe4dSAndroid Build Coastguard Worker# (This allows a fallback if a future host CPU does not match 'powerpc*'.)
592*a67afe4dSAndroid Build Coastguard Worker
593*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([PNG_POWERPC_VSX],
594*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_powerpc_vsx" != 'no' &&
595*a67afe4dSAndroid Build Coastguard Worker    case "$host_cpu" in
596*a67afe4dSAndroid Build Coastguard Worker      powerpc*|ppc64*) : ;;
597*a67afe4dSAndroid Build Coastguard Worker    esac])
598*a67afe4dSAndroid Build Coastguard Worker
599*a67afe4dSAndroid Build Coastguard Worker# LOONGARCH LSX
600*a67afe4dSAndroid Build Coastguard Worker# =============
601*a67afe4dSAndroid Build Coastguard Worker
602*a67afe4dSAndroid Build Coastguard WorkerAC_ARG_ENABLE([loongarch-lsx],
603*a67afe4dSAndroid Build Coastguard Worker   AS_HELP_STRING([[[--enable-loongarch-lsx]]],
604*a67afe4dSAndroid Build Coastguard Worker      [Enable LOONGARCH LSX optimizations: =no/off, yes/on:]
605*a67afe4dSAndroid Build Coastguard Worker      [no/off: disable the optimizations;]
606*a67afe4dSAndroid Build Coastguard Worker      [yes/on: turn on unconditionally.]
607*a67afe4dSAndroid Build Coastguard Worker      [If not specified: determined by the compiler.]),
608*a67afe4dSAndroid Build Coastguard Worker   [case "$enableval" in
609*a67afe4dSAndroid Build Coastguard Worker      no|off)
610*a67afe4dSAndroid Build Coastguard Worker         # disable the default enabling on __loongarch_simd systems:
611*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
612*a67afe4dSAndroid Build Coastguard Worker                   [Disable LOONGARCH LSX optimizations])
613*a67afe4dSAndroid Build Coastguard Worker         # Prevent inclusion of the assembler files below:
614*a67afe4dSAndroid Build Coastguard Worker         enable_loongarch_lsx=no;;
615*a67afe4dSAndroid Build Coastguard Worker      yes|on)
616*a67afe4dSAndroid Build Coastguard Worker         AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
617*a67afe4dSAndroid Build Coastguard Worker                   [Enable LOONGARCH LSX optimizations])
618*a67afe4dSAndroid Build Coastguard Worker         ;;
619*a67afe4dSAndroid Build Coastguard Worker      *)
620*a67afe4dSAndroid Build Coastguard Worker         AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}:]
621*a67afe4dSAndroid Build Coastguard Worker                      [invalid argument])
622*a67afe4dSAndroid Build Coastguard Worker   esac])
623*a67afe4dSAndroid Build Coastguard Worker
624*a67afe4dSAndroid Build Coastguard Workerif test "$enable_loongarch_lsx" != "no" &&
625*a67afe4dSAndroid Build Coastguard Worker   case "$host_cpu" in
626*a67afe4dSAndroid Build Coastguard Worker      loongarch*) : ;;
627*a67afe4dSAndroid Build Coastguard Worker      *)    test "$enable_loongarch_lsx" != '' ;;
628*a67afe4dSAndroid Build Coastguard Worker   esac
629*a67afe4dSAndroid Build Coastguard Workerthen
630*a67afe4dSAndroid Build Coastguard Worker   compiler_support_loongarch_lsx=no
631*a67afe4dSAndroid Build Coastguard Worker   AC_MSG_CHECKING(whether to use LoongArch LSX intrinsics)
632*a67afe4dSAndroid Build Coastguard Worker   save_CFLAGS="$CFLAGS"
633*a67afe4dSAndroid Build Coastguard Worker   LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}"
634*a67afe4dSAndroid Build Coastguard Worker   CFLAGS="$CFLAGS $LSX_CFLAGS"
635*a67afe4dSAndroid Build Coastguard Worker   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
636*a67afe4dSAndroid Build Coastguard Worker#include <lsxintrin.h>
637*a67afe4dSAndroid Build Coastguard Workerint main(){
638*a67afe4dSAndroid Build Coastguard Worker   __m128i a, b, c;
639*a67afe4dSAndroid Build Coastguard Worker   a = __lsx_vadd_w(b, c);
640*a67afe4dSAndroid Build Coastguard Worker   return 0;
641*a67afe4dSAndroid Build Coastguard Worker}]])],compiler_support_loongarch_lsx=yes)
642*a67afe4dSAndroid Build Coastguard Worker   CFLAGS="$save_CFLAGS"
643*a67afe4dSAndroid Build Coastguard Worker   AC_MSG_RESULT($compiler_support_loongarch_lsx)
644*a67afe4dSAndroid Build Coastguard Worker   if test "$compiler_support_loongarch_lsx" = "yes"; then
645*a67afe4dSAndroid Build Coastguard Worker      AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
646*a67afe4dSAndroid Build Coastguard Worker                [Enable LOONGARCH LSX optimizations])
647*a67afe4dSAndroid Build Coastguard Worker   else
648*a67afe4dSAndroid Build Coastguard Worker      AC_MSG_WARN([Compiler does not support loongarch LSX.])
649*a67afe4dSAndroid Build Coastguard Worker   fi
650*a67afe4dSAndroid Build Coastguard Workerfi
651*a67afe4dSAndroid Build Coastguard Worker
652*a67afe4dSAndroid Build Coastguard Worker# Add LoongArch specific files to all builds where the host_cpu is loongarch
653*a67afe4dSAndroid Build Coastguard Worker# ('loongarch*') or where LoongArch optimizations were explicitly requested.
654*a67afe4dSAndroid Build Coastguard Worker# (This allows a fallback if a future host CPU does not match 'loongarch*'.)
655*a67afe4dSAndroid Build Coastguard Worker
656*a67afe4dSAndroid Build Coastguard WorkerAM_CONDITIONAL([PNG_LOONGARCH_LSX],
657*a67afe4dSAndroid Build Coastguard Worker   [test "$enable_loongarch_lsx" != "no" &&
658*a67afe4dSAndroid Build Coastguard Worker    test "$compiler_support_loongarch_lsx" = "yes" &&
659*a67afe4dSAndroid Build Coastguard Worker    case "$host_cpu" in
660*a67afe4dSAndroid Build Coastguard Worker      loongarch*) : ;;
661*a67afe4dSAndroid Build Coastguard Worker      *)    test "$enable_loongarch_lsx" != '' ;;
662*a67afe4dSAndroid Build Coastguard Worker    esac])
663*a67afe4dSAndroid Build Coastguard Worker
664*a67afe4dSAndroid Build Coastguard WorkerAC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
665*a67afe4dSAndroid Build Coastguard Worker
666*a67afe4dSAndroid Build Coastguard Worker# Config files, substituting as above
667*a67afe4dSAndroid Build Coastguard WorkerAC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
668*a67afe4dSAndroid Build Coastguard WorkerAC_CONFIG_FILES([libpng-config:libpng-config.in],
669*a67afe4dSAndroid Build Coastguard Worker   [chmod +x libpng-config])
670*a67afe4dSAndroid Build Coastguard Worker
671*a67afe4dSAndroid Build Coastguard WorkerAC_OUTPUT
672