configure.ac 12.3 KB
Newer Older
1 2
# configure.ac

3 4 5 6 7 8 9
# Copyright (c) 2004-2015 Glenn Randers-Pehrson
# Last changed in libpng 1.6.22 [(PENDING RELEASE)]

# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h

10 11 12
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Minor upgrades (compatible ABI): increment the package version
13
dnl (third field in two places below) and set the PNGLIB_RELEASE
14 15 16 17 18 19 20 21 22 23
dnl variable.
dnl
dnl Major upgrades (incompatible ABI): increment the package major
dnl version (second field, or first if desired), set the minor
dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
dnl Makefile.am to upgrade the package name.

dnl This is here to prevent earlier autoconf from being used, it
dnl should not be necessary to regenerate configure if the time
dnl stamps are correct
24
AC_PREREQ([2.68])
25 26 27

dnl Version number stuff here:

28
AC_INIT([libpng],[1.6.22beta04],[png-mng-implement@lists.sourceforge.net])
29
AC_CONFIG_MACRO_DIR([scripts])
30 31 32 33 34

# libpng does not follow GNU file name conventions (hence 'foreign')
# color-tests requires automake 1.11 or later
# silent-rules requires automake 1.11 or later
# dist-xz requires automake 1.11 or later
35 36
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
# 1.13 is required for parallel tests
37
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
38 39 40
# The following line causes --disable-maintainer-mode to be the default to
# configure, this is necessary because libpng distributions cannot rely on the
# time stamps of the autotools generated files being correct
41 42
AM_MAINTAINER_MODE

43 44 45 46 47 48
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
dnl version; aclocal.m4 will generate a failure if you use a prior version of
dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake

49
PNGLIB_VERSION=1.6.22beta04
50
PNGLIB_MAJOR=1
51
PNGLIB_MINOR=6
52
PNGLIB_RELEASE=22
53 54 55

dnl End of version number stuff

56
AC_CONFIG_SRCDIR([pngget.c])
57
AC_CONFIG_HEADERS([config.h])
58 59

# Checks for programs.
60
AC_LANG([C])
61
AC_PROG_CC
62
AM_PROG_AS
63
LT_PATH_LD
64
AC_PROG_CPP
65
AC_PROG_AWK
66 67
AC_PROG_INSTALL
AC_PROG_LN_S
68
AC_PROG_MAKE_SET
69 70 71

dnl libtool/libtoolize; version 2.4.2 is the tested version, this or any
dnl compatible later version may be used
72
LT_INIT([win32-dll])
73
LT_PREREQ([2.4.2])
74

75 76 77 78 79 80 81 82
# Some awks crash when confronted with pnglibconf.dfa, do a test run now
# to make sure this doesn't happen
AC_MSG_CHECKING([that AWK works])
if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
   ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
   ${srcdir}/pngusr.dfa 1>&2
then
   AC_MSG_RESULT([ok])
83
else
84
   AC_MSG_FAILURE([failed], 1)
85 86
fi

87 88 89 90 91
# This is a remnant of the old cc -E validation, where it may have been
# necessary to use a different preprocessor for .dfn files
DFNCPP="$CPP"
AC_SUBST(DFNCPP)

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
# checks the compiler with a program that generates a warning), add the
# following option to deal with this
AC_ARG_VAR(PNG_COPTS,
   [additional flags for the C compiler, use this for options that would]
   [cause configure itself to fail])
AC_ARG_ENABLE(werror,
   AS_HELP_STRING([[[--enable-werror[=OPT]]]],
      [Pass -Werror or the given argument to the compiler if it is supported]),
   [test "$enable_werror" = "yes" && enable_werror="-Werror"
    if test "$enable_werror" != "no"; then
      sav_CFLAGS="$CFLAGS"
      CFLAGS="$enable_werror $CFLAGS"
      AC_MSG_CHECKING([if the compiler allows $enable_werror])
      AC_COMPILE_IFELSE(
         [AC_LANG_SOURCE([
            [int main(int argc, char **argv){]
            [return argv[argc-1][0];]
            [}]])],
         AC_MSG_RESULT(yes)
         PNG_COPTS="$PNG_COPTS $enable_werror",
         AC_MSG_RESULT(no))
      CFLAGS="$sav_CFLAGS"
    fi],)

