chiark / gitweb /
subdirmk: Make \& work (!)
[secnet.git] / subdirmk / generate
index 0ad0eb8c930da8832fedaa6b9459cf4a19189b83..14e18c0899a58c2a729d4e06bc398c4adbe1ba24 100755 (executable)
@@ -8,7 +8,7 @@
 #
 # generates in each subdirectory       from in each subdirectory
 #     Subdir.mk.tmp                        Subdir.sd.mk
-#     Makefile
+#     Makefile                          and included files
 # and in toplevel                      and in toplevel
 #     main.mk.tmp                          Perdir.sd.mk
 
@@ -102,8 +102,9 @@ default: all
 %:     FORCE-ALWAYS-RUN
        \@:
 Makefile FORCE-ALWAYS-RUN:
-       \$(MAKE) -C $cd -f main.mk \$(addprefix ${dir_prefix},\$(MAKECMDGOALS))
+       \$(MAKE) -C $cd -f main.mk \$(addprefix ${dir_prefix},\$(or \$(MAKECMDGOALS),all))
 .SUFFIXES:
+.PHONY:        FORCE-ALWAYS-RUN
 END
 }
 
@@ -137,7 +138,7 @@ sub process_input_mk ($$$$$$$$) {
        for (;;) {
            unless (s{^(.*?)(\\)?(?=$esc)}{}) { o $_; last; }
            o $1;
-           if ($2) { o $$esclitr; next; }
+           if ($2) { s#^$esc##; o $$esclitr; next; }
            s{^$esc}{} or die "$_ ?";
            if (s{^$esc}{}) { o "$$esclitr$$esclitr" }
            elsif (s{^TARGETS(?:_([0-9a-zA-Z_]+))?(?=\W)}{}) {
@@ -164,6 +165,8 @@ sub process_input_mk ($$$$$$$$) {
                s{(?<=[ \t])(?=\S)(?!\\\s*$)}{$prefix}g;
                o $_;
                $_ = $after;
+           } elsif (s{^\#}{}) {
+               $_ = '';
            } elsif (s{^![ \t]+}{}) {
                o $_;
                $_ = '';
@@ -251,7 +254,7 @@ sub process_subtree ($$) {
        }
        print O "\n";
     }
-    
+
     return @targets;
 }