1
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
3
# Last modified: 28 February 2000
5
# The programs built by this makefile are described in the book,
6
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
7
# Associates, 1999). Go buy a copy, eh? Buy some for friends
8
# and family, too. (Not that this is a blatant plug or anything.)
10
# Invoke this makefile from a shell prompt in the usual way; for example:
12
# make -f Makefile.unx
14
# This makefile assumes libpng and zlib have already been built or downloaded
15
# and are both installed in /usr/local/{include,lib} (as indicated by the
16
# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of
17
# the PNGINC, PNGLIB, ZINC and ZLIB lines.
19
# This makefile builds statically linked executables (against libpng and zlib,
20
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
24
# macros --------------------------------------------------------------------
26
PNGINC = -I/usr/local/include
27
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
28
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
31
#PNGLIB = -L../.. -lpng
32
#PNGLIB = ../../libpng.a
34
ZINC = -I/usr/local/include
35
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
36
ZLIB = /usr/local/lib/libz.a # statically linked against zlib
39
#ZLIB = ../../../zlib/libz.a
41
#XINC = -I/usr/include/X11 # old-style, stock X distributions
42
#XLIB = -L/usr/lib/X11 -lX11
43
#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
44
#XLIB = -L/usr/openwin/lib -lX11
45
XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
46
XLIB = -L/usr/X11R6/lib -lX11
48
INCS = $(PNGINC) $(ZINC) $(XINC)
49
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
50
WLIBS = $(PNGLIB) $(ZLIB)
55
CFLAGS = -O -Wall $(INCS)
56
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
57
# [-ansi, -pedantic and -W can also be used]
66
ROBJS = $(RPNG)$(O) readpng$(O)
67
ROBJS2 = $(RPNG2)$(O) readpng2$(O)
68
WOBJS = $(WPNG)$(O) writepng$(O)
70
EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
73
# implicit make rules -------------------------------------------------------
79
# dependencies --------------------------------------------------------------
84
$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS)
86
$(RPNG2)$(E): $(ROBJS2)
87
$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS)
90
$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS)
92
$(RPNG)$(O): $(RPNG).c readpng.h
93
$(RPNG2)$(O): $(RPNG2).c readpng2.h
94
$(WPNG)$(O): $(WPNG).c writepng.h
96
readpng$(O): readpng.c readpng.h
97
readpng2$(O): readpng2.c readpng2.h
98
writepng$(O): writepng.c writepng.h
101
# maintenance ---------------------------------------------------------------
104
$(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)