]> git.saurik.com Git - wxWidgets.git/blob - src/png/scripts/makefile.cygwin
fix build for watcom
[wxWidgets.git] / src / png / scripts / makefile.cygwin
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.
5 #
6 # Copyright (C) 2002 Soren Anderson, Charles Wilson, and Glenn Randers-Pehrson
7 # 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
11
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
15 # is located.
16
17 ifdef SRCDIR
18 VPATH = $(SRCDIR)
19 else
20 SRCDIR = .
21 endif
22
23 # Override DESTDIR= on the make install command line to easily support
24 # installing into a temporary location. Example:
25 #
26 # make install DESTDIR=/tmp/build/libpng
27 #
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.
31
32 DESTDIR=
33
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.
37
38 CC=gcc
39 ifdef MINGW
40 MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw
41 MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw
42 endif
43
44 # Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
45 ifndef prefix
46 prefix=/usr
47 $(warning You haven't specified a 'prefix=' location. Defaulting to "/usr")
48 endif
49
50 # Where the zlib library and include files are located
51 ZLIBLIB= /usr/lib
52 ZLIBINC=
53 #ZLIBLIB=../zlib
54 #ZLIBINC=../zlib
55
56 ALIGN=
57 # for i386:
58 #ALIGN=-malign-loops=2 -malign-functions=2
59
60 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
61 -Wmissing-declarations -Wtraditional -Wcast-align \
62 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
63
64 ### if you use the asm, add pnggccrd.o to the OBJS list
65 ###
66 ### if you don't need thread safety, but want the asm accel
67 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \
68 # $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \
69 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
70 ### if you need thread safety and want (minimal) asm accel
71 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \
72 # -Wall -O3 $(ALIGN) -funroll-loops \
73 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
74 ### Normal (non-asm) compilation
75 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
76 -Wall -O3 $(ALIGN) -funroll-loops \
77 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
78
79 LIBNAME = libpng12
80 PNGMAJ = 0
81 PNGDLL = 13
82 PNGMIN = 1.2.4
83 PNGVER = $(PNGMAJ).$(PNGMIN)
84
85 SHAREDLIB=cygpng$(PNGDLL).dll
86 STATLIB=libpng.a
87 IMPLIB=libpng.dll.a
88 SHAREDDEF=libpng.def
89 LIBS=$(SHAREDLIB) $(STATLIB)
90 EXE=.exe
91
92 LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
93 LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all)
94 LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
95
96 MKDIR=/bin/mkdir -pv
97 RANLIB=ranlib
98 #RANLIB=echo
99
100 INCPATH=$(prefix)/include
101 LIBPATH=$(prefix)/lib
102
103 BINPATH=$(prefix)/bin
104 MANPATH=$(prefix)/man
105 MAN3PATH=$(MANPATH)/man3
106 MAN5PATH=$(MANPATH)/man5
107
108 # cosmetic: shortened strings:
109 S =$(SRCDIR)
110 D =$(DESTDIR)
111 DB =$(D)$(BINPATH)
112 DI =$(D)$(INCPATH)
113 DL =$(D)$(LIBPATH)
114
115 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
116 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
117 pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o
118
119 OBJSDLL = $(OBJS:.o=.pic.o)
120
121 .SUFFIXES: .c .o .pic.o
122
123 %.o : %.c
124 $(CC) -c $(CFLAGS) -o $@ $<
125 %.pic.o : CFLAGS += -DPNG_BUILD_DLL
126 %.pic.o : %.c
127 $(CC) -c $(CFLAGS) -o $@ $<
128
129 all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
130
131 # Make this to verify that "make [...] install" will do what you want.
132 buildsetup-tell:
133 @echo VPATH is set to: \"$(VPATH)\"
134 @echo prefix is set to: \"$(prefix)\"
135 @echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
136 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
137 $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
138
139 libpng.pc: scripts/libpng.pc.in
140 @echo -e Making pkg-config file for this libpng installation..'\n' \
141 using PREFIX=\"$(prefix)\"'\n'
142 cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
143 sed -e s/-lm// > libpng.pc
144
145 libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
146 @echo -e Making $(LIBNAME) libpng-config file for this libpng \
147 installation..'\n' using PREFIX=\"$(prefix)\"'\n'
148 ( cat $(S)/scripts/libpng-config-head.in; \
149 echo prefix=\"$(prefix)\"; \
150 echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
151 echo cflags=\"\"; \
152 echo ldflags=\"-L$(LIBPATH)\"; \
153 echo libs=\"-lpng$(PNGMAJ) -lz\"; \
154 cat $(S)/scripts/libpng-config-body.in ) > libpng-config
155 chmod +x libpng-config
156
157 static: all-static
158 shared: all-shared
159 all-static: $(STATLIB) pngtest-stat$(EXE)
160 all-shared: $(SHAREDLIB) pngtest$(EXE)
161
162 pnggccrd.o: pnggccrd.c png.h pngconf.h
163 @echo ""
164 @echo ' You can ignore the "control reaches end of non-void function"'
165 @echo ' warning and "<variable> defined but not used" warnings:'
166 @echo ""
167 $(CC) -c $(CFLAGS) -o $@ $<
168
169 pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
170 @echo ""
171 @echo ' You can ignore the "control reaches end of non-void function"'
172 @echo ' warning and "<variable> defined but not used" warnings:'
173 @echo ""
174 $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
175
176 $(STATLIB): $(OBJS)
177 ar rc $@ $(OBJS)
178 $(RANLIB) $@
179
180 $(SHAREDDEF): projects/msvc/png32ms.def
181 cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
182 sed -e 's/\([^;]*\);/;/' > $@
183
184 $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
185 $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
186
187 pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
188 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
189
190 pngtest-stat$(EXE): pngtest.o $(STATLIB)
191 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
192
193 pngtest.pic.o: pngtest.c
194 $(CC) $(CFLAGS) -c $< -o $@
195
196 pngtest.o: pngtest.c
197 $(CC) $(CFLAGS) -c $< -o $@
198
199 test: test-static test-shared
200
201 test-static: pngtest-stat$(EXE)
202 ./pngtest-stat $(S)/pngtest.png
203
204 test-shared: pngtest$(EXE)
205 ./pngtest $(S)/pngtest.png
206
207 install-static: $(STATLIB) install-headers install-man
208 -@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
209 install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
210 -@rm -f $(DL)/$(STATLIB)
211 (cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
212
213 install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
214 -@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
215 -@if [ ! -d $(DB) ]; then $(MKDIR) $(DB); fi
216 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR) $(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)
225
226 install-headers:
227 -@if [ ! -d $(DI) ]; then $(MKDIR) $(DI); fi
228 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR) $(DI)/$(LIBNAME); fi
229 -@rm -f $(DI)/png.h
230 -@rm -f $(DI)/pngconf.h
231 install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
232 -@rm -f $(DI)/libpng
233 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
234
235 install-man:
236 -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR) $(D)$(MAN3PATH); fi
237 -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR) $(D)$(MAN5PATH); fi
238 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
239 install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
240
241 install-config: libpng-config
242 -@if [ ! -d $(DB) ]; then mkdir $(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)
248
249 # Run this to verify that a future `configure' run will pick up the settings
250 # you want.
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; \
255 do \
256 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
257 "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
258 gytiu=$$(( $$gytiu + 1 )); \
259 done
260
261 install: install-static install-shared install-man install-config
262
263 # If you installed in $(DESTDIR), test-installed won't work until you
264 # move the library to its final location.
265
266 test-installed:
267 $(CC) $(CFLAGS) \
268 `$(BINPATH)/libpng12-config --cppflags --cflags` pngtest.c \
269 -L$(ZLIBLIB) \
270 -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags --libs`
271 ./pngtesti$(EXE) pngtest.png
272
273 clean:
274 /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
275 pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
276 libpng-config libpng.pc pngtesti$(EXE)
277
278 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
279 writelock:
280 chmod a-w *.[ch35] $(DOCS) scripts/*
281
282 .PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
283
284 # DO NOT DELETE THIS LINE -- make depend depends on it.
285
286 png.o png.pic.o: png.h pngconf.h png.c
287 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
288 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
289 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
290 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
291 pngset.o pngset.pic.o: png.h pngconf.h pngset.c
292 pngget.o pngget.pic.o: png.h pngconf.h pngget.c
293 pngread.o pngread.pic.o: png.h pngconf.h pngread.c
294 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
295 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
296 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
297 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
298 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
299 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
300 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
301
302 pngtest.o: png.h pngconf.h pngtest.c
303 pngtest-stat.o: png.h pngconf.h pngtest.c
304
305
306