merged libpng 1.5.7 to trunk
[wxWidgets.git] / src / png / Makefile.am
1 # Makefile.am:
2 #   Source file for Makefile.in (and hence Makefile)
3 #
4
5 PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
6
7 # libpng does not follow GNU file name conventions
8
9 # "color-tests" requires automake 1.11.1 or later.  Enable it if you like,
10 # to get red "FAIL" and green "PASS" notations during tests.
11 # AUTOMAKE_OPTIONS = foreign color-tests
12 AUTOMAKE_OPTIONS = foreign
13
14 # test programs - run on make check, make distcheck
15 TESTS_ENVIRONMENT= srcdir=$(srcdir)
16 check_PROGRAMS= pngtest
17 pngtest_SOURCES = pngtest.c
18 pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
19 TESTS = test-pngtest.sh
20
21 # Only do the following if the contrib directory is present.
22 check_PROGRAMS+= pngvalid
23 pngvalid_SOURCES = contrib/libtests/pngvalid.c
24 pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
25 TESTS += test-pngvalid-simple.sh test-pngvalid-full.sh
26
27 # man pages
28 dist_man_MANS= libpng.3 libpngpf.3 png.5
29
30 # generate the -config scripts if required
31 binconfigs= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
32 EXTRA_SCRIPTS= libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
33 bin_SCRIPTS= @binconfigs@
34
35 # rules to build libpng, only build the old library on request
36 lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
37 # EXTRA_LTLIBRARIES= libpng.la
38 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
39         pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\
40         pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
41         png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
42
43 if PNG_ARM_NEON
44 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S
45 endif
46
47 nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
48
49 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_CPPFLAGS = @LIBPNG_DEFINES@
50
51 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
52         -version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0
53
54 if HAVE_LD_VERSION_SCRIPT
55 #   Versioned symbols and restricted exports
56 if HAVE_SOLARIS_LD
57   libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,-M -Wl,libpng.vers
58 else
59   libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers
60 endif
61
62   libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers
63 else
64 #   Only restricted exports when possible
65   libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym
66   libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
67 endif
68
69 #distribute headers in /usr/include/libpng/*
70 pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
71 pkginclude_HEADERS= png.h pngconf.h
72 nodist_pkginclude_HEADERS= pnglibconf.h
73
74 # pkg-config stuff, note that libpng.pc is always required in order
75 # to get the correct library
76 pkgconfigdir = @pkgconfigdir@
77 pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
78
79 #extra source distribution files.
80 EXTRA_DIST= \
81         ANNOUNCE CHANGES INSTALL LICENSE README TODO \
82         pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
83         ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
84         $(TESTS) \
85         CMakeLists.txt example.c libpng-manual.txt
86
87 SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn
88
89 CLEANFILES= dfn.c dfn?.out pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
90         libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
91         check.new pnglibconf.* symbols.new pngtest-log.txt \
92         $(SCRIPT_CLEANFILES)
93
94 MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
95 config.sub configure depcomp install-sh ltmain.sh missing
96
97 # DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe
98 # other operating systems (NeXT?) the C preprocessor selected by configure
99 # checks input tokens for validity - effectively it performs part of the ANSI-C
100 # parsing - and therefore fails with the .df files.  configure.ac has special
101 # checks for this and sets DFNCPP appropriately.
102 DFNCPP = @DFNCPP@
103
104 SUFFIXES = .chk .dfn .out
105
106 $(PNGLIB_BASENAME).pc: libpng.pc
107         cp libpng.pc $@
108
109 $(PNGLIB_BASENAME)-config: libpng-config
110         cp libpng-config $@
111
112 scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
113 scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
114
115 libpng.sym: scripts/sym.out
116         rm -f $@
117         cp $? $@
118 libpng.vers: scripts/vers.out
119         rm -f $@
120         cp $? $@
121 pnglibconf.h: pnglibconf.out
122         rm -f $@
123         cp $? $@
124 $(srcdir)/scripts/pnglibconf.h.prebuilt:
125         @echo "Attempting to build $@" >&2
126         @echo "This is a machine generated file, but if you want to make" >&2
127         @echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
128         @exit 1
129
130 # The following is necessary to ensure that the local pnglibconf.h is used, not
131 # an installed one (this can happen immediately after on a clean system if
132 # 'make test' is the first thing the user does.)
133 contrib/libtests/pngvalid.o pngtest.o: pnglibconf.h
134
135 # We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
136 # be built with PNG_USE_READ_MACROS; this prevents the read macros from
137 # interfering with the symbol file format.
138 SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
139                 -DPNGLIB_VERSION='@PNGLIB_VERSION@'\
140                 -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
141                 -DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE
142
143 .dfn.out:
144         rm -f $@ dfn.c dfn?.out
145         test -d scripts || mkdir scripts
146         echo '#include "$<"' >dfn.c
147         $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) @LIBPNG_DEFINES@\
148             $(CPPFLAGS) $(SYMBOL_CFLAGS) dfn.c > dfn1.out
149         $(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
150             dfn1.out >dfn2.out
151         $(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' dfn2.out >dfn3.out
152         rm -f dfn.c dfn[12].out
153         mv dfn3.out $@
154
155 # The .dfn file for pnglibconf.h is machine generated
156 pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
157         rm -f $@ dfn?.out
158         $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out version=search\
159             ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
160             $(DFA_XTRA) 1>&2
161         $(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
162         rm dfn1.out
163         mv dfn2.out $@
164
165 # Symbol checks (.def and .out files should match)
166 scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out
167 .out.chk:
168         rm -f $@ symbols.new
169         $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\
170             $< >&2
171         mv symbols.new $@
172
173 # used on demand to regenerate the standard header, CPPFLAGS should
174 # be empty - no non-standard defines
175 scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
176         rm -f $@ dfn?.out
177         test -z "$(CPPFLAGS)"
178         echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
179         $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1
180                 version=search ${srcdir}/pngconf.h -\
181                 ${srcdir}/scripts/pnglibconf.dfa 1>&2
182         $(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
183         rm dfn1.out
184         mv dfn2.out $@
185
186 $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \
187         pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h
188
189 test: check-am
190
191 # Extra checks
192 check: scripts/symbols.chk
193
194 # Don't distribute the generated script files
195 dist-hook:
196         cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES)
197
198 # install the .../include headers as links to the new ones
199 install-data-hook:
200         cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
201         cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
202         cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
203                 pngconf.h
204         cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
205                 pnglibconf.h
206         cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc
207         cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
208
209 # do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used
210 install-exec-hook:
211         cd $(DESTDIR)$(bindir); rm -f libpng-config
212         cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
213         @set -x;\
214         cd $(DESTDIR)$(libdir);\
215         for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\
216                 rm -f libpng.$$ext;\
217                 if test -f $(PNGLIB_BASENAME).$$ext; then\
218                        $(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
219                 fi;\
220         done
221
222 uninstall-hook:
223         cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
224         rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
225         rm -f $(DESTDIR)$(bindir)/libpng-config
226         rm -f $(DESTDIR)$(libdir)/libpng.a
227         rm -f $(DESTDIR)$(libdir)/libpng.la