blob: ce1dd987a2f2afb9b303e77e4897018a472c95c1 [file] [log] [blame]
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -06001# makefile for mingw 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.
5#
6# Built from makefile.cygwin
7# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson,
8# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by:
9# Copyright (C) 1998-2000 Greg Roelofs
10# Copyright (C) 1996, 1997 Andreas Dilger
11# For conditions of distribution and use, see copyright notice in png.h
12
13# This makefile intends to support building outside the src directory
14# if desired. When invoking it, specify an argument to SRCDIR on the
15# command line that points to the top of the directory where your source
16# is located.
17
18ifdef SRCDIR
19VPATH = $(SRCDIR)
20else
21SRCDIR = .
22endif
23
24# Override DESTDIR= on the make install command line to easily support
25# installing into a temporary location. Example:
26#
27# make install DESTDIR=/tmp/build/libpng
28#
29# If you're going to install into a temporary location
30# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
31# you execute make install.
32
33DESTDIR=
34
35# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to
36# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency
37# list at the bottom of this makefile.
38
39CC=gcc
40
41
42# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
43ifndef prefix
44prefix=/usr
45$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr")
46endif
Glenn Randers-Pehrsonad310542006-04-18 05:31:20 -050047exec_prefix=$(prefix)
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060048
49# Where the zlib library and include files are located
50ZLIBLIB= /usr/lib
51ZLIBINC=
52
53ALIGN=
54# for i386:
55#ALIGN=-malign-loops=2 -malign-functions=2
56
57WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
58 -Wmissing-declarations -Wtraditional -Wcast-align \
59 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
60
61### if you use the asm, add pnggccrd.o to the OBJS list
62###
63### if you don't need thread safety, but want the asm accel
64#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \
65# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \
66# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
67### if you need thread safety and want (minimal) asm accel
68#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \
69# -Wall -O3 $(ALIGN) -funroll-loops \
70# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
71### Normal (non-asm) compilation
72CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
73 -Wall -O3 $(ALIGN) -funroll-loops \
74 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
75
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050076LIBNAME = libpng14
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060077PNGMAJ = 0
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050078MINGDLL = 14
79PNGMIN = 1.4.0beta1
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060080PNGVER = $(PNGMAJ).$(PNGMIN)
81
82SHAREDLIB=libpng$(MINGDLL).dll
83STATLIB=libpng.a
84IMPLIB=libpng.dll.a
85SHAREDDEF=libpng.def
86LIBS=$(SHAREDLIB) $(STATLIB)
87EXE=.exe
88
89LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
90LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS))
91LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
92
93MKDIR_P=/bin/mkdir -pv
94RANLIB=ranlib
95#RANLIB=echo
96
97INCPATH=$(prefix)/include
98LIBPATH=$(exec_prefix)/lib
99
100BINPATH=$(exec_prefix)/bin
101MANPATH=$(prefix)/man
102MAN3PATH=$(MANPATH)/man3
103MAN5PATH=$(MANPATH)/man5
104
105# cosmetic: shortened strings:
106S =$(SRCDIR)
107D =$(DESTDIR)
108DB =$(D)$(BINPATH)
109DI =$(D)$(INCPATH)
110DL =$(D)$(LIBPATH)
111
112OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
113 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
114 pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o
115
116OBJSDLL = $(OBJS:.o=.pic.o)
117
118.SUFFIXES: .c .o .pic.o
119
120%.o : %.c
121 $(CC) -c $(CFLAGS) -o $@ $<
122%.pic.o : CFLAGS += -DPNG_BUILD_DLL
123%.pic.o : %.c
124 $(CC) -c $(CFLAGS) -o $@ $<
125
126all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
127
128# Make this to verify that "make [...] install" will do what you want.
129buildsetup-tell:
130 @echo VPATH is set to: \"$(VPATH)\"
131 @echo prefix is set to: \"$(prefix)\"
132 @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
133 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
134 $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
135
136libpng.pc: scripts/libpng.pc.in
137 @echo -e Making pkg-config file for this libpng installation..'\n' \
138 using PREFIX=\"$(prefix)\"'\n'
139 cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
140 sed -e s/-lm// > libpng.pc
141
142libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
143 @echo -e Making $(LIBNAME) libpng-config file for this libpng \
144 installation..'\n' using PREFIX=\"$(prefix)\"'\n'
145 ( cat $(S)/scripts/libpng-config-head.in; \
146 echo prefix=\"$(prefix)\"; \
147 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
148 echo L_opts=\"-L$(LIBPATH)\"; \
149 echo libs=\"-lpng$(MINGDLL) -lz\"; \
150 cat $(S)/scripts/libpng-config-body.in ) > libpng-config
151 chmod +x libpng-config
152
153static: all-static
154shared: all-shared
155all-static: $(STATLIB) pngtest-stat$(EXE)
156all-shared: $(SHAREDLIB) pngtest$(EXE)
157
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500158pnggccrd.o: pnggccrd.c png.h pngconf.h pngintrn.h
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600159 @echo ""
160 @echo ' You can ignore the "control reaches end of non-void function"'
161 @echo ' warning and "<variable> defined but not used" warnings:'
162 @echo ""
163 $(CC) -c $(CFLAGS) -o $@ $<
164
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500165pnggccrd.pic.o: pnggccrd.c png.h pngconf.h pngintrn.h
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600166 @echo ""
167 @echo ' You can ignore the "control reaches end of non-void function"'
168 @echo ' warning and "<variable> defined but not used" warnings:'
169 @echo ""
170 $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
171
172$(STATLIB): $(OBJS)
173 ar rc $@ $(OBJS)
174 $(RANLIB) $@
175
176$(SHAREDDEF): scripts/pngw32.def
177 cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
178 sed -e 's/\([^;]*\);/;/' > $@
179
180$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
181 $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
182
183pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
184 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
185
186pngtest-stat$(EXE): pngtest.o $(STATLIB)
187 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
188
189pngtest.pic.o: pngtest.c
190 $(CC) $(CFLAGS) -c $< -o $@
191
192pngtest.o: pngtest.c
193 $(CC) $(CFLAGS) -c $< -o $@
194
195test: test-static test-shared
196
197test-static: pngtest-stat$(EXE)
198 ./pngtest-stat $(S)/pngtest.png
199
200test-shared: pngtest$(EXE)
201 ./pngtest $(S)/pngtest.png
202
203install-static: $(STATLIB) install-headers install-man
204 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
205 install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
206 -@rm -f $(DL)/$(STATLIB)
207 (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
208
209install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
210 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
211 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
212 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
213 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
214 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
215 install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
216 -@rm -f $(DL)/$(IMPLIB)
217 (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
218 install -s -m 755 $(SHAREDLIB) $(DB)
219 install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
220 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
221
222install-headers:
223 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
224 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
225 -@rm -f $(DI)/png.h
226 -@rm -f $(DI)/pngconf.h
227 install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
228 -@rm -f $(DI)/libpng
229 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
230
231install-man:
232 -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi
233 -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi
234 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
235 install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
236
237install-config: libpng-config
238 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
239 -@/bin/rm -f $(DB)/libpng-config
240 -@/bin/rm -f $(DB)/$(LIBNAME)-config
241 cp libpng-config $(DB)/$(LIBNAME)-config
242 chmod 755 $(DB)/$(LIBNAME)-config
243 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
244
245# Run this to verify that a future `configure' run will pick up the settings
246# you want.
247test-config-install: SHELL=/bin/bash
248test-config-install: $(DB)/libpng-config
249 @echo -e Testing libpng-config functions...'\n'
250 @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
251 do \
252 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
253 "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
254 gytiu=$$(( $$gytiu + 1 )); \
255 done
256
257install: install-static install-shared install-man install-config
258
259# If you installed in $(DESTDIR), test-installed won't work until you
260# move the library to its final location. Use test-dd to test it
261# before then.
262
263test-dd:
264 echo
265 echo Testing installed dynamic shared library in $(DL).
266 $(CC) -I$(DI) $(CFLAGS) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500267 `$(BINPATH)/libpng14-config --cflags` pngtest.c \
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600268 -L$(DL) -L$(ZLIBLIB) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500269 -o pngtestd `$(BINPATH)/libpng14-config --ldflags`
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600270 ./pngtestd pngtest.png
271
272test-installed:
273 $(CC) $(CFLAGS) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500274 `$(BINPATH)/libpng14-config --cflags` pngtest.c \
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600275 -L$(ZLIBLIB) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500276 -o pngtesti$(EXE) `$(BINPATH)/libpng14-config --ldflags`
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600277 ./pngtesti$(EXE) pngtest.png
278
279clean:
280 /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
281 pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
282 libpng-config libpng.pc pngtesti$(EXE)
283
284DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
285writelock:
286 chmod a-w *.[ch35] $(DOCS) scripts/*
287
288.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
289
290# DO NOT DELETE THIS LINE -- make depend depends on it.
291
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500292png.o png.pic.o: png.h pngconf.h pngintrn.h png.c
293pngerror.o pngerror.pic.o: png.h pngconf.h pngintrn.h pngerror.c
294pngrio.o pngrio.pic.o: png.h pngconf.h pngintrn.h pngrio.c
295pngwio.o pngwio.pic.o: png.h pngconf.h pngintrn.h pngwio.c
296pngmem.o pngmem.pic.o: png.h pngconf.h pngintrn.h pngmem.c
297pngset.o pngset.pic.o: png.h pngconf.h pngintrn.h pngset.c
298pngget.o pngget.pic.o: png.h pngconf.h pngintrn.h pngget.c
299pngread.o pngread.pic.o: png.h pngconf.h pngintrn.h pngread.c
300pngrtran.o pngrtran.pic.o: png.h pngconf.h pngintrn.h pngrtran.c
301pngrutil.o pngrutil.pic.o: png.h pngconf.h pngintrn.h pngrutil.c
302pngtrans.o pngtrans.pic.o: png.h pngconf.h pngintrn.h pngtrans.c
303pngwrite.o pngwrite.pic.o: png.h pngconf.h pngintrn.h pngwrite.c
304pngwtran.o pngwtran.pic.o: png.h pngconf.h pngintrn.h pngwtran.c
305pngwutil.o pngwutil.pic.o: png.h pngconf.h pngintrn.h pngwutil.c
306pngpread.o pngpread.pic.o: png.h pngconf.h pngintrn.h pngpread.c
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600307
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500308pngtest.o: png.h pngconf.h pngintrn.h pngtest.c
309pngtest-stat.o: png.h pngconf.h pngintrn.h pngtest.c
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600310
311
312