• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# configure.ac
2
3# Copyright (c) 2004-2016 Glenn Randers-Pehrson
4# Last changed in libpng 1.6.25 [September 1, 2016]
5
6# This code is released under the libpng license.
7# For conditions of distribution and use, see the disclaimer
8# and license in png.h
9
10dnl Process this file with autoconf to produce a configure script.
11dnl
12dnl Minor upgrades (compatible ABI): increment the package version
13dnl (third field in two places below) and set the PNGLIB_RELEASE
14dnl variable.
15dnl
16dnl Major upgrades (incompatible ABI): increment the package major
17dnl version (second field, or first if desired), set the minor
18dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
19dnl Makefile.am to upgrade the package name.
20
21dnl This is here to prevent earlier autoconf from being used, it
22dnl should not be necessary to regenerate configure if the time
23dnl stamps are correct
24AC_PREREQ([2.68])
25
26dnl Version number stuff here:
27
28AC_INIT([libpng],[1.6.25],[png-mng-implement@lists.sourceforge.net])
29AC_CONFIG_MACRO_DIR([scripts])
30
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
37AM_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
41AM_MAINTAINER_MODE
42
43dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
44dnl version; aclocal.m4 will generate a failure if you use a prior version of
45dnl automake, so the following is not necessary (and is not defined anyway):
46dnl AM_PREREQ([1.11.2])
47dnl stop configure from automagically running automake
48
49PNGLIB_VERSION=1.6.25
50PNGLIB_MAJOR=1
51PNGLIB_MINOR=6
52PNGLIB_RELEASE=25
53
54dnl End of version number stuff
55
56AC_CONFIG_SRCDIR([pngget.c])
57AC_CONFIG_HEADERS([config.h])
58
59# Checks for programs.
60AC_LANG([C])
61AC_PROG_CC
62AM_PROG_AS
63LT_PATH_LD
64AC_PROG_CPP
65AC_PROG_AWK
66AC_PROG_INSTALL
67AC_PROG_LN_S
68AC_PROG_MAKE_SET
69
70dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any
71dnl compatible later version may be used
72LT_INIT([win32-dll])
73LT_PREREQ([2.4.2])
74
75# Some awks crash when confronted with pnglibconf.dfa, do a test run now
76# to make sure this doesn't happen
77AC_MSG_CHECKING([that AWK works])
78if ${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
81then
82   AC_MSG_RESULT([ok])
83else
84   AC_MSG_FAILURE([failed], 1)
85fi
86
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
89DFNCPP="$CPP"
90AC_SUBST(DFNCPP)
91
92# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
93# checks the compiler with a program that generates a warning), add the
94# following option to deal with this
95AC_ARG_VAR(PNG_COPTS,
96   [additional flags for the C compiler, use this for options that would]
97   [cause configure itself to fail])
98AC_ARG_ENABLE(werror,
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
103      sav_CFLAGS="$CFLAGS"
104      CFLAGS="$enable_werror $CFLAGS"
105      AC_MSG_CHECKING([if the compiler allows $enable_werror])
106      AC_COMPILE_IFELSE(
107         [AC_LANG_SOURCE([
108            [int main(int argc, char **argv){]
109            [return argv[argc-1][0];]
110            [}]])],
111         AC_MSG_RESULT(yes)
112         PNG_COPTS="$PNG_COPTS $enable_werror",
113         AC_MSG_RESULT(no))
114      CFLAGS="$sav_CFLAGS"
115    fi],)
116
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 _POSIX_SOURCE to 1
119# This is incompatible with the new default mode, so we test for that and force the
120# "-std=c89" compiler option:
121AC_MSG_CHECKING([if we need to force back C standard to C89])
122AC_COMPILE_IFELSE(
123   [AC_LANG_PROGRAM([
124      [#define _POSIX_SOURCE 1]
125      [#include <stdio.h>]
126   ])],
127   AC_MSG_RESULT(no),[
128      if test "x$GCC" != "xyes"; then
129         AC_MSG_ERROR(
130            [Forcing back to C89 is required but the flags are only known for GCC])
131      fi
132   AC_MSG_RESULT(yes)
133   CFLAGS="$CFLAGS -std=c89"
134])
135
136# Checks for header files.
137AC_HEADER_STDC
138
139# Checks for typedefs, structures, and compiler characteristics.
140AC_C_CONST
141AC_TYPE_SIZE_T
142AC_STRUCT_TM
143AC_C_RESTRICT
144
145# Checks for library functions.
146AC_FUNC_STRTOD
147AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
148AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
149
150# Some later POSIX 1003.1 functions are required for test programs, failure here
151# is soft (the corresponding test program is not built).
152AC_CHECK_FUNC([clock_gettime],,[AC_MSG_WARN([not building timepng])])
153AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
154
155AC_ARG_WITH(zlib-prefix,
156   AS_HELP_STRING([[[--with-zlib-prefix]]],
157      [prefix that may have been used in installed zlib]),
158      [ZPREFIX=${withval}],
159      [ZPREFIX='z_'])
160AC_CHECK_LIB(z, zlibVersion, ,
161    AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
162
163# The following is for pngvalid, to ensure it catches FP errors even on
164# platforms that don't enable FP exceptions, the function appears in the math
165# library (typically), it's not an error if it is not found.
166AC_CHECK_LIB([m], [feenableexcept])
167AC_CHECK_FUNCS([feenableexcept])
168
169AC_MSG_CHECKING([if using Solaris linker])
170SLD=`$LD --version 2>&1 | grep Solaris`
171if test "$SLD"; then
172    have_solaris_ld=yes
173    AC_MSG_RESULT(yes)
174else
175    have_solaris_ld=no
176    AC_MSG_RESULT(no)
177fi
178AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
179
180AC_MSG_CHECKING([if libraries can be versioned])
181# Special case for PE/COFF platforms: ld reports
182# support for version-script, but doesn't actually
183# DO anything with it.
184case $host in
185*cygwin* | *mingw32* | *interix* )
186    have_ld_version_script=no
187    AC_MSG_RESULT(no)
188;;
189* )
190
191if test "$have_solaris_ld" = "yes"; then
192    GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
193else
194    GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
195fi
196
197if test "$GLD"; then
198    have_ld_version_script=yes
199    AC_MSG_RESULT(yes)
200else
201    have_ld_version_script=no
202    AC_MSG_RESULT(no)
203    AC_MSG_WARN(*** You have not enabled versioned symbols.)
204fi
205;;
206esac
207
208AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
209
210if test "$have_ld_version_script" = "yes"; then
211    AC_MSG_CHECKING([for symbol prefix])
212    SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
213                  | ${CPP-${CC-gcc} -E} - 2>&1 \
214                  | ${EGREP-grep} "^PREFIX=" \
215                  | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
216    AC_SUBST(SYMBOL_PREFIX)
217    AC_MSG_RESULT($SYMBOL_PREFIX)
218fi
219
220# Substitutions for .in files
221AC_SUBST(PNGLIB_VERSION)
222AC_SUBST(PNGLIB_MAJOR)
223AC_SUBST(PNGLIB_MINOR)
224AC_SUBST(PNGLIB_RELEASE)
225
226# Additional arguments (and substitutions)
227# Allow the pkg-config directory to be set
228AC_ARG_WITH(pkgconfigdir,
229   AS_HELP_STRING([[[--with-pkgconfigdir]]],
230      [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
231   [pkgconfigdir=${withval}],
232   [pkgconfigdir='${libdir}/pkgconfig'])
233
234AC_SUBST([pkgconfigdir])
235AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
236
237# Make the *-config binary config scripts optional
238AC_ARG_WITH(binconfigs,
239   AS_HELP_STRING([[[--with-binconfigs]]],
240      [Generate shell libpng-config scripts as well as pkg-config data]
241      [@<:@default=yes@:>@]),
242   [if test "${withval}" = no; then
243      binconfigs=
244      AC_MSG_NOTICE([[libpng-config scripts will not be built]])
245    else
246      binconfigs='${binconfigs}'
247    fi],
248   [binconfigs='${binconfigs}'])
249AC_SUBST([binconfigs])
250
251# Support for prefixes to the API function names; this will generate defines
252# at the start of the build to rename exported library functions
253AC_ARG_WITH(libpng-prefix,
254   AS_HELP_STRING([[[--with-libpng-prefix]]],
255      [prefix libpng exported function (API) names with the given value]),
256   [if test "${withval:-no}" != "no"; then
257      AC_SUBST([PNG_PREFIX], [${withval}])
258    fi])
259AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
260
261# Control over what links are made for installed files.  Versioned files are
262# always installed, when the following options are turned on corresponding
263# unversioned links are also created (normally as symbolic links):
264AC_ARG_ENABLE([unversioned-links],
265   AS_HELP_STRING([[[--enable-unversioned-links]]],
266      [Installed libpng header files are placed in a versioned subdirectory]
267      [and installed libpng library (including DLL) files are versioned.]
268      [If this option is enabled unversioned links will be created pointing to]
269      [the corresponding installed files.  If you use libpng.pc or]
270      [libpng-config for all builds you do not need these links, but if you]
271      [compile programs directly they will typically #include <png.h> and]
272      [link with -lpng; in that case you need the links.]
273      [The links can be installed manually using 'make install-header-links']
274      [and 'make install-library-links' and can be removed using the]
275      [corresponding uninstall- targets.  If you do enable this option every]
276      [libpng 'make install' will recreate the links to point to the just]
277      [installed version of libpng.  The default is to create the links;]
278      [use --disable-unversioned-links to change this]))
279
280# The AM_CONDITIONAL test is written so that the default is enabled;
281# --disable-unversioned-links must be given to turn the option off.
282AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
283
284AC_ARG_ENABLE([unversioned-libpng-pc],
285   AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
286      [Install the configuration file 'libpng.pc' as a link to the versioned]
287      [version.  This is done by default - use --disable-unversioned-libpng-pc]
288      [to change this.]))
289AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
290   [test "$enable_unversioned_libpng_pc" != "no"])
291
292AC_ARG_ENABLE([unversioned-libpng-config],
293   AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
294      [Install the configuration file 'libpng-config' as a link to the]
295      [versioned version.  This is done by default - use]
296      [--disable-unversioned-libpng-config to change this.]))
297AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
298   [test "$enable_unversioned_libpng_config" != "no"])
299
300# HOST SPECIFIC OPTIONS
301# =====================
302#
303# ARM
304# ===
305#
306# ARM NEON (SIMD) support.
307
308AC_ARG_ENABLE([arm-neon],
309   AS_HELP_STRING([[[--enable-arm-neon]]],
310      [Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
311      [no/off: disable the optimizations; check: use internal checking code]
312      [(deprecated and poorly supported); api: disable by default, enable by]
313      [a call to png_set_option; yes/on: turn on unconditionally.]
314      [If not specified: determined by the compiler.]),
315   [case "$enableval" in
316      no|off)
317         # disable the default enabling on __ARM_NEON__ systems:
318         AC_DEFINE([PNG_ARM_NEON_OPT], [0],
319                   [Disable ARM Neon optimizations])
320         # Prevent inclusion of the assembler files below:
321         enable_arm_neon=no;;
322      check)
323         AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
324                   [Check for ARM Neon support at run-time]);;
325      api)
326         AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
327                   [Turn on ARM Neon optimizations at run-time]);;
328      yes|on)
329         AC_DEFINE([PNG_ARM_NEON_OPT], [2],
330                   [Enable ARM Neon optimizations])
331         AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
332            [you want the optimizations unconditionally pass -mfpu=neon]
333            [to the compiler.]);;
334      *)
335         AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
336   esac])
337
338# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
339# where ARM optimizations were explicitly requested (this allows a fallback if a
340# future host CPU does not match 'arm*')
341
342AM_CONDITIONAL([PNG_ARM_NEON],
343   [test "$enable_arm_neon" != 'no' &&
344    case "$host_cpu" in
345      arm*|aarch64*) :;;
346      *)    test "$enable_arm_neon" != '';;
347    esac])
348
349# MIPS
350# ===
351#
352# MIPS MSA (SIMD) support.
353
354AC_ARG_ENABLE([mips-msa],
355   AS_HELP_STRING([[[--enable-mips-msa]]],
356      [Enable MIPS MSA optimizations: =no/off, check, api, yes/on:]
357      [no/off: disable the optimizations; check: use internal checking code]
358      [(deprecated and poorly supported); api: disable by default, enable by]
359      [a call to png_set_option; yes/on: turn on unconditionally.]
360      [If not specified: determined by the compiler.]),
361   [case "$enableval" in
362      no|off)
363         # disable the default enabling on __mips_msa systems:
364         AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
365                   [Disable MIPS MSA optimizations])
366         # Prevent inclusion of the assembler files below:
367         enable_mips_msa=no;;
368      check)
369         AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
370                   [Check for MIPS MSA support at run-time]);;
371      api)
372         AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [],
373                   [Turn on MIPS MSA optimizations at run-time]);;
374      yes|on)
375         AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
376                   [Enable MIPS MSA optimizations])
377         AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if]
378            [you want the optimizations unconditionally pass '-mmsa -mfp64']
379            [to the compiler.]);;
380      *)
381         AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value])
382   esac])
383
384# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
385# where MIPS optimizations were explicitly requested (this allows a fallback if a
386# future host CPU does not match 'mips*')
387
388AM_CONDITIONAL([PNG_MIPS_MSA],
389   [test "$enable_mips_msa" != 'no' &&
390    case "$host_cpu" in
391      mipsel*|mips64el*) :;;
392    esac])
393
394# INTEL
395# =====
396#
397# INTEL SSE (SIMD) support.
398
399AC_ARG_ENABLE([intel-sse],
400   AS_HELP_STRING([[[--enable-intel-sse]]],
401      [Enable Intel SSE optimizations: =no/off, yes/on:]
402      [no/off: disable the optimizations;]
403      [yes/on: enable the optimizations.]
404      [If not specified: determined by the compiler.]),
405   [case "$enableval" in
406      no|off)
407         # disable the default enabling:
408         AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
409                   [Disable Intel SSE optimizations])
410         # Prevent inclusion of the assembler files below:
411         enable_intel_sse=no;;
412      yes|on)
413         AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
414                   [Enable Intel SSE optimizations]);;
415      *)
416         AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
417   esac])
418
419# Add Intel specific files to all builds where the host_cpu is Intel ('x86*')
420# or where Intel optimizations were explicitly requested (this allows a
421# fallback if a future host CPU does not match 'x86*')
422AM_CONDITIONAL([PNG_INTEL_SSE],
423   [test "$enable_intel_sse" != 'no' &&
424    case "$host_cpu" in
425      i?86|x86_64) :;;
426      *)    test "$enable_intel_sse" != '';;
427    esac])
428
429AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
430
431# Config files, substituting as above
432AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
433AC_CONFIG_FILES([libpng-config:libpng-config.in],
434   [chmod +x libpng-config])
435
436AC_OUTPUT
437