makefile.linux 7.2 KB
Newer Older
1
# makefile for libpng.a and libpng12.so on Linux ELF with gcc
2
# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson
3
# Copyright (C) 1996, 1997 Andreas Dilger
G
Guy Schalnat 已提交
4 5
# For conditions of distribution and use, see copyright notice in png.h

6 7
LIBNAME = libpng12
PNGMAJ = 0
8
PNGMIN = 1.2.9beta8
9 10
PNGVER = $(PNGMAJ).$(PNGMIN)

11
AR_RC=ar rc
G
Guy Schalnat 已提交
12
CC=gcc
13 14 15 16
MKDIR_P=mkdir -p
LN_SF=ln -sf
RANLIB=ranlib
RM_F=/bin/rm -f
A
Andreas Dilger 已提交
17

18
# where "make install" puts libpng12.a, libpng12.so*,
19
# libpng12/png.h and libpng12/pngconf.h
20
# Prefix must be a full pathname.
21
prefix=/usr/local
22
exec_prefix=$prefix
23

24
# Where the zlib library and include files are located.
A
Andreas Dilger 已提交
25 26 27 28 29
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib

30
ALIGN=
31
# for i386:
32 33
#ALIGN=-malign-loops=2 -malign-functions=2

A
Andreas Dilger 已提交
34
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
35 36
	-Wmissing-declarations -Wtraditional -Wcast-align \
	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
37

38
# for pgcc version 2.95.1, -O3 is buggy; don't use it.
39

40
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
41
	$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
42 43 44

LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
G
Guy Schalnat 已提交
45

A
Andreas Dilger 已提交
46
INCPATH=$(prefix)/include
47
LIBPATH=$(exec_prefix)/lib
48
MANPATH=$(prefix)/man
49
BINPATH=$(exec_prefix)/bin
50 51 52 53 54 55 56

# override DESTDIR= on the make install command line to easily support
# installing into a temporary location.  Example:
#
#    make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
57
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
58 59
# you execute make install.
DESTDIR=
G
Guy Schalnat 已提交
60

61 62 63 64
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
65

A
Andreas Dilger 已提交
66
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
67 68
	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
	pngwtran.o pngmem.o pngerror.o pngpread.o
G
Guy Schalnat 已提交
69

70 71 72 73 74 75 76
OBJSDLL = $(OBJS:.o=.pic.o)

.SUFFIXES:      .c .o .pic.o

.c.pic.o:
	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c

77
all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
G
Guy Schalnat 已提交
78 79

libpng.a: $(OBJS)
80
	$(AR_RC) $@ $(OBJS)
G
Guy Schalnat 已提交
81 82
	$(RANLIB) $@

83 84 85
libpng.pc:
	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc

86 87 88
libpng-config:
	( cat scripts/libpng-config-head.in; \
	echo prefix=\"$(prefix)\"; \
89 90 91
	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
	echo L_opts=\"-L$(LIBPATH)\"; \
	echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
92 93 94 95
	echo libs=\"-lpng12 -lz -lm\"; \
	cat scripts/libpng-config-body.in ) > libpng-config
	chmod +x libpng-config

96
$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
97
	$(LN_SF) $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
G
Guy Schalnat 已提交
98

99
$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
100
	$(LN_SF) $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
G
Guy Schalnat 已提交
101

102 103 104
$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
	$(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
	-o $(LIBNAME).so.$(PNGVER) \
105
	$(OBJSDLL)
G
Guy Schalnat 已提交
106

107 108 109
libpng.so.0.$(PNGMIN): $(OBJSDLL)
	$(CC) -shared -Wl,-soname,libpng.so.0 \
	-o libpng.so.0.$(PNGMIN) \
110
	$(OBJSDLL)
111

112
pngtest: pngtest.o $(LIBNAME).so
113
	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
G
Guy Schalnat 已提交
114

115
pngtest-static: pngtest.o libpng.a
116 117 118 119
	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)

test: pngtest pngtest-static
	@echo ""
120
	@echo "   Running pngtest dynamically linked with $(LIBNAME).so:"
121
	@echo ""
G
Guy Schalnat 已提交
122
	./pngtest
123 124 125 126
	@echo ""
	@echo "   Running pngtest statically linked with libpng.a:"
	@echo ""
	./pngtest-static
G
Guy Schalnat 已提交
127

128
install-headers: png.h pngconf.h
129 130
	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
131
	cp png.h pngconf.h $(DI)/$(LIBNAME)
132
	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
133 134 135
	-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
	-@$(RM_F) $(DI)/libpng
	(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
136 137

install-static: install-headers libpng.a
138
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
139 140
	cp libpng.a $(DL)/$(LIBNAME).a
	chmod 644 $(DL)/$(LIBNAME).a
141 142
	-@$(RM_F) $(DL)/libpng.a
	(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
143

144
install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \
145
	libpng.so.0.$(PNGMIN)
146 147 148 149 150 151
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
	-@$(RM_F) $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
	-@$(RM_F) $(DL)/$(LIBNAME).so.$(PNGMAJ)
	-@$(RM_F) $(DL)/libpng.so
	-@$(RM_F) $(DL)/libpng.so.0
	-@$(RM_F) $(DL)/libpng.so.0.$(PNGMIN)*
152
	cp $(LIBNAME).so.$(PNGVER) $(DL)
153
	cp libpng.so.0.$(PNGMIN) $(DL)
154
	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
155
	chmod 755 $(DL)/libpng.so.0.$(PNGMIN)
156
	(cd $(DL); \
157 158 159 160 161 162 163
	$(LN_SF) libpng.so.0.$(PNGMIN) libpng.so.0; \
	$(LN_SF) libpng.so.0 libpng.so; \
	$(LN_SF) $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
	$(LN_SF) $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
	-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
	-@$(RM_F) $(DL)/pkgconfig/libpng.pc
164 165
	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
166
	(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
167 168

install-man: libpng.3 libpngpf.3 png.5
169 170 171 172
	-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
	-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
	-@$(RM_F) $(DM)/man3/libpng.3
	-@$(RM_F) $(DM)/man3/libpngpf.3
173 174
	cp libpng.3 $(DM)/man3
	cp libpngpf.3 $(DM)/man3
175 176
	-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
	-@$(RM_F) $(DM)/man5/png.5
177
	cp png.5 $(DM)/man5
178

179
install-config: libpng-config
180 181 182
	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
	-@$(RM_F) $(DB)/libpng-config
	-@$(RM_F) $(DB)/$(LIBNAME)-config
183 184
	cp libpng-config $(DB)/$(LIBNAME)-config
	chmod 755 $(DB)/$(LIBNAME)-config
185
	(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
186 187

install: install-static install-shared install-man install-config
G
Guy Schalnat 已提交
188

189
# If you installed in $(DESTDIR), test-installed won't work until you
190 191 192 193 194 195 196
# 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) -I$(ZLIBINC) \
197
	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
198
	   -L$(DL) -L$(ZLIBLIB) -W1, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
199
	   -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
200
	./pngtestd pngtest.png
201

202 203
test-installed:
	$(CC) -I$(ZLIBINC) \
204
	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
205
	   -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
206
	   -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
207
	./pngtesti pngtest.png
208

G
Guy Schalnat 已提交
209
clean:
210
	$(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
211
	$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \
212
	libpng.so.0.$(PNGMIN) \
213
	libpng.pc
G
Guy Schalnat 已提交
214

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

G
Guy Schalnat 已提交
219 220
# DO NOT DELETE THIS LINE -- make depend depends on it.

221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h

G
Guy Schalnat 已提交
237
pngtest.o: png.h pngconf.h