source: BLFS/Makefile@ 5c8df43

ablfs-more trunk
Last change on this file since 5c8df43 was 5c8df43, checked in by Pierre Labastie <pierre.labastie@…>, 22 months ago

Adapt BLFS/Makefile to the new book layout

With the change to python modules and the pythonhosted.xml file
becoming untracked, those changes allow creating/updating this
file.

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