summaryrefslogtreecommitdiff
path: root/project/srcgen.mk
blob: 3f73ec5d99eea728c2b755f1ee94f78f9400610b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# srcgen.mk: rules for source-file generation.
# this file is covered by COPYING.BAUTOMAKE.

AM_AUTOM4TE             = autom4te
AM_AUTOCONF             = autoconf
AM_SHELL                = /bin/sh

M4_GEN_SRCS             = m4/amversion.m4
M4_CONFIGURE_INPUT      = Generated via variable substitution from $(subst $(SOURCE_DIR)/m4/,,$<).

M4_SUBST_RULES          = \
			-e 's!@configure_input@!$(M4_CONFIGURE_INPUT)!g' \
			-e 's!@VERSION@!$(AUTOMAKE_VER)!g'               \
			-e 's!@APIVERSION@!$(AUTOMAKE_VER)!g'

BIN_GEN_SRCS            = bin/aclocal-$(AUTOMAKE_VER) bin/automake-$(AUTOMAKE_VER)
BIN_CONFIGURE_INPUT     = Generated via variable substitution from $(subst $(SOURCE_DIR)/bin/,,$<).

BIN_SUBST_RULES         = \
			-e 's!@configure_input@!$(BIN_CONFIGURE_INPUT)!g' \
			-e 's!@PACKAGE@!$(PACKAGE)!g'                     \
			-e 's!@VERSION@!$(AUTOMAKE_VER)!g'                \
			-e 's!@APIVERSION@!$(AUTOMAKE_VER)!g'             \
			-e 's!@RELEASE_YEAR@!$(AUTOMAKE_YEAR)!g'          \
			-e 's!@PACKAGE_BUGREPORT@!$(PKGBUGS)!g'           \
			-e 's!@PACKAGE_URL@!$(PKGHOME)!g'                 \
			-e 's!@PERL@!$(HOST_PERL)!g'                      \
			-e 's!@SHELL@!$(AM_SHELL)!g'                      \
			-e 's!@am_AUTOCONF@!$(AM_AUTOCONF)!g'             \
			-e 's!@am_AUTOM4TE@!$(AM_AUTOM4TE)!g'             \
			-e 's!@datadir@!$(DATADIR)!g'

SRCINFO_SUBST_RULES     = \
			-e 's!@program@!$(PROGRAM)!g'                     \
			-e 's!@srcsite@!$(SRCSITE)!g'                     \
			-e 's!@package@!$(PACKAGE)!g'                     \
			-e 's,@pgprkey@,$(PGPRKEY),g'                     \
			-e 's,@pgpskey@,$(PGPSKEY),g'                     \
			-e 's!@pkgver@!$(AUTOMAKE_VER)!g'                 \
			-e 's!@srcball_sha256@!$(SRCBALL_SHA256)!g'


LIB_GEN_SRCS            = lib/Automake/Config.pm
LIB_CONFIGURE_INPUT     = Generated via variable substitution from $(subst $(SOURCE_DIR)/lib/Automake/,,$<).
LIB_SUBST_RULES         = \
			-e 's!@configure_input@!$(LIB_CONFIGURE_INPUT)!g' \
			$(BIN_SUBST_RULES)

MAN_GEN_SRCS            = man/aclocal.1  man/aclocal-$(AUTOMAKE_VER).1 \
			  man/automake.1 man/automake-$(AUTOMAKE_VER).1

ALL_GEN_SRCS            = $(M4_GEN_SRCS) $(BIN_GEN_SRCS) $(LIB_GEN_SRCS) $(MAN_GEN_SRCS)

m4/amversion.m4: $(SOURCE_DIR)/m4/amversion.in tree.tag
	sed $(M4_SUBST_RULES) $< > $@

bin/aclocal-$(AUTOMAKE_VER): PROGRAM=aclocal
bin/aclocal-$(AUTOMAKE_VER): $(SOURCE_DIR)/bin/aclocal.in tree.tag
	sed -e '/$$PACKAGE) $$VERSION/,$$d' $(BIN_SUBST_RULES) \
		$< > $@.tmp                                     \
	&& sed $(SRCINFO_SUBST_RULES)                            \
		$(SRCINFO) >> $@.tmp                              \
	&& sed -e '/$$PACKAGE) $$VERSION/p'                        \
		-e '1,/$$PACKAGE) $$VERSION/d' $(BIN_SUBST_RULES)   \
		$< >> $@.tmp                                         \
	&& chmod +x $@.tmp                                            \
	&& mv $@.tmp $@

bin/automake-$(AUTOMAKE_VER): PROGRAM=automake
bin/automake-$(AUTOMAKE_VER): $(SOURCE_DIR)/bin/automake.in tree.tag
	sed -e '/$$PACKAGE) $$VERSION/,$$d' $(BIN_SUBST_RULES) \
		$< > $@.tmp                                     \
	&& sed $(SRCINFO_SUBST_RULES)                            \
		$(SRCINFO) >> $@.tmp                              \
	&& sed -e '/$$PACKAGE) $$VERSION/p'                        \
		-e '1,/$$PACKAGE) $$VERSION/d' $(BIN_SUBST_RULES)   \
		$< >> $@.tmp                                         \
	&& chmod +x $@.tmp                                            \
	&& mv $@.tmp $@

lib/Automake/Config.pm: $(SOURCE_DIR)/lib/Automake/Config.in tree.tag
	sed $(LIB_SUBST_RULES) $< > $@

man/aclocal.1: tree.tag
	printf '.so man1/aclocal-%s.1\n' $(AUTOMAKE_VER) > $@

man/automake.1: tree.tag
	printf '.so man1/automake-%s.1\n' $(AUTOMAKE_VER) > $@

man/aclocal-$(AUTOMAKE_VER).1:	$(BIN_GEN_SRCS) $(LIB_GEN_SRCS) tree.tag
	PERL5LIB=$(SOURCE_DIR)/lib:./lib PATH=./bin:$(PATH) \
	perl $(SOURCE_DIR)/doc/help2man --output=$@ aclocal-$(AUTOMAKE_VER)

man/automake-$(AUTOMAKE_VER).1:	$(BIN_GEN_SRCS) $(LIB_GEN_SRCS) tree.tag
	PERL5LIB=$(SOURCE_DIR)/lib:./lib PATH=./bin/:$(PATH) \
	perl $(SOURCE_DIR)/doc/help2man --output=$@ automake-$(AUTOMAKE_VER)

srcgen: $(ALL_GEN_SRCS)

srcgen-clean:
	rm -f $(ALL_GEN_SRCS)

all:	srcgen

clean:	srcgen-clean

.PHONY:	srcgen srcgen-clean