# This uses the cross compiler produced by Rob Landley # Taken from http://landley.net/aboriginal/downloads/binaries/ CROSS_COMPILE ?= build_dir := $(CURDIR)/build-i586 output_dir := $(HOME) rootfs := $(HOME)/rootfs-i586.cpio install_dir := $(build_dir)/install config_file := $(build_dir)/.config rootfsbase := $(shell basename $(rootfs)) make_options := -f Makefile \ ARCH=i386 \ CROSS_COMPILE=$(CROSS_COMPILE) \ KBUILD_OUTPUT=$(build_dir) .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config [PLATFORM=foo] - configure for platform \"foo\"" @echo "make build - build the kernel and produce a RAMdisk image" @echo @echo "example:" @echo "make -f i586.mak config" @echo "make -f i586.mak build" .PHONY: have-rootfs have-rootfs: @if [ ! -d $(rootfs) ] ; then \ echo "ERROR: no rootfs at $(rootfs)" ; \ echo "This is needed to boot the system." ; \ echo "ABORTING." ; \ exit 1 ; \ else \ echo "Rootfs available at $(rootfs)" ; \ fi @if [ ! -r $(rootfs) ] ; then \ echo "ERROR: rootfs at $(rootfs) not readable" ; \ echo "ABORTING." ; \ exit 1 ; \ fi .PHONY: have-crosscompiler have-crosscompiler: @echo -n "Check that $(CROSS_COMPILE)gcc is available..." @which $(CROSS_COMPILE)gcc > /dev/null ; \ if [ ! $$? -eq 0 ] ; then \ echo "ERROR: cross-compiler $(CROSS_COMPILE)gcc not in PATH=$$PATH!" ; \ echo "ABORTING." ; \ exit 1 ; \ else \ echo "OK" ;\ fi .PHONY: config-base config-base: FORCE @mkdir -p $(build_dir) @cp -r $(rootfs) $(build_dir)/$(rootfsbase) $(MAKE) $(make_options) i386_defconfig config-initramfs: config-base FORCE # Configure in the initramfs $(CURDIR)/scripts/config --file $(config_file) \ --enable BLK_DEV_INITRD \ --set-str INITRAMFS_SOURCE $(rootfsbase) \ --enable RD_GZIP \ --enable INITRAMFS_COMPRESSION_GZIP config: config-base config-initramfs FORCE # Reconfigure a bit $(CURDIR)/scripts/config --file $(config_file) \ --enable X86_32 \ --enable M586 \ --disable ACPI \ --disable SCHED_SMT \ --disable SCHED_MC \ --enable MATH_EMULATION \ --disable VIRTUALIZATION \ --disable HAMRADIO \ --disable SMP \ --disable SUSPEND \ --disable HIBERNATION \ --enable INTEL_IDLE \ --enable NETDEV_1000 \ --enable E1000 \ --enable SERIAL_8250 \ --enable SERIAL_8250_CONSOLE \ --enable ISA \ --enable EISA \ --enable ISA_DMA_API \ --enable BLK_DEV_XD yes "" | make $(make_options) oldconfig menuconfig: FORCE $(MAKE) $(make_options) menuconfig saveconfig: config-base FORCE yes "" | make $(make_options) oldconfig $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/x86/configs/i386_defconfig build: have-crosscompiler FORCE $(MAKE) $(make_options) -j 9 bzImage $(MAKE) $(make_options) -j 9 modules # Copy to output dir cp -f $(build_dir)/arch/x86/boot/bzImage $(output_dir)/vmlinuz clean: $(MAKE) -f Makefile clean rm -rf $(build_dir) # Rules without commands or prerequisites that do not match a file name # are considered to always change when make runs. This means that any rule # that depends on FORCE will always be remade also. FORCE: