[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 | |
---|
[9e0afb5] | 45 | PROGRAMS = tok sen fla |
---|
[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 | |
---|
[9e0afb5] | 55 | FLA_OBJ_FILES = fla.o |
---|
| 56 | |
---|
[c08f3b1] | 57 | CONFIG_FILES = src/config.h Makefile |
---|
| 58 | |
---|
| 59 | .SUFFIXES: |
---|
| 60 | .SUFFIXES: .l .y .h .c .o |
---|
| 61 | |
---|
[12743b9] | 62 | .INTERMEDIATE: \$(patsubst %.l,%.c,\$(TOK_FLEX_FILES)) |
---|
| 63 | .INTERMEDIATE: \$(patsubst %.ggo,%.c,\$(TOK_GGO_FILES)) |
---|
| 64 | .INTERMEDIATE: \$(patsubst %.ggo,%.h,\$(TOK_GGO_FILES)) |
---|
[1e551bd] | 65 | .INTERMEDIATE: \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES)) |
---|
| 66 | |
---|
[c08f3b1] | 67 | .PHONY: all |
---|
| 68 | all: \$(PROGRAMS) |
---|
[12743b9] | 69 | |
---|
[c08f3b1] | 70 | |
---|
| 71 | .PHONY: help |
---|
| 72 | help: |
---|
| 73 | @\$(MAKE) --print-data-base --question | \\ |
---|
| 74 | \$(GREP) '^[^.%][-A-Za-z0-9_]*:' | \\ |
---|
| 75 | \$(CUT) -f 1 -d : | \\ |
---|
| 76 | \$(GREP) -v '^Makefile$$' | \\ |
---|
| 77 | \$(SORT) | \\ |
---|
| 78 | \$(PR) --omit-pagination --width=80 --columns=4 |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | .PHONY: clean |
---|
| 82 | clean: |
---|
| 83 | \$(RM) \$(PROGRAMS) |
---|
| 84 | \$(RM) \$(TOK_OBJ_FILES) |
---|
[44f59b8] | 85 | \$(RM) \$(patsubst %.l,%.c,\$(TOK_FLEX_FILES)) |
---|
[12743b9] | 86 | \$(RM) \$(patsubst %.ggo,%.c,\$(TOK_GGO_FILES)) |
---|
| 87 | \$(RM) \$(patsubst %.ggo,%.h,\$(TOK_GGO_FILES)) |
---|
[1e551bd] | 88 | \$(RM) \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES)) |
---|
[c08f3b1] | 89 | |
---|
| 90 | .PHONY: distclean |
---|
| 91 | distclean: clean |
---|
| 92 | \$(RM) \$(CONFIG_FILES) |
---|
| 93 | |
---|
| 94 | .PHONY: install |
---|
| 95 | install: all |
---|
| 96 | echo TODO: make install |
---|
| 97 | |
---|
| 98 | .PHONY: uninstall |
---|
| 99 | uninstall: |
---|
| 100 | echo TODO: make uninstall |
---|
| 101 | |
---|
| 102 | %.o: %.c |
---|
| 103 | \$(CC) -c \$< -o \$@ \$(ALL_CFLAGS) |
---|
| 104 | |
---|
[12743b9] | 105 | %.c: %.l |
---|
[44f59b8] | 106 | \$(FLEX) -t \$< > \$@ |
---|
| 107 | |
---|
[12743b9] | 108 | %.c: %.ggo |
---|
[1e551bd] | 109 | gengetopt --input $< --file-name \$(basename \$@) --conf-parser |
---|
[12743b9] | 110 | |
---|
| 111 | %.h: %.ggo |
---|
[1e551bd] | 112 | gengetopt --input $< --file-name \$(basename \$@) --conf-parser |
---|
[12743b9] | 113 | |
---|
[c08f3b1] | 114 | %: %.o |
---|
| 115 | \$(CC) \$? -o \$@ \$(ALL_LDFLAGS) \$(ALL_CFLAGS) \$(ALL_LDLIBS) |
---|
| 116 | |
---|
| 117 | tok: \$(TOK_OBJ_FILES) |
---|
| 118 | |
---|
| 119 | EOF |
---|
| 120 | |
---|