makefile.cygwin 10.0 KB
Newer Older
1
# makefile for cygwin on x86
2
#   Builds both dll (with import lib) and static lib versions
3 4
#   of the library, and builds two copies of pngtest: one
#   statically linked and one dynamically linked.
5
#
6
# Copyright (C) 2002 Soren Anderson, Charles Wilson, and Glenn Randers-Pehrson
7 8 9 10 11
#   based on makefile for linux-elf w/mmx by:
# Copyright (C) 1998-2000 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h

12 13
# This makefile intends to support building outside the src directory
# if desired. When invoking it, specify an argument to SRCDIR on the
14 15 16
# command line that points to the top of the directory where your source
# is located.

17 18
ifdef SRCDIR
VPATH = $(SRCDIR)
19
else
20
SRCDIR = .
21 22
endif

23
# Override DESTDIR= on the make install command line to easily support
24 25 26 27 28
# installing into a temporary location.  Example:
#
#    make install DESTDIR=/tmp/build/libpng
#
# 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 33
DESTDIR=

34
# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to
35 36
# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency
# list at the bottom of this makefile.
37 38

CC=gcc
39 40 41 42
ifdef MINGW
MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw
MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw
endif
43

44
# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
45
ifndef prefix
46
prefix=/usr
47 48
$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr")
endif
49 50

# Where the zlib library and include files are located
51 52
ZLIBLIB= /usr/lib
ZLIBINC=
53 54 55 56 57 58 59 60 61 62 63
#ZLIBLIB=../zlib
#ZLIBINC=../zlib

ALIGN=
# for i386:
#ALIGN=-malign-loops=2 -malign-functions=2

WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
	-Wmissing-declarations -Wtraditional -Wcast-align \
	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
### if you use the asm, add pnggccrd.o to the OBJS list
###
### if you don't need thread safety, but want the asm accel
#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \
#	$(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \
#	-fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
### if you need thread safety and want (minimal) asm accel
#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \
#	-Wall -O3 $(ALIGN) -funroll-loops \
#	-fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
### Normal (non-asm) compilation
CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
        -Wall -O3 $(ALIGN) -funroll-loops \
	-fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5

LIBNAME = libpng12
80
PNGMAJ = 0
81
CYGDLL = 12
82
PNGMIN = 1.2.8rc3
83 84
PNGVER = $(PNGMAJ).$(PNGMIN)

85
SHAREDLIB=cygpng$(CYGDLL).dll
86 87 88 89 90 91
STATLIB=libpng.a
IMPLIB=libpng.dll.a
SHAREDDEF=libpng.def
LIBS=$(SHAREDLIB) $(STATLIB)
EXE=.exe

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 97 98 99
MKDIR=/bin/mkdir -pv
RANLIB=ranlib
#RANLIB=echo

100 101
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
102

103 104
BINPATH=$(prefix)/bin
MANPATH=$(prefix)/man
105 106
MAN3PATH=$(MANPATH)/man3
MAN5PATH=$(MANPATH)/man5
107

108 109 110
# cosmetic: shortened strings:
S =$(SRCDIR)
D =$(DESTDIR)
111 112 113
DB =$(D)$(BINPATH)
DI =$(D)$(INCPATH)
DL =$(D)$(LIBPATH)
114

115 116 117 118 119 120
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
	pngwtran.o pngmem.o pngerror.o pngpread.o # pnggccrd.o

OBJSDLL = $(OBJS:.o=.pic.o)

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 133 134 135
buildsetup-tell:
	@echo  VPATH is set to: \"$(VPATH)\"
	@echo  prefix is set to: \"$(prefix)\"
	@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 141
	@echo -e Making pkg-config file for this libpng installation..'\n' \
           using PREFIX=\"$(prefix)\"'\n'
142 143
	cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
	   sed -e s/-lm// > libpng.pc
144

145
libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
146 147 148
	@echo -e Making $(LIBNAME) libpng-config file for this libpng \
 installation..'\n' using PREFIX=\"$(prefix)\"'\n'
	( cat $(S)/scripts/libpng-config-head.in; \
149
	echo prefix=\"$(prefix)\"; \
150 151
	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
	echo L_opts=\"-L$(LIBPATH)\"; \
152
	echo libs=\"-lpng$(CYGDLL) -lz\"; \
153
	cat $(S)/scripts/libpng-config-body.in ) > libpng-config
154
	chmod +x libpng-config
155 156 157 158 159

static: all-static
shared: all-shared
all-static: $(STATLIB) pngtest-stat$(EXE)
all-shared: $(SHAREDLIB) pngtest$(EXE)
160

161
pnggccrd.o: pnggccrd.c png.h pngconf.h
162
	@echo ""
163 164
	@echo '    You can ignore the "control reaches end of non-void function"'
	@echo '    warning and "<variable> defined but not used" warnings:'
165
	@echo ""
166
	$(CC) -c $(CFLAGS) -o $@ $<
167

168
pnggccrd.pic.o:	pnggccrd.c png.h pngconf.h
169
	@echo ""
170 171
	@echo '    You can ignore the "control reaches end of non-void function"'
	@echo '    warning and "<variable> defined but not used" warnings:'
172
	@echo ""
173
	$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
174 175

$(STATLIB): $(OBJS)
176
	ar rc $@ $(OBJS)
