[RFC] LFS Makefile Collection

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


Hi,

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

ABSTRACT
==================================================
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 
options.
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.



DIRECTORY TREE
==================================================
Here is an example tree, with some example files.

./lfs
 |-INSTALL
 |-README
 |-Makefile
 +-source
 |  |-bash-1.2.3.tar.gz
 |  |-linux-2.4.26.tar.bz2
 +-packages
 |  +-bash
 |  |  |-Makefile
 |  |  |-bash-1.2.3.tar.gz -> ../../source/bash-1.2.3.tar.gz
 |  +-gcc
 |  +-glibc
 |  +-linux
 +-scripts
 |  |-decompress
 |  |-lfs.wget
 +-config
 |  |-resolv.conf
 |  |-menu.lst
 +-init.d
 |  |-random
 +-<etc...>



EXAMPLE TOP LEVEL MAKEFILE
==================================================
#
# 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 /
    	<etc...>

chapter5 :
    	make -C packages/binutils outside-chroot
    	<etc...>

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

chapter7 :
    	<etc...>

chapter8 :
    	<etc...>



EXAMPLE LOWER LEVEL MAKEFILE
==================================================
#
# Makefile for $PACKAGE
#
# Created:		$CREATE_DATE
# Modified:		$MODIFY_DATE
# Description:	$DESCRIPTION
#
# Dependencies:	$DEPENDENCIES
#

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

PACKAGE_DIR	:= $(BASE_DIR)/$(PACKAGE)-$(VERSION)
PACAKGE_SRC	:= $(BASE_DIR)/$(PACKAGE)-$(VERSION).tar.gz
PATCH_SRC	:= $(BASE_DIR)/$(PACKAGE)-$(VERSION).patch

default : all

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

unpack :
	cd $(SOURCE_DIR) && \
	$(UNPACK) $(PACKAGE_SRC)

patch :
	cd $(PACKAGE_DIR) && \
	$(PATCH) $(PATCH_SRC)

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

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