From 8d746a1d7b875ae2118247d08e944f2fd7700e8a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 12 Nov 2019 17:34:03 +0000 Subject: [PATCH] WIP REORG --- Subdir.mk.in | 12 ------- build-aux/subdirmk.in | 34 ------------------- configure.ac | 24 +++---------- build-aux/subdirmk-setup => subdirmk/generate | 8 +++-- subdirmk/regen.mk.in | 17 ++++++++++ subdirmk/subdirmk.ac | 25 ++++++++++++++ 6 files changed, 51 insertions(+), 69 deletions(-) delete mode 100644 build-aux/subdirmk.in rename build-aux/subdirmk-setup => subdirmk/generate (97%) create mode 100644 subdirmk/regen.mk.in create mode 100644 subdirmk/subdirmk.ac diff --git a/Subdir.mk.in b/Subdir.mk.in index fa38d65..ef34280 100644 --- a/Subdir.mk.in +++ b/Subdir.mk.in @@ -22,15 +22,3 @@ COMPILE ?= $(CC) -c -o$@ -MD $(DEFS) $(INCLUDES) $(CFLAGS) %.o: %.c $(COMPILE) $< - -&^/configure: &^/configure.ac - cd &^ && autoconf - -config.status: &^/configure - ./config.status --recheck - -subdirs.mk $(MAKFILES): makefiles.phantom -.INTERMEDIATE: makefiles.phantom -makefiles.phantom: $(addprefix &^/,$(addsuffix .in,$(MAKEFILES))) \ - config.status &^/build-aux/subdirmk-setup - ./config.status diff --git a/build-aux/subdirmk.in b/build-aux/subdirmk.in deleted file mode 100644 index 5b8cfc6..0000000 --- a/build-aux/subdirmk.in +++ /dev/null @@ -1,34 +0,0 @@ -### -*-makefile-gmake-*- -### -### Stub subdirectory makefile -### -### (c) 2019 Mark Wooding -### - -###----- Licensing notice --------------------------------------------------- -### -### This program is free software; you can redistribute it and/or modify -### it under the terms of the GNU Library General Public License as -### published by the Free Software Foundation; either version 2 of the -### License, or (at your option) any later version. -### -### This program is distributed in the hope that it will be useful, -### but WITHOUT ANY WARRANTY; without even the implied warranty of -### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -### GNU Library General Public License for more details. -### -### You should have received a copy of the GNU Library General Public -### License along with this program; if not, write to the Free -### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -### MA 02111-1307, USA. - -SUBDIRS - -all: - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -top_builddir = @top_builddir@ - -subdir = $(patsubst $(top_srcdir)/%,%, $(srcdir)) -%:; $(MAKE) -C$(top_builddir) SUBDIR=$(subdir) $@ diff --git a/configure.ac b/configure.ac index e56fee9..acd7f47 100644 --- a/configure.ac +++ b/configure.ac @@ -32,26 +32,10 @@ AC_PROG_CC INCLUDES= AC_SUBST(INCLUDES) -m4_define([SUBDIRSMK_SUBDIRS], -[m4_map_args_w([$1],[_SUBDIRSMK_SUBDIR(],[/)])])dnl - -AC_CONFIG_FILES([subdirs.mk:subdirs.mk.tmp Subdir.mk:Subdir.mk.tmp],[], -[ -subdirsmk_need_prep=false -AS_IF([\$ac_need_defaults], -[subdirsmk_need_prep=true],[ -AS_CASE([" \$ac_config_targets "],[*" subdirs.mk "*], -[subdirsmk_need_prep=true])]) -AS_IF([\$subdirsmk_need_prep],[ - 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 - -SUBDIRSMK_SUBDIRS([lib lib/t src]) +m4_include([subdirmk/subdirmk.ac]) + +SUBDIRMK_SUBDIRS([lib]) +SUBDIRMK_SUBDIRS([lib/t src]) AC_OUTPUT diff --git a/build-aux/subdirmk-setup b/subdirmk/generate similarity index 97% rename from build-aux/subdirmk-setup rename to subdirmk/generate index e6e30e0..857e768 100755 --- a/build-aux/subdirmk-setup +++ b/subdirmk/generate @@ -3,8 +3,10 @@ # $(srcdir)/build-aux/subdirmk-setup SUBDIR... # # generates +# main.mk.tmp +# and in each subdirectory # Subdir.mk.tmp -# Makefile.tmp +# Makefile use strict; @@ -81,7 +83,7 @@ sub write_makefile ($$) { default: all \@: \$@ %: FORCE-ALWAYS-RUN - \$(MAKE) -C $cd -f subdirs.mk ${dir_prefix}\$@ + \$(MAKE) -C $cd -f main.mk ${dir_prefix}\$@ Makefile FORCE-ALWAYS-RUN: \@: \$@ .SUFFIXES: @@ -196,7 +198,7 @@ sub process_subtree ($$) { sub process_tree() { process_subtree($root, [ ]); - start_output_file("subdirs.mk.tmp"); + start_output_file("main.mk.tmp"); foreach my $v (qw(top_srcdir abs_top_srcdir)) { o "$v=\@$v@\n"; } diff --git a/subdirmk/regen.mk.in b/subdirmk/regen.mk.in new file mode 100644 index 0000000..0e8bb6a --- /dev/null +++ b/subdirmk/regen.mk.in @@ -0,0 +1,17 @@ + +CONFIGURE ?= configure +CONFIGURE_AC ?= $(CONFIGURE).ac +CONFIG_STATUS ?= config.status +SUBDIRMK ?= subdirmk + +&^/$(CONFIGURE): &^/$(CONFIGURE_AC) + cd &^ && autoconf + +$(CONFIG_STATUS): &^/$(CONFIGURE) + ./$(CONFIG_STATUS) --recheck + +all-subdirs.mk $(MAKFILES): makefiles.phantom +.INTERMEDIATE: makefiles.phantom +makefiles.phantom: $(addprefix &^/,$(addsuffix .in,$(MAKEFILES))) \ + $(CONFIG_STATUS) &^/$(SUBDIRMK)/generate + ./$(CONFIG_STATUS) diff --git a/subdirmk/subdirmk.ac b/subdirmk/subdirmk.ac new file mode 100644 index 0000000..43963df --- /dev/null +++ b/subdirmk/subdirmk.ac @@ -0,0 +1,25 @@ + +AC_DEFUN([SUBDIRMK_SUBDIRS], +[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],[],[ + subdirsmk_need_prep=false + AS_IF([\$ac_need_defaults],[ + subdirsmk_need_prep=true],[ + AS_CASE([" \$ac_config_targets "],[*" subdirs.mk "*],[ + subdirsmk_need_prep=true + ]) + ]) + AS_IF([\$subdirsmk_need_prep],[ + echo 'running subdirmk/generate' + '$srcdir'/subdirmk/generate --srcdir '$srcdir' $subdirsmk_subdirs + ]) + ]) +]) + +AC_DEFUN([_SUBDIRMK_SUBDIR],[ + AC_REQUIRE([_SUBDIRMK_INIT]) + subdirsmk_subdirs="$subdirsmk_subdirs '$1'" + AC_CONFIG_FILES([$1Subdir.mk:$1Subdir.mk.tmp]) +]) -- 2.30.2