source: BLFS/Makefile@ 4ed4a32

ablfs-more legacy trunk
Last change on this file since 4ed4a32 was 4ed4a32, checked in by Pierre Labastie <pierre.labastie@…>, 4 years ago

Allow using any branch/tag in BLFS Makefile

Still WIP because of the *_TREE names

  • Property mode set to 100644
File size: 7.0 KB
Line 
1# From the Build Scripts Written By: Jim Gifford <lfs@jg555.com>
2# Modified By: Joe Ciccone <jciccone@linuxfromscratch.org>
3# Additional changes: George Boudreau <georgeb@linuxfromscratch.org>
4# Pierre Labastie <pierre.labastie at neuf.fr>
5
6# $Id$
7
8ifdef V
9 Q =
10else
11 Q = @
12endif
13
14# Makefile should reside in a directory where there are two subdirectories
15# initially:
16TOPDIR = $(shell pwd)
17# the stylesheets
18XSLDIR = $(TOPDIR)/xsl
19# the menu program sources
20MENU = $(TOPDIR)/menu
21
22# Those directories and files will be created and populated by make:
23# directory of the book sources:
24LFS_XML = $(TOPDIR)/lfs-xml
25BLFS_XML = $(TOPDIR)/blfs-xml
26# contains the REV used in the preceding call:
27REVFILE = $(TOPDIR)/revision
28# the list of packages:
29PACK_LIST = $(TOPDIR)/packages.xml
30# the generated menu input:
31CONFIG_CONFIG_IN = $(TOPDIR)/Config.in
32# menu output:
33CONFIG_OUT = $(TOPDIR)/configuration
34# the linear book:
35BOOK_XML = $(TOPDIR)/book.xml
36
37LFSTMP = $(LFS_XML)/tmp
38RENDERTMP = $(BLFS_XML)/tmp
39LFS_FULL = $(LFSTMP)/lfs-full.xml
40BLFS_FULL = $(RENDERTMP)/blfs-full.xml
41
42# The right-hand side is updated by jhalfs:
43# Where the tracking file resides:
44TRACKING_DIR = tracking-dir
45
46# Will be created by make, if not existent
47TRACKFILE = $(TRACKING_DIR)/instpkg.xml
48
49# Initial content of the tracking file
50define INITIAL_TRACK
51<?xml version="1.0" encoding="ISO-8859-1"?>\n\
52\n\
53<!DOCTYPE sublist SYSTEM "$(TOPDIR)/packdesc.dtd">\n\
54<sublist>\n\
55 <name>Installed</name>\n\
56</sublist>
57endef
58
59# Git locations and branches
60LFS-GIT = git://git.linuxfromscratch.org/lfs.git
61LFS-BRANCH = trunk
62GIT = git://git.linuxfromscratch.org/blfs.git
63BLFS-BRANCH = trunk
64
65ALLXML := $(filter-out $(RENDERTMP)/%, \
66 $(shell if [ -d $(BLFS_XML) ]; then \
67 find $(BLFS_XML) -name \*.xml; \
68 fi))
69ALLXMLLFS:= $(filter-out $(LFSTMP)/%, \
70 $(shell if [ -d $(LFS_XML) ]; then \
71 find $(LFS_XML) -name \*.xml; \
72 fi))
73ALLXSL := $(filter-out $(RENDERTMP)/%, \
74 $(shell if [ -d $(BLFS_XML) ]; then \
75 find $(BLFS_XML) -name \*.xsl; \
76 fi))
77ALLXSLLFS := $(filter-out $(LFSTMP)/%, \
78 $(shell if [ -d $(LFS_XML) ]; then \
79 find $(LFS_XML) -name \*.xsl; \
80 fi))
81
82# Try to set the REV variable according to previous runs, except when
83# set on the command line:
84REV1 := $(shell if [ -f $(REVFILE) ] ; then cat $(REVFILE); fi)
85ifneq ($(origin REV),command line)
86 ifdef REV1
87 REV = $(REV1)
88 else
89 REV = not defined
90 endif
91endif
92
93ifneq ($(REV),sysv)
94 ifneq ($(REV),systemd)
95 $(error The REV variable is $(REV), but can only be 'sysv' or 'systemd')
96 endif
97endif
98
99$(BOOK_XML): $(CONFIG_OUT)
100 $(Q)$(TOPDIR)/gen_pkg_book.sh $(TOPDIR) $(BLFS_FULL) $(LFS_FULL)
101
102$(CONFIG_OUT): $(CONFIG_CONFIG_IN)
103 $(Q)CONFIG_="" KCONFIG_CONFIG=configuration \
104 python3 $(MENU)/menuconfig.py $(CONFIG_CONFIG_IN)
105
106$(CONFIG_CONFIG_IN): $(PACK_LIST) $(XSLDIR)/gen_config.xsl
107 $(Q)xsltproc --nonet -o $@ $(XSLDIR)/gen_config.xsl $(PACK_LIST)
108
109$(PACK_LIST): $(XSLDIR)/gen_pkg_list.xsl $(XSLDIR)/specialCases.xsl $(TRACKFILE) $(LFS_FULL)
110 $(Q)xsltproc --stringparam installed-packages $(TRACKFILE) \
111 --stringparam lfs-full $(LFS_FULL) \
112 -o $@.tmp $(XSLDIR)/gen_pkg_list.xsl $(BLFS_FULL)
113 $(Q)xmllint --postvalid --format -o $@ $@.tmp
114 $(Q)rm $@.tmp
115
116# Beware of the echo '$(INITIAL_TRACK)' command below:
117# if shell is bash or sh linked to bash, needs echo -e
118# if shell is dash or sh linked to dash: echo is enough
119# Don't ask me why
120# So use /bin/echo (needs -e)
121$(TRACKFILE): $(TRACKING_DIR)
122 $(Q)if ! [ -f $@ ]; then \
123 echo Initializing $(TRACKFILE) && \
124 /bin/echo -e '$(INITIAL_TRACK)' > $@; \
125 fi
126 $(Q)for track in $(TRACKING_DIR)/*-*; do \
127 if [ -f $$track ]; then \
128 pack=$$(echo $$track | sed 's@.*/\(.*\)-[0-9c].*@\1@') && \
129 version=$$(echo $$track | sed 's@.*-\([0-9c].*\)@\1@') && \
130 xsltproc --stringparam packages $(PACK_LIST) \
131 --stringparam package $$pack \
132 --stringparam version $$version \
133 -o track.tmp $(XSLDIR)/bump.xsl $@ && \
134 sed -i 's@PACKDESC@$(TOPDIR)/packdesc.dtd@' track.tmp && \
135 xmllint --format --postvalid track.tmp > $@; \
136 fi; \
137 rm -f $$track; \
138 done; \
139 rm -f track.tmp
140
141$(TRACKING_DIR):
142 @echo Creating $(TRACKING_DIR)
143 $(Q)mkdir -p $@
144
145$(XSLDIR)/specialCases.xsl: $(TOPDIR)/gen-special.sh $(BLFS_FULL)
146 $(Q)$(TOPDIR)/gen-special.sh $(BLFS_FULL) $@
147
148ifneq ($(REV),$(REV1))
149$(BLFS_FULL): FORCE
150$(LFS_FULL): FORCE
151endif
152$(LFS_FULL): $(LFS_XML) $(LFS_XML)/general.ent $(ALLXMLLFS) $(ALLXSLLFS)
153 @echo "Processing LFS bootscripts..."
154 $(Q)cd $(LFS_XML) && bash process-scripts.sh
155 $(Q)[ -d $(LFSTMP) ] || mkdir -p $(LFSTMP)
156 @echo "Adjusting LFS for revision $(REV)..."
157 $(Q)xsltproc --nonet --xinclude \
158 --stringparam profile.revision $(REV) \
159 --output $(LFSTMP)/lfs-prof.xml \
160 $(LFS_XML)/stylesheets/lfs-xsl/profile.xsl \
161 $(LFS_XML)/index.xml
162 @echo "Validating the LFS book..."
163 $(Q)xmllint --nonet --noent --postvalid \
164 -o $@ $(LFSTMP)/lfs-prof.xml
165 $(Q)rm -f $(LFS_XML)/appendices/*.script
166 $(Q)cd $(LFS_XML) && ./aux-file-data.sh $@
167 $(Q)echo $(REV) > $(REVFILE)
168
169$(BLFS_FULL): $(BLFS_XML) $(BLFS_XML)/general.ent $(ALLXML) $(ALLXSL)
170 $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
171 @echo "Adjusting BLFS for revision $(REV)..."
172 $(Q)xsltproc --nonet --xinclude \
173 --stringparam profile.revision $(REV) \
174 --output $(RENDERTMP)/blfs-prof.xml \
175 $(BLFS_XML)/stylesheets/lfs-xsl/profile.xsl \
176 $(BLFS_XML)/index.xml
177 @echo "Validating the BLFS book..."
178 $(Q)xmllint --nonet --noent --postvalid \
179 -o $@ $(RENDERTMP)/blfs-prof.xml
180 $(Q)echo $(REV) > $(REVFILE)
181
182all: update $(BOOK_XML)
183
184# If in detached head state, "git pull" returns an error, so switch back to
185# trunk before updating, and switch back to the branch/tag afterwards
186update: $(BLFS_XML) $(LFS_XML)
187 @echo Updating the book sources
188 $(Q)cd $(LFS_XML) && \
189 if [ $(LFS-BRANCH) != trunk ]; then git switch -; fi && \
190 git pull && \
191 git checkout $(LFS-BRANCH)
192 $(Q)cd $(BLFS_XML) && \
193 if [ $(BLFS-BRANCH) != trunk ]; then git switch -; fi && \
194 git pull && \
195 git checkout $(BLFS-BRANCH)
196
197$(LFS_XML):
198 @echo Getting the LFS book sources...
199 $(Q)git clone $(LFS-GIT) $@
200 if [ $(LFS-BRANCH) != trunk ]; then \
201 cd $@ && \
202 git checkout $(LFS-BRANCH); \
203 fi
204
205$(BLFS_XML):
206 @echo Getting the BLFS book sources...
207 $(Q)git clone $(GIT) $@
208 if [ $(BLFS-BRANCH) != trunk ]; then \
209 cd $@ && \
210 git checkout $(BLFS-BRANCH); \
211 fi
212
213# Clean up
214
215clean:
216 rm -f $(CONFIG_OUT) $(CONFIG_OUT).old $(TOPDIR)/packages.xml $(XSLDIR)/specialCases.xsl $(CONFIG_CONFIG_IN) book.xml
217 rm -rf $(TOPDIR)/dependencies $(TOPDIR)/book-html $(TOPDIR)/scripts
218
219FORCE:
220.PHONY: clean all update $(CONFIG_OUT) FORCE
Note: See TracBrowser for help on using the repository browser.