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