• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# makefile for libpng.a and libpng12.so on Linux ELF with gcc
2# Copyright (C) 1998, 1999, 2002, 2006-2008 Greg Roelofs and
3# 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# Library name:
11LIBNAME = libpng12
12PNGMAJ = 0
13PNGMIN = 1.2.46
14PNGVER = $(PNGMAJ).$(PNGMIN)
15
16# Shared library names:
17LIBSO=$(LIBNAME).so
18LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
19LIBSOVER=$(LIBNAME).so.$(PNGVER)
20OLDSO=libpng.so
21OLDSOMAJ=libpng.so.3
22OLDSOVER=libpng.so.3.$(PNGMIN)
23
24# Utilities:
25AR_RC=ar rc
26CC=gcc
27MKDIR_P=mkdir -p
28LN_SF=ln -sf
29RANLIB=ranlib
30RM_F=/bin/rm -f
31
32# where "make install" puts libpng12.a, libpng12.so*,
33# libpng12/png.h and libpng12/pngconf.h
34# Prefix must be a full pathname.
35prefix=/usr/local
36exec_prefix=$(prefix)
37
38# Where the zlib library and include files are located.
39#ZLIBLIB=/usr/local/lib
40#ZLIBINC=/usr/local/include
41ZLIBLIB=../zlib
42ZLIBINC=../zlib
43
44ALIGN=
45# for i386:
46#ALIGN=-malign-loops=2 -malign-functions=2
47
48WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
49	-Wmissing-declarations -Wtraditional -Wcast-align \
50	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
51
52# for pgcc version 2.95.1, -O3 is buggy; don't use it.
53
54CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
55	$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
56
57LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
58LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
59
60INCPATH=$(prefix)/include
61LIBPATH=$(exec_prefix)/lib
62MANPATH=$(prefix)/man
63BINPATH=$(exec_prefix)/bin
64
65# override DESTDIR= on the make install command line to easily support
66# installing into a temporary location.  Example:
67#
68#    make install DESTDIR=/tmp/build/libpng
69#
70# If you're going to install into a temporary location
71# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
72# you execute make install.
73DESTDIR=
74
75DB=$(DESTDIR)$(BINPATH)
76DI=$(DESTDIR)$(INCPATH)
77DL=$(DESTDIR)$(LIBPATH)
78DM=$(DESTDIR)$(MANPATH)
79
80OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
81	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
82	pngwtran.o pngmem.o pngerror.o pngpread.o
83
84OBJSDLL = $(OBJS:.o=.pic.o)
85
86.SUFFIXES:      .c .o .pic.o
87
88.c.pic.o:
89	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
90
91all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
92
93libpng.a: $(OBJS)
94	$(AR_RC) $@ $(OBJS)
95	$(RANLIB) $@
96
97libpng.pc:
98	cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
99	-e s!@exec_prefix@!$(exec_prefix)! \
100	-e s!@libdir@!$(LIBPATH)! \
101	-e s!@includedir@!$(INCPATH)! \
102	-e s!@includedir@!$(INCPATH)! \
103	-e s!-lpng12!-lpng12\ -lz\ -lm! \
104	-e s!Cflags: !Cflags:\ -DPNG_NO_MMX_CODE!> libpng.pc
105
106libpng-config:
107	( cat scripts/libpng-config-head.in; \
108	echo prefix=\"$(prefix)\"; \
109	echo I_opts=\"-I$(INCPATH)/$(LIBNAME) -DPNG_NO_MMX_CODE\"; \
110	echo L_opts=\"-L$(LIBPATH)\"; \
111	echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
112	echo libs=\"-lpng12 -lz -lm\"; \
113	cat scripts/libpng-config-body.in ) > libpng-config
114	chmod +x libpng-config
115
116$(LIBSO): $(LIBSOMAJ)
117	$(LN_SF) $(LIBSOMAJ) $(LIBSO)
118
119$(LIBSOMAJ): $(LIBSOVER)
120	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
121
122$(LIBSOVER): $(OBJSDLL)
123	$(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL)
124
125$(OLDSOVER): $(OBJSDLL)
126	$(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
127	-o $(OLDSOVER) \
128	$(OBJSDLL)
129
130pngtest: pngtest.o $(LIBSO)
131	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
132
133pngtest-static: pngtest.o libpng.a
134	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
135
136test: pngtest pngtest-static
137	@echo ""
138	@echo "   Running pngtest dynamically linked with $(LIBSO):"
139	@echo ""
140	./pngtest
141	@echo ""
142	@echo "   Running pngtest statically linked with libpng.a:"
143	@echo ""
144	./pngtest-static
145
146install-headers: png.h pngconf.h
147	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
148	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
149	cp png.h pngconf.h $(DI)/$(LIBNAME)
150	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
151	-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
152	-@$(RM_F) $(DI)/libpng
153	(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
154
155install-static: install-headers libpng.a
156	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
157	cp libpng.a $(DL)/$(LIBNAME).a
158	chmod 644 $(DL)/$(LIBNAME).a
159	-@$(RM_F) $(DL)/libpng.a
160	(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
161
162install-shared: install-headers $(LIBSOVER) libpng.pc \
163	$(OLDSOVER)
164	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
165	-@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
166	-@$(RM_F) $(DL)/$(LIBSOMAJ)
167	-@$(RM_F) $(DL)/$(OLDSO)
168	-@$(RM_F) $(DL)/$(OLDSOMAJ)
169	-@$(RM_F) $(DL)/$(OLDSOVER)*
170	cp $(LIBSOVER) $(DL)
171	cp $(OLDSOVER) $(DL)
172	chmod 755 $(DL)/$(LIBSOVER)
173	chmod 755 $(DL)/$(OLDSOVER)
174	(cd $(DL); \
175	$(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
176	$(LN_SF) $(OLDSOMAJ) $(OLDSO); \
177	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
178	$(LN_SF) $(LIBSOMAJ) $(LIBSO))
179	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
180	-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
181	-@$(RM_F) $(DL)/pkgconfig/libpng.pc
182	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
183	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
184	(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
185
186install-man: libpng.3 libpngpf.3 png.5
187	-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
188	-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
189	-@$(RM_F) $(DM)/man3/libpng.3
190	-@$(RM_F) $(DM)/man3/libpngpf.3
191	cp libpng.3 $(DM)/man3
192	cp libpngpf.3 $(DM)/man3
193	-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
194	-@$(RM_F) $(DM)/man5/png.5
195	cp png.5 $(DM)/man5
196
197install-config: libpng-config
198	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
199	-@$(RM_F) $(DB)/libpng-config
200	-@$(RM_F) $(DB)/$(LIBNAME)-config
201	cp libpng-config $(DB)/$(LIBNAME)-config
202	chmod 755 $(DB)/$(LIBNAME)-config
203	(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
204
205install: install-static install-shared install-man install-config
206
207# If you installed in $(DESTDIR), test-installed won't work until you
208# move the library to its final location.  Use test-dd to test it
209# before then.
210
211test-dd:
212	echo
213	echo Testing installed dynamic shared library in $(DL).
214	$(CC) -I$(DI) -I$(ZLIBINC) \
215	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
216	   -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
217	   -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
218	./pngtestd pngtest.png
219
220test-installed:
221	$(CC) -I$(ZLIBINC) \
222	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
223	   -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
224	   -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
225	./pngtesti pngtest.png
226
227clean:
228	$(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
229	$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
230	$(OLDSOVER) \
231	libpng.pc
232
233DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
234writelock:
235	chmod a-w *.[ch35] $(DOCS) scripts/*
236
237# DO NOT DELETE THIS LINE -- make depend depends on it.
238
239png.o png.pic.o:		png.h pngconf.h png.c
240pngerror.o pngerror.pic.o:	png.h pngconf.h pngerror.c
241pngrio.o pngrio.pic.o:		png.h pngconf.h pngrio.c
242pngwio.o pngwio.pic.o:		png.h pngconf.h pngwio.c
243pngmem.o pngmem.pic.o:		png.h pngconf.h pngmem.c
244pngset.o pngset.pic.o:		png.h pngconf.h pngset.c
245pngget.o pngget.pic.o:		png.h pngconf.h pngget.c
246pngread.o pngread.pic.o:	png.h pngconf.h pngread.c
247pngrtran.o pngrtran.pic.o:	png.h pngconf.h pngrtran.c
248pngrutil.o pngrutil.pic.o:	png.h pngconf.h pngrutil.c
249pngtrans.o pngtrans.pic.o:	png.h pngconf.h pngtrans.c
250pngwrite.o pngwrite.pic.o:	png.h pngconf.h pngwrite.c
251pngwtran.o pngwtran.pic.o:	png.h pngconf.h pngwtran.c
252pngwutil.o pngwutil.pic.o:	png.h pngconf.h pngwutil.c
253pngpread.o pngpread.pic.o:	png.h pngconf.h pngpread.c
254
255pngtest.o:			png.h pngconf.h pngtest.c
256