diff mk/agfile-rules.sh @ 20:bb115deb6fb2

Improve agfiles rule. (1) It didn't depend on $(AGCL) and it absolutely should have. (2) allow AGFORCE=1 to make it rebuild whether or not it looks out of date. (3) Document this.
author David A. Holland
date Mon, 13 Jun 2022 00:02:15 -0400
parents 13d2b8934445
children
line wrap: on
line diff
--- a/mk/agfile-rules.sh	Tue May 31 02:06:45 2022 -0400
+++ b/mk/agfile-rules.sh	Mon Jun 13 00:02:15 2022 -0400
@@ -1,15 +1,22 @@
 #!/bin/sh
 # agfile-rules.sh - generate make rules for AG files
-# usage: agfile-rules.sh here|srcdir "syns" "output-extension" > rules.mk
+# usage:
+#    agfile-rules.sh where syns ext maint > rules.mk
+#
 
-if [ $# != 3 ]; then
-    echo "$0: usage: $0 here|srcdir 'syns' 'output-extension'" 1>&2
+if [ $# != 4 ]; then
+    echo "$0: usage: $0 where syns ext maint" 1>&2
+    echo "    where:      here | srcdir" 1>&2
+    echo "    syns:       list of .syn files" 1>&2
+    echo "    ext:        output extension, e.g. '.c'" 1>&2
+    echo "    maint:      maintainer | nonmaintainer" 1>&2
     exit 1
 fi
 
 WHERE="$1"
 SYNS="$2"
 EXT="$3"
+MAINT="$4"
 
 case "$WHERE" in
     here|srcdir) ;;
@@ -23,6 +30,11 @@
     exit 0
 fi
 
+echo 'agforce: ;'
+echo 'DOAGFORCE='
+echo 'DOAGFORCE0='
+echo 'DOAGFORCE1=agforce'
+
 for S in $SYNS; do
     echo $S | awk '
 	{
@@ -31,6 +43,7 @@
 	    sub("\\.syn$", "", base);
 	    cout=base ext;
 	    hout=base ".h";
+	    synsrc="$(SRCDIR)/" syn;
 
 	    if (where == "srcdir") {
 		dcout = "$(SRCDIR)/" cout;
@@ -41,8 +54,17 @@
 		dhout = hout;
 	    }
 
+	    if (maint == "maintainer") {
+	        tool = " $(AGCL)";
+	    }
+	    else {
+		tool = "";
+	    }
+
+	    force = "$(DOAGFORCE$(AGFORCE))"
+
 	    printf "agfiles: %s %s\n", dcout, dhout;
-	    printf "%s %s: $(SRCDIR)/%s\n", dcout, dhout, syn;
+	    printf "%s %s: %s %s %s\n", dcout, dhout, synsrc, tool, force;
 	    printf "\t@echo \"        [AGCL]    %-12s $(AGCLQUAL)\"\n", syn;
 
 	    printf "\t@$(AGCL) $(SRCDIR)/%s\n", syn;
@@ -51,7 +73,7 @@
 		printf "\t@mv %s %s\n", hout, dhout;
 	    }
 	}
-    ' "ext=$EXT" "where=$WHERE"
+    ' "ext=$EXT" "where=$WHERE" "maint=$MAINT"
 done
 
 echo $SYNS | tr ' ' '\n' | sed 's/.syn$//' | awk '