configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. # configure.ac
  2. dnl Process this file with autoconf to produce a configure script.
  3. dnl
  4. dnl Minor upgrades (compatible ABI): increment the package version
  5. dnl (third field in two places below) and set the PNGLIB_RELEASE
  6. dnl variable.
  7. dnl
  8. dnl Major upgrades (incompatible ABI): increment the package major
  9. dnl version (second field, or first if desired), set the minor
  10. dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
  11. dnl Makefile.am to upgrade the package name.
  12. dnl This is here to prevent earlier autoconf from being used, it
  13. dnl should not be necessary to regenerate configure if the time
  14. dnl stamps are correct
  15. AC_PREREQ([2.68])
  16. dnl Version number stuff here:
  17. AC_INIT([libpng],[1.6.20],[[email protected]])
  18. AC_CONFIG_MACRO_DIR([scripts])
  19. # libpng does not follow GNU file name conventions (hence 'foreign')
  20. # color-tests requires automake 1.11 or later
  21. # silent-rules requires automake 1.11 or later
  22. # dist-xz requires automake 1.11 or later
  23. # 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
  24. # 1.13 is required for parallel tests
  25. AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
  26. # The following line causes --disable-maintainer-mode to be the default to
  27. # configure, this is necessary because libpng distributions cannot rely on the
  28. # time stamps of the autotools generated files being correct
  29. AM_MAINTAINER_MODE
  30. dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
  31. dnl version; aclocal.m4 will generate a failure if you use a prior version of
  32. dnl automake, so the following is not necessary (and is not defined anyway):
  33. dnl AM_PREREQ([1.11.2])
  34. dnl stop configure from automagically running automake
  35. PNGLIB_VERSION=1.6.20
  36. PNGLIB_MAJOR=1
  37. PNGLIB_MINOR=6
  38. PNGLIB_RELEASE=20
  39. dnl End of version number stuff
  40. AC_CONFIG_SRCDIR([pngget.c])
  41. AC_CONFIG_HEADERS([config.h])
  42. # Checks for programs.
  43. AC_LANG([C])
  44. AC_PROG_CC
  45. AM_PROG_AS
  46. LT_PATH_LD
  47. AC_PROG_CPP
  48. AC_PROG_AWK
  49. AC_PROG_INSTALL
  50. AC_PROG_LN_S
  51. AC_PROG_MAKE_SET
  52. dnl libtool/libtoolize; version 2.4.2 is the tested version, this or any
  53. dnl compatible later version may be used
  54. LT_INIT([win32-dll])
  55. LT_PREREQ([2.4.2])
  56. # Some awks crash when confronted with pnglibconf.dfa, do a test run now
  57. # to make sure this doesn't happen
  58. AC_MSG_CHECKING([that AWK works])
  59. if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
  60. ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
  61. ${srcdir}/pngusr.dfa 1>&2
  62. then
  63. AC_MSG_RESULT([ok])
  64. else
  65. AC_MSG_FAILURE([failed], 1)
  66. fi
  67. # This is a remnant of the old cc -E validation, where it may have been
  68. # necessary to use a different preprocessor for .dfn files
  69. DFNCPP="$CPP"
  70. AC_SUBST(DFNCPP)
  71. # -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
  72. # checks the compiler with a program that generates a warning), add the
  73. # following option to deal with this
  74. AC_ARG_VAR(PNG_COPTS,
  75. [additional flags for the C compiler, use this for options that would]
  76. [cause configure itself to fail])
  77. AC_ARG_ENABLE(werror,
  78. AS_HELP_STRING([[[--enable-werror[=OPT]]]],
  79. [Pass -Werror or the given argument to the compiler if it is supported]),
  80. [test "$enable_werror" = "yes" && enable_werror="-Werror"
  81. if test "$enable_werror" != "no"; then
  82. sav_CFLAGS="$CFLAGS"
  83. CFLAGS="$enable_werror $CFLAGS"
  84. AC_MSG_CHECKING([if the compiler allows $enable_werror])
  85. AC_COMPILE_IFELSE(
  86. [AC_LANG_SOURCE([
  87. [int main(int argc, char **argv){]
  88. [return argv[argc-1][0];]
  89. [}]])],
  90. AC_MSG_RESULT(yes)
  91. PNG_COPTS="$PNG_COPTS $enable_werror",
  92. AC_MSG_RESULT(no))
  93. CFLAGS="$sav_CFLAGS"
  94. fi],)
  95. # Checks for header files.
  96. AC_HEADER_STDC
  97. # Checks for typedefs, structures, and compiler characteristics.
  98. AC_C_CONST
  99. AC_TYPE_SIZE_T
  100. AC_STRUCT_TM
  101. AC_C_RESTRICT
  102. # Checks for library functions.
  103. AC_FUNC_STRTOD
  104. AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
  105. AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
  106. AC_ARG_WITH(zlib-prefix,
  107. AS_HELP_STRING([[[--with-zlib-prefix]]],
  108. [prefix that may have been used in installed zlib]),
  109. [ZPREFIX=${withval}],
  110. [ZPREFIX='z_'])
  111. AC_CHECK_LIB(z, zlibVersion, ,
  112. AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
  113. # The following is for pngvalid, to ensure it catches FP errors even on
  114. # platforms that don't enable FP exceptions, the function appears in the math
  115. # library (typically), it's not an error if it is not found.
  116. AC_CHECK_LIB([m], [feenableexcept])
  117. AC_CHECK_FUNCS([feenableexcept])
  118. AC_MSG_CHECKING([if using Solaris linker])
  119. SLD=`$LD --version 2>&1 | grep Solaris`
  120. if test "$SLD"; then
  121. have_solaris_ld=yes
  122. AC_MSG_RESULT(yes)
  123. else
  124. have_solaris_ld=no
  125. AC_MSG_RESULT(no)
  126. fi
  127. AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
  128. AC_MSG_CHECKING([if libraries can be versioned])
  129. # Special case for PE/COFF platforms: ld reports
  130. # support for version-script, but doesn't actually
  131. # DO anything with it.
  132. case $host in
  133. *cygwin* | *mingw32* | *interix* )
  134. have_ld_version_script=no
  135. AC_MSG_RESULT(no)
  136. ;;
  137. * )
  138. if test "$have_solaris_ld" = "yes"; then
  139. GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
  140. else
  141. GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
  142. fi
  143. if test "$GLD"; then
  144. have_ld_version_script=yes
  145. AC_MSG_RESULT(yes)
  146. else
  147. have_ld_version_script=no
  148. AC_MSG_RESULT(no)
  149. AC_MSG_WARN(*** You have not enabled versioned symbols.)
  150. fi
  151. ;;
  152. esac
  153. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  154. if test "$have_ld_version_script" = "yes"; then
  155. AC_MSG_CHECKING([for symbol prefix])
  156. SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
  157. | ${CPP-${CC-gcc} -E} - 2>&1 \
  158. | ${EGREP-grep} "^PREFIX=" \
  159. | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
  160. AC_SUBST(SYMBOL_PREFIX)
  161. AC_MSG_RESULT($SYMBOL_PREFIX)
  162. fi
  163. # Substitutions for .in files
  164. AC_SUBST(PNGLIB_VERSION)
  165. AC_SUBST(PNGLIB_MAJOR)
  166. AC_SUBST(PNGLIB_MINOR)
  167. AC_SUBST(PNGLIB_RELEASE)
  168. # Additional arguments (and substitutions)
  169. # Allow the pkg-config directory to be set
  170. AC_ARG_WITH(pkgconfigdir,
  171. AS_HELP_STRING([[[--with-pkgconfigdir]]],
  172. [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
  173. [pkgconfigdir=${withval}],
  174. [pkgconfigdir='${libdir}/pkgconfig'])
  175. AC_SUBST([pkgconfigdir])
  176. AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
  177. # Make the *-config binary config scripts optional
  178. AC_ARG_WITH(binconfigs,
  179. AS_HELP_STRING([[[--with-binconfigs]]],
  180. [Generate shell libpng-config scripts as well as pkg-config data]
  181. [@<:@default=yes@:>@]),
  182. [if test "${withval}" = no; then
  183. binconfigs=
  184. AC_MSG_NOTICE([[libpng-config scripts will not be built]])
  185. else
  186. binconfigs='${binconfigs}'
  187. fi],
  188. [binconfigs='${binconfigs}'])
  189. AC_SUBST([binconfigs])
  190. # Support for prefixes to the API function names; this will generate defines
  191. # at the start of the build to rename exported library functions
  192. AC_ARG_WITH(libpng-prefix,
  193. AS_HELP_STRING([[[--with-libpng-prefix]]],
  194. [prefix libpng exported function (API) names with the given value]),
  195. [if test "${withval:-no}" != "no"; then
  196. AC_SUBST([PNG_PREFIX], [${withval}])
  197. fi])
  198. AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
  199. # Control over what links are made for installed files. Versioned files are
  200. # always installed, when the following options are turned on corresponding
  201. # unversioned links are also created (normally as symbolic links):
  202. AC_ARG_ENABLE([unversioned-links],
  203. AS_HELP_STRING([[[--enable-unversioned-links]]],
  204. [Installed libpng header files are placed in a versioned subdirectory]
  205. [and installed libpng library (including DLL) files are versioned.]
  206. [If this option is enabled unversioned links will be created pointing to]
  207. [the corresponding installed files. If you use libpng.pc or]
  208. [libpng-config for all builds you do not need these links, but if you]
  209. [compile programs directly they will typically #include <png.h> and]
  210. [link with -lpng; in that case you need the links.]
  211. [The links can be installed manually using 'make install-header-links']
  212. [and 'make install-library-links' and can be removed using the]
  213. [corresponding uninstall- targets. If you do enable this option every]
  214. [libpng 'make install' will recreate the links to point to the just]
  215. [installed version of libpng. The default is to create the links;]
  216. [use --disable-unversioned-links to change this]))
  217. # The AM_CONDITIONAL test is written so that the default is enabled;
  218. # --disable-unversioned-links must be given to turn the option off.
  219. AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
  220. AC_ARG_ENABLE([unversioned-libpng-pc],
  221. AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
  222. [Install the configuration file 'libpng.pc' as a link to the versioned]
  223. [version. This is done by default - use --disable-unversioned-libpng-pc]
  224. [to change this.]))
  225. AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
  226. [test "$enable_unversioned_libpng_pc" != "no"])
  227. AC_ARG_ENABLE([unversioned-libpng-config],
  228. AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
  229. [Install the configuration file 'libpng-config' as a link to the]
  230. [versioned version. This is done by default - use]
  231. [--disable-unversioned-libpng-config to change this.]))
  232. AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
  233. [test "$enable_unversioned_libpng_config" != "no"])
  234. # HOST SPECIFIC OPTIONS
  235. # =====================
  236. #
  237. # ARM
  238. # ===
  239. #
  240. # ARM NEON (SIMD) support.
  241. AC_ARG_ENABLE([arm-neon],
  242. AS_HELP_STRING([[[--enable-arm-neon]]],
  243. [Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
  244. [no/off: disable the optimizations; check: use internal checking code]
  245. [(deprecated and poorly supported); api: disable by default, enable by]
  246. [a call to png_set_option; yes/on: turn on unconditionally.]
  247. [If not specified: determined by the compiler.]),
  248. [case "$enableval" in
  249. no|off)
  250. # disable the default enabling on __ARM_NEON__ systems:
  251. AC_DEFINE([PNG_ARM_NEON], [], [ARM NEON support])
  252. AC_DEFINE([PNG_ARM_NEON_OPT], [0],
  253. [Disable ARM Neon optimizations])
  254. # Prevent inclusion of the assembler files below:
  255. enable_arm_neon=no;;
  256. check)
  257. AC_DEFINE([PNG_ARM_NEON], [], [ARM NEON support])
  258. AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
  259. [Check for ARM Neon support at run-time]);;
  260. api)
  261. AC_DEFINE([PNG_ARM_NEON], [], [ARM NEON support])
  262. AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
  263. [Turn on ARM Neon optimizations at run-time]);;
  264. yes|on)
  265. AC_DEFINE([PNG_ARM_NEON], [], [ARM NEON support])
  266. AC_DEFINE([PNG_ARM_NEON_OPT], [2],
  267. [Enable ARM Neon optimizations])
  268. AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
  269. [you want the optimizations unconditionally pass -mfpu=neon]
  270. [to the compiler.]);;
  271. *)
  272. AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
  273. esac])
  274. # Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
  275. # where ARM optimizations were explicitly requested (this allows a fallback if a
  276. # future host CPU does not match 'arm*')
  277. AM_CONDITIONAL([PNG_ARM_NEON],
  278. [test "$enable_arm_neon" != 'no' &&
  279. case "$host_cpu" in
  280. arm*|aarch64*) :;;
  281. *) test "$enable_arm_neon" != '';;
  282. esac])
  283. AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
  284. # Config files, substituting as above
  285. AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
  286. AC_CONFIG_FILES([libpng-config:libpng-config.in],
  287. [chmod +x libpng-config])
  288. AC_OUTPUT