diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-04-26 11:45:55 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-04-26 11:45:55 +0000 |
commit | 08782ae7d8812933ad3f932132955ea1c0fb1e52 (patch) | |
tree | 1808993dc06e0c9a473c2e77236ce5d31039466d /Makefile | |
parent | 057adc1c84e0082cdf88da23a32bf2098680ff4e (diff) |
Major rework
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 305 |
1 files changed, 110 insertions, 195 deletions
@@ -1,218 +1,133 @@ -# Makefile for user-mode-linux with a simple busybox/uClibc root filesystem +# Makefile for a simple busybox/uClibc root filesystem # -# Copyright (C) 2001 by Erik Andersen <andersen@codepoet.org> -# Copyright (C) 2001 by Alcove, Julien Gaulmin <julien.gaulmin@fr.alcove.com> -# Copyright (C) 2001 by Jon Nelson <jnelson@boa.org> +# Copyright (C) 2001-2002 by Erik Andersen <andersen@codepoet.org> +# Copyright (C) 2002 by Tim Riker <Tim@Rikers.org> # -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU Library General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) any -# later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more -# details. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. # -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Library General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA -# Known problems : -# - genext2fs: couldn't allocate a block (no free space) -# As genext2fs allocate only one group of blocks, the FS size -# is limited to 8Mb. -# Update this stuff by hand : -ARCH = i386 -# If you are running a cross compiler, you may want to set this -# to something more interesting, like "arm-linux-". -#CROSS = $(ARCH)-linux- - -#IMAGE_SIZE=8192 # Max size -#IMAGE_INODES=500 -IMAGE_SIZE=550 # library is 550K -IMAGE_INODES=300 +############################################################# +# +# EDIT this stuff to suit your system and preferences +# +# Use := when possible to get precomputation, thereby +# speeding up the build process. +# +############################################################# -LINUX_SOURCE=linux-2.4.17.tar.bz2 -LINUX_URI=http://www.kernel.org/pub/linux/kernel/v2.4 +# What sortof target system shall we compile this for? +ARCH:=i386 +#ARCH:=arm +#ARCH:=whatever -USERMODELINUX_PATCH=uml-patch-2.4.17-3.bz2 -USERMODELINUX_URI=http://prdownloads.sourceforge.net/user-mode-linux +# Enable this to use the uClibc daily snapshot instead of a released +# version. Daily snapshots may contain new features and bugfixes. Or +# they may not even compile at all, depending on what Erik is doing... +USE_UCLIBC_SNAPSHOT:=true -UCLIBC_SOURCE=uClibc-snapshot.tar.gz -UCLIBC_URI=http://www.uclibc.org/downloads/ +# Enable large file (files > 2 GB) support +BUILD_WITH_LARGEFILE:=false -# Don't alter below this line unless you (think) you know -# what you are doing! Danger, Danger! +############################################################# +# +# The list of stuff to build for the target filesystem +# +############################################################# +TARGETS:=user-mode-linux uclibc busybox tinylogin -.SUFFIXES: # Delete the default suffixes -.SUFFIXES: .c .o .h # Define our suffix list +# Pick your root filesystem type. +TARGETS+=ext2root -# Directories -BASE_DIR=${shell pwd} -TARGET_DIR=$(BASE_DIR)/root -STAGING_DIR=$(BASE_DIR)/staging_dir -SOURCE_DIR=$(BASE_DIR)/sources -LINUX_DIR=$(BASE_DIR)/linux -UCLIBC_DIR=$(BASE_DIR)/uClibc -GENEXT2FS_DIR=$(BASE_DIR)/genext2fs +############################################################# +# +# You should probably leave this stuff alone unless you know +# what you are doing. +# +############################################################# +BASE_DIR:=${shell pwd} +HOSTCC:=gcc +LINUX_KERNEL=$(BASE_DIR)/UMlinux +SOURCE_DIR:=$(BASE_DIR)/sources +DL_DIR:=$(SOURCE_DIR)/dl +PATCH_DIR=$(SOURCE_DIR)/patches +BUILD_DIR:=$(BASE_DIR)/build +TARGET_DIR:=$(BUILD_DIR)/root +STAGING_DIR:=$(BUILD_DIR)/staging_dir +TARGET_CC:=$(STAGING_DIR)/bin/gcc +TARGET_CROSS:=$(STAGING_DIR)/usr/bin/$(ARCH)-uclibc- +TARGET_CC1:=$(TARGET_CROSS)gcc +TARGET_PATH:=$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin +STRIP:=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note +IMAGE:=$(BASE_DIR)/root_fs +ifneq ($(strip $(ARCH)),i386) +CROSS:=$(ARCH)-linux- +endif -TARGET_CC=$(STAGING_DIR)/bin/gcc -TARGET_CC1=$(STAGING_DIR)/usr/bin/$(ARCH)-uclibc-gcc -TARGET_CROSS=$(STAGING_DIR)/usr/bin/$(ARCH)-uclibc- -TARGET_PATH=$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin +all: world -LINUX=$(BASE_DIR)/UMlinux -IMAGE=$(BASE_DIR)/root_fs +TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS)) +TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS)) -KCONFIG=$(SOURCE_DIR)/linux-uml.config +world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS) -all: world +.PHONY: all world clean dirclean distclean $(TARGETS) $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) -#So what shall we build today? -TARGETS= +include make/*.mk --include busybox.mk --include boa.mk +############################################################# +# +# staging and target directories do NOT list these as +# dependancies anywhere else +# +############################################################# +$(DL_DIR): + mkdir $(DL_DIR) -world: $(TARGETS) root_fs $(LINUX) +$(BUILD_DIR): + mkdir $(BUILD_DIR) -root_fs: $(GENEXT2FS_DIR)/genext2fs $(TARGET_DIR) - $(GENEXT2FS_DIR)/genext2fs \ - -b `echo $(IMAGE_SIZE) | bc` \ - -i `echo $(IMAGE_INODES) | bc` \ - -d $(TARGET_DIR) \ - -D $(SOURCE_DIR)/device_table.txt root_fs +$(STAGING_DIR): + rm -rf $(STAGING_DIR) + mkdir $(STAGING_DIR) -$(STAGING_DIR)/.target_dir_exists: +$(TARGET_DIR): rm -rf $(TARGET_DIR) - tar -xf $(SOURCE_DIR)/skel.tar - cp -a target_skeleton/* $(TARGET_DIR)/ + zcat $(SOURCE_DIR)/skel.tar.gz | tar -C $(BUILD_DIR) -xf - + cp -a $(SOURCE_DIR)/target_skeleton/* $(TARGET_DIR)/ -find $(TARGET_DIR) -type d -name CVS -exec rm -rf {} \; > /dev/null 2>&1 - touch $(STAGING_DIR)/.target_dir_exists - -# The kernel -$(SOURCE_DIR)/$(LINUX_SOURCE): - while [ ! -f $(SOURCE_DIR)/$(LINUX_SOURCE) ] ; do \ - wget -P $(SOURCE_DIR) --passive $(LINUX_URI)/$(LINUX_SOURCE); \ - done - -$(LINUX_DIR)/.unpacked: $(SOURCE_DIR)/$(LINUX_SOURCE) - rm -rf $(LINUX_DIR) # Keeps old versions from messing things up - bzip2 -dc $(SOURCE_DIR)/$(LINUX_SOURCE) | tar -xvf - - touch $(LINUX_DIR)/.unpacked - -$(SOURCE_DIR)/$(USERMODELINUX_PATCH): - while [ ! -f $(SOURCE_DIR)/$(USERMODELINUX_PATCH) ] ; do \ - wget -P $(SOURCE_DIR) --passive $(USERMODELINUX_URI)/$(USERMODELINUX_PATCH); \ - done - -$(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked $(SOURCE_DIR)/$(USERMODELINUX_PATCH) - # This step cannot gracefully recover from interruption - @if [ -f $(LINUX_DIR)/.started_patch ]; then \ - echo "Something went wrong patching the kernel."; \ - echo "Please rm -rf the kernel directory (\"$(LINUX_DIR)\") and type \"make\" again."; \ - exit 1; \ - fi - touch $(LINUX_DIR)/.started_patch - bzcat $(SOURCE_DIR)/$(USERMODELINUX_PATCH) | patch -d $(LINUX_DIR) -p1 - cp -f $(KCONFIG) $(LINUX_DIR)/.config - mv $(LINUX_DIR)/.started_patch $(LINUX_DIR)/.patched # Hah! Atomic - -$(LINUX_DIR)/.um: $(LINUX_DIR)/.patched - sed -e 's/^ARCH :=.*/ARCH=um/g' < $(LINUX_DIR)/Makefile > \ - $(LINUX_DIR)/Makefile.new - mv -f $(LINUX_DIR)/Makefile.new $(LINUX_DIR)/Makefile - touch $(LINUX_DIR)/.um - -$(LINUX_DIR)/.configdone: $(LINUX_DIR)/.um - make -C $(LINUX_DIR) oldconfig - touch $(LINUX_DIR)/.configdone - -$(LINUX_DIR)/.dep: $(LINUX_DIR)/.configdone - make -C $(LINUX_DIR) dep - touch $(LINUX_DIR)/.dep - -$(LINUX_DIR)/linux: $(LINUX_DIR)/.dep - make -C $(LINUX_DIR) linux - -$(LINUX): $(LINUX_DIR)/linux - ln -sf $(LINUX_DIR)/linux $(LINUX) - -# uClibc -$(SOURCE_DIR)/$(UCLIBC_SOURCE): - while [ ! -f $(SOURCE_DIR)/$(UCLIBC_SOURCE) ] ; do \ - wget -P $(SOURCE_DIR) --passive $(UCLIBC_URI)/$(UCLIBC_SOURCE) ; \ - done; - -$(UCLIBC_DIR)/Config: $(SOURCE_DIR)/$(UCLIBC_SOURCE) - rm -rf $(UCLIBC_DIR) # Make sure no previous version interferes here - gzip -d -c $(SOURCE_DIR)/$(UCLIBC_SOURCE) | tar -xvf - - # The next step patches uClibc - # Place patches in the source directory, named uClibc-*.patch - for p in `find $(SOURCE_DIR) -name uClibc-*.patch | sort -g`;do \ - patch -p0 < $$p ; \ - done - # Finally, patch the Config file to our liking - # uClibc-Config.awk should be pretty staightforward - awk -f $(SOURCE_DIR)/uClibc-Config.awk < \ - $(UCLIBC_DIR)/extra/Configs/Config.$(ARCH) > \ - $(UCLIBC_DIR)/Config - -$(UCLIBC_DIR)/lib/libc.a: $(LINUX_DIR)/.dep $(UCLIBC_DIR)/Config - $(MAKE) CROSS=$(CROSS) \ - DEVEL_PREFIX=$(STAGING_DIR) \ - SYSTEM_DEVEL_PREFIX=$(STAGING_DIR)/usr \ - SHARED_LIB_LOADER_PATH=/lib \ - KERNEL_SOURCE=$(LINUX_DIR) \ - -C $(UCLIBC_DIR) - -$(TARGET_CC): $(UCLIBC_DIR)/lib/libc.a - $(MAKE) CROSS=$(CROSS) \ - DEVEL_PREFIX=$(STAGING_DIR) \ - SYSTEM_DEVEL_PREFIX=$(STAGING_DIR)/usr \ - SHARED_LIB_LOADER_PATH=$(STAGING_DIR)/lib \ - -C $(UCLIBC_DIR) install - -$(UCLIBC_DIR)/.installed_runtime: $(STAGING_DIR)/.target_dir_exists $(TARGET_CC) - $(MAKE) CROSS=$(CROSS) \ - PREFIX=$(TARGET_DIR) \ - DEVEL_PREFIX=/ \ - SYSTEM_DEVEL_PREFIX=/usr \ - SHARED_LIB_LOADER_PATH=/lib \ - -C $(UCLIBC_DIR) install_runtime - touch $(UCLIBC_DIR)/.installed_runtime - -uclibc: $(TARGET_CC) $(UCLIBC_DIR)/.installed_runtime - -# genext2fs -$(GENEXT2FS_DIR)/genext2fs: - $(MAKE) -C $(GENEXT2FS_DIR) - -# others -clean: $(TARGETS_CLEAN) - make -C $(GENEXT2FS_DIR) clean - @if [ -d $(UCLIBC_DIR) ] ; then \ - make -C $(UCLIBC_DIR) clean; \ - fi; - @if [ -d $(LINUX_DIR) ] ; then \ - make -C $(LINUX_DIR) clean; \ - fi; - rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) - rm -f *~ - -mrproper: $(TARGETS_MRPROPER) - rm -rf $(UCLIBC_DIR) - rm -rf $(LINUX_DIR) - rm -f root_fs $(LINUX) - make -C $(GENEXT2FS_DIR) clean - rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) - rm -f *~ - -distclean: mrproper $(TARGETS_DISTCLEAN) - rm -f $(SOURCE_DIR)/$(UCLIBC_SOURCE) - rm -f $(SOURCE_DIR)/$(USERMODELINUX_PATCH) - rm -f $(SOURCE_DIR)/$(LINUX_SOURCE) - -.PHONY: uclibc uclibc-build uclibc-runtime $(TARGETS) world test clean mrproper distclean + + +############################################################# +# +# Cleanup and misc junk +# +############################################################# +clean: $(TARGETS_CLEAN) + rm -rf $(TARGET_DIR) $(STAGING_DIR) $(IMAGE) + +dirclean: $(TARGETS_DIRCLEAN) + rm -rf $(TARGET_DIR) $(STAGING_DIR) $(IMAGE) + +distclean: + rm -rf $(DL_DIR) $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE) + +sourceball: + rm -rf $(BUILD_DIR) + set -e; \ + cd ..; \ + rm -f buildroot.tar.bz2; \ + tar -cvf buildroot.tar buildroot; \ + bzip2 -9 buildroot.tar; \ |