[f4ed135] | 1 | # From the Build Scripts Written By: Jim Gifford <lfs@jg555.com>
|
---|
[e415656] | 2 | # Modified By: Joe Ciccone <jciccone@linuxfromscratch.org>
|
---|
[f4ed135] | 3 | # Additional changes: George Boudreau <georgeb@linuxfromscratch.org>
|
---|
[e576789] | 4 | # Pierre Labastie <pierre.labastie at neuf.fr>
|
---|
[f4ed135] | 5 |
|
---|
[e576789] | 6 | ifdef V
|
---|
| 7 | Q =
|
---|
| 8 | else
|
---|
| 9 | Q = @
|
---|
| 10 | endif
|
---|
| 11 |
|
---|
[84440e6] | 12 | # Makefile should reside in a directory where there are two subdirectories
|
---|
| 13 | # initially:
|
---|
| 14 | TOPDIR = $(shell pwd)
|
---|
| 15 | # the stylesheets
|
---|
| 16 | XSLDIR = $(TOPDIR)/xsl
|
---|
| 17 | # the menu program sources
|
---|
| 18 | MENU = $(TOPDIR)/menu
|
---|
| 19 |
|
---|
| 20 | # Those directories and files will be created and populated by make:
|
---|
| 21 | # directory of the book sources:
|
---|
[506120ee] | 22 | LFS_XML = $(TOPDIR)/lfs-xml
|
---|
[84440e6] | 23 | BLFS_XML = $(TOPDIR)/blfs-xml
|
---|
| 24 | # contains the REV used in the preceding call:
|
---|
| 25 | REVFILE = $(TOPDIR)/revision
|
---|
| 26 | # the list of packages:
|
---|
| 27 | PACK_LIST = $(TOPDIR)/packages.xml
|
---|
| 28 | # the generated menu input:
|
---|
[e576789] | 29 | CONFIG_CONFIG_IN = $(TOPDIR)/Config.in
|
---|
[84440e6] | 30 | # menu output:
|
---|
| 31 | CONFIG_OUT = $(TOPDIR)/configuration
|
---|
| 32 | # the linear book:
|
---|
| 33 | BOOK_XML = $(TOPDIR)/book.xml
|
---|
| 34 |
|
---|
[506120ee] | 35 | LFSTMP = $(LFS_XML)/tmp
|
---|
[84440e6] | 36 | RENDERTMP = $(BLFS_XML)/tmp
|
---|
[506120ee] | 37 | LFS_FULL = $(LFSTMP)/lfs-full.xml
|
---|
[84440e6] | 38 | BLFS_FULL = $(RENDERTMP)/blfs-full.xml
|
---|
| 39 |
|
---|
| 40 | # The right-hand side is updated by jhalfs:
|
---|
| 41 | # Where the tracking file resides:
|
---|
| 42 | TRACKING_DIR = tracking-dir
|
---|
| 43 |
|
---|
| 44 | # Will be created by make, if not existent
|
---|
| 45 | TRACKFILE = $(TRACKING_DIR)/instpkg.xml
|
---|
[e576789] | 46 |
|
---|
[84440e6] | 47 | # Initial content of the tracking file
|
---|
[e576789] | 48 | define 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>
|
---|
| 55 | endef
|
---|
| 56 |
|
---|
[4ed4a32] | 57 | # Git locations and branches
|
---|
[875366f] | 58 | LFS-GIT = https://git.linuxfromscratch.org/lfs.git
|
---|
[4ed4a32] | 59 | LFS-BRANCH = trunk
|
---|
[875366f] | 60 | GIT = https://git.linuxfromscratch.org/blfs.git
|
---|
[4ed4a32] | 61 | BLFS-BRANCH = trunk
|
---|
[e576789] | 62 |
|
---|
[5c8df43] | 63 | # Name of a file that is not tracked by git in BLFS_XML
|
---|
| 64 | # but has to be updated
|
---|
| 65 | PYHOSTED = general/prog/python-dependencies/pythonhosted.xml
|
---|
| 66 |
|
---|
[e576789] | 67 | ALLXML := $(filter-out $(RENDERTMP)/%, \
|
---|
[5c8df43] | 68 | $(filter-out $(BLFS_XML)/$(PYHOSTED), \
|
---|
[84440e6] | 69 | $(shell if [ -d $(BLFS_XML) ]; then \
|
---|
| 70 | find $(BLFS_XML) -name \*.xml; \
|
---|
[5c8df43] | 71 | fi)))
|
---|
[506120ee] | 72 | ALLXMLLFS:= $(filter-out $(LFSTMP)/%, \
|
---|
| 73 | $(shell if [ -d $(LFS_XML) ]; then \
|
---|
| 74 | find $(LFS_XML) -name \*.xml; \
|
---|
| 75 | fi))
|
---|
[e576789] | 76 | ALLXSL := $(filter-out $(RENDERTMP)/%, \
|
---|
[84440e6] | 77 | $(shell if [ -d $(BLFS_XML) ]; then \
|
---|
| 78 | find $(BLFS_XML) -name \*.xsl; \
|
---|
| 79 | fi))
|
---|
[506120ee] | 80 | ALLXSLLFS := $(filter-out $(LFSTMP)/%, \
|
---|
| 81 | $(shell if [ -d $(LFS_XML) ]; then \
|
---|
| 82 | find $(LFS_XML) -name \*.xsl; \
|
---|
| 83 | fi))
|
---|
[84440e6] | 84 |
|
---|
| 85 | # Try to set the REV variable according to previous runs, except when
|
---|
| 86 | # set on the command line:
|
---|
| 87 | REV1 := $(shell if [ -f $(REVFILE) ] ; then cat $(REVFILE); fi)
|
---|
| 88 | ifneq ($(origin REV),command line)
|
---|
| 89 | ifdef REV1
|
---|
| 90 | REV = $(REV1)
|
---|
| 91 | else
|
---|
| 92 | REV = not defined
|
---|
| 93 | endif
|
---|
| 94 | endif
|
---|
| 95 |
|
---|
| 96 | ifneq ($(REV),sysv)
|
---|
| 97 | ifneq ($(REV),systemd)
|
---|
| 98 | $(error The REV variable is $(REV), but can only be 'sysv' or 'systemd')
|
---|
| 99 | endif
|
---|
| 100 | endif
|
---|
[e576789] | 101 |
|
---|
| 102 | $(BOOK_XML): $(CONFIG_OUT)
|
---|
[b8e5cad] | 103 | $(Q)$(TOPDIR)/gen_pkg_book.sh $(TRACKFILE) $(TOPDIR) $(BLFS_FULL) $(LFS_FULL)
|
---|
[f4ed135] | 104 |
|
---|
[f596dde] | 105 | $(CONFIG_OUT): $(CONFIG_CONFIG_IN)
|
---|
| 106 | $(Q)CONFIG_="" KCONFIG_CONFIG=configuration \
|
---|
[a4af6811] | 107 | python3 $(MENU)/menuconfig.py $(CONFIG_CONFIG_IN)
|
---|
[f4ed135] | 108 |
|
---|
[e576789] | 109 | $(CONFIG_CONFIG_IN): $(PACK_LIST) $(XSLDIR)/gen_config.xsl
|
---|
| 110 | $(Q)xsltproc --nonet -o $@ $(XSLDIR)/gen_config.xsl $(PACK_LIST)
|
---|
[f4ed135] | 111 |
|
---|
[506120ee] | 112 | $(PACK_LIST): $(XSLDIR)/gen_pkg_list.xsl $(XSLDIR)/specialCases.xsl $(TRACKFILE) $(LFS_FULL)
|
---|
[e576789] | 113 | $(Q)xsltproc --stringparam installed-packages $(TRACKFILE) \
|
---|
[506120ee] | 114 | --stringparam lfs-full $(LFS_FULL) \
|
---|
[e576789] | 115 | -o $@.tmp $(XSLDIR)/gen_pkg_list.xsl $(BLFS_FULL)
|
---|
| 116 | $(Q)xmllint --postvalid --format -o $@ $@.tmp
|
---|
| 117 | $(Q)rm $@.tmp
|
---|
[f4ed135] | 118 |
|
---|
[e576789] | 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) && \
|
---|
[e415656] | 127 | /bin/echo -e '$(INITIAL_TRACK)' > $@; \
|
---|
[e576789] | 128 | fi
|
---|
| 129 | $(Q)for track in $(TRACKING_DIR)/*-*; do \
|
---|
[e415656] | 130 | if [ -f $$track ]; then \
|
---|
[e576789] | 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 > $@; \
|
---|
[e415656] | 139 | fi; \
|
---|
| 140 | rm -f $$track; \
|
---|
[e576789] | 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 |
|
---|
[84440e6] | 151 | ifneq ($(REV),$(REV1))
|
---|
| 152 | $(BLFS_FULL): FORCE
|
---|
[506120ee] | 153 | $(LFS_FULL): FORCE
|
---|
[84440e6] | 154 | endif
|
---|
[f756851] | 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
|
---|
[506120ee] | 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 |
|
---|
[f756851] | 176 | $(BLFS_FULL): $(BLFS_XML) $(BLFS_XML)/general.ent $(ALLXML) $(ALLXSL)
|
---|
| 177 | $(Q)cd $(BLFS_XML) && if [ -x git-version.sh ] ; then \
|
---|
[5c8df43] | 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
|
---|
[e576789] | 185 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
[506120ee] | 186 | @echo "Adjusting BLFS for revision $(REV)..."
|
---|
[4f3c433] | 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
|
---|
[506120ee] | 192 | @echo "Validating the BLFS book..."
|
---|
[4f3c433] | 193 | $(Q)xmllint --nonet --noent --postvalid \
|
---|
| 194 | -o $@ $(RENDERTMP)/blfs-prof.xml
|
---|
[84440e6] | 195 | $(Q)echo $(REV) > $(REVFILE)
|
---|
[e576789] | 196 |
|
---|
| 197 | all: update $(BOOK_XML)
|
---|
| 198 |
|
---|
[4ed4a32] | 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
|
---|
[506120ee] | 201 | update: $(BLFS_XML) $(LFS_XML)
|
---|
[e576789] | 202 | @echo Updating the book sources
|
---|
[1242857] | 203 | ifneq (,$(LFS-BRANCH))
|
---|
[4ed4a32] | 204 | $(Q)cd $(LFS_XML) && \
|
---|
[1242857] | 205 | git checkout trunk && \
|
---|
[4ed4a32] | 206 | git pull && \
|
---|
[1242857] | 207 | if [ $(LFS-BRANCH) != trunk ]; then git checkout $(LFS-BRANCH); fi
|
---|
| 208 | endif
|
---|
| 209 | ifneq (,$(BLFS-BRANCH))
|
---|
[4ed4a32] | 210 | $(Q)cd $(BLFS_XML) && \
|
---|
[1242857] | 211 | git checkout trunk && \
|
---|
[4ed4a32] | 212 | git pull && \
|
---|
[1242857] | 213 | if [ $(BLFS-BRANCH) != trunk ]; then git checkout $(BLFS-BRANCH); fi
|
---|
| 214 | endif
|
---|
[e576789] | 215 |
|
---|
[506120ee] | 216 | $(LFS_XML):
|
---|
| 217 | @echo Getting the LFS book sources...
|
---|
[fbbe081] | 218 | $(Q)git clone $(LFS-GIT) $@
|
---|
[1242857] | 219 | ifneq (,$(LFS-BRANCH))
|
---|
[4ed4a32] | 220 | if [ $(LFS-BRANCH) != trunk ]; then \
|
---|
| 221 | cd $@ && \
|
---|
| 222 | git checkout $(LFS-BRANCH); \
|
---|
| 223 | fi
|
---|
[1242857] | 224 | endif
|
---|
[506120ee] | 225 |
|
---|
[e576789] | 226 | $(BLFS_XML):
|
---|
[506120ee] | 227 | @echo Getting the BLFS book sources...
|
---|
[fbbe081] | 228 | $(Q)git clone $(GIT) $@
|
---|
[1242857] | 229 | ifneq (,$(BLFS-BRANCH))
|
---|
[894eec3] | 230 | $(Q)if [ $(BLFS-BRANCH) != trunk ]; then \
|
---|
[4ed4a32] | 231 | cd $@ && \
|
---|
| 232 | git checkout $(BLFS-BRANCH); \
|
---|
| 233 | fi
|
---|
[1242857] | 234 | endif
|
---|
[f4ed135] | 235 | # Clean up
|
---|
| 236 |
|
---|
| 237 | clean:
|
---|
[e576789] | 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
|
---|
[f4ed135] | 240 |
|
---|
[84440e6] | 241 | FORCE:
|
---|
[5c8df43] | 242 | .PHONY: clean all update $(CONFIG_OUT) FORCE
|
---|