makefile.linux 7.4 KB
Newer Older
1
# makefile for libpng.a and libpng14.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
# Library name:
7
LIBNAME = libpng14
8
PNGMAJ = 14
9
PNGMIN = 1.4.0beta40
10 11
PNGVER = $(PNGMAJ).$(PNGMIN)

12 13 14 15 16 17 18
# Shared library names:
LIBSO=$(LIBNAME).so
LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
LIBSOVER=$(LIBNAME).so.$(PNGVER)
OLDSO=libpng.so

# Utilities:
19
AR_RC=ar rc
G
Guy Schalnat 已提交
20
CC=gcc
21 22 23 24
MKDIR_P=mkdir -p
LN_SF=ln -sf
RANLIB=ranlib
RM_F=/bin/rm -f
A
Andreas Dilger 已提交
25

26 27
# where "make install" puts libpng14.a, libpng14.so*,
# libpng14/png.h and libpng14/pngconf.h
28
# Prefix must be a full pathname.
29
prefix=/usr/local
30
exec_prefix=$(prefix)
31

32
# Where the zlib library and include files are located.
A
Andreas Dilger 已提交
33 34 35 36 37
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib

38
ALIGN=
39
# for i386:
40 41
#ALIGN=-malign-loops=2 -malign-functions=2

A
Andreas Dilger 已提交
42
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
43 44
	-Wmissing-declarations -Wtraditional -Wcast-align \
	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
45

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

48
CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \
49
	$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
50

51
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng14 -lz -lm
52
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
G
Guy Schalnat 已提交
53

A
Andreas Dilger 已提交
54
INCPATH=$(prefix)/include
55
LIBPATH=$(exec_prefix)/lib
56
MANPATH=$(prefix)/man
57
BINPATH=$(exec_prefix)/bin
58 59 60 61 62 63 64

# 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
65
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
66 67
# you execute make install.
DESTDIR=
G
Guy Schalnat 已提交
68

69 70 71 72
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
73

A
Andreas Dilger 已提交
74
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
75 76
	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
	pngwtran.o pngmem.o pngerror.o pngpread.o
G
Guy Schalnat 已提交
77

78 79 80 81 82 83 84
OBJSDLL = $(OBJS:.o=.pic.o)

.SUFFIXES:      .c .o .pic.o

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

85 86 87 88 89 90 91 92
all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config pngdefs.h

# Use makefile.gcmmx if you want to use the MMX assembler code.
# If you don't need thread safety you can uncomment the define.
pngdefs.h:
	echo "/* pngdefs.h was built by makefile.linux */" > pngdefs.h
	echo "#define PNG_NO_MMX_CODE" >> pngdefs.h
	# echo "#define PNG_THREAD_UNSAFE_OK" >> pngdefs.h
G
Guy Schalnat 已提交
93 94

libpng.a: $(OBJS)
95
	$(AR_RC) $@ $(OBJS)
G
Guy Schalnat 已提交
96 97
	$(RANLIB) $@

98 99 100
libpng.pc:
	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc

101 102 103
libpng-config:
	( cat scripts/libpng-config-head.in; \
	echo prefix=\"$(prefix)\"; \
104 105 106
	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
	echo L_opts=\"-L$(LIBPATH)\"; \
	echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
107
	echo libs=\"-lpng14 -lz -lm\"; \
108 109 110
	cat scripts/libpng-config-body.in ) > libpng-config
	chmod +x libpng-config

111 112
$(LIBSO): $(LIBSOMAJ)
	$(LN_SF) $(LIBSOMAJ) $(LIBSO)
G
Guy Schalnat 已提交
113

114 115
$(LIBSOMAJ): $(LIBSOVER)
	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
G
Guy Schalnat 已提交
116

117 118
$(LIBSOVER): $(OBJSDLL)
	$(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL)
G
Guy Schalnat 已提交
119

120
pngtest: pngtest.o $(LIBSO)
121
	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
G
Guy Schalnat 已提交
122

123
pngtest-static: pngtest.o libpng.a
124 125 126 127
	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)

test: pngtest pngtest-static
	@echo ""
128
	@echo "   Running pngtest dynamically linked with $(LIBSO):"
129
	@echo ""
G
Guy Schalnat 已提交
130
	./pngtest
131 132 133 134
	@echo ""
	@echo "   Running pngtest statically linked with libpng.a:"
	@echo ""
	./pngtest-static
G
Guy Schalnat 已提交
135

136
install-headers: png.h pngconf.h pngdefs.h
137 138
	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
139 140 141 142
	cp png.h pngconf.h pngdefs.h $(DI)/$(LIBNAME)
	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h \
	          $(DI)/$(LIBNAME)/pngdefs.h
	-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pngdefs.h
143 144
	-@$(RM_F) $(DI)/libpng
	(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
145 146

install-static: install-headers libpng.a
147
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
148 149
	cp libpng.a $(DL)/$(LIBNAME).a
	chmod 644 $(DL)/$(LIBNAME).a
150 151
	-@$(RM_F) $(DL)/libpng.a
	(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
152

153
install-shared: install-headers $(LIBSOVER) libpng.pc
154
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
155 156 157 158 159
	-@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
	-@$(RM_F) $(DL)/$(LIBSOMAJ)
	-@$(RM_F) $(DL)/$(OLDSO)
	cp $(LIBSOVER) $(DL)
	chmod 755 $(DL)/$(LIBSOVER)
160
	(cd $(DL); \
161
	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
162 163
	$(LN_SF) $(LIBSOMAJ) $(LIBSO); \
	$(LN_SF) $(OLDSO) $(LIBSO))
164 165 166
	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
	-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
	-@$(RM_F) $(DL)/pkgconfig/libpng.pc
167 168
	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
169
	(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
170 171

install-man: libpng.3 libpngpf.3 png.5
172 173 174 175
	-@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
176 177
	cp libpng.3 $(DM)/man3
	cp libpngpf.3 $(DM)/man3
178 179
	-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
	-@$(RM_F) $(DM)/man5/png.5
180
	cp png.5 $(DM)/man5
181

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

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

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

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

G
Guy Schalnat 已提交
212
clean:
213
	$(RM_F) *.o libpng.a pngtest pngout.png libpng-config pngdefs.h \
214
	$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
215
	libpng.pc
G
Guy Schalnat 已提交
216

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

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

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

pngtest.o: png.h pngconf.h pngdefs.h