1# Makefile.am, the source file for Makefile.in (and hence Makefile), is 2# 3# Copyright (c) 2018-2024 Cosmin Truta 4# Copyright (c) 2004-2016 Glenn Randers-Pehrson 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 10PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ 11 12ACLOCAL_AMFLAGS = -I scripts/autoconf 13 14# test programs - run on make check, make distcheck 15if ENABLE_TESTS 16check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp 17if HAVE_CLOCK_GETTIME 18check_PROGRAMS += timepng 19endif 20else 21check_PROGRAMS= 22endif 23 24# Utilities - installed 25if ENABLE_TOOLS 26bin_PROGRAMS= pngfix png-fix-itxt 27else 28bin_PROGRAMS= 29endif 30 31# This ensures that pnglibconf.h gets built at the start of 'make all' or 32# 'make check', but it does not add dependencies to the individual programs, 33# this is done below. 34# 35# IMPORTANT: always add the object modules of new programs to the list below 36# because otherwise the sequence 'configure; make new-program' will *sometimes* 37# result in the installed (system) pnglibconf.h being used and the result is 38# always wrong and always very confusing. 39BUILT_SOURCES = pnglibconf.h 40 41if ENABLE_TESTS 42pngtest_SOURCES = pngtest.c 43pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 44 45pngvalid_SOURCES = contrib/libtests/pngvalid.c 46pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 47 48pngstest_SOURCES = contrib/libtests/pngstest.c 49pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 50 51pngunknown_SOURCES = contrib/libtests/pngunknown.c 52pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 53 54pngimage_SOURCES = contrib/libtests/pngimage.c 55pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 56 57timepng_SOURCES = contrib/libtests/timepng.c 58timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 59 60pngcp_SOURCES = contrib/tools/pngcp.c 61pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 62endif 63 64if ENABLE_TOOLS 65pngfix_SOURCES = contrib/tools/pngfix.c 66pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 67 68png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c 69endif 70 71# Generally these are single line shell scripts to run a test with a particular 72# set of parameters: 73if ENABLE_TESTS 74TESTS =\ 75 tests/pngtest-all\ 76 tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\ 77 tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\ 78 tests/pngvalid-gamma-expand16-background\ 79 tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\ 80 tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\ 81 tests/pngvalid-progressive-size\ 82 tests/pngvalid-progressive-interlace-standard\ 83 tests/pngvalid-transform\ 84 tests/pngvalid-progressive-standard tests/pngvalid-standard\ 85 tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\ 86 tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\ 87 tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\ 88 tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\ 89 tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\ 90 tests/pngimage-quick tests/pngimage-full 91endif 92 93# man pages 94dist_man_MANS= libpng.3 libpngpf.3 png.5 95 96# generate the -config scripts if required 97binconfigs= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config 98EXTRA_SCRIPTS= libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config 99bin_SCRIPTS= @binconfigs@ 100 101# rules to build libpng, only build the old library on request 102lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la 103# EXTRA_LTLIBRARIES= libpng.la 104libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\ 105 pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\ 106 pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\ 107 png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa 108 109if PNG_ARM_NEON 110libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\ 111 arm/filter_neon.S arm/filter_neon_intrinsics.c \ 112 arm/palette_neon_intrinsics.c 113endif 114 115if PNG_MIPS_MSA 116libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\ 117 mips/filter_msa_intrinsics.c 118endif 119 120if PNG_MIPS_MMI 121if !PNG_MIPS_MSA 122libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c 123endif 124libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/filter_mmi_inline_assembly.c 125endif 126 127if PNG_INTEL_SSE 128libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\ 129 intel/filter_sse2_intrinsics.c 130endif 131 132if PNG_POWERPC_VSX 133libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\ 134 powerpc/filter_vsx_intrinsics.c 135endif 136 137if PNG_LOONGARCH_LSX 138noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la 139libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\ 140 loongarch/filter_lsx_intrinsics.c 141libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx 142libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la 143# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la 144endif 145 146nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h 147 148libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \ 149 -version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 150 151if HAVE_LD_VERSION_SCRIPT 152# Versioned symbols and restricted exports 153if HAVE_SOLARIS_LD 154 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,-M -Wl,libpng.vers 155else 156 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers 157endif 158 159 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers 160else 161# Only restricted exports when possible 162 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym 163 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym 164endif 165 166if PNG_LOONGARCH_LSX 167 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la 168endif 169 170#distribute headers in /usr/include/libpng/* 171pkgincludedir= $(includedir)/$(PNGLIB_BASENAME) 172pkginclude_HEADERS= png.h pngconf.h 173nodist_pkginclude_HEADERS= pnglibconf.h 174 175# pkg-config stuff, note that libpng.pc is always required in order 176# to get the correct library 177pkgconfigdir = @pkgconfigdir@ 178pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc 179 180# Extra source distribution files, '${srcdir}' is used below to stop build files 181# from those directories being included. This only works if the configure is 182# not done in the source directory! 183EXTRA_DIST= \ 184 ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \ 185 pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ 186 ${srcdir}/ci ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ 187 $(TESTS) $(XFAIL_TESTS) tests/pngstest \ 188 CMakeLists.txt example.c libpng-manual.txt 189 190SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk 191 192CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \ 193 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \ 194 check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \ 195 pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \ 196 $(SCRIPT_CLEANFILES) 197 198MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ 199config.sub configure depcomp install-sh ltmain.sh missing 200 201# PNG_COPTS give extra options for the C compiler to be used on all compilation 202# steps (unless targe_CFLAGS is specified; that will take precedence over 203# AM_CFLAGS) 204PNG_COPTS = @PNG_COPTS@ 205AM_CFLAGS = ${PNG_COPTS} 206 207# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe 208# other operating systems (NeXT?) the C preprocessor selected by configure 209# checks input tokens for validity - effectively it performs part of the ANSI-C 210# parsing - and therefore fails with the .df files. configure.ac has special 211# checks for this and sets DFNCPP appropriately. 212DFNCPP = @DFNCPP@ 213 214SUFFIXES = .chk .out 215 216$(PNGLIB_BASENAME).pc: libpng.pc 217 cp libpng.pc $@ 218 219$(PNGLIB_BASENAME)-config: libpng-config 220 cp libpng-config $@ 221 222scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h 223scripts/prefix.out: png.h pngconf.h pnglibconf.out 224scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt 225scripts/intprefix.out: pnglibconf.h 226 227libpng.sym: scripts/sym.out 228 rm -f $@ 229 cp $? $@ 230libpng.vers: scripts/vers.out 231 rm -f $@ 232 cp $? $@ 233 234if DO_PNG_PREFIX 235# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix. 236# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual 237# implementation of the macro). 238pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst 239 rm -f $@ 240 $(AWK) 's==0 && NR>1{print prev}\ 241 s==0{prev=$$0}\ 242 s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\ 243 s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\ 244 END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\ 245 s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8 246 mv pnglibconf.tf8 $@ 247 248pngprefix.h: scripts/intprefix.out 249 rm -f pngprefix.tf1 250 $(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1 251 mv pngprefix.tf1 $@ 252else 253pnglibconf.h: pnglibconf.out 254 rm -f $@ 255 cp $? $@ 256 257pngprefix.h: # is empty 258 :>$@ 259endif 260 261$(srcdir)/scripts/pnglibconf.h.prebuilt: 262 @echo "Attempting to build $@" >&2 263 @echo "This is a machine generated file, but if you want to make" >&2 264 @echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2 265 @echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2 266 @exit 1 267 268# The following is necessary to ensure that the local pnglibconf.h is used, not 269# an installed one (this can happen immediately after on a clean system if 270# 'make test' is the first thing the user does.) Only files which include 271# one of the png source files (typically png.h or pngpriv.h) need to be listed 272# here: 273pngtest.o: pnglibconf.h 274 275contrib/libtests/makepng.o: pnglibconf.h 276contrib/libtests/pngstest.o: pnglibconf.h 277contrib/libtests/pngunknown.o: pnglibconf.h 278contrib/libtests/pngimage.o: pnglibconf.h 279contrib/libtests/pngvalid.o: pnglibconf.h 280contrib/libtests/readpng.o: pnglibconf.h 281contrib/libtests/tarith.o: pnglibconf.h 282contrib/libtests/timepng.o: pnglibconf.h 283 284contrib/tools/makesRGB.o: pnglibconf.h 285contrib/tools/pngfix.o: pnglibconf.h 286contrib/tools/pngcp.o: pnglibconf.h 287 288# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually 289# be built with PNG_USE_READ_MACROS; this prevents the read macros from 290# interfering with the symbol file format. 291SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\ 292 -DPNGLIB_VERSION='@PNGLIB_VERSION@'\ 293 -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\ 294 -DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE 295 296if DO_PNG_PREFIX 297SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@' 298endif 299 300.c.out: 301 rm -f $@ $*.tf[12] 302 test -d scripts || mkdir scripts || test -d scripts 303 $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\ 304 $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1 305 $(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2 306 rm -f $*.tf1 307 mv $*.tf2 $@ 308 309# The .c file for pnglibconf.h is machine generated 310pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) 311 rm -f $@ $*.tf[45] 312 $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\ 313 ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ 314 ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2 315 $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2 316 rm $*.tf4 317 mv $*.tf5 $@ 318 319# Symbol checks (.def and .out files should match) 320scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out 321 322.out.chk: 323 rm -f $@ $*.new 324 $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\ 325 of="$*.new" $< >&2 326 mv $*.new $@ 327 328# used on demand to regenerate the standard header, CPPFLAGS should 329# be empty - no non-standard defines 330scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h 331 rm -f $@ pnglibconf.tf[67] 332 test -z "$(CPPFLAGS)" 333 echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ 334 $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\ 335 logunsupported=1 version=search ${srcdir}/pngconf.h -\ 336 ${srcdir}/scripts/pnglibconf.dfa 1>&2 337 $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\ 338 pnglibconf.tf6 1>&2 339 rm pnglibconf.tf6 340 mv pnglibconf.tf7 $@ 341 342$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \ 343 pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h 344 345test: check-am 346 347# Extra checks 348check: scripts/symbols.chk 349 350# Don't distribute the generated script files 351dist-hook: 352 cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES) 353 354# Make links between installed files with release-specific names and the generic 355# file names. If this install rule is run the generic names will be deleted and 356# recreated - this has obvious issues for systems with multiple installations. 357 358install-header-links: 359 @set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \ 360 rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done 361 362uninstall-header-links: 363 cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS) 364 365install-libpng-pc: 366 @set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \ 367 $(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc 368 369uninstall-libpng-pc: 370 rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc' 371 372# EXT_LIST is a list of the possibly library directory extensions, this exists 373# because we can't find a good way of discovering the file extensions that are 374# actually installed on a given system, so instead we check for every extension 375# we have seen. 376 377EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib 378 379install-library-links: 380 @set -x; cd '$(DESTDIR)$(libdir)';\ 381 for ext in $(EXT_LIST); do\ 382 rm -f "libpng.$$ext";\ 383 if test -f "$(PNGLIB_BASENAME).$$ext"; then\ 384 $(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\ 385 fi;\ 386 done 387 388uninstall-library-links: 389 @set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\ 390 rm -f "libpng.$$ext"; done 391 392install-libpng-config: 393 @set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \ 394 $(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config 395 396uninstall-libpng-config: 397 rm -f '$(DESTDIR)$(bindir)/libpng-config' 398 399if DO_INSTALL_LINKS 400# If --enable-unversioned-links is specified the header and lib file links 401# will be automatically made on a 'make install': 402 403install-data-hook: install-header-links 404uninstall-hook: uninstall-header-links 405install-exec-hook: install-library-links 406uninstall-hook: uninstall-library-links 407endif 408 409if DO_INSTALL_LIBPNG_PC 410# Likewise, --install-pc causes libpng.pc to be constructed: 411 412install-data-hook: install-libpng-pc 413uninstall-hook: uninstall-libpng-pc 414endif 415 416if DO_INSTALL_LIBPNG_CONFIG 417# And --install-config: 418 419install-exec-hook: install-libpng-config 420uninstall-hook: uninstall-libpng-config 421endif 422 423# The following addition ensures that 'make all' always builds the test programs 424# too. It used to, but some change either in libpng or configure stopped this 425# working. 426all-am: $(check_PROGRAMS) 427