blob: 6713dfe3e4e6e81c8ef7a5c0385c2e0965f938a9 [file] [log] [blame]
The Android Open Source Project893912b2009-03-03 19:30:05 -08001# 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
The Android Open Source Project4215dd12009-03-09 11:52:12 -07007# Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson,
The Android Open Source Project893912b2009-03-03 19:30:05 -08008# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by:
9# Copyright (C) 1998-2000, 2007 Greg Roelofs
10# Copyright (C) 1996, 1997 Andreas Dilger
11# For conditions of distribution and use, see copyright notice in png.h
12
13
14# This makefile intends to support building outside the src directory
15# if desired. When invoking it, specify an argument to SRCDIR on the
16# command line that points to the top of the directory where your source
17# is located.
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.
32DESTDIR=
33
34# If you're using a cross-compiler, add the appropriate prefix (e.g.,
35# "i386-mingw32msvc-") to the following three commands:
36CC=gcc
37AR=ar
38RANLIB=ranlib
39
40MKDIR_P=/bin/mkdir -pv
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
47exec_prefix=$(prefix)
48
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 don't need thread safety, but want the asm accel
62#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \
The Android Open Source Project4215dd12009-03-09 11:52:12 -070063# $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \
The Android Open Source Project893912b2009-03-03 19:30:05 -080064# -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)) \
The Android Open Source Project4215dd12009-03-09 11:52:12 -070067# -W -Wall -O $(ALIGN) -funroll-loops \
The Android Open Source Project893912b2009-03-03 19:30:05 -080068# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
69### Normal (non-asm) compilation
70CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
The Android Open Source Project4215dd12009-03-09 11:52:12 -070071 -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \
The Android Open Source Project893912b2009-03-03 19:30:05 -080072 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
73
74LIBNAME = libpng12
75PNGMAJ = 0
76MINGDLL = 12
The Android Open Source Project4215dd12009-03-09 11:52:12 -070077PNGMIN = 1.2.35
The Android Open Source Project893912b2009-03-03 19:30:05 -080078PNGVER = $(PNGMAJ).$(PNGMIN)
79
80SHAREDLIB=libpng$(MINGDLL).dll
81STATLIB=libpng.a
82IMPLIB=libpng.dll.a
83SHAREDDEF=libpng.def
84LIBS=$(SHAREDLIB) $(STATLIB)
85EXE=.exe
86
87LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
88LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS))
89LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
90
91INCPATH=$(prefix)/include
92LIBPATH=$(exec_prefix)/lib
93
94BINPATH=$(exec_prefix)/bin
95MANPATH=$(prefix)/man
96MAN3PATH=$(MANPATH)/man3
97MAN5PATH=$(MANPATH)/man5
98
99# cosmetic: shortened strings:
100S =$(SRCDIR)
101D =$(DESTDIR)
102DB =$(D)$(BINPATH)
103DI =$(D)$(INCPATH)
104DL =$(D)$(LIBPATH)
105
106OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
107 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
108 pngwtran.o pngmem.o pngerror.o pngpread.o
109
110OBJSDLL = $(OBJS:.o=.pic.o)
111
112.SUFFIXES: .c .o .pic.o
113
114%.o : %.c
115 $(CC) -c $(CFLAGS) -o $@ $<
116%.pic.o : CFLAGS += -DPNG_BUILD_DLL
117%.pic.o : %.c
118 $(CC) -c $(CFLAGS) -o $@ $<
119
120all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
121
122# Make this to verify that "make [...] install" will do what you want.
123buildsetup-tell:
124 @echo VPATH is set to: \"$(VPATH)\"
125 @echo prefix is set to: \"$(prefix)\"
126 @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
127 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
128 $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
129
130libpng.pc: scripts/libpng.pc.in
131 @echo -e Making pkg-config file for this libpng installation..'\n' \
132 using PREFIX=\"$(prefix)\"'\n'
133 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
134 -e s!@exec_prefix@!$(exec_prefix)! \
135 -e s!@libdir@!$(LIBPATH)! \
136 -e s!@includedir@!$(INCPATH)! \
137 -e s!@includedir@!$(INCPATH)! \
138 -e s!-lpng12!-lpng12\ -lz\ -lm! > libpng.pc
139
140libpng-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$(MINGDLL) -lz\"; \
148 cat $(S)/scripts/libpng-config-body.in ) > libpng-config
149 chmod +x libpng-config
150
151static: all-static
152shared: all-shared
153all-static: $(STATLIB) pngtest-stat$(EXE)
154all-shared: $(SHAREDLIB) pngtest$(EXE)
155
156$(STATLIB): $(OBJS)
157 $(AR) rc $@ $(OBJS)
158 $(RANLIB) $@
159
160$(SHAREDDEF): scripts/pngw32.def
161 cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
162 sed -e 's/\([^;]*\);/;/' > $@
163
164$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
165 $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
166
167pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
168 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
169
170pngtest-stat$(EXE): pngtest.o $(STATLIB)
171 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
172
173test: test-static test-shared
174
175test-static: pngtest-stat$(EXE)
176 ./pngtest-stat $(S)/pngtest.png
177
178test-shared: pngtest$(EXE)
179 ./pngtest $(S)/pngtest.png
180
181install-static: $(STATLIB) install-headers install-man
182 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
183 install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
184 -@rm -f $(DL)/$(STATLIB)
185 (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
186
187install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
188 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
189 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
190 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
191 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
192 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
193 install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
194 -@rm -f $(DL)/$(IMPLIB)
195 (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
196 install -s -m 755 $(SHAREDLIB) $(DB)
197 install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
198 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
199
200install-headers:
201 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
202 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
203 -@rm -f $(DI)/png.h
204 -@rm -f $(DI)/pngconf.h
205 install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
206 -@rm -f $(DI)/libpng
207 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
208
209install-man:
210 -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi
211 -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi
212 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
213 install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
214
215install-config: libpng-config
216 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
217 -@/bin/rm -f $(DB)/libpng-config
218 -@/bin/rm -f $(DB)/$(LIBNAME)-config
219 cp libpng-config $(DB)/$(LIBNAME)-config
220 chmod 755 $(DB)/$(LIBNAME)-config
221 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
222
223# Run this to verify that a future `configure' run will pick up the settings
224# you want.
225test-config-install: SHELL=/bin/bash
226test-config-install: $(DB)/libpng-config
227 @echo -e Testing libpng-config functions...'\n'
228 @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
229 do \
230 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
231 "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
232 gytiu=$$(( $$gytiu + 1 )); \
233 done
234
235install: install-static install-shared install-man install-config
236
237# If you installed in $(DESTDIR), test-installed won't work until you
238# move the library to its final location. Use test-dd to test it
239# before then.
240
241test-dd:
242 echo
243 echo Testing installed dynamic shared library in $(DL).
244 $(CC) -I$(DI) $(CFLAGS) \
245 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
246 -L$(DL) -L$(ZLIBLIB) \
247 -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
248 ./pngtestd pngtest.png
249
250test-installed:
251 $(CC) $(CFLAGS) \
252 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
253 -L$(ZLIBLIB) \
254 -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags`
255 ./pngtesti$(EXE) pngtest.png
256
257clean:
258 /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
259 pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
260 libpng-config libpng.pc pngtesti$(EXE)
261
262DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
263writelock:
264 chmod a-w *.[ch35] $(DOCS) scripts/*
265
266.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
267
268# DO NOT DELETE THIS LINE -- make depend depends on it.
269
270png.o png.pic.o: png.h pngconf.h png.c
271pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
272pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
273pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
274pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
275pngset.o pngset.pic.o: png.h pngconf.h pngset.c
276pngget.o pngget.pic.o: png.h pngconf.h pngget.c
277pngread.o pngread.pic.o: png.h pngconf.h pngread.c
278pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
279pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
280pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
281pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
282pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
283pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
284pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
285
286pngtest.o pngtest.pic.o: png.h pngconf.h pngtest.c
287
288
289