--- trunk/mkinitrd-magellan/klibc/Makefile 2010/07/22 07:47:49 1121 +++ trunk/mkinitrd-magellan/klibc/Makefile 2010/08/18 21:11:40 1122 @@ -1,15 +1,21 @@ SRCROOT = . +# *DOCUMENTATION* +# To see a list of typical targets execute "make help" + # kbuild compatibility export srctree := $(shell pwd) export objtree := $(shell pwd) export KLIBCSRC := usr/klibc -export VERSION := $(shell cat $(KLIBCSRC)/version) +export VERSION := $(shell cat $(srctree)/$(KLIBCSRC)/version) export KLIBCINC := usr/include export KLIBCOBJ := usr/klibc -export KLIBCKERNELSRC := linux/ -export KLIBCKERNELOBJ := linux/ -include scripts/Kbuild.include +export KLIBCKERNELSRC ?= linux +export KLIBCKERNELOBJ ?= $(KLIBCKERNELSRC) + +export VPATH := $(srctree) + +include $(srctree)/scripts/Kbuild.include KLIBCROSS ?= $(CROSS_COMPILE) export KLIBCROSS @@ -24,7 +30,7 @@ NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include) -ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh4/sh/) +ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/) export KLIBCARCH ?= $(ARCH) export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/) @@ -42,7 +48,8 @@ # Create a fake .config as present in the kernel tree # But if it exists leave it alone -$(if $(wildcard $(objtree)/.config),,$(shell cp defconfig .config)) +$(if $(wildcard $(objtree)/.config),,\ + $(shell cp $(srctree)/defconfig $(objtree)/.config)) # Prefix Make commands with $(Q) to silence them # Use quiet_cmd_xxx, cmd_xxx to create nice output @@ -84,13 +91,15 @@ .PHONY: all klcc klibc all: klcc klibc -.config: defconfig linux +$(objtree)/.config: $(srctree)/defconfig $(KLIBCKERNELOBJ) @echo "defconfig has changed, please remove or edit .config" @false -linux: - @echo "The 'linux' symlink is missing; it should point to a kernel tree " - @echo "configured for the $(KLIBCARCH) architecture." +$(KLIBCKERNELSRC): + @echo "Cannot find kernel sources." + @echo "Either make a 'linux' symlink point to a kernel tree " + @echo "configured for the $(KLIBCARCH) architecture or specify " + @echo "KLIBCKERNELSRC= to the build." @false rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm) @@ -99,15 +108,34 @@ sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@ # Build klcc - it is the first target -klcc: .config +klcc: $(objtree)/.config $(Q)$(MAKE) $(klibc)=klcc -klibc: .config +klibc: $(objtree)/.config $(Q)$(MAKE) $(klibc)=. test: klibc $(Q)$(MAKE) $(klibc)=usr/klibc/tests +help: + @echo 'Cleaning targets:' + @echo ' clean - Remove most generated files' + @echo ' mrproper - Remove all generated files + config' + @echo ' distclean - mprproper + editor backup + patch files' + @echo '' + @echo 'Build targets:' + @echo 'all - Build all targets' + @echo 'install - Install klibc' + @echo 'klcc - Wrapper around gcc to compile against klibc' + @echo 'test - Run klibc tests' + @echo + @echo 'Build options:' + @echo 'KLIBCKERNELSRC - Path to a configured linux-2.6 tree' + @echo 'KLIBCKERNELOBJ - Path to kernel output dir (defaults to KLIBCKERNELSRC)' + @echo 'make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' + @echo + @echo 'Sample invocation:' + @echo 'make KLIBCKERNELSRC=`pwd`/../linux-2.6' ### # allow one to say make dir/file.o @@ -135,7 +163,7 @@ -name '.*.d' -o -name '.*.tmp' \) \ -type f -print | xargs rm -f -rm-files := .config linux +rm-files := $(objtree)/.config linux distclean mrproper: clean $(Q)find . $(FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \