1# makefile for SCO OSr5  ELF and Unixware 7 with Native cc
2# Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx
3#   force ELF build dynamic linking, SONAME setting in lib and RPATH in app
4# Copyright (C) 2002, 2006, 2010-2011 Glenn Randers-Pehrson
5# Copyright (C) 1998 Greg Roelofs
6# Copyright (C) 1996, 1997 Andreas Dilger
7#
8# This code is released under the libpng license.
9# For conditions of distribution and use, see the disclaimer
10# and license in png.h
11
12# Library name:
13LIBNAME = libpng15
14PNGMAJ = 15
15
16# Shared library names:
17LIBSO=$(LIBNAME).so
18LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
19LIBSOREL=$(LIBSOMAJ).$(RELEASE)
20OLDSO=libpng.so
21
22# Utilities:
23CC=cc
24AR_RC=ar rc
25MKDIR_P=mkdir
26LN_SF=ln -f -s
27RANLIB=echo
28RM_F=/bin/rm -f
29
30# where make install puts libpng.a, $(OLDSO)*, and png.h
31prefix=/usr/local
32exec_prefix=$(prefix)
33
34# Where the zlib library and include files are located
35#ZLIBLIB=/usr/local/lib
36#ZLIBINC=/usr/local/include
37ZLIBLIB=../zlib
38ZLIBINC=../zlib
39
40CFLAGS= -dy -belf -I$(ZLIBINC) -O3
41LDFLAGS=-L. -L$(ZLIBLIB) -lpng15 -lz -lm
42
43INCPATH=$(prefix)/include
44LIBPATH=$(exec_prefix)/lib
45MANPATH=$(prefix)/man
46BINPATH=$(exec_prefix)/bin
47
48# override DESTDIR= on the make install command line to easily support
49# installing into a temporary location.  Example:
50#
51#    make install DESTDIR=/tmp/build/libpng
52#
53# If you're going to install into a temporary location
54# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
55# you execute make install.
56DESTDIR=
57
58DB=$(DESTDIR)$(BINPATH)
59DI=$(DESTDIR)$(INCPATH)
60DL=$(DESTDIR)$(LIBPATH)
61DM=$(DESTDIR)$(MANPATH)
62
63OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
64	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
65	pngwtran.o pngmem.o pngerror.o pngpread.o
66
67OBJSDLL = $(OBJS:.o=.pic.o)
68
69.SUFFIXES:      .c .o .pic.o
70
71.c.pic.o:
72	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
73
74all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
75
76# see scripts/pnglibconf.mak for more options
77pnglibconf.h: scripts/pnglibconf.h.prebuilt
78	cp scripts/pnglibconf.h.prebuilt $@
79
80libpng.a: $(OBJS)
81	$(AR_RC) $@ $(OBJS)
82	$(RANLIB) $@
83
84libpng.pc:
85	cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
86	-e s!@exec_prefix@!$(exec_prefix)! \
87	-e s!@libdir@!$(LIBPATH)! \
88	-e s!@includedir@!$(INCPATH)! \
89	-e s!-lpng15!-lpng15\ -lz\ -lm! > libpng.pc
90
91libpng-config:
92	( cat scripts/libpng-config-head.in; \
93	echo prefix=\"$(prefix)\"; \
94	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
95	echo ccopts=\"-belf\"; \
96	echo L_opts=\"-L$(LIBPATH)\"; \
97	echo libs=\"-lpng15 -lz -lm\"; \
98	cat scripts/libpng-config-body.in ) > libpng-config
99	chmod +x libpng-config
100
101$(LIBSO): $(LIBSOMAJ)
102	$(LN_SF) $(LIBSOMAJ) $(LIBSO)
103
104$(LIBSOMAJ): $(OBJSDLL)
105	$(CC) -G  -Wl,-h,$(LIBSOMAJ) -o $(LIBSOMAJ) \
106	 $(OBJSDLL)
107
108pngtest: pngtest.o $(LIBSO)
109	LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
110
111test: pngtest
112	./pngtest
113
114install-headers: png.h pngconf.h pnglibconf.h
115	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
116	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
117	-@$(RM_F) $(DI)/png.h
118	-@$(RM_F) $(DI)/pngconf.h
119	-@$(RM_F) $(DI)/pnglibconf.h
120	cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
121	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
122	-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
123	-@$(RM_F) $(DI)/libpng
124	(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
125
126install-static: install-headers libpng.a
127	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
128	cp libpng.a $(DL)/$(LIBNAME).a
129	chmod 644 $(DL)/$(LIBNAME).a
130	-@$(RM_F) $(DL)/libpng.a
131	(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
132
133install-shared: install-headers $(LIBSOMAJ) libpng.pc
134	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
135	-@$(RM_F) $(DL)/$(LIBSO)
136	-@$(RM_F) $(DL)/$(LIBSOREL)
137	-@$(RM_F) $(DL)/$(OLDSO)
138	cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
139	chmod 755 $(DL)/$(LIBSOREL)
140	(cd $(DL); \
141	$(LN_SF) $(LIBSOREL) $(LIBSO); \
142	$(LN_SF) $(LIBSO) $(OLDSO))
143	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
144	-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
145	-@$(RM_F) $(DL)/pkgconfig/libpng.pc
146	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
147	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
148	(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
149
150install-man: libpng.3 libpngpf.3 png.5
151	-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
152	-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
153	-@$(RM_F) $(DM)/man3/libpng.3
154	-@$(RM_F) $(DM)/man3/libpngpf.3
155	cp libpng.3 $(DM)/man3
156	cp libpngpf.3 $(DM)/man3
157	-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
158	-@$(RM_F) $(DM)/man5/png.5
159	cp png.5 $(DM)/man5
160
161install-config: libpng-config
162	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
163	-@$(RM_F) $(DB)/libpng-config
164	-@$(RM_F) $(DB)/$(LIBNAME)-config
165	cp libpng-config $(DB)/$(LIBNAME)-config
166	chmod 755 $(DB)/$(LIBNAME)-config
167	(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
168
169install: install-static install-shared install-man install-config
170
171# If you installed in $(DESTDIR), test-installed won't work until you
172# move the library to its final location.  Use test-dd to test it
173# before then.
174
175test-dd:
176	echo
177	echo Testing installed dynamic shared library in $(DL).
178	$(CC) -I$(DI) $(CFLAGS) \
179	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
180	   -L$(DL) -L$(ZLIBLIB) \
181	   -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
182	./pngtestd pngtest.png
183
184test-installed:
185	$(CC) $(CFLAGS) \
186	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
187	   -L$(ZLIBLIB) \
188	   -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
189	./pngtesti pngtest.png
190
191clean:
192	$(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
193	$(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
194	pnglibconf.h libpng.pc
195
196DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
197writelock:
198	chmod a-w *.[ch35] $(DOCS) scripts/*
199
200# DO NOT DELETE THIS LINE -- make depend depends on it.
201
202png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
203pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
204pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
205pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
206pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
207pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
208pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
209pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
210pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
211pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
212pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
213pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
214pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
215pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
216pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
217
218pngtest.o: png.h pngconf.h pnglibconf.h
219