chiark / gitweb /
subdirmk/regen.mk.in: Trim `$(srcdir)/' prefix from output makefile names
[subdirmk.git] / subdirmk / regen.mk.in
1 # subdirmk - rules for regenerating makefiles etc.
2 #  Copyright 2019 Mark Wooding
3 #  Copyright 2019 Ian Jackson
4 # SPDX-License-Identifier: LGPL-2.0-or-later
5
6 CONFIGURE       ?= configure
7 CONFIGURE_AC    ?= $(CONFIGURE).ac
8 CONFIG_STATUS   ?= config.status
9
10 CONFIGURE_ACS   += $(CONFIGURE_AC)
11 CONFIGURE_ACS   += subdirmk/subdirmk.ac
12
13 $(top_srcdir)/$(CONFIGURE): $(addprefix $(top_srcdir)/,$(CONFIGURE_ACS))
14         cd $(top_srcdir) && autoconf
15
16 $(CONFIG_STATUS): $(top_srcdir)/$(CONFIGURE)
17         ./$(CONFIG_STATUS) --recheck
18
19 MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.sd.mk
20 MAKEFILE_TEMPLATES += $(addprefix $(top_srcdir)/, $(addsuffix .in, \
21         @_SUBDIRMK_MAKEFILES@ \
22         ))
23
24 main.mk $(MAKEFILES): .makefiles.stamp ;
25 .makefiles.stamp:                                               \
26                 $(top_srcdir)/subdirmk/generate                 \
27                 $(CONFIG_STATUS)                                \
28                 $(MAKEFILE_TEMPLATES)
29 # This filtering arranges that we can often run config.status to
30 # generate only particular output files.  We look for *inputs* that
31 # have changed.  If the only inputs that have changed are ones that we
32 # know affect only one output (Subdir.mk.in and regen.mk.in), we pass
33 # config.status the corresponding output file names.  Otherwise we
34 # pass nothing and config.status does them all.  We need to mention
35 # regen.mk.in twice because if $(top_srcdir) is `.', make elides the
36 # directory part from $?.
37         ./$(CONFIG_STATUS) $(if                                 \
38                 $(filter-out Subdir.sd.mk %/Subdir.sd.mk        \
39                              %.mk.in                            \
40                         , $?),,                                 \
41                 $(patsubst $(top_srcdir)/%,%, $(sort            \
42                         $(patsubst %.sd.mk,%.mk,$(filter %.sd.mk,$?)) \
43                         $(patsubst %.mk.in,%.mk,$(filter %.mk.in,$?)))))
44         touch $@
45
46 realclean:: clean
47         $(RM) config.status config.log
48         $(RM) main.mk subdirmk/regen.mk $(MAKEFILES)
49         $(RM) $(addsuffix Makefile,$(dir $(MAKEFILES)))
50
51 -include $(ALL_DEPFILES)