Mercurial > ~dholland > hg > ag > index.cgi
comparison mk/agfile-rules.sh @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children | bb115deb6fb2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 #!/bin/sh | |
2 # agfile-rules.sh - generate make rules for AG files | |
3 # usage: agfile-rules.sh here|srcdir "syns" "output-extension" > rules.mk | |
4 | |
5 if [ $# != 3 ]; then | |
6 echo "$0: usage: $0 here|srcdir 'syns' 'output-extension'" 1>&2 | |
7 exit 1 | |
8 fi | |
9 | |
10 WHERE="$1" | |
11 SYNS="$2" | |
12 EXT="$3" | |
13 | |
14 case "$WHERE" in | |
15 here|srcdir) ;; | |
16 *) echo "$0: deposit location must be either 'here' or 'srcdir'" | |
17 exit 1 | |
18 ;; | |
19 esac | |
20 | |
21 if [ "x$SYNS" = x ]; then | |
22 echo 'agfiles agclean:;' | |
23 exit 0 | |
24 fi | |
25 | |
26 for S in $SYNS; do | |
27 echo $S | awk ' | |
28 { | |
29 syn=$1; | |
30 base=syn; | |
31 sub("\\.syn$", "", base); | |
32 cout=base ext; | |
33 hout=base ".h"; | |
34 | |
35 if (where == "srcdir") { | |
36 dcout = "$(SRCDIR)/" cout; | |
37 dhout = "$(SRCDIR)/" hout; | |
38 } | |
39 else { | |
40 dcout = cout; | |
41 dhout = hout; | |
42 } | |
43 | |
44 printf "agfiles: %s %s\n", dcout, dhout; | |
45 printf "%s %s: $(SRCDIR)/%s\n", dcout, dhout, syn; | |
46 printf "\t@echo \" [AGCL] %-12s $(AGCLQUAL)\"\n", syn; | |
47 | |
48 printf "\t@$(AGCL) $(SRCDIR)/%s\n", syn; | |
49 if (where == "srcdir") { | |
50 printf "\t@mv %s %s\n", cout, dcout; | |
51 printf "\t@mv %s %s\n", hout, dhout; | |
52 } | |
53 } | |
54 ' "ext=$EXT" "where=$WHERE" | |
55 done | |
56 | |
57 echo $SYNS | tr ' ' '\n' | sed 's/.syn$//' | awk ' | |
58 BEGIN { printf "agclean:\n"; } | |
59 { | |
60 base = $1; | |
61 if (where == "srcdir") { | |
62 base = "$(SRCDIR)/" base; | |
63 } | |
64 | |
65 printf "\t@echo \" [RM] %s%s %s.h\"\n", base, ext, base; | |
66 printf "\t@rm -f %s%s %s.h\n", base, ext, base; | |
67 } | |
68 ' "ext=$EXT" "where=$WHERE" | |
69 | |
70 if [ $WHERE = here ]; then | |
71 echo 'clean: agclean' | |
72 echo 'beforeall: agfiles' | |
73 fi |