• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Makefile for PngMinus (pnm2pngm)
2# Linux / Unix
3
4#CC=cc
5CC=gcc
6LD=$(CC)
7
8# If awk fails try
9# make AWK=nawk
10
11# If cpp fails try
12# make CPP=/lib/cpp
13
14RM=rm -f
15COPY=cp
16
17CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
18CFLAGS=-O1 -Wall
19
20C=.c
21O=.o
22L=.a
23E=
24
25# Where to find the source code:
26PNGSRC =../../..
27ZLIBSRC=$(PNGSRC)/../zlib
28PROGSRC=$(PNGSRC)/contrib/pngminus
29
30# Zlib
31ZSRCS  = adler32$(C) compress$(C) crc32$(C) deflate$(C) \
32	 trees$(C) zutil$(C)
33
34# Standard headers
35#ZH     = zlib.h crc32.h deflate.h trees.h zutil.h
36ZH     = zlib.h crc32.h deflate.h trees.h zutil.h
37
38# Machine generated headers
39ZCONF  = zconf.h
40
41# Headers callers use
42ZINC   = zlib.h $(ZCONF)
43
44# Headers the Zlib source uses
45ZHDRS  = $(ZH) $(ZCONF)
46
47# compress is not required; it is needed to link the zlib
48# code because deflate defines an unused API function deflateBound
49# which itself calls compressBound from compress.
50ZOBJS  = adler32$(O) compress$(O) crc32$(O) deflate$(O) \
51	 trees$(O) zutil$(O)
52
53# libpng
54PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
55	pngset$(C) pngtrans$(C) pngwio$(C) pngwrite$(C) \
56	pngwtran$(C) pngwutil$(C)
57
58# Standard headers
59PNGH   =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
60
61# Machine generated headers
62PNGCONF=pnglibconf.h
63
64# Headers callers use
65PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
66
67# Headers the PNG library uses
68PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
69
70PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
71	pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \
72	pngwtran$(O) pngwutil$(O)
73
74PROGSRCS= pnm2pngm$(C)
75PROGHDRS=
76PROGDOCS=
77PROGOBJS= pnm2pngm$(O)
78
79OBJS    = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
80
81# implicit make rules -------------------------------------------------------
82
83.c$(O):
84	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
85
86# dependencies
87
88all: pnm2pngm$(E)
89
90pnm2pngm$(E): $(OBJS)
91	$(LD) -o pnm2pngm$(E) $(OBJS)
92
93# The DFA_XTRA setting turns all libpng options off then
94# turns on those required for this minimal build.
95# The CPP_FLAGS setting causes pngusr.h to be included in
96# both the build of pnglibconf.h and, subsequently, when
97# building libpng itself.
98$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
99	$(PNGSRC)/scripts/pnglibconf.dfa \
100	$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
101	$(RM) pnglibconf.h pnglibconf.dfn
102	$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
103	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
104	    DFA_XTRA="pngusr.dfa" $@
105
106clean:
107	$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
108	    srcdir=$(PNGSRC) clean
109	$(RM) pnm2pngm$(O)
110	$(RM) pnm2pngm$(E)
111	$(RM) $(OBJS)
112
113# distclean also removes the copied source and headers
114distclean: clean
115	$(RM) -r scripts # historical reasons
116	$(RM) $(PNGSRCS) $(PNGH)
117	$(RM) $(ZSRCS) $(ZH) $(ZCONF)
118	$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
119
120# Header file dependencies:
121$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
122$(PNGOBJS): $(PNGHDRS) $(ZINC)
123$(ZOBJS): $(ZHDRS)
124
125# Gather the source code from the respective directories
126$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
127	$(RM) $@
128	$(COPY) $(PNGSRC)/$@ $@
129
130# No dependency on the ZLIBSRC target so that it only needs
131# to be specified once.
132$(ZSRCS) $(ZH):
133	$(RM) $@
134	$(COPY) $(ZLIBSRC)/$@ $@
135
136# The unconfigured zconf.h varies in name according to the
137# zlib release
138$(ZCONF):
139	$(RM) $@
140	@for f in zconf.h.in zconf.in.h zconf.h; do\
141	    test -r $(ZLIBSRC)/$$f &&\
142	    echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
143	    $(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
144	done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
145
146pnm2pngm.c: $(PROGSRC)/pnm2png.c
147	$(RM) $@
148	$(COPY) $(PROGSRC)/pnm2png.c $@
149
150# End of makefile for pnm2pngm
151