1 | #!/bin/sh |
---|
2 | |
---|
3 | cat << EOF > Makefile |
---|
4 | # Default target |
---|
5 | .DEFAULT_GOAL = all |
---|
6 | |
---|
7 | SHELL = $SHELL |
---|
8 | CC = $CC |
---|
9 | BISON = $BISON |
---|
10 | FLEX = $FLEX |
---|
11 | RM = $RM |
---|
12 | RMDIR = $RMDIR |
---|
13 | TEST = $TEST |
---|
14 | MAKE = $MAKE |
---|
15 | GREP = $GREP |
---|
16 | CUT = $CUT |
---|
17 | SORT = $SORT |
---|
18 | PR = $PR |
---|
19 | CP = $CP |
---|
20 | CHMOD = $CHMOD |
---|
21 | |
---|
22 | CFLAGS = $CFLAGS |
---|
23 | LDFLAGS = $LDFLAGS |
---|
24 | LDLIBS = $LDLIBS |
---|
25 | BFLAGS = $BFLAGS |
---|
26 | FFLAGS = $FFLAGS |
---|
27 | |
---|
28 | DESTDIR = $DESTDIR |
---|
29 | |
---|
30 | prefix = $prefix |
---|
31 | exec_prefix = $exec_prefix |
---|
32 | bindir = $bindir |
---|
33 | sbindir = $sbindir |
---|
34 | datarootdir = $datarootdir |
---|
35 | datadir = $datadir |
---|
36 | sysconfdir = $sysconfdir |
---|
37 | sharedstatedir = $sharestatedir |
---|
38 | localstatedir = $localstatedir |
---|
39 | |
---|
40 | ALL_CFLAGS = \$(CFLAGS) |
---|
41 | ALL_LDFLAGS = \$(LDFLAGS) |
---|
42 | ALL_LDLIBS = \$(LDLIBS) |
---|
43 | ALL_BFLAGS = \$(BFLAGS) |
---|
44 | ALL_FFLAGS = -t \$(FFLAGS) |
---|
45 | |
---|
46 | VPATH = ./src |
---|
47 | |
---|
48 | PROGRAMS = tok sen fla gph |
---|
49 | |
---|
50 | TOK_OBJ_FILES = tok.o tok_cmdline.o |
---|
51 | TOK_FLEX_FILES = tok.l |
---|
52 | TOK_GGO_FILES = tok_cmdline.ggo |
---|
53 | tok.o: tok_cmdline.h |
---|
54 | |
---|
55 | SEN_OBJ_FILES = sen.o |
---|
56 | SEN_FLEX_FILES = sen.l |
---|
57 | |
---|
58 | FLA_OBJ_FILES = fla.o |
---|
59 | |
---|
60 | GPH_PERL_FILES = gph.pl |
---|
61 | |
---|
62 | CONFIG_FILES = src/config.h Makefile |
---|
63 | |
---|
64 | .SUFFIXES: |
---|
65 | .SUFFIXES: .l .y .h .c .o |
---|
66 | |
---|
67 | .INTERMEDIATE: \$(patsubst %.l,%.c,\$(TOK_FLEX_FILES)) |
---|
68 | .INTERMEDIATE: \$(patsubst %.ggo,%.c,\$(TOK_GGO_FILES)) |
---|
69 | .INTERMEDIATE: \$(patsubst %.ggo,%.h,\$(TOK_GGO_FILES)) |
---|
70 | .INTERMEDIATE: \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES)) |
---|
71 | |
---|
72 | .PHONY: all |
---|
73 | all: \$(PROGRAMS) |
---|
74 | |
---|
75 | |
---|
76 | .PHONY: help |
---|
77 | help: |
---|
78 | @\$(MAKE) --print-data-base --question | \\ |
---|
79 | \$(GREP) '^[^.%][-A-Za-z0-9_]*:' | \\ |
---|
80 | \$(CUT) -f 1 -d : | \\ |
---|
81 | \$(GREP) -v '^Makefile$$' | \\ |
---|
82 | \$(SORT) | \\ |
---|
83 | \$(PR) --omit-pagination --width=80 --columns=4 |
---|
84 | |
---|
85 | |
---|
86 | .PHONY: clean |
---|
87 | clean: |
---|
88 | \$(RM) \$(PROGRAMS) |
---|
89 | \$(RM) \$(TOK_OBJ_FILES) |
---|
90 | \$(RM) \$(patsubst %.l,%.c,\$(TOK_FLEX_FILES)) |
---|
91 | \$(RM) \$(patsubst %.ggo,%.c,\$(TOK_GGO_FILES)) |
---|
92 | \$(RM) \$(patsubst %.ggo,%.h,\$(TOK_GGO_FILES)) |
---|
93 | \$(RM) \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES)) |
---|
94 | |
---|
95 | .PHONY: distclean |
---|
96 | distclean: clean |
---|
97 | \$(RM) \$(CONFIG_FILES) |
---|
98 | |
---|
99 | .PHONY: install |
---|
100 | install: all |
---|
101 | echo TODO: make install |
---|
102 | |
---|
103 | .PHONY: uninstall |
---|
104 | uninstall: |
---|
105 | echo TODO: make uninstall |
---|
106 | |
---|
107 | %.o: %.c |
---|
108 | \$(CC) -c \$< -o \$@ \$(ALL_CFLAGS) |
---|
109 | |
---|
110 | %.c: %.l |
---|
111 | \$(FLEX) -t \$< > \$@ |
---|
112 | |
---|
113 | %.c: %.ggo |
---|
114 | gengetopt --input \$< --file-name \$(basename \$@) --conf-parser |
---|
115 | |
---|
116 | %.h: %.ggo |
---|
117 | gengetopt --input \$< --file-name \$(basename \$@) --conf-parser |
---|
118 | |
---|
119 | %: %.o |
---|
120 | \$(CC) \$? -o \$@ \$(ALL_LDFLAGS) \$(ALL_CFLAGS) \$(ALL_LDLIBS) |
---|
121 | |
---|
122 | %: %.pl |
---|
123 | \$(CP) \$< \$@ |
---|
124 | \$(CHMOD) a+x \$@ |
---|
125 | |
---|
126 | tok: \$(TOK_OBJ_FILES) |
---|
127 | |
---|
128 | EOF |
---|
129 | |
---|