3 # Copyright (c) 2018-2022 Cosmin Truta
4 # Copyright (c) 2004-2016 Glenn Randers-Pehrson
6 # This code is released under the libpng license.
7 # For conditions of distribution and use, see the disclaimer
10 dnl Process this file with autoconf to produce a configure script.
12 dnl Minor upgrades (compatible ABI): increment the package version
13 dnl (third field in two places below) and set the PNGLIB_RELEASE
16 dnl Major upgrades (incompatible ABI): increment the package major
17 dnl version (second field, or first if desired), set the minor
18 dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
19 dnl Makefile.am to upgrade the package name.
21 dnl This is here to prevent earlier autoconf from being used, it
22 dnl should not be necessary to regenerate configure if the time
23 dnl stamps are correct
26 dnl Version number stuff here:
28 AC_INIT([libpng],[1.6.40],[png-mng-implement@lists.sourceforge.net])
29 AC_CONFIG_MACRO_DIR([scripts])
31 # libpng does not follow GNU file name conventions (hence 'foreign')
32 # color-tests requires automake 1.11 or later
33 # silent-rules requires automake 1.11 or later
34 # dist-xz requires automake 1.11 or later
35 # 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
36 # 1.13 is required for parallel tests
37 AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
38 # The following line causes --disable-maintainer-mode to be the default to
39 # configure. This is necessary because libpng distributions cannot rely on the
40 # time stamps of the autotools generated files being correct
43 dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
44 dnl version; aclocal.m4 will generate a failure if you use a prior version of
45 dnl automake, so the following is not necessary (and is not defined anyway):
46 dnl AM_PREREQ([1.11.2])
47 dnl stop configure from automagically running automake
54 dnl End of version number stuff
56 AC_CONFIG_SRCDIR([pngget.c])
57 AC_CONFIG_HEADERS([config.h])
59 # Checks for programs.
70 dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any
71 dnl compatible later version may be used
75 # Some awks crash when confronted with pnglibconf.dfa, do a test run now
76 # to make sure this doesn't happen
77 AC_MSG_CHECKING([that AWK works])
78 if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
79 ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
80 ${srcdir}/pngusr.dfa 1>&2
84 AC_MSG_FAILURE([failed], 1)
87 # This is a remnant of the old cc -E validation, where it may have been
88 # necessary to use a different preprocessor for .dfn files
92 # -Werror cannot be passed to GCC in CFLAGS because configure will fail
93 # (it checks the compiler with a program that generates a warning).
94 # Add the following option to deal with this:
96 [additional flags for the C compiler, use this for options that would]
97 [cause configure itself to fail])
99 AS_HELP_STRING([[[--enable-werror[=OPT]]]],
100 [Pass -Werror or the given argument to the compiler if it is supported]),
101 [test "$enable_werror" = "yes" && enable_werror="-Werror"
102 if test "$enable_werror" != "no"; then
104 CFLAGS="$enable_werror $CFLAGS"
105 AC_MSG_CHECKING([if the compiler allows $enable_werror])
108 [int main(int argc, char **argv){]
109 [return argv[argc-1][0];]
112 PNG_COPTS="$PNG_COPTS $enable_werror",
117 # For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89.
118 # In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining
119 # _POSIX_SOURCE to 1. This is incompatible with the new default mode, so
120 # we test for that and force the "-std=c89" compiler option:
121 AC_MSG_CHECKING([if we need to force back C standard to C89])
124 [#define _POSIX_SOURCE 1]
128 if test "x$GCC" != "xyes"; then
130 [Forcing back to C89 is required but the flags are only known for GCC])
133 CFLAGS="$CFLAGS -std=c89"
136 # Checks for structures and compiler characteristics.
140 # Checks for library functions.
141 AC_CHECK_FUNCS([pow], ,
142 [AC_CHECK_LIB([m], [pow], , [AC_MSG_ERROR([cannot find pow])])])
144 # Some later POSIX 1003.1 functions are required for test programs, failure
145 # here is soft (the corresponding test program is not built).
146 AC_CHECK_FUNC([clock_gettime], , [AC_MSG_WARN([not building timepng])])
147 AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
149 AC_ARG_WITH(zlib-prefix,
150 AS_HELP_STRING([[[--with-zlib-prefix]]],
151 [prefix that may have been used in installed zlib]),
152 [ZPREFIX=${withval}],
154 AC_CHECK_LIB([z], [zlibVersion], ,
155 [AC_CHECK_LIB([z], [${ZPREFIX}zlibVersion], ,
156 [AC_MSG_ERROR([zlib not installed])])])
158 # The following is for pngvalid, to ensure it catches FP errors even on
159 # platforms that don't enable FP exceptions, the function appears in the math
160 # library (typically), it's not an error if it is not found.
161 AC_CHECK_LIB([m], [feenableexcept])
162 AC_CHECK_FUNCS([feenableexcept])
164 AC_MSG_CHECKING([if using Solaris linker])
165 SLD=`$LD --version 2>&1 | grep Solaris`
173 AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
175 AC_MSG_CHECKING([if libraries can be versioned])
176 # Special case for PE/COFF platforms: ld reports
177 # support for version-script, but doesn't actually
178 # DO anything with it.
180 *cygwin* | *mingw32* | *interix* )
181 have_ld_version_script=no
186 if test "$have_solaris_ld" = "yes"; then
187 GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
189 GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
193 have_ld_version_script=yes
196 have_ld_version_script=no
198 AC_MSG_WARN(*** You have not enabled versioned symbols.)
203 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
205 if test "$have_ld_version_script" = "yes"; then
206 AC_MSG_CHECKING([for symbol prefix])
207 SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
208 | ${CPP-${CC-gcc} -E} - 2>&1 \
209 | ${EGREP-grep} "^PREFIX=" \
210 | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
211 AC_SUBST(SYMBOL_PREFIX)
212 AC_MSG_RESULT($SYMBOL_PREFIX)
215 # Substitutions for .in files
216 AC_SUBST(PNGLIB_VERSION)
217 AC_SUBST(PNGLIB_MAJOR)
218 AC_SUBST(PNGLIB_MINOR)
219 AC_SUBST(PNGLIB_RELEASE)
221 # Additional arguments (and substitutions)
222 # Allow the pkg-config directory to be set
223 AC_ARG_WITH(pkgconfigdir,
224 AS_HELP_STRING([[[--with-pkgconfigdir]]],
225 [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
226 [pkgconfigdir=${withval}],
227 [pkgconfigdir='${libdir}/pkgconfig'])
229 AC_SUBST([pkgconfigdir])
230 AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
232 # Make the *-config binary config scripts optional
233 AC_ARG_WITH(binconfigs,
234 AS_HELP_STRING([[[--with-binconfigs]]],
235 [Generate shell libpng-config scripts as well as pkg-config data]
236 [@<:@default=yes@:>@]),
237 [if test "${withval}" = no; then
239 AC_MSG_NOTICE([[libpng-config scripts will not be built]])
241 binconfigs='${binconfigs}'
243 [binconfigs='${binconfigs}'])
244 AC_SUBST([binconfigs])
246 # Support for prefixes to the API function names; this will generate defines
247 # at the start of the build to rename exported library functions
248 AC_ARG_WITH(libpng-prefix,
249 AS_HELP_STRING([[[--with-libpng-prefix]]],
250 [prefix libpng exported function (API) names with the given value]),
251 [if test "${withval:-no}" != "no"; then
252 AC_SUBST([PNG_PREFIX], [${withval}])
254 AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
256 # Control over what links are made for installed files. Versioned files are
257 # always installed, when the following options are turned on corresponding
258 # unversioned links are also created (normally as symbolic links):
259 AC_ARG_ENABLE([unversioned-links],
260 AS_HELP_STRING([[[--enable-unversioned-links]]],
261 [Installed libpng header files are placed in a versioned subdirectory]
262 [and installed libpng library (including DLL) files are versioned.]
263 [If this option is enabled unversioned links will be created pointing to]
264 [the corresponding installed files. If you use libpng.pc or]
265 [libpng-config for all builds you do not need these links, but if you]
266 [compile programs directly they will typically #include <png.h> and]
267 [link with -lpng; in that case you need the links.]
268 [The links can be installed manually using 'make install-header-links']
269 [and 'make install-library-links' and can be removed using the]
270 [corresponding uninstall- targets. If you do enable this option every]
271 [libpng 'make install' will recreate the links to point to the just]
272 [installed version of libpng. The default is to create the links;]
273 [use --disable-unversioned-links to change this]))
275 # The AM_CONDITIONAL test is written so that the default is enabled;
276 # --disable-unversioned-links must be given to turn the option off.
277 AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
279 AC_ARG_ENABLE([unversioned-libpng-pc],
280 AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
281 [Install the configuration file 'libpng.pc' as a link to the versioned]
282 [version. This is done by default - use --disable-unversioned-libpng-pc]
284 AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
285 [test "$enable_unversioned_libpng_pc" != "no"])
287 AC_ARG_ENABLE([unversioned-libpng-config],
288 AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
289 [Install the configuration file 'libpng-config' as a link to the]
290 [versioned version. This is done by default - use]
291 [--disable-unversioned-libpng-config to change this.]))
292 AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
293 [test "$enable_unversioned_libpng_config" != "no"])
295 # HOST-SPECIFIC OPTIONS
296 # =====================
301 AC_ARG_ENABLE([hardware-optimizations],
302 AS_HELP_STRING([[[--enable-hardware-optimizations]]],
303 [Enable hardware optimizations: =no/off, yes/on:]),
304 [case "$enableval" in
306 # disable hardware optimization on all systems:
308 AC_DEFINE([PNG_ARM_NEON_OPT], [0],
309 [Disable ARM_NEON optimizations])
311 AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
312 [Disable MIPS_MSA optimizations])
313 enable_powerpc_vsx=no
314 AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
315 [Disable POWERPC VSX optimizations])
317 AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
318 [Disable INTEL_SSE optimizations])
321 # allow enabling hardware optimization on any system:
325 AC_DEFINE([PNG_ARM_NEON_OPT], [2],
326 [Enable ARM_NEON optimizations])
330 AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
331 [Enable MIPS_MSA optimizations])
335 AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
336 [Enable Intel SSE optimizations])
339 enable_powerpc_vsx=yes
340 AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
341 [Enable POWERPC VSX optimizations])
350 # ARM NEON (SIMD) support.
352 AC_ARG_ENABLE([arm-neon],
353 AS_HELP_STRING([[[--enable-arm-neon]]],
354 [Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
355 [no/off: disable the optimizations; check: use internal checking code]
356 [(deprecated and poorly supported); api: disable by default, enable by]
357 [a call to png_set_option; yes/on: turn on unconditionally.]
358 [If not specified: determined by the compiler.]),
359 [case "$enableval" in
361 # disable the default enabling on __ARM_NEON__ systems:
362 AC_DEFINE([PNG_ARM_NEON_OPT], [0],
363 [Disable ARM Neon optimizations])
364 # Prevent inclusion of the assembler files below:
365 enable_arm_neon=no ;;
367 AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
368 [Check for ARM Neon support at run-time]);;
370 AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
371 [Turn on ARM Neon optimizations at run-time]);;
373 AC_DEFINE([PNG_ARM_NEON_OPT], [2],
374 [Enable ARM Neon optimizations])
375 AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
376 [you want the optimizations unconditionally pass -mfpu=neon]
377 [to the compiler.]);;
379 AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
382 # Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or
383 # where ARM optimizations were explicitly requested (this allows a fallback
384 # if a future host CPU does not match 'arm*')
386 AM_CONDITIONAL([PNG_ARM_NEON],
387 [test "$enable_arm_neon" != 'no' &&
390 *) test "$enable_arm_neon" != '' ;;
396 # MIPS MSA (SIMD) support.
398 AC_ARG_ENABLE([mips-msa],
399 AS_HELP_STRING([[[--enable-mips-msa]]],
400 [Enable MIPS MSA optimizations: =no/off, check, api, yes/on:]
401 [no/off: disable the optimizations; check: use internal checking code]
402 [(deprecated and poorly supported); api: disable by default, enable by]
403 [a call to png_set_option; yes/on: turn on unconditionally.]
404 [If not specified: determined by the compiler.]),
405 [case "$enableval" in
407 # disable the default enabling on __mips_msa systems:
408 AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
409 [Disable MIPS MSA optimizations])
410 # Prevent inclusion of the assembler files below:
411 enable_mips_msa=no ;;
413 AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
414 [Check for MIPS MSA support at run-time]);;
416 AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [],
417 [Turn on MIPS MSA optimizations at run-time]);;
419 AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
420 [Enable MIPS MSA optimizations])
421 AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if]
422 [you want the optimizations unconditionally pass '-mmsa -mfp64']
423 [to the compiler.]);;
425 AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value])
428 # Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or
429 # where MIPS optimizations were explicitly requested (this allows a fallback
430 # if a future host CPU does not match 'mips*')
432 AM_CONDITIONAL([PNG_MIPS_MSA],
433 [test "$enable_mips_msa" != 'no' &&
435 mipsel*|mips64el*) : ;;
441 # INTEL SSE (SIMD) support.
443 AC_ARG_ENABLE([intel-sse],
444 AS_HELP_STRING([[[--enable-intel-sse]]],
445 [Enable Intel SSE optimizations: =no/off, yes/on:]
446 [no/off: disable the optimizations;]
447 [yes/on: enable the optimizations.]
448 [If not specified: determined by the compiler.]),
449 [case "$enableval" in
451 # disable the default enabling:
452 AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
453 [Disable Intel SSE optimizations])
454 # Prevent inclusion of the assembler files below:
455 enable_intel_sse=no ;;
457 AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
458 [Enable Intel SSE optimizations]);;
460 AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
463 # Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or
464 # where Intel optimizations were explicitly requested (this allows a fallback
465 # if a future host CPU does not match 'x86*')
466 AM_CONDITIONAL([PNG_INTEL_SSE],
467 [test "$enable_intel_sse" != 'no' &&
470 *) test "$enable_intel_sse" != '' ;;
476 # PowerPC VSX (SIMD) support.
478 AC_ARG_ENABLE([powerpc-vsx],
479 AS_HELP_STRING([[[--enable-powerpc-vsx]]],
480 [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:]
481 [no/off: disable the optimizations; check: use internal checking code]
482 [api: disable by default, enable by a call to png_set_option]
483 [yes/on: turn on unconditionally.]
484 [If not specified: determined by the compiler.]),
485 [case "$enableval" in
487 # disable the default enabling on __ppc64__ systems:
488 AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
489 [Disable POWERPC VSX optimizations])
490 # Prevent inclusion of the platform-specific files below:
491 enable_powerpc_vsx=no ;;
493 AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
494 [Check for POWERPC VSX support at run-time])
495 AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file]
496 [for the list of supported OSes.]);;
498 AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
499 [Turn on POWERPC VSX optimizations at run-time]);;
501 AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
502 [Enable POWERPC VSX optimizations])
503 AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if]
504 [you want the optimizations unconditionally pass '-maltivec -mvsx']
505 [or '-mcpu=power8' to the compiler.]);;
507 AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value])
510 # Add PowerPC-specific files to all builds where $host_cpu is powerpc('powerpc*')
511 # or where PowerPC optimizations were explicitly requested (this allows a fallback
512 # if a future host CPU does not match 'powerpc*')
514 AM_CONDITIONAL([PNG_POWERPC_VSX],
515 [test "$enable_powerpc_vsx" != 'no' &&
517 powerpc*|ppc64*) : ;;
520 AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
522 # Config files, substituting as above
523 AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
524 AC_CONFIG_FILES([libpng-config:libpng-config.in],
525 [chmod +x libpng-config])