makefile.elf 8.1 KB
Newer Older
1
# makefile for libpng.a and libpng14.so on Linux ELF with gcc
2 3
# Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs
# and Glenn Randers-Pehrson
4
# Copyright (C) 1996, 1997 Andreas Dilger
5
#
6
# This code is released under the libpng license.
7
# For conditions of distribution and use, see the disclaimer
8
# and license in png.h
9

10 11 12
# Modified for Debian by Junichi Uekawa and Josselin Mouette
# Major modifications are:
#    * link libpng explicitly with libz and libm
13
#    * $(OLDSO).14 is a symlink rather than a different library
14 15
#    * versioned symbols

16
# Library name:
17
LIBNAME = libpng14
18
PNGMAJ = 14
19
PNGMIN = 1.4.0rc06
20 21
PNGVER = $(PNGMAJ).$(PNGMIN)

22 23 24
# Shared library names:
LIBSO=$(LIBNAME).so
LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
25
LIBSOVER=$(LIBNAME).so.$(PNGVER)
26
OLDSO=libpng.so
27 28
OLDSOMAJ=libpng.so.14
OLDSOVER=libpng.so.14.$(PNGMIN)
29 30

# Utilities:
31
AR_RC=ar rc
32
CC=gcc
33 34 35 36
MKDIR_P=mkdir -p
LN_SF=ln -sf
RANLIB=ranlib
RM_F=/bin/rm -f
37

38 39
# where "make install" puts libpng14.a, libpng14.so*,
# libpng14/png.h and libpng14/pngconf.h
40 41
# Prefix must be a full pathname.
prefix=/usr/local
42
exec_prefix=$(prefix)
43 44

# Where the zlib library and include files are located.
45 46 47 48
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
# ZLIBLIB=../zlib
# ZLIBINC=../zlib
49 50 51 52 53 54 55 56 57 58 59

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

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

60
CFLAGS=-W -Wall -D_REENTRANT -O2 \
61 62
	$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5

63
LDFLAGS=-L. -lpng14
64 65
LDFLAGS_A=libpng.a -lz -lm
LIBADDFLAGS=-lz -lm
66 67 68


INCPATH=$(prefix)/include
69
LIBPATH=$(exec_prefix)/lib
70
MANPATH=$(prefix)/man
71
BINPATH=$(exec_prefix)/bin
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

# 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
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=

DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)

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

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

.SUFFIXES:      .c .o .pic.o

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

99
all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
100 101

libpng.a: $(OBJS)
102
	$(AR_RC) $@ $(OBJS)
103 104 105
	$(RANLIB) $@

libpng.pc:
106 107 108 109 110
	cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
	-e s!@exec_prefix@!$(exec_prefix)! \
	-e s!@libdir@!$(LIBPATH)! \
	-e s!@includedir@!$(INCPATH)! \
	-e s!-lpng14!-lpng14\ -lz\ -lm! > libpng.pc
111 112

