Makefile.unx 2.9 KB
Newer Older
1 2
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
# Greg Roelofs
3
# Last modified:  28 February 2000
4 5 6 7 8 9 10 11
#
#	The programs built by this makefile are described in the book,
#	"PNG:  The Definitive Guide," by Greg Roelofs (O'Reilly and
#	Associates, 1999).  Go buy a copy, eh?  Buy some for friends
#	and family, too.  (Not that this is a blatant plug or anything.)
#
# Invoke this makefile from a shell prompt in the usual way; for example:
#
12
#	make -f Makefile.unx
13 14 15
#
# This makefile assumes libpng and zlib have already been built or downloaded
# and are both installed in /usr/local/{include,lib} (as indicated by the
16 17
# PNG* and Z* macros below).  Edit as appropriate--choose only ONE each of
# the PNGINC, PNGLIB, ZINC and ZLIB lines.
18 19 20 21 22 23 24 25
#
# This makefile builds statically linked executables (against libpng and zlib,
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
# ZLIB lines.


# macros --------------------------------------------------------------------

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
PNGINC = -I/usr/local/include
#PNGLIB = -L/usr/local/lib -lpng	# dynamically linked against libpng
PNGLIB = /usr/local/lib/libpng.a	# statically linked against libpng
# or:
#PNGINC = -I../..
#PNGLIB = -L../.. -lpng
#PNGLIB = ../../libpng.a

ZINC = -I/usr/local/include
#ZLIB = -L/usr/local/lib -lz		# dynamically linked against zlib
ZLIB = /usr/local/lib/libz.a		# statically linked against zlib
#ZINC = -I../zlib
#ZLIB = -L../zlib -lz
#ZLIB = ../../../zlib/libz.a

#XINC = -I/usr/include/X11		# old-style, stock X distributions
#XLIB = -L/usr/lib/X11 -lX11
43
#XINC = -I/usr/openwin/include    	# Sun workstations (OpenWindows)
44 45 46
#XLIB = -L/usr/openwin/lib -lX11
XINC = -I/usr/X11R6/include		# new X distributions (XFree86, etc.)
XLIB = -L/usr/X11R6/lib -lX11
47 48 49

INCS = $(PNGINC) $(ZINC) $(XINC)
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
50
WLIBS = $(PNGLIB) $(ZLIB)
51 52 53 54 55

CC = gcc
LD = gcc
RM = rm -f
CFLAGS = -O -Wall $(INCS)
56 57
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used]
58 59 60 61 62 63 64 65 66 67 68 69 70 71 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 99 100 101 102 103 104
LDFLAGS =
O = .o
E =

RPNG  = rpng-x
RPNG2 = rpng2-x
WPNG  = wpng

ROBJS  = $(RPNG)$(O) readpng$(O)
ROBJS2 = $(RPNG2)$(O) readpng2$(O)
WOBJS  = $(WPNG)$(O) writepng$(O)

EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)


# implicit make rules -------------------------------------------------------

.c$(O):
	$(CC) -c $(CFLAGS) $<


# dependencies --------------------------------------------------------------

all:  $(EXES)

$(RPNG)$(E): $(ROBJS)
	$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS)

$(RPNG2)$(E): $(ROBJS2)
	$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS)

$(WPNG)$(E): $(WOBJS)
	$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS)

$(RPNG)$(O):	$(RPNG).c readpng.h
$(RPNG2)$(O):	$(RPNG2).c readpng2.h
$(WPNG)$(O):	$(WPNG).c writepng.h

readpng$(O):	readpng.c readpng.h
readpng2$(O):	readpng2.c readpng2.h
writepng$(O):	writepng.c writepng.h


# maintenance ---------------------------------------------------------------

clean:
	$(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)