117 118 119 120 121 122 123 124 125 126 127 128 129 130
# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89
# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1
# This is incompatible with the new default mode, so we test for that and force the 
AC_MSG_CHECKING([if we need to force back C standard to C89])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define _POSIX_SOURCE 1
#include <stdio.h>
])],AC_MSG_RESULT(no),[
if test "x$GCC" != "xyes"; then
  AC_MSG_ERROR([Forcing back to C89 is required but the flags are unknown for other compilers than GCC])
fi
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -std=c89"
])

131 132 133 134 135 136 137
# Checks for header files.
AC_HEADER_STDC

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
J
John Bowler 已提交
138
AC_C_RESTRICT
139 140 141

# Checks for library functions.
AC_FUNC_STRTOD
142 143
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
144
AC_ARG_WITH(zlib-prefix,
145 146 147 148
   AS_HELP_STRING([[[--with-zlib-prefix]]],
      [prefix that may have been used in installed zlib]),
      [ZPREFIX=${withval}],
      [ZPREFIX='z_'])
149
AC_CHECK_LIB(z, zlibVersion, ,
150
    AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
151

J
John Bowler 已提交
152 153 154 155 156
# The following is for pngvalid, to ensure it catches FP errors even on
# platforms that don't enable FP exceptions, the function appears in the math
# library (typically), it's not an error if it is not found.
AC_CHECK_LIB([m], [feenableexcept])
AC_CHECK_FUNCS([feenableexcept])
157

158 159 160 161 162 163 164 165 166 167 168
AC_MSG_CHECKING([if using Solaris linker])
SLD=`$LD --version 2>&1 | grep Solaris`
if test "$SLD"; then
    have_solaris_ld=yes
    AC_MSG_RESULT(yes)
else
    have_solaris_ld=no
    AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")

169
AC_MSG_CHECKING([if libraries can be versioned])
170 171 172 173 174 175 176 177 178 179
# Special case for PE/COFF platforms: ld reports
# support for version-script, but doesn't actually
# DO anything with it.
case $host in
*cygwin* | *mingw32* | *interix* )
    have_ld_version_script=no
    AC_MSG_RESULT(no)
;;
* )

180 181 182 183 184 185
if test "$have_solaris_ld" = "yes"; then
    GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
else
    GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
fi

186 187 188 189 190 191
if test "$GLD"; then
    have_ld_version_script=yes
    AC_MSG_RESULT(yes)
else
    have_ld_version_script=no
    AC_MSG_RESULT(no)
192
    AC_MSG_WARN(*** You have not enabled versioned symbols.)
193
fi
194 195 196
;;
esac

197
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
198

199 200 201
if test "$have_ld_version_script" = "yes"; then
    AC_MSG_CHECKING([for symbol prefix])
    SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
202 203 204
                  | ${CPP-${CC-gcc} -E} - 2>&1 \
                  | ${EGREP-grep} "^PREFIX=" \
                  | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
205 206 207 208
    AC_SUBST(SYMBOL_PREFIX)
    AC_MSG_RESULT($SYMBOL_PREFIX)
fi

209 210 211 212
# Substitutions for .in files
AC_SUBST(PNGLIB_VERSION)
AC_SUBST(PNGLIB_MAJOR)
AC_SUBST(PNGLIB_MINOR)
213
AC_SUBST(PNGLIB_RELEASE)
214 215 216 217

