blob: 46a3b494eb4734f18794c03080d550385d1a9f16 [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#
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -05006# Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson,
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -06007# and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by:
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -05008# Copyright (C) 1998-2000, 2007 Greg Roelofs
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -06009# Copyright (C) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -050010#
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -050011# This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -050012# For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050013# and license in png.h
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060014
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -050015# Built from makefile.cygwin
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -050016
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060017# This makefile intends to support building outside the src directory
18# if desired. When invoking it, specify an argument to SRCDIR on the
19# command line that points to the top of the directory where your source
20# is located.
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060021ifdef SRCDIR
22VPATH = $(SRCDIR)
23else
24SRCDIR = .
25endif
26
27# Override DESTDIR= on the make install command line to easily support
28# installing into a temporary location. Example:
29#
30# make install DESTDIR=/tmp/build/libpng
31#
32# If you're going to install into a temporary location
33# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
34# you execute make install.
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060035DESTDIR=
36
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -050037# If you're using a cross-compiler, add the appropriate prefix (e.g.,
38# "i386-mingw32msvc-") to the following three commands:
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060039CC=gcc
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -050040AR=ar
41RANLIB=ranlib
42
43MKDIR_P=/bin/mkdir -pv
44
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060045# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
46ifndef prefix
47prefix=/usr
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -050048$(warning "You haven't specified a 'prefix=' location. Defaulting to '/usr'")
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060049endif
Glenn Randers-Pehrsonad310542006-04-18 05:31:20 -050050exec_prefix=$(prefix)
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060051
52# Where the zlib library and include files are located
53ZLIBLIB= /usr/lib
54ZLIBINC=
55
56ALIGN=
57# for i386:
58#ALIGN=-malign-loops=2 -malign-functions=2
59
60WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
61 -Wmissing-declarations -Wtraditional -Wcast-align \
62 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
63
Glenn Randers-Pehrson03f9b022009-12-04 08:40:41 -060064CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -050065 -W -Wall -O3 $(ALIGN) -funroll-loops \
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060066 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
67
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050068LIBNAME = libpng14
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -050069PNGMAJ = 14
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050070MINGDLL = 14
Glenn Randers-Pehrsondbcfb712009-12-25 14:24:18 -060071PNGMIN = 1.4.0rc04
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060072PNGVER = $(PNGMAJ).$(PNGMIN)
73
74SHAREDLIB=libpng$(MINGDLL).dll
75STATLIB=libpng.a
76IMPLIB=libpng.dll.a
77SHAREDDEF=libpng.def
78LIBS=$(SHAREDLIB) $(STATLIB)
79EXE=.exe
80
81LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
82LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS))
83LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
84
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -060085INCPATH=$(prefix)/include
86LIBPATH=$(exec_prefix)/lib
87
88BINPATH=$(exec_prefix)/bin
89MANPATH=$(prefix)/man
90MAN3PATH=$(MANPATH)/man3
91MAN5PATH=$(MANPATH)/man5
92
93# cosmetic: shortened strings:
94S =$(SRCDIR)
95D =$(DESTDIR)
96DB =$(D)$(BINPATH)
97DI =$(D)$(INCPATH)
98DL =$(D)$(LIBPATH)
99
100OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
101 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500102 pngwtran.o pngmem.o pngerror.o pngpread.o
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600103
104OBJSDLL = $(OBJS:.o=.pic.o)
105
106.SUFFIXES: .c .o .pic.o
107
108%.o : %.c
109 $(CC) -c $(CFLAGS) -o $@ $<
110%.pic.o : CFLAGS += -DPNG_BUILD_DLL
111%.pic.o : %.c
112 $(CC) -c $(CFLAGS) -o $@ $<
113
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500114all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
Glenn Randers-Pehrsonb3870ab2006-05-11 09:43:09 -0500115
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600116# Make this to verify that "make [...] install" will do what you want.
117buildsetup-tell:
118 @echo VPATH is set to: \"$(VPATH)\"
119 @echo prefix is set to: \"$(prefix)\"
120 @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
121 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
122 $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
123
124libpng.pc: scripts/libpng.pc.in
125 @echo -e Making pkg-config file for this libpng installation..'\n' \
126 using PREFIX=\"$(prefix)\"'\n'
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500127 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
128 -e s!@exec_prefix@!$(exec_prefix)! \
129 -e s!@libdir@!$(LIBPATH)! \
130 -e s!@includedir@!$(INCPATH)! \
131 -e s!@includedir@!$(INCPATH)! \
132 -e s!-lpng14!-lpng14\ -lz\ -lm! > libpng.pc
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600133
134libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
135 @echo -e Making $(LIBNAME) libpng-config file for this libpng \
136 installation..'\n' using PREFIX=\"$(prefix)\"'\n'
137 ( cat $(S)/scripts/libpng-config-head.in; \
138 echo prefix=\"$(prefix)\"; \
139 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
140 echo L_opts=\"-L$(LIBPATH)\"; \
141 echo libs=\"-lpng$(MINGDLL) -lz\"; \
142 cat $(S)/scripts/libpng-config-body.in ) > libpng-config
143 chmod +x libpng-config
144
145static: all-static
146shared: all-shared
147all-static: $(STATLIB) pngtest-stat$(EXE)
148all-shared: $(SHAREDLIB) pngtest$(EXE)
149
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600150$(STATLIB): $(OBJS)
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500151 $(AR) rc $@ $(OBJS)
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600152 $(RANLIB) $@
153
Glenn Randers-Pehrson glennrp@comcast.netd603c892009-05-03 05:47:20 -0500154$(SHAREDDEF): scripts/pngwin.def
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600155 cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
156 sed -e 's/\([^;]*\);/;/' > $@
157
158$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
159 $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
160
161pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
162 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
163
164pngtest-stat$(EXE): pngtest.o $(STATLIB)
165 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
166
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600167test: test-static test-shared
168
169test-static: pngtest-stat$(EXE)
170 ./pngtest-stat $(S)/pngtest.png
171
172test-shared: pngtest$(EXE)
173 ./pngtest $(S)/pngtest.png
174
175install-static: $(STATLIB) install-headers install-man
176 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
177 install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
178 -@rm -f $(DL)/$(STATLIB)
179 (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
180
181install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
182 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
183 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
184 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
185 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
186 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
187 install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
188 -@rm -f $(DL)/$(IMPLIB)
189 (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
190 install -s -m 755 $(SHAREDLIB) $(DB)
191 install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
192 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
193
194install-headers:
195 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
196 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
197 -@rm -f $(DI)/png.h
198 -@rm -f $(DI)/pngconf.h
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500199 install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600200 -@rm -f $(DI)/libpng
201 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
202
203install-man:
204 -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi
205 -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi
206 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
207 install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
208
209install-config: libpng-config
210 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
211 -@/bin/rm -f $(DB)/libpng-config
212 -@/bin/rm -f $(DB)/$(LIBNAME)-config
213 cp libpng-config $(DB)/$(LIBNAME)-config
214 chmod 755 $(DB)/$(LIBNAME)-config
215 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
216
217# Run this to verify that a future `configure' run will pick up the settings
218# you want.
219test-config-install: SHELL=/bin/bash
220test-config-install: $(DB)/libpng-config
221 @echo -e Testing libpng-config functions...'\n'
222 @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
223 do \
224 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
225 "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
226 gytiu=$$(( $$gytiu + 1 )); \
227 done
228
229install: install-static install-shared install-man install-config
230
231# If you installed in $(DESTDIR), test-installed won't work until you
232# move the library to its final location. Use test-dd to test it
233# before then.
234
235test-dd:
236 echo
237 echo Testing installed dynamic shared library in $(DL).
238 $(CC) -I$(DI) $(CFLAGS) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500239 `$(BINPATH)/libpng14-config --cflags` pngtest.c \
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600240 -L$(DL) -L$(ZLIBLIB) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500241 -o pngtestd `$(BINPATH)/libpng14-config --ldflags`
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600242 ./pngtestd pngtest.png
243
244test-installed:
245 $(CC) $(CFLAGS) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500246 `$(BINPATH)/libpng14-config --cflags` pngtest.c \
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600247 -L$(ZLIBLIB) \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -0500248 -o pngtesti$(EXE) `$(BINPATH)/libpng14-config --ldflags`
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600249 ./pngtesti$(EXE) pngtest.png
250
251clean:
252 /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
Glenn Randers-Pehrson145f5c82008-07-10 09:13:13 -0500253 pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
254 libpng-config libpng.pc pngtesti$(EXE)
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600255
256DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
257writelock:
258 chmod a-w *.[ch35] $(DOCS) scripts/*
259
260.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
261
262# DO NOT DELETE THIS LINE -- make depend depends on it.
263
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500264png.o png.pic.o: png.h pngconf.h pngpriv.h png.c
265pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h pngerror.c
266pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h pngrio.c
267pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h pngwio.c
268pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h pngmem.c
269pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h pngset.c
270pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h pngget.c
271pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h pngread.c
272pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h pngrtran.c
273pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h pngrutil.c
274pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h pngtrans.c
275pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h pngwrite.c
276pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h pngwtran.c
277pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h pngwutil.c
278pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h pngpread.c
Glenn Randers-Pehrson26e47d92006-03-20 07:24:58 -0600279
Glenn Randers-Pehrson17ca3402009-11-09 06:51:16 -0600280pngtest.o pngtest.pic.o: png.h pngconf.h pngtest.c