makefile 4.1 KB
Newer Older
1 2 3 4 5 6 7
# Makefile for PngMinus (rpng2)
# Linux / Unix

#CC=cc
CC=gcc
LD=$(CC)

8 9 10
# If awk fails try
# make AWK=nawk

11 12 13
# If cpp fails try
# make CPP=/lib/cpp

14
RM=rm -f
15
COPY=cp
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

#XINC = -I/usr/include			# old-style, stock X distributions
#XLIB = -L/usr/lib/X11 -lX11		#  (including SGI IRIX)

#XINC = -I/usr/openwin/include		# Sun workstations (OpenWindows)
#XLIB = -L/usr/openwin/lib -lX11

XINC = -I/usr/X11R6/include		# new X distributions (X.org, etc.)
XLIB = -L/usr/X11R6/lib -lX11
#XLIB = -L/usr/X11R6/lib64 -lX11	# e.g., Red Hat on AMD64

#XINC = -I/usr/local/include   		# FreeBSD
#XLIB = -L/usr/local/lib -lX11

#LIBS = $(XLIB)
LIBS = $(XLIB) -lm                      #platforms that need libm

33
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
34
CFLAGS=-O1 -Wall
35 36 37 38 39 40

C=.c
O=.o
L=.a
E=

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
# Where to find the source code:
PNGSRC =../../..
ZLIBSRC=$(PNGSRC)/../zlib
PROGSRC=$(PNGSRC)/contrib/gregbook

# Zlib (minimal inflate requirements - crc32 is used by libpng)
# zutil can be eliminated if you provide your own zcalloc and zcfree
ZSRCS  = adler32$(C) crc32$(C) \
	 inffast$(C) inflate$(C) inftrees$(C) \
	 zutil$(C)

# Standard headers
ZH     = zlib.h crc32.h inffast.h inffixed.h \
	 inflate.h inftrees.h zutil.h

# Machine generated headers
ZCONF  = zconf.h

# Headers callers use
ZINC   = zlib.h $(ZCONF)

# Headers the Zlib source uses
ZHDRS  = $(ZH) $(ZCONF)

65
ZOBJS  = adler32$(O) crc32$(O) \
66 67 68 69
	 inffast$(O) inflate$(O) inftrees$(O) \
	 zutil$(O)

# libpng
70
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
71 72
	pngpread$(C) pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \
	pngset$(C) pngtrans$(C)
73

74
# Standard headers
75 76 77 78 79 80 81 82 83 84 85
PNGH   =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h

# Machine generated headers
PNGCONF=pnglibconf.h

# Headers callers use
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)

# Headers the PNG library uses
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h

86
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
87
	pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
88 89 90 91 92 93 94 95
	pngset$(O) pngtrans$(O)

PROGSRCS= rpng2-x$(C) readpng2$(C)
PROGHDRS= readpng2.h
PROGDOCS= COPYING LICENSE
PROGOBJS= rpng2-x$(O) readpng2$(O)

OBJS    = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
96 97 98

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

99
.c$(O):
100
	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
101 102 103

# dependencies

104
all: $(PROGDOCS) rpng2-x$(E)
105 106 107

rpng2-x$(E): $(OBJS)
	$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
108 109 110 111 112 113

# The DFA_XTRA setting turns all libpng options off then
# turns on those required for this minimal build.
# The CPP_FLAGS setting causes pngusr.h to be included in
# both the build of pnglibconf.h and, subsequently, when
# building libpng itself.
114
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
115 116 117
	$(PNGSRC)/scripts/pnglibconf.dfa \
	$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
	$(RM) pnglibconf.h pnglibconf.dfn
118
	$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
119
	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
120
	    DFA_XTRA="pngusr.dfa" $@
121

122
clean:
123
	$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
124
	    srcdir=$(PNGSRC) clean
125 126 127 128
	$(RM) rpng2-x$(O)
	$(RM) rpng2-x$(E)
	$(RM) $(OBJS)

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
# distclean also removes the copied source and headers
distclean: clean
	$(RM) -r scripts # historical reasons
	$(RM) $(PNGSRCS) $(PNGH)
	$(RM) $(ZSRCS) $(ZH) $(ZCONF)
	$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)

# Header file dependencies:
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
$(PNGOBJS): $(PNGHDRS) $(ZINC)
$(ZOBJS): $(ZHDRS)

# Gather the source code from the respective directories
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
	$(RM) $@
	$(COPY) $(PNGSRC)/$@ $@

# No dependency on the ZLIBSRC target so that it only needs
# to be specified once.
$(ZSRCS) $(ZH):
	$(RM) $@
	$(COPY) $(ZLIBSRC)/$@ $@

# The unconfigured zconf.h varies in name according to the
# zlib release
$(ZCONF):
	$(RM) $@
	@for f in zconf.h.in zconf.in.h zconf.h; do\
	    test -r $(ZLIBSRC)/$$f &&\
	    echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
	    $(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
	done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1

$(PROGSRCS) $(PROGHDRS) $(PROGDOCS): $(PROGSRC)/$@
	$(RM) $@
	$(COPY) $(PROGSRC)/$@ $@
165

166
# End of makefile for rpng2-x