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, 2006 Soren Anderson, Charles Wilson,
7 # and Glenn Randers-Pehrson, 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")
51 # Where the zlib library and include files are located
59 #ALIGN=-malign-loops=2 -malign-functions=2
61 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
62 -Wmissing-declarations -Wtraditional -Wcast-align \
63 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
65 ### if you use the asm, add pnggccrd.o to the OBJS list
67 ### if you don't need thread safety, but want the asm accel
68 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \
69 # $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \
70 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
71 ### if you need thread safety and want (minimal) asm accel
72 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \
73 # -Wall -O3 $(ALIGN) -funroll-loops \
74 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
75 ### Normal (non-asm) compilation
76 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
77 -Wall -O3 $(ALIGN) -funroll-loops \
78 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
84 PNGVER = $(PNGMAJ).$(PNGMIN)
86 SHAREDLIB=cygpng$(CYGDLL).dll
90 LIBS=$(SHAREDLIB) $(STATLIB)
93 LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
94 LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all)
95 LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
97 MKDIR_P=/bin/mkdir -pv
101 INCPATH=$(prefix)/include
102 LIBPATH=$(exec_prefix)/lib
104 BINPATH=$(exec_prefix)/bin
105 MANPATH=$(prefix)/man
106 MAN3PATH=$(MANPATH)/man3
107 MAN5PATH=$(MANPATH)/man5
109 # cosmetic: shortened strings:
116 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
117 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
118 pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o
120 OBJSDLL = $(OBJS:.o=.pic.o)
122 .SUFFIXES: .c .o .pic.o
125 $(CC) -c $(CFLAGS) -o $@ $<
126 %.pic.o : CFLAGS += -DPNG_BUILD_DLL
128 $(CC) -c $(CFLAGS) -o $@ $<
130 all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
132 # Make this to verify that "make [...] install" will do what you want.
134 @echo VPATH is set to: \"$(VPATH)\"
135 @echo prefix is set to: \"$(prefix)\"
136 @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
137 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
138 $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
140 libpng.pc: scripts/libpng.pc.in
141 @echo -e Making pkg-config file for this libpng installation..'\n' \
142 using PREFIX=\"$(prefix)\"'\n'
143 cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
144 sed -e s/-lm// > libpng.pc
146 libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
147 @echo -e Making $(LIBNAME) libpng-config file for this libpng \
148 installation..'\n' using PREFIX=\"$(prefix)\"'\n'
149 ( cat $(S)/scripts/libpng-config-head.in; \
150 echo prefix=\"$(prefix)\"; \
151 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
152 echo L_opts=\"-L$(LIBPATH)\"; \
153 echo libs=\"-lpng$(CYGDLL) -lz\"; \
154 cat $(S)/scripts/libpng-config-body.in ) > libpng-config
155 chmod +x libpng-config
159 all-static: $(STATLIB) pngtest-stat$(EXE)
160 all-shared: $(SHAREDLIB) pngtest$(EXE)
162 pnggccrd.o: pnggccrd.c png.h pngconf.h
164 @echo ' You can ignore the "control reaches end of non-void function"'
165 @echo ' warning and "<variable> defined but not used" warnings:'
167 $(CC) -c $(CFLAGS) -o $@ $<
169 pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
171 @echo ' You can ignore the "control reaches end of non-void function"'
172 @echo ' warning and "<variable> defined but not used" warnings:'
174 $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
180 $(SHAREDDEF): scripts/pngw32.def
181 cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
182 sed -e 's/\([^;]*\);/;/' > $@
184 $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
185 $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
187 pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
188 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
190 pngtest-stat$(EXE): pngtest.o $(STATLIB)
191 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
193 pngtest.pic.o: pngtest.c
194 $(CC) $(CFLAGS) -c $< -o $@
197 $(CC) $(CFLAGS) -c $< -o $@
199 test: test-static test-shared
201 test-static: pngtest-stat$(EXE)
202 ./pngtest-stat $(S)/pngtest.png
204 test-shared: pngtest$(EXE)
205 ./pngtest $(S)/pngtest.png
207 install-static: $(STATLIB) install-headers install-man
208 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
209 install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
210 -@rm -f $(DL)/$(STATLIB)
211 (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
213 install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
214 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
215 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
216 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
217 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
218 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
219 install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
220 -@rm -f $(DL)/$(IMPLIB)
221 (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
222 install -s -m 755 $(SHAREDLIB) $(DB)
223 install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
224 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
227 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
228 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
230 -@rm -f $(DI)/pngconf.h
231 install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
233 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
236 -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi
237 -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi
238 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
239 install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
241 install-config: libpng-config
242 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
243 -@/bin/rm -f $(DB)/libpng-config
244 -@/bin/rm -f $(DB)/$(LIBNAME)-config
245 cp libpng-config $(DB)/$(LIBNAME)-config
246 chmod 755 $(DB)/$(LIBNAME)-config
247 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
249 # Run this to verify that a future `configure' run will pick up the settings
251 test-config-install: SHELL=/bin/bash
252 test-config-install: $(DB)/libpng-config
253 @echo -e Testing libpng-config functions...'\n'
254 @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
256 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
257 "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
258 gytiu=$$(( $$gytiu + 1 )); \
261 install: install-static install-shared install-man install-config
263 # If you installed in $(DESTDIR), test-installed won't work until you
264 # move the library to its final location. Use test-dd to test it
269 echo Testing installed dynamic shared library in $(DL).
270 $(CC) -I$(DI) $(CFLAGS) \
271 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
272 -L$(DL) -L$(ZLIBLIB) \
273 -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
274 ./pngtestd pngtest.png
278 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
280 -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags`
281 ./pngtesti$(EXE) pngtest.png
284 /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
285 pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
286 libpng-config libpng.pc pngtesti$(EXE)
288 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
290 chmod a-w *.[ch35] $(DOCS) scripts/*
292 .PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
294 # DO NOT DELETE THIS LINE -- make depend depends on it.
296 png.o png.pic.o: png.h pngconf.h png.c
297 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
298 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
299 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
300 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
301 pngset.o pngset.pic.o: png.h pngconf.h pngset.c
302 pngget.o pngget.pic.o: png.h pngconf.h pngget.c
303 pngread.o pngread.pic.o: png.h pngconf.h pngread.c
304 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
305 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
306 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
307 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
308 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
309 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
310 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
312 pngtest.o: png.h pngconf.h pngtest.c
313 pngtest-stat.o: png.h pngconf.h pngtest.c