177 178
	$(RANLIB) $@

179
$(SHAREDDEF): scripts/png32ms.def
180 181
	cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
	sed -e 's/\([^;]*\);/;/' > $@
182 183

$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
184
	$(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
185 186 187 188 189 190 191 192 193 194 195

pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
	$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@

pngtest-stat$(EXE): pngtest.o $(STATLIB)
	$(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@

pngtest.pic.o: pngtest.c
	$(CC) $(CFLAGS) -c $< -o $@

pngtest.o: pngtest.c
196
	$(CC) $(CFLAGS) -c $< -o $@
197

198
test: test-static test-shared
199

200
test-static: pngtest-stat$(EXE)
201
	./pngtest-stat $(S)/pngtest.png
202

203
test-shared: pngtest$(EXE)
204
	./pngtest $(S)/pngtest.png
205

206
install-static: $(STATLIB) install-headers install-man
207 208 209 210
	-@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
	install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
	-@rm -f $(DL)/$(STATLIB)
	(cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
211

212
install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
213 214 215 216 217 218 219 220 221 222 223
	-@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
	-@if [ ! -d $(DB) ]; then $(MKDIR) $(DB); fi
	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR) $(DL)/pkgconfig; fi
	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
	install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
	-@rm -f $(DL)/$(IMPLIB)
	(cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
	install -s -m 755 $(SHAREDLIB) $(DB)
	install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
224 225

install-headers:
226 227 228 229 230 231 232
	-@if [ ! -d $(DI) ]; then $(MKDIR) $(DI); fi
	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR) $(DI)/$(LIBNAME); fi
	-@rm -f $(DI)/png.h
	-@rm -f $(DI)/pngconf.h
	install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
	-@rm -f $(DI)/libpng
	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
233 234

install-man:
235 236
	-@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR) $(D)$(MAN3PATH); fi
	-@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR) $(D)$(MAN5PATH); fi
237 238
	install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
	install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
239

240
install-config: libpng-config
241 242 243 244 245 246 247 248
	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
	-@/bin/rm -f $(DB)/libpng-config
	-@/bin/rm -f $(DB)/$(LIBNAME)-config
	cp libpng-config $(DB)/$(LIBNAME)-config
	chmod 755 $(DB)/$(LIBNAME)-config
	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)

# Run this to verify that a future `configure' run will pick up the settings
249
# you want.
250
test-config-install: SHELL=/bin/bash
251
test-config-install: $(DB)/libpng-config
252 253 254
	@echo -e Testing libpng-config functions...'\n'
	@ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
   do \
255 256
    printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
    "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
257 258 259
    gytiu=$$(( $$gytiu + 1 )); \
   done

260 261
install: install-static install-shared install-man install-config

262
# If you installed in $(DESTDIR), test-installed won't work until you
263 264 265 266 267 268 269 270 271 272 273
# move the library to its final location.  Use test-dd to test it
# before then.

test-dd:
	echo
	echo Testing installed dynamic shared library in $(DL).
	$(CC) -I$(DI) $(CFLAGS) \
	   `$(BINPATH)/libpng12-config --cflags` pngtest.c \
	   -L$(DL) -L$(ZLIBLIB) \
	   -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
	./pngtestd pngtest.png
274 275 276

test-installed:
	$(CC) $(CFLAGS) \
277
	   `$(BINPATH)/libpng12-config --cflags` pngtest.c \
278
	   -L$(ZLIBLIB) \
279
	   -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags`
280 281
	./pngtesti$(EXE) pngtest.png

282 283
clean:
	/bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
284
	pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
285
	libpng-config libpng.pc pngtesti$(EXE)
286 287 288 289 290

DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
	chmod a-w *.[ch35] $(DOCS) scripts/*

291 292
.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean

293 294
# DO NOT DELETE THIS LINE -- make depend depends on it.

295
png.o png.pic.o:		png.h pngconf.h png.c
296 297 298 299 300 301 302 303
pngerror.o pngerror.pic.o:	png.h pngconf.h pngerror.c
pngrio.o pngrio.pic.o:		png.h pngconf.h pngrio.c
pngwio.o pngwio.pic.o:		png.h pngconf.h pngwio.c
pngmem.o pngmem.pic.o:		png.h pngconf.h pngmem.c
pngset.o pngset.pic.o:		png.h pngconf.h pngset.c
pngget.o pngget.pic.o:		png.h pngconf.h pngget.c
pngread.o pngread.pic.o:	png.h pngconf.h pngread.c
pngrtran.o pngrtran.pic.o:	png.h pngconf.h pngrtran.c
304
pngrutil.o pngrutil.pic.o:	png.h pngconf.h pngrutil.c
305 306 307 308 309 310 311 312
pngtrans.o pngtrans.pic.o:	png.h pngconf.h pngtrans.c
pngwrite.o pngwrite.pic.o:	png.h pngconf.h pngwrite.c
pngwtran.o pngwtran.pic.o:	png.h pngconf.h pngwtran.c
pngwutil.o pngwutil.pic.o:	png.h pngconf.h pngwutil.c
pngpread.o pngpread.pic.o:	png.h pngconf.h pngpread.c

pngtest.o:			png.h pngconf.h pngtest.c
pngtest-stat.o:			png.h pngconf.h pngtest.c
313 314 315