1999-10-14 08:43:10 -04:00
|
|
|
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
|
|
|
|
# Greg Roelofs
|
2008-07-30 15:47:09 -04:00
|
|
|
# Last modified: 2 June 2007
|
1999-10-14 08:43:10 -04:00
|
|
|
#
|
|
|
|
# The programs built by this makefile are described in the book,
|
|
|
|
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
|
2008-07-30 15:47:09 -04:00
|
|
|
# Associates, 1999). Go buy a copy, eh? Well, OK, it's not
|
|
|
|
# generally for sale anymore, but it's the thought that counts,
|
|
|
|
# right? (Hint: http://www.libpng.org/pub/png/book/ )
|
1999-10-14 08:43:10 -04:00
|
|
|
#
|
|
|
|
# Invoke this makefile from a shell prompt in the usual way; for example:
|
|
|
|
#
|
2000-03-21 06:13:06 -05:00
|
|
|
# make -f Makefile.unx
|
1999-10-14 08:43:10 -04:00
|
|
|
#
|
|
|
|
# This makefile assumes libpng and zlib have already been built or downloaded
|
2008-07-30 15:47:09 -04:00
|
|
|
# and are installed in /usr/local/{include,lib} or as otherwise indicated by
|
|
|
|
# the PNG* and Z* macros below. Edit as appropriate--choose only ONE each of
|
|
|
|
# the PNGINC, PNGLIBd, PNGLIBs, ZINC, ZLIBd and ZLIBs lines.
|
1999-10-14 08:43:10 -04:00
|
|
|
#
|
2008-07-30 15:47:09 -04:00
|
|
|
# This makefile builds both dynamically and statically linked executables
|
|
|
|
# (against libpng and zlib, that is), but that can be changed by modifying
|
|
|
|
# the "EXES =" line. (You need only one set, but for testing it can be handy
|
|
|
|
# to have both.)
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
# macros --------------------------------------------------------------------
|
|
|
|
|
2008-07-30 15:47:09 -04:00
|
|
|
#PNGDIR = /usr/local/lib
|
2013-02-13 23:49:19 -05:00
|
|
|
#PNGINC = -I/usr/local/include/libpng16
|
|
|
|
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
|
|
|
|
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
|
2000-03-21 06:13:06 -05:00
|
|
|
# or:
|
2008-07-30 15:47:09 -04:00
|
|
|
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
|
|
|
#PNGDIR = ../libpng
|
|
|
|
PNGINC = -I$(PNGDIR)
|
2013-02-13 23:49:19 -05:00
|
|
|
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
|
2008-07-30 15:47:09 -04:00
|
|
|
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
|
|
|
|
|
|
|
ZDIR = /usr/local/lib
|
|
|
|
#ZDIR = /usr/lib64
|
2000-03-21 06:13:06 -05:00
|
|
|
ZINC = -I/usr/local/include
|
2008-07-30 15:47:09 -04:00
|
|
|
ZLIBd = -L$(ZDIR) -lz # dynamically linked against zlib
|
|
|
|
ZLIBs = $(ZDIR)/libz.a # statically linked against zlib
|
|
|
|
# or:
|
|
|
|
#ZDIR = ../zlib
|
|
|
|
#ZINC = -I$(ZDIR)
|
|
|
|
#ZLIBd = -Wl,-rpath,$(ZDIR) -L$(ZDIR) -lz # -rpath allows in-place testing
|
|
|
|
#ZLIBs = $(ZDIR)/libz.a
|
2000-03-21 06:13:06 -05:00
|
|
|
|
2001-06-23 09:03:17 -04:00
|
|
|
#XINC = -I/usr/include # old-style, stock X distributions
|
2008-07-30 15:47:09 -04:00
|
|
|
#XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX)
|
2001-06-23 09:03:17 -04:00
|
|
|
#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
|
2000-03-21 06:13:06 -05:00
|
|
|
#XLIB = -L/usr/openwin/lib -lX11
|
2008-07-30 15:47:09 -04:00
|
|
|
XINC = -I/usr/X11R6/include # new X distributions (X.org, etc.)
|
2000-03-21 06:13:06 -05:00
|
|
|
XLIB = -L/usr/X11R6/lib -lX11
|
2008-07-30 15:47:09 -04:00
|
|
|
#XLIB = -L/usr/X11R6/lib64 -lX11 # e.g., Red Hat on AMD64
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
INCS = $(PNGINC) $(ZINC) $(XINC)
|
2008-07-30 15:47:09 -04:00
|
|
|
RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
|
|
|
|
RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
|
|
|
|
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
|
2014-08-21 06:53:38 -04:00
|
|
|
WLIBSs = $(PNGLIBs) $(ZLIBs) -lm
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
CC = gcc
|
|
|
|
LD = gcc
|
|
|
|
RM = rm -f
|
2014-02-05 23:28:57 -05:00
|
|
|
CPPFLAGS = $(INCS) -DFEATURE_LOOP
|
|
|
|
CFLAGS = -O -Wall
|
2014-08-21 06:53:38 -04:00
|
|
|
#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi
|
2000-03-21 06:13:06 -05:00
|
|
|
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
2014-08-21 06:53:38 -04:00
|
|
|
# [-ansi, -pedantic, -Wextra, and -W can also be used]
|
1999-10-14 08:43:10 -04:00
|
|
|
LDFLAGS =
|
|
|
|
O = .o
|
|
|
|
E =
|
|
|
|
|
2008-07-30 15:47:09 -04:00
|
|
|
RPNG = rpng-x
|
|
|
|
RPNG2 = rpng2-x
|
|
|
|
WPNG = wpng
|
|
|
|
|
|
|
|
RPNGs = $(RPNG)-static
|
|
|
|
RPNG2s = $(RPNG2)-static
|
|
|
|
WPNGs = $(WPNG)-static
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
ROBJS = $(RPNG)$(O) readpng$(O)
|
|
|
|
ROBJS2 = $(RPNG2)$(O) readpng2$(O)
|
|
|
|
WOBJS = $(WPNG)$(O) writepng$(O)
|
|
|
|
|
2008-07-30 15:47:09 -04:00
|
|
|
STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
|
|
|
|
DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
|
|
|
|
|
|
|
EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
# implicit make rules -------------------------------------------------------
|
|
|
|
|
|
|
|
.c$(O):
|
2014-02-05 23:28:57 -05:00
|
|
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
# dependencies --------------------------------------------------------------
|
|
|
|
|
|
|
|
all: $(EXES)
|
|
|
|
|
2008-07-30 15:47:09 -04:00
|
|
|
$(RPNGs)$(E): $(ROBJS)
|
|
|
|
$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSs)
|
|
|
|
|
1999-10-14 08:43:10 -04:00
|
|
|
$(RPNG)$(E): $(ROBJS)
|
2008-07-30 15:47:09 -04:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSd)
|
|
|
|
|
|
|
|
$(RPNG2s)$(E): $(ROBJS2)
|
|
|
|
$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSs)
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
$(RPNG2)$(E): $(ROBJS2)
|
2008-07-30 15:47:09 -04:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSd)
|
|
|
|
|
|
|
|
$(WPNGs)$(E): $(WOBJS)
|
|
|
|
$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSs)
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
$(WPNG)$(E): $(WOBJS)
|
2008-07-30 15:47:09 -04:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSd)
|
1999-10-14 08:43:10 -04:00
|
|
|
|
|
|
|
$(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)
|