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, 2007 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.
36 MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw
37 MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw
40 # Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
43 $(warning You haven't specified a 'prefix=' location. Defaulting to "/usr")
47 # Where the zlib library and include files are located
55 #ALIGN=-malign-loops=2 -malign-functions=2
57 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
58 -Wmissing-declarations -Wtraditional -Wcast-align \
59 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
61 ### if you don't need thread safety, but want the asm accel
62 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \
63 # $(addprefix -I,$(ZLIBINC)) -Wall -O $(ALIGN) -funroll-loops \
64 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
65 ### if you need thread safety and want (minimal) asm accel
66 #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
67 # -Wall -O $(ALIGN) -funroll-loops \
68 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
69 ### Normal (non-asm) compilation
70 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
71 -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \
72 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
78 PNGVER = $(PNGMAJ).$(PNGMIN)
80 SHAREDLIB=cygpng$(CYGDLL).dll
84 LIBS=$(SHAREDLIB) $(STATLIB)
87 LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
88 LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all)
89 LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
91 MKDIR_P=/bin/mkdir -pv
95 INCPATH=$(prefix)/include
96 LIBPATH=$(exec_prefix)/lib
98 BINPATH=$(exec_prefix)/bin
100 MAN3PATH=$(MANPATH)/man3
101 MAN5PATH=$(MANPATH)/man5
103 # cosmetic: shortened strings:
110 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
111 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
112 pngwtran.o pngmem.o pngerror.o pngpread.o
114 OBJSDLL = $(OBJS:.o=.pic.o)
116 .SUFFIXES: .c .o .pic.o
119 $(CC) -c $(CFLAGS) -o $@ $<
120 %.pic.o : CFLAGS += -DPNG_BUILD_DLL
122 $(CC) -c $(CFLAGS) -o $@ $<
124 all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
126 # Make this to verify that "make [...] install" will do what you want.
128 @echo VPATH is set to: \"$(VPATH)\"
129 @echo prefix is set to: \"$(prefix)\"
130 @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
131 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
132 $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
134 libpng.pc: scripts/libpng.pc.in
135 @echo -e Making pkg-config file for this libpng installation..'\n' \
136 using PREFIX=\"$(prefix)\"'\n'
137 cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
138 sed -e s/-lm// > libpng.pc
140 libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
141 @echo -e Making $(LIBNAME) libpng-config file for this libpng \
142 installation..'\n' using PREFIX=\"$(prefix)\"'\n'
143 ( cat $(S)/scripts/libpng-config-head.in; \
144 echo prefix=\"$(prefix)\"; \
145 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
146 echo L_opts=\"-L$(LIBPATH)\"; \
147 echo libs=\"-lpng$(CYGDLL) -lz\"; \
148 cat $(S)/scripts/libpng-config-body.in ) > libpng-config
149 chmod +x libpng-config
153 all-static: $(STATLIB) pngtest-stat$(EXE)
154 all-shared: $(SHAREDLIB) pngtest$(EXE)
160 $(SHAREDDEF): scripts/pngw32.def
161 cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
162 sed -e 's/\([^;]*\);/;/' > $@
164 $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
165 $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
167 pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
168 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
170 pngtest-stat$(EXE): pngtest.o $(STATLIB)
171 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
173 pngtest.pic.o: pngtest.c
174 $(CC) $(CFLAGS) -c $< -o $@
177 $(CC) $(CFLAGS) -c $< -o $@
179 test: test-static test-shared
181 test-static: pngtest-stat$(EXE)
182 ./pngtest-stat $(S)/pngtest.png
184 test-shared: pngtest$(EXE)
185 ./pngtest $(S)/pngtest.png
187 install-static: $(STATLIB) install-headers install-man
188 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
189 install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
190 -@rm -f $(DL)/$(STATLIB)
191 (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
193 install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
194 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
195 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
196 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
197 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
198 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
199 install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
200 -@rm -f $(DL)/$(IMPLIB)
201 (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
202 install -s -m 755 $(SHAREDLIB) $(DB)
203 install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
204 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
207 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
208 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
210 -@rm -f $(DI)/pngconf.h
211 install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
213 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
216 -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi
217 -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi
218 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
219 install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
221 install-config: libpng-config
222 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
223 -@/bin/rm -f $(DB)/libpng-config
224 -@/bin/rm -f $(DB)/$(LIBNAME)-config
225 cp libpng-config $(DB)/$(LIBNAME)-config
226 chmod 755 $(DB)/$(LIBNAME)-config
227 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
229 # Run this to verify that a future `configure' run will pick up the settings
231 test-config-install: SHELL=/bin/bash
232 test-config-install: $(DB)/libpng-config
233 @echo -e Testing libpng-config functions...'\n'
234 @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
236 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
237 "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
238 gytiu=$$(( $$gytiu + 1 )); \
241 install: install-static install-shared install-man install-config
243 # If you installed in $(DESTDIR), test-installed won't work until you
244 # move the library to its final location. Use test-dd to test it
249 echo Testing installed dynamic shared library in $(DL).
250 $(CC) -I$(DI) $(CFLAGS) \
251 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
252 -L$(DL) -L$(ZLIBLIB) \
253 -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
254 ./pngtestd pngtest.png
258 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
260 -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags`
261 ./pngtesti$(EXE) pngtest.png
264 /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
265 pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
266 libpng-config libpng.pc pngtesti$(EXE)
268 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
270 chmod a-w *.[ch35] $(DOCS) scripts/*
272 .PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
274 # DO NOT DELETE THIS LINE -- make depend depends on it.
276 png.o png.pic.o: png.h pngconf.h png.c
277 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
278 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
279 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
280 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
281 pngset.o pngset.pic.o: png.h pngconf.h pngset.c
282 pngget.o pngget.pic.o: png.h pngconf.h pngget.c
283 pngread.o pngread.pic.o: png.h pngconf.h pngread.c
284 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
285 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
286 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
287 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
288 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
289 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
290 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
292 pngtest.o: png.h pngconf.h pngtest.c
293 pngtest-stat.o: png.h pngconf.h pngtest.c