# Additional arguments (and substitutions)
# Allow the pkg-config directory to be set
AC_ARG_WITH(pkgconfigdir,
218 219 220 221
   AS_HELP_STRING([[[--with-pkgconfigdir]]],
      [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
   [pkgconfigdir=${withval}],
   [pkgconfigdir='${libdir}/pkgconfig'])
222

223
AC_SUBST([pkgconfigdir])
224
AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
225

226 227
# Make the *-config binary config scripts optional
AC_ARG_WITH(binconfigs,
228 229 230 231 232 233 234 235 236 237
   AS_HELP_STRING([[[--with-binconfigs]]],
      [Generate shell libpng-config scripts as well as pkg-config data]
      [@<:@default=yes@:>@]),
   [if test "${withval}" = no; then
      binconfigs=
      AC_MSG_NOTICE([[libpng-config scripts will not be built]])
    else
      binconfigs='${binconfigs}'
    fi],
   [binconfigs='${binconfigs}'])
238
AC_SUBST([binconfigs])
239

240 241 242 243 244 245 246 247
# Support for prefixes to the API function names; this will generate defines
# at the start of the build to rename exported library functions
AC_ARG_WITH(libpng-prefix,
   AS_HELP_STRING([[[--with-libpng-prefix]]],
      [prefix libpng exported function (API) names with the given value]),
   [if test "${withval:-no}" != "no"; then
      AC_SUBST([PNG_PREFIX], [${withval}])
    fi])
248
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
249

250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
# Control over what links are made for installed files.  Versioned files are
# always installed, when the following options are turned on corresponding
# unversioned links are also created (normally as symbolic links):
AC_ARG_ENABLE([unversioned-links],
   AS_HELP_STRING([[[--enable-unversioned-links]]],
      [Installed libpng header files are placed in a versioned subdirectory]
      [and installed libpng library (including DLL) files are versioned.]
      [If this option is enabled unversioned links will be created pointing to]
      [the corresponding installed files.  If you use libpng.pc or]
      [libpng-config for all builds you do not need these links, but if you]
      [compile programs directly they will typically #include <png.h> and]
      [link with -lpng; in that case you need the links.]
      [The links can be installed manually using 'make install-header-links']
      [and 'make install-library-links' and can be removed using the]
      [corresponding uninstall- targets.  If you do enable this option every]
      [libpng 'make install' will recreate the links to point to the just]
      [installed version of libpng.  The default is to create the links;]
      [use --disable-unversioned-links to change this]))

# The AM_CONDITIONAL test is written so that the default is enabled;
# --disable-unversioned-links must be given to turn the option off.
AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])

AC_ARG_ENABLE([unversioned-libpng-pc],
   AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
      [Install the configuration file 'libpng.pc' as a link to the versioned]
      [version.  This is done by default - use --disable-unversioned-libpng-pc]
      [to change this.]))
AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
   [test "$enable_unversioned_libpng_pc" != "no"])

AC_ARG_ENABLE([unversioned-libpng-config],
   AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
      [Install the configuration file 'libpng-config' as a link to the]
      [versioned version.  This is done by default - use]
      [--disable-unversioned-libpng-config to change this.]))
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
   [test "$enable_unversioned_libpng_config" != "no"])

289 290 291 292 293 294 295 296
# HOST SPECIFIC OPTIONS
# =====================
#
# ARM
# ===
#
# ARM NEON (SIMD) support.

297
AC_ARG_ENABLE([arm-neon],
298
   AS_HELP_STRING([[[--enable-arm-neon]]],
299 300
      [Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
      [no/off: disable the optimizations; check: use internal checking code]
301
      [(deprecated and poorly supported); api: disable by default, enable by]
302 303
      [a call to png_set_option; yes/on: turn on unconditionally.]
      [If not specified: determined by the compiler.]),
304
   [case "$enableval" in
305 306
      no|off)
         # disable the default enabling on __ARM_NEON__ systems:
307
         AC_DEFINE([PNG_ARM_NEON_OPT], [0],
308 309 310
                   [Disable ARM Neon optimizations])
         # Prevent inclusion of the assembler files below:
         enable_arm_neon=no;;
311
      check)
312 313
         AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
                   [Check for ARM Neon support at run-time]);;
314
      api)
315 316
         AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
                   [Turn on ARM Neon optimizations at run-time]);;
317
      yes|on)
318 319 320 321 322
         AC_DEFINE([PNG_ARM_NEON_OPT], [2],
                   [Enable ARM Neon optimizations])
         AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
            [you want the optimizations unconditionally pass -mfpu=neon]
            [to the compiler.]);;
323
      *)
324
         AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
325
   esac])
326

327 328 329
# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
# where ARM optimizations were explicitly requested (this allows a fallback if a
# future host CPU does not match 'arm*')
330 331 332

AM_CONDITIONAL([PNG_ARM_NEON],
   [test "$enable_arm_neon" != 'no' &&
333
    case "$host_cpu" in
334
      arm*|aarch64*) :;;
335 336
      *)    test "$enable_arm_neon" != '';;
    esac])
337

338 339
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])

340
# Config files, substituting as above
341
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
342
AC_CONFIG_FILES([libpng-config:libpng-config.in],
343
   [chmod +x libpng-config])
344 345

AC_OUTPUT