configure.ac 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. # configure.ac
  2. # Copyright (c) 2018-2024 Cosmin Truta
  3. # Copyright (c) 2004-2016 Glenn Randers-Pehrson
  4. # This code is released under the libpng license.
  5. # For conditions of distribution and use, see the disclaimer
  6. # and license in png.h
  7. dnl Process this file with autoconf to produce a configure script.
  8. dnl
  9. dnl Minor upgrades (compatible ABI): increment the package version
  10. dnl (third field in two places below) and set the PNGLIB_RELEASE
  11. dnl variable.
  12. dnl
  13. dnl Major upgrades (incompatible ABI): increment the package major
  14. dnl version (second field, or first if desired), set the minor
  15. dnl to 0, set PNGLIB_MAJOR below *and* follow the instructions in
  16. dnl Makefile.am to upgrade the package name.
  17. dnl This is here to prevent earlier autoconf from being used, it
  18. dnl should not be necessary to regenerate configure if the time
  19. dnl stamps are correct
  20. AC_PREREQ([2.68])
  21. dnl Version number stuff here:
  22. AC_INIT([libpng],[1.6.48],[[email protected]])
  23. AC_CONFIG_MACRO_DIR([scripts/autoconf])
  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
  28. # 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
  29. # 1.13 is required for parallel tests
  30. AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
  31. # 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
  34. AM_MAINTAINER_MODE
  35. dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
  36. dnl version; aclocal.m4 will generate a failure if you use a prior version of
  37. dnl automake, so the following is not necessary (and is not defined anyway):
  38. dnl AM_PREREQ([1.11.2])
  39. dnl stop configure from automagically running automake
  40. PNGLIB_VERSION=1.6.48
  41. PNGLIB_MAJOR=1
  42. PNGLIB_MINOR=6
  43. PNGLIB_RELEASE=48
  44. dnl End of version number stuff
  45. AC_CONFIG_SRCDIR([pngget.c])
  46. AC_CONFIG_HEADERS([config.h])
  47. # Check the basic programs.
  48. AC_LANG([C])
  49. AC_PROG_CC
  50. AM_PROG_AS
  51. LT_PATH_LD
  52. AC_PROG_CPP
  53. AC_PROG_AWK
  54. AC_PROG_INSTALL
  55. AC_PROG_LN_S
  56. AC_PROG_MAKE_SET
  57. dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any
  58. dnl compatible later version may be used
  59. LT_INIT([win32-dll])
  60. LT_PREREQ([2.4.2])
  61. dnl Declare the AWK variable.
  62. AC_ARG_VAR(AWK, [AWK language processor])
  63. # Some awk implementations crash when confronted with pnglibconf.dfa.
  64. # Run a test now, to make sure this doesn't happen.
  65. AC_MSG_CHECKING([if awk ($AWK) works])
  66. if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
  67. ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
  68. ${srcdir}/pngusr.dfa 1>&2
  69. then
  70. AC_MSG_RESULT([yes])
  71. else
  72. AC_MSG_FAILURE([no], 1)
  73. fi
  74. # This is a remnant of the old cc -E validation, where it may have been
  75. # necessary to use a different preprocessor for .dfn files
  76. DFNCPP="$CPP"
  77. AC_SUBST(DFNCPP)
  78. AC_ARG_ENABLE([tests],
  79. AS_HELP_STRING([--disable-tests],
  80. [do not build the test programs (default is to build)]),
  81. [enable_tests="$enableval"],
  82. [enable_tests=yes])
  83. AM_CONDITIONAL([ENABLE_TESTS],
  84. [test "$enable_tests" != "no"])
  85. AC_ARG_ENABLE([tools],
  86. AS_HELP_STRING([--disable-tools],
  87. [do not build the auxiliary tools (default is to build)]),
  88. [enable_tools="$enableval"],
  89. [enable_tools=yes])
  90. AM_CONDITIONAL([ENABLE_TOOLS],
  91. [test "$enable_tools" != "no"])
  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:
  95. AC_ARG_VAR(PNG_COPTS,
  96. [additional flags for the C compiler, to be used for options that would]
  97. [cause configure itself to fail])
  98. AC_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. # For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89.
  117. # In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining
  118. # _POSIX_SOURCE to 1. This is incompatible with the new default mode, so
  119. # we test for that and force the "-std=c89" compiler option:
  120. AC_MSG_CHECKING([if we need to force back C standard to C89])
  121. AC_COMPILE_IFELSE(
  122. [AC_LANG_PROGRAM([
  123. [#define _POSIX_SOURCE 1]
  124. [#include <stdio.h>]
  125. ])],
  126. AC_MSG_RESULT(no),[
  127. if test "x$GCC" != "xyes"; then
  128. AC_MSG_ERROR(
  129. [Forcing back to C89 is required but the flags are only known for GCC])
  130. fi
  131. AC_MSG_RESULT(yes)
  132. CFLAGS="$CFLAGS -std=c89"
  133. ])
  134. # Checks for structures and compiler characteristics.
  135. AC_STRUCT_TM
  136. AC_C_RESTRICT
  137. # Checks for library functions.
  138. AC_CHECK_FUNCS([pow], ,
  139. [AC_CHECK_LIB([m], [pow], , [AC_MSG_ERROR([cannot find pow])])])
  140. # Some later POSIX 1003.1 functions are required for test programs, failure
  141. # here is soft (the corresponding test program is not built).
  142. AC_CHECK_FUNC([clock_gettime], , [AC_MSG_WARN([not building timepng])])
  143. AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
  144. AC_ARG_WITH(zlib-prefix,
  145. AS_HELP_STRING([[[--with-zlib-prefix]]],
  146. [prefix that may have been used in installed zlib]),
  147. [ZPREFIX=${withval}],
  148. [ZPREFIX='z_'])
  149. AC_CHECK_LIB([z], [zlibVersion], ,
  150. [AC_CHECK_LIB([z], [${ZPREFIX}zlibVersion], ,
  151. [AC_MSG_ERROR([zlib not installed])])])
  152. # The following is for pngvalid, to ensure it catches FP errors even on
  153. # platforms that don't enable FP exceptions, the function appears in the math
  154. # library (typically), it's not an error if it is not found.
  155. AC_CHECK_LIB([m], [feenableexcept])
  156. AC_CHECK_FUNCS([feenableexcept])
  157. AC_MSG_CHECKING([if using Solaris linker])
  158. SLD=`$LD --version 2>&1 | grep Solaris`
  159. if test "$SLD"; then
  160. have_solaris_ld=yes
  161. AC_MSG_RESULT(yes)
  162. else
  163. have_solaris_ld=no
  164. AC_MSG_RESULT(no)
  165. fi
  166. AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
  167. AC_MSG_CHECKING([if libraries can be versioned])
  168. # Special case for PE/COFF platforms: ld reports
  169. # support for version-script, but doesn't actually
  170. # DO anything with it.
  171. case $host in
  172. *cygwin* | *mingw32* | *interix* )
  173. have_ld_version_script=no
  174. AC_MSG_RESULT(no)
  175. ;;
  176. * )
  177. if test "$have_solaris_ld" = "yes"; then
  178. GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
  179. else
  180. GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
  181. fi
  182. if test "$GLD"; then
  183. have_ld_version_script=yes
  184. AC_MSG_RESULT(yes)
  185. else
  186. have_ld_version_script=no
  187. AC_MSG_RESULT(no)
  188. AC_MSG_WARN(*** You have not enabled versioned symbols.)
  189. fi
  190. ;;
  191. esac
  192. AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
  193. if test "$have_ld_version_script" = "yes"; then
  194. AC_MSG_CHECKING([for symbol prefix])
  195. SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
  196. | ${CPP:-${CC:-gcc} -E} - 2>&1 \
  197. | ${EGREP:-grep} "^PREFIX=" \
  198. | ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
  199. AC_SUBST(SYMBOL_PREFIX)
  200. AC_MSG_RESULT($SYMBOL_PREFIX)
  201. fi
  202. # Substitutions for .in files
  203. AC_SUBST(PNGLIB_VERSION)
  204. AC_SUBST(PNGLIB_MAJOR)
  205. AC_SUBST(PNGLIB_MINOR)
  206. AC_SUBST(PNGLIB_RELEASE)
  207. # Additional arguments (and substitutions)
  208. # Allow the pkg-config directory to be set
  209. AC_ARG_WITH(pkgconfigdir,
  210. AS_HELP_STRING([[[--with-pkgconfigdir]]],
  211. [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
  212. [pkgconfigdir=${withval}],
  213. [pkgconfigdir='${libdir}/pkgconfig'])
  214. AC_SUBST([pkgconfigdir])
  215. AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
  216. # Make the *-config binary config scripts optional
  217. AC_ARG_WITH(binconfigs,
  218. AS_HELP_STRING([[[--with-binconfigs]]],
  219. [Generate shell libpng-config scripts as well as pkg-config data]
  220. [@<:@default=yes@:>@]),
  221. [if test "${withval}" = no; then
  222. binconfigs=
  223. AC_MSG_NOTICE([[libpng-config scripts will not be built]])
  224. else
  225. binconfigs='${binconfigs}'
  226. fi],
  227. [binconfigs='${binconfigs}'])
  228. AC_SUBST([binconfigs])
  229. # Support for prefixes to the API function names; this will generate defines
  230. # at the start of the build to rename exported library functions
  231. AC_ARG_WITH(libpng-prefix,
  232. AS_HELP_STRING([[[--with-libpng-prefix]]],
  233. [prefix libpng exported function (API) names with the given value]),
  234. [if test "${withval:-no}" != "no"; then
  235. AC_SUBST([PNG_PREFIX], [${withval}])
  236. fi])
  237. AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
  238. # Control over what links are made for installed files. Versioned files are
  239. # always installed, when the following options are turned on corresponding
  240. # unversioned links are also created (normally as symbolic links):
  241. AC_ARG_ENABLE([unversioned-links],
  242. AS_HELP_STRING([[[--enable-unversioned-links]]],
  243. [Installed libpng header files are placed in a versioned subdirectory]
  244. [and installed libpng library (including DLL) files are versioned.]
  245. [If this option is enabled unversioned links will be created pointing to]
  246. [the corresponding installed files. If you use libpng.pc or]
  247. [libpng-config for all builds you do not need these links, but if you]
  248. [compile programs directly they will typically #include <png.h> and]
  249. [link with -lpng; in that case you need the links.]
  250. [The links can be installed manually using 'make install-header-links']
  251. [and 'make install-library-links' and can be removed using the]
  252. [corresponding uninstall- targets. If you do enable this option every]
  253. [libpng 'make install' will recreate the links to point to the just]
  254. [installed version of libpng. The default is to create the links;]
  255. [use --disable-unversioned-links to change this]))
  256. # The AM_CONDITIONAL test is written so that the default is enabled;
  257. # --disable-unversioned-links must be given to turn the option off.
  258. AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
  259. AC_ARG_ENABLE([unversioned-libpng-pc],
  260. AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
  261. [Install the configuration file 'libpng.pc' as a link to the versioned]
  262. [version. This is done by default - use --disable-unversioned-libpng-pc]
  263. [to change this.]))
  264. AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
  265. [test "$enable_unversioned_libpng_pc" != "no"])
  266. AC_ARG_ENABLE([unversioned-libpng-config],
  267. AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
  268. [Install the configuration file 'libpng-config' as a link to the]
  269. [versioned version. This is done by default - use]
  270. [--disable-unversioned-libpng-config to change this.]))
  271. AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
  272. [test "$enable_unversioned_libpng_config" != "no"])
  273. # HOST-SPECIFIC OPTIONS
  274. # =====================
  275. #
  276. # DEFAULT
  277. # =======
  278. #
  279. AC_ARG_ENABLE([hardware-optimizations],
  280. AS_HELP_STRING([[[--enable-hardware-optimizations]]],
  281. [Enable hardware optimizations: =no/off, yes/on.]),
  282. [case "$enableval" in
  283. no|off)
  284. # disable hardware optimization on all systems:
  285. enable_arm_neon=no
  286. AC_DEFINE([PNG_ARM_NEON_OPT], [0],
  287. [Disable ARM_NEON optimizations])
  288. enable_mips_msa=no
  289. AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
  290. [Disable MIPS_MSA optimizations])
  291. enable_mips_mmi=no
  292. AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
  293. [Disable MIPS_MMI optimizations])
  294. enable_powerpc_vsx=no
  295. AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
  296. [Disable POWERPC VSX optimizations])
  297. enable_intel_sse=no
  298. AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
  299. [Disable INTEL_SSE optimizations])
  300. enable_loongarch_lsx=no
  301. AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
  302. [Disable LOONGARCH_LSX optimizations])
  303. ;;
  304. *)
  305. # allow enabling hardware optimization on any system:
  306. case "$host_cpu" in
  307. arm*|aarch64*)
  308. enable_arm_neon=yes
  309. AC_DEFINE([PNG_ARM_NEON_OPT], [2],
  310. [Enable ARM_NEON optimizations])
  311. ;;
  312. mipsel*|mips64el*)
  313. enable_mips_mmi=yes
  314. enable_mips_msa=yes
  315. AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
  316. [Enable MIPS_MMI optimizations])
  317. AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
  318. [Enable MIPS_MSA optimizations])
  319. ;;
  320. i?86|x86_64)
  321. enable_intel_sse=yes
  322. AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
  323. [Enable Intel SSE optimizations])
  324. ;;
  325. powerpc*|ppc64*)
  326. enable_powerpc_vsx=yes
  327. AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
  328. [Enable POWERPC VSX optimizations])
  329. ;;
  330. loongarch*)
  331. enable_loongarch_lsx=yes
  332. AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
  333. [Enable LOONGARCH_LSX optimizations])
  334. ;;
  335. esac
  336. ;;
  337. esac])
  338. # ARM NEON
  339. # ========
  340. AC_ARG_ENABLE([arm-neon],
  341. AS_HELP_STRING([[[--enable-arm-neon]]],
  342. [Enable ARM NEON optimizations: =no/off, check, api, yes/on.]
  343. [no/off: disable the optimizations;]
  344. [check: use internal checking code (deprecated and poorly supported);]
  345. [api: disable by default, enable by a call to png_set_option;]
  346. [yes/on: turn on unconditionally.]
  347. [If not specified: determined by the compiler.]),
  348. [case "$enableval" in
  349. no|off)
  350. # disable the default enabling on __ARM_NEON__ systems:
  351. AC_DEFINE([PNG_ARM_NEON_OPT], [0],
  352. [Disable ARM Neon optimizations])
  353. # Prevent inclusion of the assembler files below:
  354. enable_arm_neon=no ;;
  355. check)
  356. AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
  357. [Check for ARM Neon support at run-time]);;
  358. api)
  359. AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
  360. [Turn on ARM Neon optimizations at run-time]);;
  361. yes|on)
  362. AC_DEFINE([PNG_ARM_NEON_OPT], [2],
  363. [Enable ARM Neon optimizations])
  364. AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api';]
  365. [if you want the optimizations unconditionally,]
  366. [pass '-mfpu=neon' to the compiler.]);;
  367. *)
  368. AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}:]
  369. [invalid argument])
  370. esac])
  371. # Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or
  372. # where ARM optimizations were explicitly requested. (This allows a fallback
  373. # if a future host CPU does not match 'arm*'.)
  374. AM_CONDITIONAL([PNG_ARM_NEON],
  375. [test "$enable_arm_neon" != 'no' &&
  376. case "$host_cpu" in
  377. arm*|aarch64*) : ;;
  378. *) test "$enable_arm_neon" != '' ;;
  379. esac])
  380. # MIPS MSA
  381. # ========
  382. AC_ARG_ENABLE([mips-msa],
  383. AS_HELP_STRING([[[--enable-mips-msa]]],
  384. [Enable MIPS MSA optimizations: =no/off, check, api, yes/on.]
  385. [no/off: disable the optimizations;]
  386. [check: use internal checking code (deprecated and poorly supported);]
  387. [api: disable by default, enable by a call to png_set_option;]
  388. [yes/on: turn on unconditionally.]
  389. [If not specified: determined by the compiler.]),
  390. [case "$enableval" in
  391. no|off)
  392. # disable the default enabling on __mips_msa systems:
  393. AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
  394. [Disable MIPS MSA optimizations])
  395. # Prevent inclusion of the assembler files below:
  396. enable_mips_msa=no ;;
  397. check)
  398. AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
  399. [Check for MIPS MSA support at run-time]);;
  400. api)
  401. AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [],
  402. [Turn on MIPS MSA optimizations at run-time]);;
  403. yes|on)
  404. AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
  405. [Enable MIPS MSA optimizations])
  406. AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api';]
  407. [if you want the optimizations unconditionally,]
  408. [pass '-mmsa -mfp64' to the compiler.]);;
  409. *)
  410. AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}:]
  411. [invalid argument])
  412. esac])
  413. # Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or
  414. # where MIPS optimizations were explicitly requested. (This allows a fallback
  415. # if a future host CPU does not match 'mips*'.)
  416. AM_CONDITIONAL([PNG_MIPS_MSA],
  417. [test "$enable_mips_msa" != 'no' &&
  418. case "$host_cpu" in
  419. mipsel*|mips64el*) : ;;
  420. esac])
  421. # MIPS MMI
  422. # ========
  423. AC_ARG_ENABLE([mips-mmi],
  424. AS_HELP_STRING([[[--enable-mips-mmi]]],
  425. [Enable MIPS MMI optimizations: =no/off, check, api, yes/on.]
  426. [no/off: disable the optimizations;]
  427. [check: use internal checking code (deprecated and poorly supported);]
  428. [api: disable by default, enable by a call to png_set_option;]
  429. [yes/on: turn on unconditionally.]
  430. [If not specified: determined by the compiler.]),
  431. [case "$enableval" in
  432. no|off)
  433. # disable the default enabling on __mips_mmi systems:
  434. AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
  435. [Disable MIPS MMI optimizations])
  436. # Prevent inclusion of the assembler files below:
  437. enable_mips_mmi=no;;
  438. check)
  439. AC_DEFINE([PNG_MIPS_MMI_CHECK_SUPPORTED], [],
  440. [Check for MIPS MMI support at run-time]);;
  441. api)
  442. AC_DEFINE([PNG_MIPS_MMI_API_SUPPORTED], [],
  443. [Turn on MIPS MMI optimizations at run-time]);;
  444. yes|on)
  445. AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
  446. [Enable MIPS MMI optimizations])
  447. AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api';]
  448. [if you want the optimizations unconditionally]
  449. [pass '-mloongson-mmi -march=loongson3a' to the compiler.]);;
  450. *)
  451. AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}:]
  452. [invalid argument])
  453. esac])
  454. # Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
  455. # where MIPS optimizations were explicitly requested. (This allows a fallback
  456. # if a future host CPU does not match 'mips*'.)
  457. AM_CONDITIONAL([PNG_MIPS_MMI],
  458. [test "$enable_mips_mmi" != 'no' &&
  459. case "$host_cpu" in
  460. mipsel*|mips64el*) : ;;
  461. esac])
  462. # INTEL SSE
  463. # =========
  464. AC_ARG_ENABLE([intel-sse],
  465. AS_HELP_STRING([[[--enable-intel-sse]]],
  466. [Enable Intel SSE optimizations: =no/off, yes/on.]
  467. [no/off: disable the optimizations;]
  468. [yes/on: enable the optimizations.]
  469. [If not specified: determined by the compiler.]),
  470. [case "$enableval" in
  471. no|off)
  472. # disable the default enabling:
  473. AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
  474. [Disable Intel SSE optimizations])
  475. # Prevent inclusion of the assembler files below:
  476. enable_intel_sse=no ;;
  477. yes|on)
  478. AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
  479. [Enable Intel SSE optimizations]);;
  480. *)
  481. AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}:]
  482. [invalid argument])
  483. esac])
  484. # Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or
  485. # where Intel optimizations were explicitly requested. (This allows a fallback
  486. # if a future host CPU does not match 'x86*'.)
  487. AM_CONDITIONAL([PNG_INTEL_SSE],
  488. [test "$enable_intel_sse" != 'no' &&
  489. case "$host_cpu" in
  490. i?86|x86_64) : ;;
  491. *) test "$enable_intel_sse" != '' ;;
  492. esac])
  493. # POWERPC VSX
  494. # ===========
  495. AC_ARG_ENABLE([powerpc-vsx],
  496. AS_HELP_STRING([[[--enable-powerpc-vsx]]],
  497. [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on.]
  498. [no/off: disable the optimizations;]
  499. [check: use internal checking code;]
  500. [api: disable by default, enable by a call to png_set_option;]
  501. [yes/on: turn on unconditionally.]
  502. [If not specified: determined by the compiler.]),
  503. [case "$enableval" in
  504. no|off)
  505. # disable the default enabling on __ppc64__ systems:
  506. AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
  507. [Disable POWERPC VSX optimizations])
  508. # Prevent inclusion of the platform-specific files below:
  509. enable_powerpc_vsx=no ;;
  510. check)
  511. AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
  512. [Check for POWERPC VSX support at run-time])
  513. AC_MSG_WARN([--enable-powerpc-vsx: please see contrib/powerpc/README]
  514. [for the list of supported systems.]);;
  515. api)
  516. AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
  517. [Turn on POWERPC VSX optimizations at run-time]);;
  518. yes|on)
  519. AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
  520. [Enable POWERPC VSX optimizations])
  521. AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api';]
  522. [if you want the optimizations unconditionally,]
  523. [pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler.]);;
  524. *)
  525. AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}:]
  526. [invalid argument])
  527. esac])
  528. # Add PowerPC-specific files to all builds where $host_cpu is powerpc
  529. # ('powerpc*') or where PowerPC optimizations were explicitly requested.
  530. # (This allows a fallback if a future host CPU does not match 'powerpc*'.)
  531. AM_CONDITIONAL([PNG_POWERPC_VSX],
  532. [test "$enable_powerpc_vsx" != 'no' &&
  533. case "$host_cpu" in
  534. powerpc*|ppc64*) : ;;
  535. esac])
  536. # LOONGARCH LSX
  537. # =============
  538. AC_ARG_ENABLE([loongarch-lsx],
  539. AS_HELP_STRING([[[--enable-loongarch-lsx]]],
  540. [Enable LOONGARCH LSX optimizations: =no/off, yes/on:]
  541. [no/off: disable the optimizations;]
  542. [yes/on: turn on unconditionally.]
  543. [If not specified: determined by the compiler.]),
  544. [case "$enableval" in
  545. no|off)
  546. # disable the default enabling on __loongarch_simd systems:
  547. AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
  548. [Disable LOONGARCH LSX optimizations])
  549. # Prevent inclusion of the assembler files below:
  550. enable_loongarch_lsx=no;;
  551. yes|on)
  552. AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
  553. [Enable LOONGARCH LSX optimizations])
  554. ;;
  555. *)
  556. AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}:]
  557. [invalid argument])
  558. esac])
  559. if test "$enable_loongarch_lsx" != "no" &&
  560. case "$host_cpu" in
  561. loongarch*) : ;;
  562. *) test "$enable_loongarch_lsx" != '' ;;
  563. esac
  564. then
  565. compiler_support_loongarch_lsx=no
  566. AC_MSG_CHECKING(whether to use LoongArch LSX intrinsics)
  567. save_CFLAGS="$CFLAGS"
  568. LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}"
  569. CFLAGS="$CFLAGS $LSX_CFLAGS"
  570. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  571. #include <lsxintrin.h>
  572. int main(){
  573. __m128i a, b, c;
  574. a = __lsx_vadd_w(b, c);
  575. return 0;
  576. }]])],compiler_support_loongarch_lsx=yes)
  577. CFLAGS="$save_CFLAGS"
  578. AC_MSG_RESULT($compiler_support_loongarch_lsx)
  579. if test "$compiler_support_loongarch_lsx" = "yes"; then
  580. AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
  581. [Enable LOONGARCH LSX optimizations])
  582. else
  583. AC_MSG_WARN([Compiler does not support loongarch LSX.])
  584. fi
  585. fi
  586. # Add LoongArch specific files to all builds where the host_cpu is loongarch
  587. # ('loongarch*') or where LoongArch optimizations were explicitly requested.
  588. # (This allows a fallback if a future host CPU does not match 'loongarch*'.)
  589. AM_CONDITIONAL([PNG_LOONGARCH_LSX],
  590. [test "$enable_loongarch_lsx" != "no" &&
  591. test "$compiler_support_loongarch_lsx" = "yes" &&
  592. case "$host_cpu" in
  593. loongarch*) : ;;
  594. *) test "$enable_loongarch_lsx" != '' ;;
  595. esac])
  596. AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
  597. # Config files, substituting as above
  598. AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
  599. AC_CONFIG_FILES([libpng-config:libpng-config.in],
  600. [chmod +x libpng-config])
  601. AC_OUTPUT