chiark / gitweb /
WIP
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 11 Nov 2019 00:55:16 +0000 (00:55 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 11 Nov 2019 00:55:16 +0000 (00:55 +0000)
Makefile.in
Perdir.mk.in [new file with mode: 0644]
Subdir.mk.in
build-aux/subdirmk-setup
configure.ac
lib/Subdir.mk.in

index d8d8def..f7c845b 100644 (file)
@@ -41,15 +41,6 @@ exec_prefix           = @exec_prefix@
 bindir                  = @bindir@
 
 ## Build options.
-CC                      = @CC@
-CFLAGS                  = @CFLAGS@
-DEFS                    = @DEFS@
-INCLUDES                = @INCLUDES@
-LD                      = @CC@
-LDFLAGS                         = @LDFLAGS@
-LIBS                    = @LIBS@
-
-INCLUDES               += -I$(srcdir)/lib/
 
 ###--------------------------------------------------------------------------
 ### Machinery.
@@ -83,18 +74,7 @@ V_AT                  = $(%V_AT.$V)
 %V_AT.0                         = @
 %V_AT.1                         =
 
-VPATH                   = $(srcdir)
-
-COMPILE                         = $(call v-tag,CC)$(CC) -c -o$@ -MD \
-                               $(DEFS) $(INCLUDES) $(CFLAGS)
-%.o: %.c
-       $(COMPILE) $<
-
-LINK                    = $(call v-tag,LD)$(LD) -o$@ \
-                               $(CFLAGS) $(LDFLAGS) $(LIBS)
 
-objects                         = $(addsuffix $(if $2,$2,.o), \
-                               $(basename $(filter %.c %.s %.S,$1)))
 
 ALL_DEPFILES           :=
 notice-objects          = $(eval ALL_DEPFILES += $$(patsubst %.o,%.d,$1))
diff --git a/Perdir.mk.in b/Perdir.mk.in
new file mode 100644 (file)
index 0000000..4e5bb31
--- /dev/null
@@ -0,0 +1,3 @@
+
+&DEPFILES += $(patsubst %.o,%.d,$(&OBJECTS))
+include $(&DEPFILES)
index 792d600..e29c332 100644 (file)
@@ -1 +1,25 @@
 #
+
+VPATH          = &^
+
+prefix         = @prefix@
+exec_prefix    = @exec_prefix@
+bindir         = @bindir@
+
+CC             ?= @CC@
+CFLAGS         ?= @CFLAGS@
+DEFS           ?= @DEFS@
+INCLUDES       ?= @INCLUDES@
+LD             ?= @CC@
+LDFLAGS                ?= @LDFLAGS@
+LIBS           ?= @LIBS@
+
+INCLUDES       += -I&^/lib/
+
+LINK           ?= $(LD) -o$@ $(CFLAGS) $(LDFLAGS)
+AR             ?= ar
+COMPILE                ?= $(CC) -c -o$@ -MD $(DEFS) $(INCLUDES) $(CFLAGS)
+
+%.o: %.c
+       $(COMPILE) $<
+
index 976e3ce..e08de6e 100755 (executable)
@@ -89,14 +89,15 @@ sub filter_subdir_mk ($$$$$) {
     #use Data::Dumper;
     #print STDERR "filter @_\n";
 
-    my $in = "${srcdir}/${dir_prefix}Subdir.mk.in";
-    open I, '<', $in or die "open $in: $!\n";
+    my $in = "${dir_prefix}Subdir.mk.in";
     my $caps_re = qr{[A-Z][0-9_A-Z]*(?=\W)};
     my $lc_re = qr{[a-z][-+,0-9_a-z]*(?=\W)};
     my $esclit = '&';
     my $esc = '\\&';
 
-    while (<I>) {
+    for my $f ($in, "Perdir.mk.in") {
+      open I, '<', $f or die "open $f: $!\n";
+      while (<I>) {
        for (;;) {
            unless (s{^(.*?)(\\)?(?=$esc)}{}) { o $_; last; }
            o $1;
@@ -138,6 +139,8 @@ sub filter_subdir_mk ($$$$$) {
                die "bad escape $esclit$_ ";
            }
        }
+      }
+      I->error and die "read $f: $!\n";
     }
 }
 
index a16380f..4557f95 100644 (file)
@@ -35,14 +35,13 @@ AC_SUBST(INCLUDES)
 m4_define([SUBDIRSMK_SUBDIRS],
 [m4_map_args_w([$1],[_SUBDIRSMK_SUBDIR(],[/)])])dnl
 
-AC_CONFIG_COMMANDS([subdirsmk],[],
-['$srcdir'/build-aux/subdirmk-setup --srcdir '$srcdir' $subdirsmk_subdirs])
+AC_CONFIG_FILES([subdirs.mk:subdirs.mk.tmp Subdir.mk:Subdir.mk.tmp],[],
+[echo 'running subdirmk-setup'
+'$srcdir'/build-aux/subdirmk-setup --srcdir '$srcdir' $subdirsmk_subdirs])
 
 m4_define([_SUBDIRSMK_SUBDIR],
 [subdirsmk_subdirs="$subdirsmk_subdirs '$1'"
 AC_CONFIG_FILES([$1Subdir.mk:$1Subdir.mk.tmp])])dnl
-dnl 
-dnl [AC_CONFIG_COMMANDS([$1Subdir.mk],)
 
 SUBDIRSMK_SUBDIRS([lib lib/t src])
 
index 6162e90..03d1359 100644 (file)
@@ -25,7 +25,7 @@
 
 &TARGETS       += & libtoy.a
 
-&OBJECTS       += & toylib.c
+&OBJECTS       += & toylib.o
 
 &libtoy.a:     $(&OBJECTS)
        $(AR) rc $@ $^