makefile.cygwin 5.4 KB
Newer Older
1 2 3 4
# makefile for cygwin on x86
#   builds both dll (with import lib) and static lib versions
#   of the library, and builds two copies of pngtest: one
#   statically linked and one dynamically linked.
5
#
6 7 8 9 10 11 12 13 14 15
#   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

# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to
# $CFLAGS, and include pnggccrd.o in $OBJS, below.

CC=gcc

16
# where "make install" puts libpng.a, libpng.so*, png.h, and pngconf.h
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
prefix=/usr

# Where the zlib library and include files are located
ZLIBLIB=${prefix}/lib
ZLIBINC=${prefix}/include
#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

#CFLAGS=-DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \
#        -fomit-frame-pointer  # $(WARNMORE) -g -DPNG_DEBUG=5
CFLAGS=-I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \
36
	-fomit-frame-pointer
37

38 39 40
# read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
# have to change it.
PNGMAJ = 2
41
#PNGDLL = $1# msvc
42 43 44
PNGDLL = 2# cygwin 1.0.11beta1
PNGMIN = 1.0.11beta1
PNGMIN_BASE = 1.0.11
45 46
PNGVER = $(PNGMAJ).$(PNGMIN)

47
SHAREDLIB=cygpng$(PNGDLL).dll
48 49 50 51 52 53
STATLIB=libpng.a
IMPLIB=libpng.dll.a
SHAREDDEF=libpng.def
LIBS=$(SHAREDLIB) $(STATLIB)
EXE=.exe

54 55 56 57 58 59 60 61 62 63 64 65
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz
LDSHARED=gcc -shared -Wl,--enable-auto-image-base
LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(SHAREDDEF)

RANLIB=ranlib
#RANLIB=echo

INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
BINPATH=$(prefix)/bin
MANPATH=$(prefix)/man
MAN3PATH=$(MANPATH)/man3
66
DOCPATH=$(prefix)/doc/libpng-$(PNGMIN_BASE)
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

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)

.SUFFIXES:      .c .o .pic.o

%.o : %.c
	$(CC) -c $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -o $@ $<

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

82 83 84 85 86 87 88 89 90
all: all-static all-shared

static: all-static

shared: all-shared

all-static: $(STATLIB) pngtest-stat$(EXE)

all-shared: $(SHAREDLIB) pngtest$(EXE)
91

92
pnggccrd.o:	png.h pngconf.h
93 94 95 96 97 98
	@echo ""
	@echo '    You can ignore the single "control reaches end of non-void function"'
	@echo '    warning and multiple "<variable> defined but not used" warnings:'
	@echo ""
	$(CC) -c $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -o $@ $*.c

99
pnggccrd.pic.o:	png.h pngconf.h
100 101 102 103
	@echo ""
	@echo '    You can ignore the single "control reaches end of non-void function"'
	@echo '    warning and multiple "<variable> defined but not used" warnings:'
	@echo ""
104
	$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ pnggccrd.c
105 106 107 108 109

$(STATLIB): $(OBJS)
	ar rc $@ $(OBJS)
	$(RANLIB) $@

110
$(SHAREDDEF): projects/msvc/png32ms.def
111 112 113
	cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' > $@

$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
114
	$(LDSHARED) -o $@ $(LDEXTRA) $(OBJSDLL) -L. -L$(ZLIBLIB) -lz
115 116 117 118 119 120 121 122 123 124 125 126 127

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
	$(CC) $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -c $< -o $@

128
test: test-static test-shared
129

130
test-static: pngtest-stat$(EXE)
131 132
	./pngtest-stat

133
test-shared: pngtest$(EXE)
134 135
	./pngtest

136 137
install: install-static install-shared

138
install-static: $(STATLIB) install-headers install-docs install-man
139 140 141 142
	-@if [ ! -d $(LIBPATH) ]; then mkdir -p $(LIBPATH); fi
	install -m 755 $(STATLIB) $(LIBPATH)

install-shared: $(SHAREDLIB) install-headers install-docs install-man
143 144
	-@if [ ! -d $(LIBPATH) ]; then mkdir -p $(LIBPATH); fi
	-@if [ ! -d $(BINPATH) ]; then mkdir -p $(BINPATH); fi
145
	install -m 755 $(IMPLIB) $(LIBPATH)
146
	install -s -m 755 $(SHAREDLIB) $(BINPATH)
147 148 149 150 151 152 153

install-headers:
	-@if [ ! -d $(INCPATH)  ]; then mkdir -p $(INCPATH); fi
	install -m 644 png.h pngconf.h $(INCPATH)

install-docs:
	-@if [ ! -d $(DOCPATH) ]; then mkdir -p $(DOCPATH); fi
154
	install -m 644 $(DOCS) $(DOCPATH)
155 156 157

install-man:
	-@if [ ! -d $(MAN3PATH) ]; then mkdir -p $(MAN3PATH); fi
158 159 160 161 162 163 164 165 166 167 168 169
	install -m 644 libpngpf.3 libpng.3 $(MAN3PATH)

clean:
	/bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
	pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF)

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

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

170
png.o png.pic.o:		png.h pngconf.h png.c
171 172 173 174 175 176 177 178
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
179
pngrutil.o pngrutil.pic.o:	png.h pngconf.h pngrutil.c
180 181 182 183 184 185 186 187
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