]>
Commit | Line | Data |
---|---|---|
9c0d9ce3 DS |
1 | #!/usr/bin/make -f |
2 | # pnglibconf.mak - standard make lines for pnglibconf.h | |
3 | # | |
4 | # These lines are copied from Makefile.am, they illustrate | |
5 | # how to automate the build of pnglibconf.h from scripts/pnglibconf.dfa | |
6 | # given 'awk' and 'sed' | |
7 | ||
8 | # Override as appropriate, these definitions can be overridden on | |
9 | # the make command line (AWK='nawk' for example). | |
10 | AWK = gawk | |
11 | AWK = mawk | |
12 | AWK = nawk | |
13 | AWK = one-true-awk | |
14 | AWK = awk # Crashes on SunOS 5.10 - use 'nawk' | |
15 | CPP = $(CC) -E # Does not work on SUN OS 5.10 - use /lib/cpp | |
16 | SED = sed | |
17 | ||
18 | COPY = cp | |
19 | DELETE = rm -f | |
20 | ECHO = echo | |
21 | DFA_XTRA = # Appended to scripts/options.awk | |
22 | ||
23 | # CPPFLAGS should contain the options to control the result, | |
24 | # but DEFS and CFLAGS are also supported here, override | |
25 | # as appropriate | |
26 | DFNFLAGS = $(DEFS) $(CPPFLAGS) $(CFLAGS) | |
27 | ||
28 | # srcdir is a defacto standard for the location of the source | |
29 | srcdir = . | |
30 | ||
31 | # The standard pnglibconf.h exists as scripts/pnglibconf.h.prebuilt, | |
32 | # copy this if the following doesn't work. | |
33 | pnglibconf.h: pnglibconf.dfn | |
34 | $(DELETE) $@ dfn.c dfn1.out dfn2.out dfn3.out | |
35 | $(ECHO) '#include "pnglibconf.dfn"' >dfn.c | |
36 | $(CPP) $(DFNFLAGS) dfn.c >dfn1.out | |
37 | $(ECHO) "If 'cpp -e' crashes try /lib/cpp (e.g. CPP='/lib/cpp')" >&2 | |
72281370 | 38 | $(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\ |
9c0d9ce3 | 39 | dfn1.out >dfn2.out |
72281370 | 40 | $(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' dfn2.out >dfn3.out |
9c0d9ce3 DS |
41 | $(COPY) dfn3.out $@ |
42 | $(DELETE) dfn.c dfn1.out dfn2.out dfn3.out | |
43 | ||
72281370 | 44 | pnglibconf.dfn: $(srcdir)/scripts/pnglibconf.dfa $(srcdir)/scripts/options.awk $(srcdir)/pngconf.h |
9c0d9ce3 DS |
45 | $(DELETE) $@ dfn1.out dfn2.out |
46 | $(ECHO) "Calling $(AWK) from scripts/pnglibconf.mak" >&2 | |
47 | $(ECHO) "If 'awk' crashes try a better awk (e.g. AWK='nawk')" >&2 | |
72281370 DS |
48 | $(AWK) -f $(srcdir)/scripts/options.awk out=dfn1.out version=search\ |
49 | $(srcdir)/pngconf.h $(srcdir)/scripts/pnglibconf.dfa\ | |
50 | $(DFA_XTRA) 1>&2 | |
9c0d9ce3 DS |
51 | $(AWK) -f $(srcdir)/scripts/options.awk out=dfn2.out dfn1.out 1>&2 |
52 | $(COPY) dfn2.out $@ | |
53 | $(DELETE) dfn1.out dfn2.out | |
54 | ||
55 | clean-pnglibconf: | |
56 | $(DELETE) pnglibconf.h pnglibconf.dfn dfn.c dfn1.out dfn2.out dfn3.out | |
57 | ||
58 | clean: clean-pnglibconf |