From: Ian Jackson Date: Wed, 13 Nov 2019 16:12:20 +0000 (+0000) Subject: change filenames X-Git-Tag: subdirmk/0.1~67 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=subdirmk.git;a=commitdiff_plain;h=7e1f352747ae8256f549becda8df9c9447ef1d5e change filenames --- diff --git a/Perdir.mk.in b/Perdir.mk.in deleted file mode 100644 index 2b08993..0000000 --- a/Perdir.mk.in +++ /dev/null @@ -1,3 +0,0 @@ - -&:include subdirmk/cdeps.mk.in -&:include subdirmk/clean.mk.in diff --git a/Perdir.sd.mk b/Perdir.sd.mk new file mode 100644 index 0000000..76a83a9 --- /dev/null +++ b/Perdir.sd.mk @@ -0,0 +1,3 @@ + +&:include subdirmk/cdeps.sd.mk +&:include subdirmk/clean.sd.mk diff --git a/Subdir.mk.in b/Subdir.sd.mk similarity index 61% rename from Subdir.mk.in rename to Subdir.sd.mk index e80ef52..4a8eec9 100644 --- a/Subdir.mk.in +++ b/Subdir.sd.mk @@ -1,5 +1,5 @@ INCLUDES += -I&^/lib/ -&:include subdirmk/usual.mk.in +include subdirmk/usual.mk include subdirmk/regen.mk diff --git a/lib/Subdir.mk.in b/lib/Subdir.sd.mk similarity index 100% rename from lib/Subdir.mk.in rename to lib/Subdir.sd.mk diff --git a/lib/t/Subdir.mk.in b/lib/t/Subdir.sd.mk similarity index 100% rename from lib/t/Subdir.mk.in rename to lib/t/Subdir.sd.mk diff --git a/src/Subdir.mk.in b/src/Subdir.sd.mk similarity index 100% rename from src/Subdir.mk.in rename to src/Subdir.sd.mk diff --git a/subdirmk/README b/subdirmk/README index 28cff6e..256fdbc 100644 --- a/subdirmk/README +++ b/subdirmk/README @@ -26,7 +26,7 @@ Basic approach -------------- The developer is expected to write a makefile fragment in each -relevant subdirectory called `Subdir.mk.in'. +relevant subdirectory called `Subdir.sd.mk'. These fragments may contain ordinary make language. @@ -34,11 +34,11 @@ However, the sigil & is treated specially. By and large, it refers to `the current directory'. There are a variety of convenient constructions. -The result is that to a large extent, the Subdir.mk.in has an easy way +The result is that to a large extent, the Subdir.sd.mk has an easy way to namespace its "local" make variables, and an easy way to refer to its "local" filenames. -The Subdir.mk.in's are filtered, fed through autoconf in the usual way +The Subdir.sd.mk's are filtered, fed through autoconf in the usual way (for @..@-substitutions) and included by one autogenerated toplevel makefile. @@ -50,7 +50,7 @@ Each subdirectory is also provided with an autogenerated `Makefile' which exists purely to capture ordinary make invocations and arrange for something suitable to happen. -Where there are dependencies between subdirectories, each Subdir.mk.in +Where there are dependencies between subdirectories, each Subdir.sd.mk can simply refer to files in other subdirectories directly. Invocation, "recursive" per-directory targets @@ -66,7 +66,7 @@ But `foo' can also be a conventional target like `all'. Each subdirectory has its own `all' target. For example a subdirectory `src' has a target `src/all'. The rules for these are automatically generated from the settings of the per-directory -&TARGETS variables. (In src/Subdir.mk.in, this of course refers to a +&TARGETS variables. (In src/Subdir.sd.mk, this of course refers to a make variable called src_TARGETS.) The `all' target in a parent directory is taken to imply the `all' @@ -86,24 +86,42 @@ Unlike `all', these other targets only exist in areas of the project where at least something mentions them. So for example, if &TARGETS_zonk is mentioned in src but not lib, `make zonk' in lib will fail. If you want to make a target exist everywhere, -mention its name in Perdir.mk.in (see below). +mention its name in Perdir.sd.mk (see below). -Perdir.mk.in, inclusion +Perdir.sd.mk, inclusion ----------------------- -The file Perdir.mk.in in the toplevel of fthe source is automatically -processed after each individual directory's Subdir.mk.in, and the +The file Perdir.sd.mk in the toplevel of fthe source is automatically +processed after each individual directory's Subdir.sd.mk, and the &-substituted contents therefore appear once for each subdirectory. This lets you do per-directory boilerplate. Some useful boilerplate is already provided in subdirmk, for you to reference like this: - &:include subdirmk/cdeps.mk.in - &:include subdirmk/clean.mk.in + &:include subdirmk/cdeps.sd.mk + &:include subdirmk/clean.sd.mk +(for example in Perdir.sd.mk). -Note that you must use &:include, which is an include processed during -the generation of the per-directory Subdir.mk files. That ensures -that the contents of these files is replicated, with appropriate -per-directory substitutions, for each directory. +Subdirectory templates `.sd.mk' vs plain autoconf templates `.mk.in' +-------------------------------------------------------------------- + +There are two kinds of template files. + + Filename .sd.mk .mk.in + + Processed by &-substitution, autoconf only + then autoconf + + Need to be mentioned No, but Subdir.sd.mk All not in subdirmk/ + in configure.ac via SUBDIRMK_SUBDIRS via SUBDIRMK_MAKEFILES + + How to include `&:include foo.sd.mk' `include foo.mk' + in all relevant .sd.mk in only one + (but not needed for Subdir.sd.mk + Subdir and Perdir) + +If you `include subdirmk/regen.mk', dependency management and +automatic regeneration for all of this template substitution, and for +config.status etc. is done for you. Global definitions ------------------ diff --git a/subdirmk/clean.mk.in b/subdirmk/clean.sd.mk similarity index 100% rename from subdirmk/clean.mk.in rename to subdirmk/clean.sd.mk diff --git a/subdirmk/generate b/subdirmk/generate index 55323d2..4b303bb 100755 --- a/subdirmk/generate +++ b/subdirmk/generate @@ -3,10 +3,10 @@ # $(srcdir)/subdirmk/generate [--srcdir=SRCDIR] [--] SUBDIR... # # generates in each subdirectory from in each subdirectory -# Subdir.mk.tmp Subdir.mk.in +# Subdir.mk.tmp Subdir.sd.mk # Makefile # and in toplevel and in toplevel -# main.mk.tmp Perdir.mk.in +# main.mk.tmp Perdir.sd.mk use strict; use POSIX; @@ -124,6 +124,8 @@ sub process_input_mk ($$$$$$$$) { die "open $f: $!\n" unless $!==ENOENT && $enoent_ok; return; } + o "MAKEFILE_TEMPLATES += $f\n"; + while (<$input>) { if (s#^\s*$esc\:##) { $buffering_output=''; @@ -173,7 +175,6 @@ sub process_input_mk ($$$$$$$$) { $buffering_output=undef; if (m#^(-?)include\s+(\S+)\s+$#) { my $subf = "$srcdir/$2"; - o "MAKEFILE_TEMPLATES += $subf\n"; process_input_mk($dir_prefix, $dir_suffix, $dir_name, $var_prefix, $targets, $subf, $esclitr, $subf); @@ -202,8 +203,8 @@ sub filter_subdir_mk ($$$$$) { $var_prefix, $targets, "${srcdir}/$f", \$esclit, $enoentok); }; - $pi->("${dir_prefix}Subdir.mk.in", 0); - $pi->("Perdir.mk.in", 1); + $pi->("${dir_prefix}Subdir.sd.mk", 0); + $pi->("Perdir.sd.mk", 1); } sub process_subtree ($$); diff --git a/subdirmk/regen.mk.in b/subdirmk/regen.mk.in index b8e031f..eb54fc3 100644 --- a/subdirmk/regen.mk.in +++ b/subdirmk/regen.mk.in @@ -12,16 +12,16 @@ $(top_srcdir)/$(CONFIGURE): $(addprefix $(top_srcdir)/,$(CONFIGURE_ACS)) $(CONFIG_STATUS): $(top_srcdir)/$(CONFIGURE) ./$(CONFIG_STATUS) --recheck -MAKEFILES += subdirmk/regen.mk - -MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.mk.in +MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.sd.mk +MAKEFILE_TEMPLATES += $(addprefix $(top_srcdir)/, $(addsuffix .in, \ + @_SUBDIRMK_MAKEFILES@ \ + )) main.mk $(MAKEFILES): .makefiles.stamp ; .makefiles.stamp: \ $(top_srcdir)/subdirmk/generate \ $(CONFIG_STATUS) \ - $(MAKEFILE_TEMPLATES) \ - $(foreach m,$(MAKEFILES),$(top_srcdir)/$(m).in) + $(MAKEFILE_TEMPLATES) # This filtering arranges that we can often run config.status to # generate only particular output files. We look for *inputs* that # have changed. If the only inputs that have changed are ones that we @@ -31,11 +31,12 @@ main.mk $(MAKEFILES): .makefiles.stamp ; # regen.mk.in twice because if $(top_srcdir) is `.', make elides the # directory part from $?. ./$(CONFIG_STATUS) $(if \ - $(filter-out Subdir.mk.in %/Subdir.mk.in \ - subdirmk/regen.mk.in \ - $(top_srcdir)/subdirmk/regen.mk.in \ + $(filter-out Subdir.sd.mk %/Subdir.sd.mk \ + %.mk.in \ , $?),, \ - $(sort $(patsubst %.mk.in,%.mk,$(filter %.mk.in,$?)))) + $(sort \ + $(patsubst %.sd.mk,%.mk,$(filter %.sd.mk,$?)) \ + $(patsubst %.mk.in,%.mk,$(filter %.mk.in,$?)))) touch $@ realclean:: clean diff --git a/subdirmk/subdirmk.ac b/subdirmk/subdirmk.ac index aebde16..e8150f4 100644 --- a/subdirmk/subdirmk.ac +++ b/subdirmk/subdirmk.ac @@ -1,19 +1,31 @@ +_SUBDIRMK_MAKEFILES="" +AC_SUBST([_SUBDIRMK_MAKEFILES]) + AC_DEFUN([SUBDIRMK_SUBDIRS], -[m4_map_args_w([$1],[_SUBDIRMK_SUBDIR(],[/)])])dnl +[_SUBDIRMK_INIT +m4_map_args_w([$1],[_SUBDIRMK_SUBDIR(],[/)])])dnl AC_DEFUN_ONCE([_SUBDIRMK_INIT],[ AC_CONFIG_FILES([ main.mk:main.mk.tmp Subdir.mk:Subdir.mk.tmp - subdirmk/regen.mk ],[],[ - '$srcdir'/subdirmk/generate --srcdir='$srcdir' $subdirsmk_subdirs + '$srcdir'/subdirmk/generate --srcdir='$srcdir' $subdirmk_subdirs ]) + SUBDIRMK_MAKEFILES([subdirmk/regen.mk subdirmk/usual.mk]) ]) AC_DEFUN([_SUBDIRMK_SUBDIR],[ - AC_REQUIRE([_SUBDIRMK_INIT]) - subdirsmk_subdirs="$subdirsmk_subdirs '$1'" + subdirmk_subdirs="$subdirmk_subdirs '$1'" AC_CONFIG_FILES([$1Subdir.mk:$1Subdir.mk.tmp]) ]) + +AC_DEFUN([SUBDIRMK_MAKEFILES], +[_SUBDIRMK_INIT +m4_map_args_w([$1],[_SUBDIRMK_MAKEFILE(],[)])])dnl + +AC_DEFUN([_SUBDIRMK_MAKEFILE],[ + _SUBDIRMK_MAKEFILES="$_SUBDIRMK_MAKEFILES $1" + AC_CONFIG_FILES([$1:$1.in]) +])