1 # makefile for cygwin on x86
2 # Builds both dll (with import lib) and static lib versions
3 # of the library, and builds two copies of pngtest: one
4 # statically linked and one dynamically linked.
6 # Copyright (C) 2002 Soren Anderson, Charles Wilson, and Glenn Randers-Pehrson
7 # based on makefile for linux-elf w/mmx by:
8 # Copyright (C) 1998-2000 Greg Roelofs
9 # Copyright (C) 1996, 1997 Andreas Dilger
10 # For conditions of distribution and use, see copyright notice in png.h
12 # This makefile intends to support building outside the src directory
13 # if desired. When invoking it, specify an argument to SRCDIR on the
14 # command line that points to the top of the directory where your source
23 # Override DESTDIR= on the make install command line to easily support
24 # installing into a temporary location. Example:
26 # make install DESTDIR=/tmp/build/libpng
28 # If you're going to install into a temporary location
29 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
30 # you execute make install.
34 # To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to
35 # $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency
36 # list at the bottom of this makefile.
40 MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw
41 MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw
44 # Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
47 $(warning You haven't specified a 'prefix=' location. Defaulting to "/usr")
50 # Where the zlib library and include files are located
58 #ALIGN=-malign-loops=2 -malign-functions=2
60 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
61 -Wmissing-declarations -Wtraditional -Wcast-align \
62 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
64 ### if you use the asm, add pnggccrd.o to the OBJS list
66 ### if you don't need thread safety, but want the asm accel
67 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \
68 # $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \
69 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
70 ### if you need thread safety and want (minimal) asm accel
71 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \
72 # -Wall -O3 $(ALIGN) -funroll-loops \
73 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
74 ### Normal (non-asm) compilation
75 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
76 -Wall -O3 $(ALIGN) -funroll-loops \
77 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
83 PNGVER = $(PNGMAJ).$(PNGMIN)
85 SHAREDLIB=cygpng$(CYGDLL).dll
89 LIBS=$(SHAREDLIB) $(STATLIB)
92 LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
93 LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all)
94 LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
100 INCPATH=$(prefix)/include
101 LIBPATH=$(prefix)/lib
103 BINPATH=$(prefix)/bin
104 MANPATH=$(prefix)/man
105 MAN3PATH=$(MANPATH)/man3
106 MAN5PATH=$(MANPATH)/man5
108 # cosmetic: shortened strings:
115 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
116 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
117 pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o
119 OBJSDLL = $(OBJS:.o=.pic.o)
121 .SUFFIXES: .c .o .pic.o
124 $(CC) -c $(CFLAGS) -o $@ $<
125 %.pic.o : CFLAGS += -DPNG_BUILD_DLL
127 $(CC) -c $(CFLAGS) -o $@ $<
129 all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
131 # Make this to verify that "make [...] install" will do what you want.
133 @echo VPATH is set to: \"$(VPATH)\"
134 @echo prefix is set to: \"$(prefix)\"
135 @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
136 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
137 $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
139 libpng.pc: scripts/libpng.pc.in
140 @echo -e Making pkg-config file for this libpng installation..'\n' \
141 using PREFIX=\"$(prefix)\"'\n'
142 cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
143 sed -e s/-lm// > libpng.pc
145 libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
146 @echo -e Making $(LIBNAME) libpng-config file for this libpng \
147 installation..'\n' using PREFIX=\"$(prefix)\"'\n'
148 ( cat $(S)/scripts/libpng-config-head.in; \
149 echo prefix=\"$(prefix)\"; \
150 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
151 echo L_opts=\"-L$(LIBPATH)\"; \
152 echo libs=\"-lpng$(CYGDLL) -lz\"; \
153 cat $(S)/scripts/libpng-config-body.in ) > libpng-config
154 chmod +x libpng-config
158 all-static: $(STATLIB) pngtest-stat$(EXE)
159 all-shared: $(SHAREDLIB) pngtest$(EXE)
161 pnggccrd.o: pnggccrd.c png.h pngconf.h
163 @echo ' You can ignore the "control reaches end of non-void function"'
164 @echo ' warning and "<variable> defined but not used" warnings:'
166 $(CC) -c $(CFLAGS) -o $@ $<
168 pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
170 @echo ' You can ignore the "control reaches end of non-void function"'
171 @echo ' warning and "<variable> defined but not used" warnings:'
173 $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
179 $(SHAREDDEF): projects/msvc/png32ms.def
180 cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
181 sed -e 's/\([^;]*\);/;/' > $@
183 $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
184 $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
186 pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
187 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
189 pngtest-stat$(EXE): pngtest.o $(STATLIB)
190 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
192 pngtest.pic.o: pngtest.c
193 $(CC) $(CFLAGS) -c $< -o $@
196 $(CC) $(CFLAGS) -c $< -o $@
198 test: test-static test-shared
200 test-static: pngtest-stat$(EXE)
201 ./pngtest-stat $(S)/pngtest.png
203 test-shared: pngtest$(EXE)
204 ./pngtest $(S)/pngtest.png
206 install-static: $(STATLIB) install-headers install-man
207 -@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
208 install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
209 -@rm -f $(DL)/$(STATLIB)
210 (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
212 install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
213 -@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
214 -@if [ ! -d $(DB) ]; then $(MKDIR) $(DB); fi
215 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR) $(DL)/pkgconfig; fi
216 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
217 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
218 install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
219 -@rm -f $(DL)/$(IMPLIB)
220 (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
221 install -s -m 755 $(SHAREDLIB) $(DB)
222 install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
223 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
226 -@if [ ! -d $(DI) ]; then $(MKDIR) $(DI); fi
227 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR) $(DI)/$(LIBNAME); fi
229 -@rm -f $(DI)/pngconf.h
230 install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
232 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
235 -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR) $(D)$(MAN3PATH); fi
236 -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR) $(D)$(MAN5PATH); fi
237 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
238 install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
240 install-config: libpng-config
241 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
242 -@/bin/rm -f $(DB)/libpng-config
243 -@/bin/rm -f $(DB)/$(LIBNAME)-config
244 cp libpng-config $(DB)/$(LIBNAME)-config
245 chmod 755 $(DB)/$(LIBNAME)-config
246 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
248 # Run this to verify that a future `configure' run will pick up the settings
250 test-config-install: SHELL=/bin/bash
251 test-config-install: $(DB)/libpng-config
252 @echo -e Testing libpng-config functions...'\n'
253 @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
255 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
256 "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
257 gytiu=$$(( $$gytiu + 1 )); \
260 install: install-static install-shared install-man install-config
262 # If you installed in $(DESTDIR), test-installed won't work until you
263 # move the library to its final location.
267 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
269 -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags`
270 ./pngtesti$(EXE) pngtest.png
273 /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
274 pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
275 libpng-config libpng.pc pngtesti$(EXE)
277 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
279 chmod a-w *.[ch35] $(DOCS) scripts/*
281 .PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
283 # DO NOT DELETE THIS LINE -- make depend depends on it.
285 png.o png.pic.o: png.h pngconf.h png.c
286 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
287 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
288 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
289 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
290 pngset.o pngset.pic.o: png.h pngconf.h pngset.c
291 pngget.o pngget.pic.o: png.h pngconf.h pngget.c
292 pngread.o pngread.pic.o: png.h pngconf.h pngread.c
293 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
294 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
295 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
296 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
297 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
298 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
299 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
301 pngtest.o: png.h pngconf.h pngtest.c
302 pngtest-stat.o: png.h pngconf.h pngtest.c