blob: c10a72a91786874e69bb6438034a3addd0b131f6 [file] [log] [blame]
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -06001# configure.ac
2
3dnl Process this file with autoconf to produce a configure script.
4dnl
5dnl Minor upgrades (compatible ABI): increment the package version
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -05006dnl (third field in two places below) and set the PNGLIB_RELEASE
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -06007dnl variable.
8dnl
9dnl Major upgrades (incompatible ABI): increment the package major
10dnl version (second field, or first if desired), set the minor
11dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
12dnl Makefile.am to upgrade the package name.
13
14dnl This is here to prevent earlier autoconf from being used, it
15dnl should not be necessary to regenerate configure if the time
16dnl stamps are correct
John Bowlerfeecc892012-01-28 00:48:08 -060017AC_PREREQ([2.68])
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -060018
19dnl Version number stuff here:
20
Glenn Randers-Pehrson45687622013-12-26 11:28:37 -060021AC_INIT([libpng],[1.6.9beta02],[png-mng-implement@lists.sourceforge.net])
John Bowlera23f3db2012-01-27 10:24:21 -060022AC_CONFIG_MACRO_DIR([scripts])
John Bowler05cbe5a2012-01-28 18:06:55 -060023
24# libpng does not follow GNU file name conventions (hence 'foreign')
25# color-tests requires automake 1.11 or later
26# silent-rules requires automake 1.11 or later
27# dist-xz requires automake 1.11 or later
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -060028# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
29# 1.13 is required for parallel tests
John Bowler940b37b2013-10-04 19:56:19 -050030AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -060031# The following line causes --disable-maintainer-mode to be the default to
32# configure, this is necessary because libpng distributions cannot rely on the
33# time stamps of the autotools generated files being correct
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -060034AM_MAINTAINER_MODE
35
John Bowlerfeecc892012-01-28 00:48:08 -060036dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
37dnl version; aclocal.m4 will generate a failure if you use a prior version of
38dnl automake, so the following is not necessary (and is not defined anyway):
39dnl AM_PREREQ([1.11.2])
40dnl stop configure from automagically running automake
41
Glenn Randers-Pehrson45687622013-12-26 11:28:37 -060042PNGLIB_VERSION=1.6.9beta02
Glenn Randers-Pehrson8568f6e2009-07-28 17:20:26 -050043PNGLIB_MAJOR=1
Glenn Randers-Pehrson15ea1fa2011-11-23 15:28:01 -060044PNGLIB_MINOR=6
Glenn Randers-Pehrsonbff81bd2013-12-19 15:13:00 -060045PNGLIB_RELEASE=9
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -060046
47dnl End of version number stuff
48
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -060049AC_CONFIG_SRCDIR([pngget.c])
John Bowler1eb2c482012-01-25 08:07:29 -060050AC_CONFIG_HEADERS([config.h])
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -060051
52# Checks for programs.
John Bowler71a10f22011-01-22 17:03:33 -060053AC_LANG([C])
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -060054AC_PROG_CC
Glenn Randers-Pehrson6d7705e2011-11-03 00:42:58 -050055AM_PROG_AS
John Bowler1eb2c482012-01-25 08:07:29 -060056LT_PATH_LD
Glenn Randers-Pehrsone6474622006-03-04 16:50:47 -060057AC_PROG_CPP
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -060058AC_PROG_AWK
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -060059AC_PROG_INSTALL
60AC_PROG_LN_S
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -060061AC_PROG_MAKE_SET
John Bowlerfeecc892012-01-28 00:48:08 -060062
63dnl libtool/libtoolize; version 2.4.2 is the tested version, this or any
64dnl compatible later version may be used
Glenn Randers-Pehrson9f650592010-08-11 08:06:11 -050065LT_INIT([win32-dll])
John Bowlerfeecc892012-01-28 00:48:08 -060066LT_PREREQ([2.4.2])
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -060067
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -060068# Some awks crash when confronted with pnglibconf.dfa, do a test run now
69# to make sure this doesn't happen
70AC_MSG_CHECKING([that AWK works])
71if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
72 ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
73 ${srcdir}/pngusr.dfa 1>&2
74then
75 AC_MSG_RESULT([ok])
John Bowler71a10f22011-01-22 17:03:33 -060076else
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -060077 AC_MSG_FAILURE([failed], 1)
John Bowler71a10f22011-01-22 17:03:33 -060078fi
79
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -060080# This is a remnant of the old cc -E validation, where it may have been
81# necessary to use a different preprocessor for .dfn files
82DFNCPP="$CPP"
83AC_SUBST(DFNCPP)
84
John Bowler1eb2c482012-01-25 08:07:29 -060085# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
86# checks the compiler with a program that generates a warning), add the
87# following option to deal with this
88AC_ARG_VAR(PNG_COPTS,
89 [additional flags for the C compiler, use this for options that would]
90 [cause configure itself to fail])
91AC_ARG_ENABLE(werror,
92 AS_HELP_STRING([[[--enable-werror[=OPT]]]],
93 [Pass -Werror or the given argument to the compiler if it is supported]),
94 [test "$enable_werror" = "yes" && enable_werror="-Werror"
95 if test "$enable_werror" != "no"; then
96 sav_CFLAGS="$CFLAGS"
97 CFLAGS="$enable_werror $CFLAGS"
98 AC_MSG_CHECKING([if the compiler allows $enable_werror])
99 AC_COMPILE_IFELSE(
100 [AC_LANG_SOURCE([
101 [int main(int argc, char **argv){]
102 [return argv[argc-1][0];]
103 [}]])],
104 AC_MSG_RESULT(yes)
105 PNG_COPTS="$PNG_COPTS $enable_werror",
106 AC_MSG_RESULT(no))
107 CFLAGS="$sav_CFLAGS"
108 fi],)
109
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600110# Checks for header files.
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600111AC_HEADER_STDC
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600112
113# Checks for typedefs, structures, and compiler characteristics.
114AC_C_CONST
115AC_TYPE_SIZE_T
116AC_STRUCT_TM
John Bowlerfc45f682011-11-04 21:03:39 -0500117AC_C_RESTRICT
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600118
119# Checks for library functions.
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600120AC_FUNC_STRTOD
John Bowler1eb2c482012-01-25 08:07:29 -0600121AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
122AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
Glenn Randers-Pehrson977f6eb2011-01-04 09:07:45 -0600123AC_ARG_WITH(zlib-prefix,
John Bowler1eb2c482012-01-25 08:07:29 -0600124 AS_HELP_STRING([[[--with-zlib-prefix]]],
125 [prefix that may have been used in installed zlib]),
126 [ZPREFIX=${withval}],
127 [ZPREFIX='z_'])
Glenn Randers-Pehrson571db952010-12-09 06:03:03 -0600128AC_CHECK_LIB(z, zlibVersion, ,
John Bowler1eb2c482012-01-25 08:07:29 -0600129 AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
Glenn Randers-Pehrson571db952010-12-09 06:03:03 -0600130
John Bowlerfc45f682011-11-04 21:03:39 -0500131# The following is for pngvalid, to ensure it catches FP errors even on
132# platforms that don't enable FP exceptions, the function appears in the math
133# library (typically), it's not an error if it is not found.
134AC_CHECK_LIB([m], [feenableexcept])
135AC_CHECK_FUNCS([feenableexcept])
Glenn Randers-Pehrsone6474622006-03-04 16:50:47 -0600136
Glenn Randers-Pehrson83bd94f2011-09-01 14:06:49 -0500137AC_MSG_CHECKING([if using Solaris linker])
138SLD=`$LD --version 2>&1 | grep Solaris`
139if test "$SLD"; then
140 have_solaris_ld=yes
141 AC_MSG_RESULT(yes)
142else
143 have_solaris_ld=no
144 AC_MSG_RESULT(no)
145fi
146AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
147
Gilles Espinassef87ef8b2011-12-26 13:10:01 -0600148AC_MSG_CHECKING([if libraries can be versioned])
Glenn Randers-Pehrsonccff3832011-09-09 07:55:25 -0500149# Special case for PE/COFF platforms: ld reports
150# support for version-script, but doesn't actually
151# DO anything with it.
152case $host in
153*cygwin* | *mingw32* | *interix* )
154 have_ld_version_script=no
155 AC_MSG_RESULT(no)
156;;
157* )
158
Glenn Randers-Pehrson83bd94f2011-09-01 14:06:49 -0500159if test "$have_solaris_ld" = "yes"; then
160 GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
161else
162 GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
163fi
164
Glenn Randers-Pehrsone6474622006-03-04 16:50:47 -0600165if test "$GLD"; then
166 have_ld_version_script=yes
167 AC_MSG_RESULT(yes)
168else
169 have_ld_version_script=no
170 AC_MSG_RESULT(no)
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500171 AC_MSG_WARN(*** You have not enabled versioned symbols.)
Glenn Randers-Pehrsone6474622006-03-04 16:50:47 -0600172fi
Glenn Randers-Pehrson9f650592010-08-11 08:06:11 -0500173;;
174esac
175
Glenn Randers-Pehrsone6474622006-03-04 16:50:47 -0600176AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600177
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500178if test "$have_ld_version_script" = "yes"; then
179 AC_MSG_CHECKING([for symbol prefix])
180 SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600181 | ${CPP-${CC-gcc} -E} - 2>&1 \
182 | ${EGREP-grep} "^PREFIX=" \
183 | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500184 AC_SUBST(SYMBOL_PREFIX)
185 AC_MSG_RESULT($SYMBOL_PREFIX)
186fi
187
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -0600188# Substitutions for .in files
189AC_SUBST(PNGLIB_VERSION)
190AC_SUBST(PNGLIB_MAJOR)
191AC_SUBST(PNGLIB_MINOR)
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500192AC_SUBST(PNGLIB_RELEASE)
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600193
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -0600194# Additional arguments (and substitutions)
195# Allow the pkg-config directory to be set
196AC_ARG_WITH(pkgconfigdir,
John Bowler1eb2c482012-01-25 08:07:29 -0600197 AS_HELP_STRING([[[--with-pkgconfigdir]]],
198 [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
199 [pkgconfigdir=${withval}],
200 [pkgconfigdir='${libdir}/pkgconfig'])
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600201
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -0600202AC_SUBST([pkgconfigdir])
John Bowler1eb2c482012-01-25 08:07:29 -0600203AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600204
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -0600205# Make the *-config binary config scripts optional
206AC_ARG_WITH(binconfigs,
John Bowler1eb2c482012-01-25 08:07:29 -0600207 AS_HELP_STRING([[[--with-binconfigs]]],
208 [Generate shell libpng-config scripts as well as pkg-config data]
209 [@<:@default=yes@:>@]),
210 [if test "${withval}" = no; then
211 binconfigs=
212 AC_MSG_NOTICE([[libpng-config scripts will not be built]])
213 else
214 binconfigs='${binconfigs}'
215 fi],
216 [binconfigs='${binconfigs}'])
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -0600217AC_SUBST([binconfigs])
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600218
John Bowler42369cc2012-01-31 07:28:13 -0600219# Support for prefixes to the API function names; this will generate defines
220# at the start of the build to rename exported library functions
221AC_ARG_WITH(libpng-prefix,
222 AS_HELP_STRING([[[--with-libpng-prefix]]],
223 [prefix libpng exported function (API) names with the given value]),
224 [if test "${withval:-no}" != "no"; then
225 AC_SUBST([PNG_PREFIX], [${withval}])
226 fi])
John Bowler516c9c92012-02-01 07:14:24 -0600227AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
John Bowler42369cc2012-01-31 07:28:13 -0600228
John Bowlerd0479d22013-12-29 19:31:56 -0600229# Control over what links are made for installed files. Versioned files are
230# always installed, when the following options are turned on corresponding
231# unversioned links are also created (normally as symbolic links):
232AC_ARG_ENABLE([unversioned-links],
233 AS_HELP_STRING([[[--enable-unversioned-links]]],
234 [Installed libpng header files are placed in a versioned subdirectory]
235 [and installed libpng library (including DLL) files are versioned.]
236 [If this option is enabled unversioned links will be created pointing to]
237 [the corresponding installed files. If you use libpng.pc or]
238 [libpng-config for all builds you do not need these links, but if you]
239 [compile programs directly they will typically #include <png.h> and]
240 [link with -lpng; in that case you need the links.]
241 [The links can be installed manually using 'make install-header-links']
242 [and 'make install-library-links' and can be removed using the]
243 [corresponding uninstall- targets. If you do enable this option every]
244 [libpng 'make install' will recreate the links to point to the just]
245 [installed version of libpng. The default is to create the links;]
246 [use --disable-unversioned-links to change this]))
247
248# The AM_CONDITIONAL test is written so that the default is enabled;
249# --disable-unversioned-links must be given to turn the option off.
250AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
251
252AC_ARG_ENABLE([unversioned-libpng-pc],
253 AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
254 [Install the configuration file 'libpng.pc' as a link to the versioned]
255 [version. This is done by default - use --disable-unversioned-libpng-pc]
256 [to change this.]))
257AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
258 [test "$enable_unversioned_libpng_pc" != "no"])
259
260AC_ARG_ENABLE([unversioned-libpng-config],
261 AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
262 [Install the configuration file 'libpng-config' as a link to the]
263 [versioned version. This is done by default - use]
264 [--disable-unversioned-libpng-config to change this.]))
265AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
266 [test "$enable_unversioned_libpng_config" != "no"])
267
John Bowler7b1da522013-04-25 10:03:42 -0500268# HOST SPECIFIC OPTIONS
269# =====================
270#
271# ARM
272# ===
273#
274# ARM NEON (SIMD) support.
275
Glenn Randers-Pehrson6d7705e2011-11-03 00:42:58 -0500276AC_ARG_ENABLE([arm-neon],
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -0600277 AS_HELP_STRING([[[--enable-arm-neon]]],
John Bowler7b1da522013-04-25 10:03:42 -0500278 [Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
279 [no/off: disable the optimizations; check: use internal checking code]
John Bowlerf3728102013-03-04 16:26:31 -0600280 [(deprecated and poorly supported); api: disable by default, enable by]
John Bowleraa224422013-06-06 12:49:53 -0500281 [a call to png_set_option; yes/on: turn on unconditionally.]
282 [If not specified: determined by the compiler.]),
John Bowlerf3728102013-03-04 16:26:31 -0600283 [case "$enableval" in
John Bowler7b1da522013-04-25 10:03:42 -0500284 no|off)
285 # disable the default enabling on __ARM_NEON__ systems:
John Bowler18dd07e2013-06-08 13:07:13 -0500286 AC_DEFINE([PNG_ARM_NEON_OPT], [0],
John Bowler7b1da522013-04-25 10:03:42 -0500287 [Disable ARM Neon optimizations])
288 # Prevent inclusion of the assembler files below:
289 enable_arm_neon=no;;
John Bowler83a841a2013-10-15 21:19:56 -0500290 check)
John Bowlerf3728102013-03-04 16:26:31 -0600291 AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
292 [Check for ARM Neon support at run-time]);;
John Bowler83a841a2013-10-15 21:19:56 -0500293 api)
John Bowlerf3728102013-03-04 16:26:31 -0600294 AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
295 [Turn on ARM Neon optimizations at run-time]);;
John Bowler83a841a2013-10-15 21:19:56 -0500296 yes|on)
John Bowler18dd07e2013-06-08 13:07:13 -0500297 AC_DEFINE([PNG_ARM_NEON_OPT], [2],
298 [Enable ARM Neon optimizations])
299 AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
300 [you want the optimizations unconditionally pass -mfpu=neon]
301 [to the compiler.]);;
John Bowlerf3728102013-03-04 16:26:31 -0600302 *)
John Bowler7b1da522013-04-25 10:03:42 -0500303 AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
John Bowlerf3728102013-03-04 16:26:31 -0600304 esac])
John Bowler7b1da522013-04-25 10:03:42 -0500305
John Bowlerac09cd02013-04-25 23:13:08 -0500306# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
307# where ARM optimizations were explicitly requested (this allows a fallback if a
308# future host CPU does not match 'arm*')
John Bowler7b1da522013-04-25 10:03:42 -0500309
310AM_CONDITIONAL([PNG_ARM_NEON],
311 [test "$enable_arm_neon" != 'no' &&
John Bowlerac09cd02013-04-25 23:13:08 -0500312 case "$host_cpu" in
313 arm*) :;;
314 *) test "$enable_arm_neon" != '';;
315 esac])
Glenn Randers-Pehrson6d7705e2011-11-03 00:42:58 -0500316
John Bowler1eb2c482012-01-25 08:07:29 -0600317AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
318
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -0600319# Config files, substituting as above
Glenn Randers-Pehrsona687af12009-12-25 16:17:30 -0600320AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
Glenn Randers-Pehrson28d4aae2009-11-13 16:29:45 -0600321AC_CONFIG_FILES([libpng-config:libpng-config.in],
John Bowler1eb2c482012-01-25 08:07:29 -0600322 [chmod +x libpng-config])
Glenn Randers-Pehrsonc3d51c12006-03-02 07:23:18 -0600323
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -0600324AC_OUTPUT