[RFC] LFS Makefile Collection

Michael Kipper mkipper at rogers.com
Mon Jun 14 19:40:09 PDT 2004


Referring to thread: "Makefile for LFS 5,1"

I had been using the Chris Lingard's LFS boot CD for a while to build my own LFS 
system. It worked well for both building systems, as well as repairing old ones. 
However, I was left with no flexibility in terms of changing certain build 
options, as Chris' Makefiles were sporadic, and not the easiest to patch 
tagainst. As well, I was not necessarily interested in building my system the 
same way he was, and was looking for a little more flexibility in the build 
I came up with the idea of using GNU make to do the build in stages, allowing me 
to take much more control of the build. Instead of just building, I could 
customize each step. For example, instead of me just using "make build" on a 
package, there could be another target "make build-static" to build a static 
version of a package. Some people will want to call "make remove-source", some 
people may not.
A top level Makefile would call the lower level makefiles to build complete LFS 
systems, or software packages. That is:
make -C packages/gcc

This is my first RFC, so go easy. If there are any ideas, etc. please let me 
know. I already have a lot of these files made up, but they are not LFS 
compliant; there is a lot of my own stuff in them. If there were a centralized 
repository of these Makefiles, people could create their own top-level Makefiles 
with specialized targets to produce their own custom systems.

Here is an example tree, with some example files.

 |  |-bash-1.2.3.tar.gz
 |  |-linux-2.4.26.tar.bz2
 |  +-bash
 |  |  |-Makefile
 |  |  |-bash-1.2.3.tar.gz -> ../../source/bash-1.2.3.tar.gz
 |  +-gcc
 |  +-glibc
 |  +-linux
 |  |-decompress
 |  |-lfs.wget
 |  |-resolv.conf
 |  |-menu.lst
 |  |-random

# Makefile for LFS-v5.1

LFS    	:= /mnt/lfs

all :
    	make chapter4
    	make chapter5

    	mkdir -p $(LFS)/usr/src/lfs
    	cp -R . $(LFS)/usr/src/lfs

    	chroot $(LFS) make -C /usr/src/lfs chapter6
    	chroot $(LFS) make -C /usr/src/lfs chapter7
    	chroot $(LFS) make -C /usr/src/lfs chapter8

chapter4 :
    	mkdir $(LFS)/tools
    	ln -s $(LFS)/tools /

chapter5 :
    	make -C packages/binutils outside-chroot

chapter6 :
    	mkdir -p /{proc,dev/pts}
    	mount proc /proc -t proc
    	make -C packages/linux install-headers

chapter7 :

chapter8 :

# Makefile for $PACKAGE
# Created:		$CREATE_DATE
# Modified:		$MODIFY_DATE
# Description:	$DESCRIPTION
# Dependencies:	$DEPENDENCIES

PACKAGE	:= example
VERSION	:= 1.2.3
BASE_DIR	:= $(shell pwd)


default : all

all :
	make unpack
	make patch
	make build
	make install
	make configure
	make init.d
    	make remove-source

unpack :
	cd $(SOURCE_DIR) && \

patch :
	cd $(PACKAGE_DIR) && \

build :
	cd $(PACKAGE_DIR) && \
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc && \

install :
	cd $(PACKAGE_DIR) && \
	make install

configure :

init.d :
	cp $(PACKAGE) /etc/rc.d/init.d/
	chmod 0755 /etc/rc.d/init.d/$(PACKAGE)
	ln -s ../init.d/$(PACKAGE) /etc/rc.d/rc0.d/K00$(PACKAGE)
	ln -s ../init.d/$(PACKAGE) /etc/rc.d/rc1.d/K00$(PACKAGE)
	ln -s ../init.d/$(PACKAGE) /etc/rc.d/rc2.d/K00$(PACKAGE)
	ln -s ../init.d/$(PACKAGE) /etc/rc.d/rc3.d/K00$(PACKAGE)
	ln -s ../init.d/$(PACKAGE) /etc/rc.d/rc4.d/K00$(PACKAGE)
	ln -s ../init.d/$(PACKAGE) /etc/rc.d/rc5.d/K00$(PACKAGE)
	ln -s ../init.d/$(PACKAGE) /etc/rc.d/rc6.d/K00$(PACKAGE)

remove-source :
    	rm -Rf $(PACKAGE_DIR)

.PHONY : unpack patch build install configure init.d remove-source

# End Makefile for $PACKAGE

More information about the lfs-dev mailing list