Author: jhuntwork Date: 2005-07-17 20:32:26 -0600 (Sun, 17 Jul 2005) New Revision: 355
Added: x86/trunk/scripts/functions Modified: x86/trunk/Makefile x86/trunk/packages/template/Makefile x86/trunk/packages/wget/Makefile Log: General updates in Makefile layout - use of functions and making more use of make's power, as per suggestions posted by Alexander Modified: x86/trunk/Makefile =================================================================== --- x86/trunk/Makefile 2005-07-17 09:23:07 UTC (rev 354) +++ x86/trunk/Makefile 2005-07-18 02:32:26 UTC (rev 355) @@ -1,6 +1,5 @@ -#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -# Makefile for automating the LFS LiveCD build +# Makefiles for automating the LFS LiveCD build # # Written by Jeremy Huntwork, 2004-1-27 # @@ -8,7 +7,7 @@ # # Version for x86 arch using LFS 6.1 # -#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +#============================================================================== # Edit this line to match the mount-point of the # partition you'll be using to build the cd. @@ -26,14 +25,19 @@ # an absolute file path.) export ROOT := /lfs-livecd +# Parallel Build Level +export PM := -j3 + # Http server for the lfs-base packages export HTTP := http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/conglomeration # Don't edit these! export VERSION=x86-6.1-1 +export KVERS= 2.6.11.12 export HOSTNAME := lfslivecd export WD := /tools export SRC := /sources +export LFSSRC := /lfs-sources export PKG := packages export MKTREE := $(MP)$(ROOT) export CFLAGS := -Os -s -march=i486 @@ -43,20 +47,23 @@ export lfsbash := set +h && umask 022 && cd $(MKTREE) -export chenv1 := $(WD)/bin/env -i HOME=/root CFLAGS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' TERM=$(TERM) PS1='\u:\w\$$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:$(WD)/bin $(WD)/bin/bash -c +export chenv-pre-bash := $(WD)/bin/env -i HOME=/root CFLAGS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' TERM=$(TERM) PS1='\u:\w\$$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:$(WD)/bin $(WD)/bin/bash -c -export chenv2 := $(WD)/bin/env -i HOME=/root CFLGAS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' TERM=$(TERM) PS1='\u:\w\$$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:$(WD)/bin /bin/bash -c +export chenv-post-bash := $(WD)/bin/env -i HOME=/root CFLGAS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' TERM=$(TERM) PS1='\u:\w\$$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:$(WD)/bin /bin/bash -c -export chenv3 := /usr/bin/env -i HOME=/root CFLAGS='$(CFLAGS)' TERM=$(TERM) PS1='\u:\w\$$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin INPUTRC=/etc/inputrc XML_CATALOG_FILES="/usr/share/xml/docbook/xsl-stylesheets-1.68.1/catalog.xml /etc/xml/catalog" PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig /bin/bash -c +export chenv-blfs := /usr/bin/env -i HOME=/root CFLAGS='$(CFLAGS)' TERM=$(TERM) PS1='\u:\w\$$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin INPUTRC=/etc/inputrc XML_CATALOG_FILES="/usr/share/xml/docbook/xsl-stylesheets-1.68.1/catalog.xml /etc/xml/catalog" PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig /bin/bash -c -export chenvstrip := $(WD)/bin/env -i HOME=/root TERM=$(TERM) PS1='\u:\w\$$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin $(WD)/bin/bash -c - -export chbash1 := SHELL=$(WD)/bin/bash -export chbash2 := SHELL=/bin/bash +export chbash-pre-bash := SHELL=$(WD)/bin/bash +export chbash-post-bash := SHELL=/bin/bash export WHICH= $(WD)/bin/which export WGET= wget --passive-ftp -export KVERS= 2.6.11.12 +export BRW= "[0;1m" +export RED= "[0;31m" +export GREEN= "[0;32m" +export ORANGE= "[0;33m" +export BLUE= "[0;44m" +export WHITE= "[00m" FTPGET= $(WD)/bin/ftpget WGET_V= 1.9.1 @@ -68,61 +75,52 @@ # The make build starts and ends here, first building the dependency targets, # lfs-base, extend-lfs and iso, then it echos a notice that it's finished. :) -all: lfs-base extend-lfs iso +all: test-host lfs-base extend-lfs iso @echo "The livecd, $(MKTREE)/lfslivecd-$(VERSION).iso, is ready!" +test-host: + @if [ `whoami` != "root" ] ; then echo "You must be logged in as root." \ + && exit 1 ; fi + @if [ `uname -r` != "$(KVERS)" ] ; then echo "Please update your host kernel to version $(KVERS)." \ + && exit 1 ; fi + # This target builds just a base LFS system, minus the kernel and bootscripts -lfs-base: - @if [ `whoami` != "root" ] ; then echo "You must be logged in as root." \ - && exit 1 ; fi - @echo "===============================================================" - @echo " Before you begin building the LiveCD image, please ensure " - @echo " that the following is true: " - @echo "" - @echo " 1) Your running kernel is the same version as the target " - @echo " kernel for the cd." - @echo "" - @echo " 2) You have an active internet connection." - @echo "===============================================================" - @echo "" - @echo -n -e "Countdown to commence building:" - @for i in 10 9 8 7 6 5 4 3 2 1 ; do echo -n -e " $$i" && sleep 1 ; done - @echo "" - @-mkdir -p $(MP)$(WD)/bin; ln -s $(MP)$(WD) / +lfs-base: lfsuser + @if [ ! -d $(MP)$(WD)/bin ] ; then mkdir -p $(MP)$(WD)/bin ; fi @if [ ! -d $(MP)$(SRC) ] ; then mkdir $(MP)$(SRC) ; fi + @if [ ! -d $(MP)$(LFSSRC) ] ; then mkdir $(MP)$(LFSSRC) ; fi + @-ln -sf $(MP)$(WD) / @-ln -sf $(MP)$(SRC) / - @-ln -s $(MP)$(ROOT) / - @make lfsuser + @-ln -sf $(MP)$(ROOT) / + @-ln -sf $(MP)$(LFSSRC) / + @-make unamemod @-chown -R lfs $(WD) $(MP)$(WD) $(WD)/bin $(SRC) $(MP)$(SRC) $(MKTREE) - @echo "" - @echo "==========================" - @echo " Building LFS Base System" - @echo "==========================" - @echo "" - @make unamemod @cp $(ROOT)/scripts/unpack $(WD)/bin @su - lfs -c "$(lfsenv) '$(lfsbash) && $(MAKE) tools'" @if [ ! -f $(PKG)/wget/.pass2 ] ; then make lfs-rm-wget && make lfs-wget ; fi @touch $(PKG)/wget/.pass2 @make prep-chroot @-mkdir $(MP)/bin - @if [ ! -f $(MP)/bin/bash ] ; then if [ ! -d $(MP) ] ; then mkdir $(MP)/bin ; fi ; ln -s ${WD}/bin/bash ${MP}/bin/bash ; fi - @chroot "$(MP)" $(chenv1) 'set +h && chown -R 0:0 $(WD) $(SRC) $(ROOT) && cd $(ROOT) && make pre-bash $(chbash1)' - @chroot "$(MP)" $(chenv2) 'set +h && cd $(ROOT) && make post-bash $(chbash2)' + @if [ ! -f $(MP)/bin/bash ] ; then if [ ! -d $(MP) ] ; then \ + mkdir $(MP)/bin ; fi ; ln -s ${WD}/bin/bash ${MP}/bin/bash ; fi + @chroot "$(MP)" $(chenv-pre-bash) 'set +h && chown -R 0:0 $(WD) $(SRC) $(ROOT) && \ + cd $(ROOT) && make pre-bash $(chbash-pre-bash)' + @chroot "$(MP)" $(chenv-post-bash) 'set +h && cd $(ROOT) && make post-bash $(chbash-post-bash)' + @touch $@ extend-lfs: @cp $(WD)/bin/which $(MP)/usr/bin @cp $(ROOT)/scripts/unpack $(MP)/bin - @chroot "$(MP)" $(chenv3) 'set +h && cd $(ROOT) && make blfs $(chbash2)' - [EMAIL PROTECTED] "$(MP)" $(chenvstrip) 'set +h && cd $(ROOT) && make ch-strip' + @chroot "$(MP)" $(chenv-blfs) 'set +h && cd $(ROOT) && make blfs $(chbash-post-bash)' @make unloadmodule @make unmount + @touch $@ lfsuser: @-groupadd lfs @-useradd -s /bin/bash -g lfs -m -k /dev/null lfs - @touch lfsuser + @touch $@ pre-which: @echo "#!/bin/sh" > $(WHICH) @@ -130,23 +128,26 @@ @chmod 755 $(WHICH) pre-wget: - @if [ ! -f /tools/bin/ftpget ] ; then echo "#!/bin/sh" > $(FTPGET) && \ - echo "ftp -n << END" >> $(FTPGET) && \ - echo "open ftp.gnu.org" >> $(FTPGET) && \ - echo "user anonymous" >> $(FTPGET) && \ - echo "passive" >> $(FTPGET) && \ - echo "binary" >> $(FTPGET) && \ - echo "cd gnu/wget" >> $(FTPGET) && \ - echo "get wget-$(WGET_V).tar.gz" >> $(FTPGET) && \ - echo "bye" >> $(FTPGET) && \ - echo "END" >> $(FTPGET) && \ - chmod 755 $(FTPGET) ; fi + @if [ ! -f /tools/bin/ftpget ] ; then \ + echo "#!/bin/sh" > $(FTPGET) && \ + echo "if [ ! -f wget-$(WGET_V).tar.gz ] ; then" >> $(FTPGET) && \ + echo "ftp -n << END" >> $(FTPGET) && \ + echo "open ftp.gnu.org" >> $(FTPGET) && \ + echo "user anonymous" >> $(FTPGET) && \ + echo "passive" >> $(FTPGET) && \ + echo "binary" >> $(FTPGET) && \ + echo "cd gnu/wget" >> $(FTPGET) && \ + echo "get wget-$(WGET_V).tar.gz" >> $(FTPGET) && \ + echo "bye" >> $(FTPGET) && \ + echo "END" >> $(FTPGET) && \ + echo "fi" >> $(FTPGET) && \ + chmod 755 $(FTPGET) ; fi @$(MAKE) -C $(PKG)/wget prebuild unamemod: @if [ ! -d ${WD}/bin ] ; then mkdir ${WD}/bin ; fi @install -m 755 uname/uname ${WD}/bin/ - @touch unamemod + @touch $@ tools: pre-which pre-wget lfs-binutils-pass1-scpt lfs-gcc-pass1-scpt lfs-linux-libc-headers-scpt lfs-glibc-scpt \ lfs-adjust-toolchain-scpt lfs-tcl-scpt lfs-expect-scpt lfs-dejagnu-scpt lfs-gcc-pass2-scpt lfs-binutils-pass2-scpt \ @@ -162,6 +163,7 @@ @-mount -f -t ramfs ramfs $(MP)/dev @-mount -f -t tmpfs tmpfs $(MP)/dev/shm @-mount -f -t devpts -o gid=4,mode=620 devpts $(MP)/dev/pts + @touch $@ pre-bash: createdirs createfiles popdev ch-linux-libc-headers ch-man-pages ch-glibc ch-re-adjust-toolchain \ ch-binutils ch-gcc ch-coreutils ch-zlib ch-mktemp ch-iana-etc ch-findutils ch-gawk ch-sharutils ch-gpm ch-ncurses \ @@ -1493,10 +1495,4 @@ @-umount $(MP)/dev @-umount $(MP)/proc @-umount $(MP)/sys - -.PHONY: lfs-base pre-which pre-wget tools prep-chroot chroot createdirs createfiles popdev \ - clean scrub unloadmodule unmount lfs-wget lfs-rm-wget lfs-binutils-pass1 lfs-gcc-pass1 \ - lfs-linux-libc-headers lfs-glibc lfs-adjust-toolchain lfs-tcl lfs-expect lfs-dejagnu lfs-gcc-pass2 \ - lfs-binutils-pass2 lfs-gawk lfs-coreutils lfs-bzip2 lfs-gzip lfs-diffutils lfs-findutils lfs-make \ - lfs-grep lfs-gettext lfs-ncurses lfs-patch lfs-tar lfs-texinfo lfs-bash lfs-m4 lfs-bison lfs-flex \ - lfs-util-linux lfs-perl + @rm -f $(ROOT)/prep-chroot Modified: x86/trunk/packages/template/Makefile =================================================================== --- x86/trunk/packages/template/Makefile 2005-07-17 09:23:07 UTC (rev 354) +++ x86/trunk/packages/template/Makefile 2005-07-18 02:32:26 UTC (rev 355) @@ -1,54 +1,116 @@ -# [package-name] Makefile +# [package-name] Makefile (This is a template for package Makefiles) +#============================================================================== -# Package versions NM= [package-name] -VRS= 1.2.3 +VRS= [version-number] DIR= $(NM)-$(VRS) -FILE= $(DIR).tar.bz2 -PATCH1= $(DIR)-some_patch-1.patch +FILE= $(DIR).tar.gz URL= $(HTTP)/$(NM)/$(FILE) -URL1= $(HTTP)/$(NM)/$(PATCH1) +PATCH= $(DIR)-some-1.patch +PATCHURL= http://www.linuxfromscratch.org/patches/downloads/$(NM)/$(PATCH) -# RULES +# Targets +# ============================================================================= -.PHONY: stage1 clean stage2 chroot +include $(ROOT)/scripts/functions -# Stage1 is for packages built to the /tools dir in the base LFS -stage1: - @echo "" - @echo "=====> Building $(NM)" - @echo "" - @if [ ! -f $(SRC)/$(FILE) ] ; then $(WGET) $(URL) && \ - mv $(FILE) $(SRC) ; fi # This command, mv file to sources directory, is only for LFS Core packages and patches - @if [ ! -f $(WD)/bin/ls ] ; then unpack $(SRC)/$(FILE) && cd $(DIR) && \ - ./configure --prefix=$(WD) && make -j3 && make install ; fi - @make clean +$(FILE): + @cd $(SRC) ; $(WGET) $(FILE) + @ln -s $(SRC)/$(FILE) . -# This target allows us to chroot if we haven't already -# Useful if the make has bombed and we want to build just -# this package for the chroot environment. In that case, we -# just call "make package-name" from the top directory, and -# this target is used to enter chroot and recall the ch-package-name -# target from the top Makefile. +$(PATCH): + @cd $(SRC) ; $(WGET) $(PATCH) + @ln -s $(SRC)/$(PATCH) . + + +stage1: Makefile $(FILE) + @$(std_build) # See the scripts/functions file for functions like this + @cp $(SRC)/$(FILE) $(LFSSRC) # Copy LFS-Base packages to safe location + +compile-stage1: + @$(call echo_message, Configuring) +#============================================================================== +# Configure commands below \/ +#============================================================================== + @./configure --prefix=$(WD) >../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + @$(call echo_message, Making) +#============================================================================== +# Make commands below \/ +#============================================================================== + @make $(PM) >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + @$(call echo_message, Installing) +#============================================================================== +# Install commands below \/ +#============================================================================== + @make install >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + +# The following target is for use with packages that must be built in chroot +# and which you want to build one at a time. Mostly for troubleshooting. +# For use with packages built in chroot but before the chroot installation of +# Bash. +# NOTE: You would never call the 'chroot' targets directly, they would be +# referenced by other targets in the root Makefile. chroot: - @chroot "$(MP)" $(chenv3) 'cd $(ROOT) && make ch-$(NM) $(chbash2)' + @chroot "$(MP)" $(chenv-pre-bash) \ + 'cd $(ROOT) && make ch-$(NM) $(chbash-pre-bash)' -# This target is for building the package once we're already inside -# the chroot environment. -stage2: - @echo "" - @echo "=====> Building $(NM) in chroot" - @echo "" - @if [ ! -f $(SRC)/$(FILE) ] ; then $(WGET) $(URL) && \ - mv $(FILE) $(SRC) ; fi # This command, mv file to sources directory, is only for LFS Core packages and patches - @if [ ! -f $(SRC)/$(PATCH1) ] ; then $(WGET) $(URL1) && \ - mv $(PATCH1) $(SRC) ; fi # This command, mv file to sources directory, is only for LFS Core packages and patches - @if [ ! -f /bin/ls ] ; then unpack $(SRC)/$(FILE) && cd $(DIR) && \ - patch -Np1 -i $(SRC)/$(PATCH1) && \ - ./configure --prefix=/usr && \ - make -j3 && make install ; fi - @make clean - -# Does what it says +# Below is a variation of the above target. This would be used with packages +# built in chroot after Bash, but before BLFS-type packages. +#chroot: +# @chroot "$(MP)" $(chenv-post-bash) \ + 'cd $(ROOT) && make ch-$(NM) $(chbash-post-bash)' + +# Below is the final variation of the above two. For use with packages built +# in chroot but after the lfs-base is done. BLFS-type packages. +#chroot: +# @chroot "$(MP)" $(chenv-blfs) \ + 'cd $(ROOT) && make ch-$(NM) $(chbash-post-bash)' + +stage2: Makefile $(FILE) + @$(std_build) + +compile-stage2: + @$(call echo_message, Configuring) +#============================================================================== +# Configure commands below \/ +#============================================================================== + @./configure --prefix=/usr >../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + @$(call echo_message, Making) +#============================================================================== +# Make commands below \/ +#============================================================================== + @make $(PM) >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages=========================================== +# + @$(OK) + @$(call echo_message, Installing) +#============================================================================== +# Install commands below \/ +#============================================================================== + @make install >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages=========================================== +# + @$(OK) + clean: @-rm -rf $(DIR) + +.PHONY: compile-stage1 clean chroot compile-stage2 Modified: x86/trunk/packages/wget/Makefile =================================================================== --- x86/trunk/packages/wget/Makefile 2005-07-17 09:23:07 UTC (rev 354) +++ x86/trunk/packages/wget/Makefile 2005-07-18 02:32:26 UTC (rev 355) @@ -1,40 +1,91 @@ # Wget Makefile +#============================================================================== -# Package versions NM= wget VRS= 1.9.1 DIR= $(NM)-$(VRS) FILE= $(DIR).tar.gz -#RULES +# Targets +# ============================================================================= -.PHONY: prebuild clean chroot stage2 +include $(ROOT)/scripts/functions -prebuild: - @echo "" - @echo "=====> Building $(NM)" - @echo "" - @if [ ! -f $(FILE) ] ; then ftpget ; fi - @if [ ! -f $(WD)/bin/$(NM) ] ; then \ - unpack $(FILE) && cd $(DIR) && \ - ./configure --prefix=$(WD) --libdir=$(WD)/lib --without-ssl \ - --enable-static --disable-shared && \ - make -j3 && make install ; fi - @make clean +$(FILE): + @cd $(SRC) ; ftpget + @ln -s $(SRC)/$(FILE) . + +prebuild: Makefile $(FILE) + @$(std_build) + +compile-prebuild: + @$(call echo_message, Configuring) +#============================================================================== +# Configure commands below \/ +#============================================================================== + @./configure --prefix=$(WD) --libdir=$(WD)/lib --without-ssl \ + --enable-static --disable-shared >../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + @$(call echo_message, Making) +#============================================================================== +# Make commands below \/ +#============================================================================== + @make $(PM) >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + @$(call echo_message, Installing) +#============================================================================== +# Install commands below \/ +#============================================================================== + @make install >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + chroot: - @chroot "$(MP)" $(chenv3) 'cd $(ROOT) && make ch-$(NM) $(chbash2)' + @chroot "$(MP)" $(chenv-blfs) \ + 'cd $(ROOT) && make ch-$(NM) $(chbash-post-bash)' -stage2: - @echo "" - @echo "=====> Building $(NM) in chroot" - @echo "" - @if [ ! -f $(FILE) ] ; then $(WD)/bin/ftpget ; fi - @if [ ! -f /usr/bin/$(NM) ] ; then \ - unpack $(FILE) && cd $(DIR) && \ - ./configure --prefix=/usr --with-ssl && \ - make -j3 && make install ; fi - @make clean +stage2: Makefile $(FILE) + @$(std_build) +compile-stage2: + @$(call echo_message, Configuring) +#============================================================================== +# Configure commands below \/ +#============================================================================== + @./configure --prefix=$(WD) --with-ssl >../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages========================================== +# + @$(OK) + @$(call echo_message, Making) +#============================================================================== +# Make commands below \/ +#============================================================================== + @make $(PM) >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages=========================================== +# + @$(OK) + @$(call echo_message, Installing) +#============================================================================== +# Install commands below \/ +#============================================================================== + @make install >>../$(DIR)[EMAIL PROTECTED] +# +#==Status Messages=========================================== +# + @$(OK) + clean: @-rm -rf $(DIR) + +.PHONY: compile-prebuild clean chroot compile-stage2 Added: x86/trunk/scripts/functions =================================================================== --- x86/trunk/scripts/functions 2005-07-17 09:23:07 UTC (rev 354) +++ x86/trunk/scripts/functions 2005-07-18 02:32:26 UTC (rev 355) @@ -0,0 +1,23 @@ +#============================================================================== +# Functions for use in the LiveCD Makefiles +# +# Author: Jeremy Huntwork +# Date : 2005-07-17 +#============================================================================== +define echo_message + @echo $(BRW) + @echo =========================================================== + @echo $(BRW)$(1) $(ORANGE)$(NM)-$(VRS)$(BRW) for target $(ORANGE)[EMAIL PROTECTED](BRW) + @echo ===========================================================$(WHITE) +endef + +define OK + @echo $(GREEN) [ OK ]$(WHITE) +endef + +define std_build + @unpack $(FILE) + @make -C $(DIR) -f ../Makefile compile-$@ + @make clean + @touch $@ +endef -- http://linuxfromscratch.org/mailman/listinfo/livecd FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page