libpng.syms: png.h pngconf.h
113
	$(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
114
	awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG14_%s {global:\n",PNGMAJ)}\
115 116 117 118 119 120 121
	{ for (i=1;i+2<=NF;++i)\
		if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
			print $$(i+1) ";";\
	for (i=1;i+1<=NF;++i)\
		if ($$(i)=="PNG_DATA_EXPORT")\
			print $$(i+1) ";";}\
	END{print "local: *; };"}' >$@.new
122
	$(RM_F) $@
123 124 125 126 127 128
	mv $@.new $@

libpng-config:
	( cat scripts/libpng-config-head.in; \
	echo prefix=\"$(prefix)\"; \
	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
129 130
	echo L_opts=\"\"; \
	echo R_opts=\"\"; \
131 132
	echo libs=\"-lpng14\"; \
	echo all_libs=\"-lpng14 $(LIBADDFLAGS)\"; \
133 134 135
	cat scripts/libpng-config-body.in ) > libpng-config
	chmod +x libpng-config

136 137
$(LIBSO): $(LIBSOMAJ)
	$(LN_SF) $(LIBSOMAJ) $(LIBSO)
138

139 140 141 142
$(LIBSOMAJ): $(LIBSOVER)
	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ)

$(LIBSOVER): $(OBJSDLL) libpng.syms
143
	$(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
144
	-Wl,-version-script,libpng.syms \
145 146 147 148 149 150 151
	-o $(LIBSOVER) \
	$(OBJSDLL)

$(OLDSOVER): $(OBJSDLL) libpng.syms
	$(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
	-Wl,-version-script,libpng.syms \
	-o $(OLDSOVER) \
152 153
	$(OBJSDLL)

154
pngtest: pngtest.o $(LIBSO)
155 156 157 158 159 160 161
	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)

pngtest-static: pngtest.o libpng.a
	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)

test: pngtest pngtest-static
	@echo ""
162
	@echo "   Running pngtest dynamically linked with $(LIBSO):"
163
	@echo ""
164
	LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest
165 166 167 168 169
	@echo ""
	@echo "   Running pngtest statically linked with libpng.a:"
	@echo ""
	./pngtest-static

170
install-headers: png.h pngconf.h
171 172
	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
173
	cp png.h pngconf.h $(DI)/$(LIBNAME)
174
	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
175
	-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
176 177
	-@$(RM_F) $(DI)/libpng
	(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
178 179

install-static: install-headers libpng.a
180
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
181 182
	cp libpng.a $(DL)/$(LIBNAME).a
	chmod 644 $(DL)/$(LIBNAME).a
183 184
	-@$(RM_F) $(DL)/libpng.a
	(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
185

186 187
install-shared: install-headers $(LIBSOVER) libpng.pc \
	$(OLDSOVER)
188
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
189
	-@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
190 191
	-@$(RM_F) $(DL)/$(LIBSOMAJ)
	-@$(RM_F) $(DL)/$(OLDSO)
192 193 194 195 196 197
	-@$(RM_F) $(DL)/$(OLDSOMAJ)
	-@$(RM_F) $(DL)/$(OLDSOVER)*
	cp $(LIBSOVER) $(DL)
	cp $(OLDSOVER) $(DL)
	chmod 755 $(DL)/$(LIBSOVER)
	chmod 755 $(DL)/$(OLDSOVER)
198
	(cd $(DL); \
199 200 201 202
	$(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
	$(LN_SF) $(OLDSOMAJ) $(OLDSO); \
	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
	$(LN_SF) $(LIBSOMAJ) $(LIBSO))
203 204 205
	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
	-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
	-@$(RM_F) $(DL)/pkgconfig/libpng.pc
206 207
	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
208
	(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
209 210

install-man: libpng.3 libpngpf.3 png.5
211 212 213 214
	-@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
215 216
	cp libpng.3 $(DM)/man3
	cp libpngpf.3 $(DM)/man3
217 218
	-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
	-@$(RM_F) $(DM)/man5/png.5
219 220 221
	cp png.5 $(DM)/man5

install-config: libpng-config
222 223 224
	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
	-@$(RM_F) $(DB)/libpng-config
	-@$(RM_F) $(DB)/$(LIBNAME)-config
225 226
	cp libpng-config $(DB)/$(LIBNAME)-config
	chmod 755 $(DB)/$(LIBNAME)-config
227
	(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
228 229 230 231 232 233 234 235 236 237 238

install: install-static install-shared install-man install-config

# If you installed in $(DESTDIR), test-installed won't work until you
# 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) \
239
	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
240
	   -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
241
	   -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
242 243 244 245
	./pngtestd pngtest.png

test-installed:
	$(CC) -I$(ZLIBINC) \
246
	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
247
	   -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
248
	   -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
249 250 251
	./pngtesti pngtest.png

clean:
252
	$(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
253
	$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
254 255
	$(OLDSOVER) \
	libpng.pc
256 257 258 259 260 261 262

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.

263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
png.o png.pic.o: png.h pngconf.h pngpriv.h
pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h
pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h
pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h
pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h
pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h
pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h
pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h
pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h

279
pngtest.o: png.h pngconf.h