[c08f3b1] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | cat << EOF > Makefile |
---|
| 4 | # Default target |
---|
[12743b9] | 5 | .DEFAULT_GOAL = all |
---|
[c08f3b1] | 6 | |
---|
| 7 | SHELL = $SHELL |
---|
| 8 | CC = $CC |
---|
| 9 | BISON = $BISON |
---|
[44f59b8] | 10 | FLEX = $FLEX |
---|
[c08f3b1] | 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) |
---|
[44f59b8] | 41 | ALL_FFLAGS = -t \$(FFLAGS) |
---|
[c08f3b1] | 42 | |
---|
| 43 | VPATH = ./src |
---|
| 44 | |
---|
[1e551bd] | 45 | PROGRAMS = tok sen |
---|
[12743b9] | 46 | |
---|
[44f59b8] | 47 | TOK_OBJ_FILES = tok.o tok_cmdline.o |
---|
| 48 | TOK_FLEX_FILES = tok.l |
---|
[12743b9] | 49 | TOK_GGO_FILES = tok_cmdline.ggo |
---|
| 50 | tok.o: tok_cmdline.h |
---|
| 51 | |
---|
[1e551bd] | 52 | SEN_OBJ_FILES = sen.o |
---|
| 53 | SEN_FLEX_FILES = sen.l |
---|
| 54 | |
---|
[c08f3b1] | 55 | CONFIG_FILES = src/config.h Makefile |
---|
| 56 | |
---|
| 57 | .SUFFIXES: |
---|
| 58 | .SUFFIXES: .l .y .h .c .o |
---|
| 59 | |
---|
[12743b9] | 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 | |
---|
[1e551bd] | 64 | .INTERMEDIATE: \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES)) |
---|
| 65 | |
---|
[c08f3b1] | 66 | .PHONY: all |
---|
| 67 | all: \$(PROGRAMS) |
---|
[12743b9] | 68 | |
---|
[c08f3b1] | 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) |
---|
[44f59b8] | 84 | \$(RM) \$(patsubst %.l,%.c,\$(TOK_FLEX_FILES)) |
---|
[12743b9] | 85 | \$(RM) \$(patsubst %.ggo,%.c,\$(TOK_GGO_FILES)) |
---|
| 86 | \$(RM) \$(patsubst %.ggo,%.h,\$(TOK_GGO_FILES)) |
---|
[1e551bd] | 87 | \$(RM) \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES)) |
---|
[c08f3b1] | 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 | |
---|
[12743b9] | 104 | %.c: %.l |
---|
[44f59b8] | 105 | \$(FLEX) -t \$< > \$@ |
---|
| 106 | |
---|
[12743b9] | 107 | %.c: %.ggo |
---|
[1e551bd] | 108 | gengetopt --input $< --file-name \$(basename \$@) --conf-parser |
---|
[12743b9] | 109 | |
---|
| 110 | %.h: %.ggo |
---|
[1e551bd] | 111 | gengetopt --input $< --file-name \$(basename \$@) --conf-parser |
---|
[12743b9] | 112 | |
---|
[c08f3b1] | 113 | %: %.o |
---|
| 114 | \$(CC) \$? -o \$@ \$(ALL_LDFLAGS) \$(ALL_CFLAGS) \$(ALL_LDLIBS) |
---|
| 115 | |
---|
| 116 | tok: \$(TOK_OBJ_FILES) |
---|
| 117 | |
---|
| 118 | EOF |
---|
| 119 | |
---|