se505-buildsystem/Makefile

460 lines
15 KiB
Makefile
Raw Normal View History

2007-06-15 15:11:23 +02:00
PATH := /opt/brcm/hndtools-mipsel-uclibc-3.2.3/bin:/opt/brcm/hndtools-mipsel-linux-3.2.3/bin:$(PATH)
export PATH
export TOOLCHAIN := /opt/brcm/hndtools-mipsel-uclibc-3.2.3
# #####################################################################
export BUILD := i386-pc-linux-gnu
export TARGET := mipsel-uclibc
export HOST := mipsel-linux
export CROSS_COMPILE := mipsel-uclibc-
export CONFIGURE := ./configure --target=$(TARGET) --build=$(BUILD) --host=$(HOST)
export CC := $(CROSS_COMPILE)gcc
export AR := $(CROSS_COMPILE)ar
export AS := $(CROSS_COMPILE)as
export LD := $(CROSS_COMPILE)ld
export LDD := $(CROSS_COMPILE)ldd
export NM := $(CROSS_COMPILE)nm
export RANLIB := $(CROSS_COMPILE)ranlib
export STRIP := $(CROSS_COMPILE)strip
export SIZE := $(CROSS_COMPILE)size
export WGET := /usr/bin/wget --passive-ftp -nd
_SRCBASE=$(shell /bin/pwd)
_CONFIGS=$(_SRCBASE)/configs
_DOWNLOAD_DIR=$(_SRCBASE)/download
_SOURCE=$(_SRCBASE)/source
_STATE=$(_SRCBASE)/state
_TOOLS=$(_SRCBASE)/tools
_STAGE1_SKEL=stage1.skel
_STAGE1=$(shell /bin/pwd)/stage1
_STAGE1_IMG=stage1.img
_STAGE2_SKEL=stage2.skel
_STAGE2=$(shell /bin/pwd)/stage2
# #####################################################################
# build firmware and filesystem
all: stage1 stage2
# stage1 (firmware)
_STAGE1_TARGETS=kernel-zImage busybox-stage1 cramfs tools
# stage2 (filesystem)
_STAGE2_TARGETS=kernel-modules busybox-stage2 strace bridge-utils iproute2 pppd
# fetch all needed sources
fetch: stage1-fetch stage2-fetch
# trigger rebuild of all packages
clean: stage1-clean stage2-clean
# remove all builddirs
distclean: stage1-distclean stage2-distclean
# #####################################################################
_BUILD_TOOLS=$(_TOOLS)
tools: tools-clean $(_STATE)/tools.all-done
tools-fetch:
$(_STATE)/tools.all-done:
make -C $(_BUILD_TOOLS) all
touch $(_STATE)/tools.all-done
tools-install: $(_STATE)/tools.all-done
tools-clean:
rm -f $(_STATE)/tools.*
tools-distclean: tools-clean
make -C $(_BUILD_TOOLS) clean
# #####################################################################
_PACKAGE_KERNEL=$(_DOWNLOAD_DIR)/linux-2.4.20.tar.bz2
_DOWNLOAD_KERNEL=ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.20.tar.bz2
_BUILD_KERNEL=$(_SOURCE)/linux-2.4.20
_KERNELHEADERS=$(_BUILD_KERNEL)/include
kernel: $(_STATE)/kernel-zImage.all-done $(_STATE)/kernel-modules.all-done
kernel-zImage: kernel-zImage-clean $(_STATE)/kernel-zImage.all-done
kernel-modules: kernel-modules-clean $(_STATE)/kernel-modules.all-done
kernel-zImage-fetch: $(_PACKAGE_KERNEL)
kernel-modules-fetch: $(_PACKAGE_KERNEL)
$(_PACKAGE_KERNEL):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_KERNEL)
$(_STATE)/kernel.unpacked: $(_PACKAGE_KERNEL)
tar -C $(_SOURCE) -xjf $(_PACKAGE_KERNEL)
(cd $(_BUILD_KERNEL); bzcat $(_CONFIGS)/kernel-vanilla2siemens_small.patch.bz2 | patch -lp1 );
(cd $(_BUILD_KERNEL); tar -xjf $(_CONFIGS)/wl-rel_3_01_05.tar.bz2 );
touch $(_STATE)/kernel.unpacked
$(_STATE)/kernel.configured: $(_STATE)/kernel.unpacked
cp $(_CONFIGS)/kernel-config $(_BUILD_KERNEL)/.config
make -C $(_BUILD_KERNEL) oldconfig
touch $(_STATE)/kernel.configured
$(_STATE)/kernel.dep: $(_STATE)/kernel.configured
make -C $(_BUILD_KERNEL) dep
touch $(_STATE)/kernel.dep
$(_STATE)/kernel-zImage.all-done: $(_STATE)/kernel.dep
make -C $(_BUILD_KERNEL) zImage
touch $(_STATE)/kernel-zImage.all-done
$(_STATE)/kernel-modules.all-done: $(_STATE)/kernel-zImage.all-done
make -C $(_BUILD_KERNEL) modules
touch $(_STATE)/kernel-modules.all-done
kernel-zImage-install: $(_STAGE1) $(_STATE)/kernel-zImage.all-done
kernel-modules-install: $(_STAGE2) $(_STATE)/kernel-modules.all-done
make -C $(_BUILD_KERNEL) modules_install DEPMOD=/bin/true INSTALL_MOD_PATH=$(_STAGE2)
rm -rf $(_STAGE2)/lib/modules/2.4.20/build
rm -rf $(_STAGE2)/lib/modules/2.4.20/pcmcia
kernel-clean: kernel-zImage-clean kernel-modules-clean
kernel-distclean:
rm -r $(_STATE)/kernel.*
make -C $(_BUILD_KERNEL) mrproper
kernel-zImage-clean:
rm -f $(_STATE)/kernel-zImage.all-done
kernel-zImage-distclean: kernel-distclean
kernel-modules-clean:
rm -f $(_STATE)/kernel-modules.all-done
kernel-modules-distclean: kernel-distclean
# #####################################################################
_PACKAGE_CRAMFS=$(_DOWNLOAD_DIR)/cramfs-1.1.tar.gz
_DOWNLOAD_CRAMFS=http://mesh.dl.sourceforge.net/sourceforge/cramfs/cramfs-1.1.tar.gz
_BUILD_CRAMFS=$(_SOURCE)/cramfs-1.1
cramfs: cramfs-clean $(_STATE)/cramfs.all_done
cramfs-fetch: $(_PACKAGE_CRAMFS)
$(_PACKAGE_CRAMFS):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_CRAMFS)
$(_STATE)/cramfs.unpacked: $(_PACKAGE_CRAMFS)
tar -C $(_SOURCE) -xzf $(_PACKAGE_CRAMFS)
touch $(_STATE)/cramfs.unpacked
$(_STATE)/cramfs.all_done: $(_STATE)/cramfs.unpacked
make -C $(_BUILD_CRAMFS) all
touch $(_STATE)/cramfs.all_done
cramfs-install: $(_STATE)/cramfs.all_done
cramfs-clean:
rm -f $(_STATE)/cramfs.*
cramfs-distclean: strace-clean
rm -rf $(_BUILD_CRAMFS)
# #####################################################################
_PACKAGE_BUSYBOX=$(_DOWNLOAD_DIR)/busybox-1.00.tar.bz2
_DOWNLOAD_BUSYBOX=http://www.busybox.net/downloads/busybox-1.00.tar.bz2
_BUILD_BUSYBOX=$(_SOURCE)/busybox-1.00
_BUILD_BUSYBOX_STAGE1=$(_SOURCE)/busybox-stage1
busybox-stage1: busybox-stage1-clean $(_STATE)/busybox-stage1.all_done
busybox-stage1-fetch: $(_PACKAGE_BUSYBOX)
$(_PACKAGE_BUSYBOX):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_BUSYBOX)
$(_STATE)/busybox-stage1.unpacked: $(_PACKAGE_BUSYBOX)
tar -C $(_SOURCE) -xjf $(_PACKAGE_BUSYBOX)
rm -rf $(_BUILD_BUSYBOX_STAGE1)
mv $(_BUILD_BUSYBOX) $(_BUILD_BUSYBOX_STAGE1)
touch $(_STATE)/busybox-stage1.unpacked
$(_STATE)/busybox-stage1.configured: $(_STATE)/busybox-stage1.unpacked
cp $(_CONFIGS)/busybox-stage1.conf $(_BUILD_BUSYBOX_STAGE1)/.config
touch $(_STATE)/busybox-stage1.configured
$(_STATE)/busybox-stage1.compiled: $(_STATE)/busybox-stage1.configured
make -C $(_BUILD_BUSYBOX_STAGE1) all
touch $(_STATE)/busybox-stage1.compiled
$(_STATE)/busybox-stage1.all_done: $(_STATE)/busybox-stage1.compiled
make -C $(_BUILD_BUSYBOX_STAGE1) install
chmod 4775 $(_BUILD_BUSYBOX_STAGE1)/_install/bin/busybox
touch $(_STATE)/busybox-stage1.all_done
busybox-stage1-install: $(_STAGE1) $(_STATE)/busybox-stage1.all_done
cp -r $(_BUILD_BUSYBOX_STAGE1)/_install/* $(_STAGE1)
busybox-stage1-clean:
rm -f $(_STATE)/busybox-stage1.*
busybox-stage1-distclean: busybox-stage1-clean
rm -rf $(_BUILD_BUSYBOX_STAGE1)
# #####################################################################
_BUILD_BUSYBOX_STAGE2=$(_SOURCE)/busybox-stage2
busybox-stage2: busybox-stage2-clean $(_STATE)/busybox-stage2.all_done
busybox-stage2-fetch: $(_PACKAGE_BUSYBOX)
$(_STATE)/busybox-stage2.unpacked: $(_PACKAGE_BUSYBOX)
tar -C $(_SOURCE) -xjf $(_PACKAGE_BUSYBOX)
rm -rf $(_BUILD_BUSYBOX_STAGE2)
mv $(_BUILD_BUSYBOX) $(_BUILD_BUSYBOX_STAGE2)
touch $(_STATE)/busybox-stage2.unpacked
$(_STATE)/busybox-stage2.configured: $(_STATE)/busybox-stage2.unpacked
cp $(_CONFIGS)/busybox-stage2.conf $(_BUILD_BUSYBOX_STAGE2)/.config
touch $(_STATE)/busybox-stage2.configured
$(_STATE)/busybox-stage2.compiled: $(_STATE)/busybox-stage2.configured
make -C $(_BUILD_BUSYBOX_STAGE2) all
touch $(_STATE)/busybox-stage2.compiled
$(_STATE)/busybox-stage2.all_done: $(_STATE)/busybox-stage2.compiled
make -C $(_BUILD_BUSYBOX_STAGE2) install
chmod 4775 $(_BUILD_BUSYBOX_STAGE2)/_install/bin/busybox
touch $(_STATE)/busybox-stage2.all_done
busybox-stage2-install: $(_STAGE2) $(_STATE)/busybox-stage2.all_done
cp -r $(_BUILD_BUSYBOX_STAGE2)/_install/* $(_STAGE2)
busybox-stage2-clean:
rm -f $(_STATE)/busybox-stage2.*
busybox-stage2-distclean: busybox-stage2-clean
rm -rf $(_BUILD_BUSYBOX_STAGE2)
# #####################################################################
_PACKAGE_STRACE=$(_DOWNLOAD_DIR)/strace-4.5.7.tar.bz2
_DOWNLOAD_STRACE=http://mesh.dl.sourceforge.net/sourceforge/strace/strace-4.5.7.tar.bz2
_BUILD_STRACE=$(_SOURCE)/strace-4.5.7
strace: strace-clean $(_STATE)/strace.all_done
strace-fetch: $(_PACKAGE_STRACE)
$(_PACKAGE_STRACE):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_STRACE)
$(_STATE)/strace.unpacked: $(_PACKAGE_STRACE)
tar -C $(_SOURCE) -xjf $(_PACKAGE_STRACE)
touch $(_STATE)/strace.unpacked
$(_STATE)/strace.configured: $(_STATE)/strace.unpacked
(cd $(_BUILD_STRACE); $(CONFIGURE) --prefix=/usr );
touch $(_STATE)/strace.configured
$(_STATE)/strace.compiled: $(_STATE)/strace.configured
make -C $(_BUILD_STRACE) all
touch $(_STATE)/strace.compiled
$(_STATE)/strace.all_done: $(_STATE)/strace.compiled
$(STRIP) --strip-all $(_BUILD_STRACE)/strace
touch $(_STATE)/strace.all_done
strace-install: $(_STAGE2) $(_STATE)/strace.all_done
cp $(_BUILD_STRACE)/strace $(_STAGE2)/usr/bin
strace-clean:
rm -f $(_STATE)/strace.*
strace-distclean: strace-clean
rm -rf $(_BUILD_STRACE)
# #####################################################################
_PACKAGE_BRIDGE_UTILS=$(_DOWNLOAD_DIR)/bridge-utils-1.0.4.tar.gz
_DOWNLOAD_BRIDGE_UTILS=http://mesh.dl.sourceforge.net/sourceforge/bridge/bridge-utils-1.0.4.tar.gz
_BUILD_BRIDGE_UTILS=$(_SOURCE)/bridge-utils-1.0.4
bridge-utils: bridge-utils-clean $(_STATE)/bridge-utils.all_done
bridge-utils-fetch: $(_PACKAGE_BRIDGE_UTILS)
$(_PACKAGE_BRIDGE_UTILS):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_BRIDGE_UTILS)
$(_STATE)/bridge-utils.unpacked: $(_PACKAGE_BRIDGE_UTILS)
tar -C $(_SOURCE) -xzf $(_PACKAGE_BRIDGE_UTILS)
touch $(_STATE)/bridge-utils.unpacked
$(_STATE)/bridge-utils.configured: $(_STATE)/bridge-utils.unpacked
(cd $(_BUILD_BRIDGE_UTILS); $(CONFIGURE) --prefix=/usr --with-linux-headers=$(_KERNELHEADERS));
touch $(_STATE)/bridge-utils.configured
$(_STATE)/bridge-utils.compiled: $(_STATE)/bridge-utils.configured
make -C $(_BUILD_BRIDGE_UTILS) all
touch $(_STATE)/bridge-utils.compiled
$(_STATE)/bridge-utils.all_done: $(_STATE)/bridge-utils.compiled
$(STRIP) --strip-all $(_BUILD_BRIDGE_UTILS)/brctl/brctl
touch $(_STATE)/bridge-utils.all_done
bridge-utils-install: $(_STAGE2) $(_STATE)/bridge-utils.all_done
cp $(_BUILD_BRIDGE_UTILS)/brctl/brctl $(_STAGE2)/usr/sbin
bridge-utils-clean:
rm -f $(_STATE)/bridge-utils.*
bridge-utils-distclean: bridge-utils-clean
rm -rf $(_BUILD_BRIDGE_UTILS)
# #####################################################################
_PACKAGE_IPROUTE2=$(_DOWNLOAD_DIR)/iproute2-2.6.10-050209.tar.gz
_DOWNLOAD_IPROUTE2=http://developer.osdl.org/dev/iproute2/download/iproute2-2.6.10-050209.tar.gz
_BUILD_IPROUTE2=$(_SOURCE)/iproute2-2.6.9-050209
iproute2: iproute2-clean $(_STATE)/iproute2.all_done
iproute2-fetch: $(_PACKAGE_IPROUTE2)
$(_PACKAGE_IPROUTE2):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_IPROUTE2)
$(_STATE)/iproute2.unpacked: $(_PACKAGE_IPROUTE2)
tar -C $(_SOURCE) -xzf $(_PACKAGE_IPROUTE2)
touch $(_STATE)/iproute2.unpacked
$(_STATE)/iproute2.configured: $(_STATE)/iproute2.unpacked
(cd $(_BUILD_IPROUTE2); $(CONFIGURE) --prefix=/usr);
touch $(_STATE)/iproute2.configured
$(_STATE)/iproute2.compiled: $(_STATE)/iproute2.configured
make -C $(_BUILD_IPROUTE2) CC=$(CC) all
touch $(_STATE)/iproute2.compiled
$(_STATE)/iproute2.all_done: $(_STATE)/iproute2.compiled
$(STRIP) --strip-all $(_BUILD_IPROUTE2)/ip/ip
$(STRIP) --strip-all $(_BUILD_IPROUTE2)/tc/tc
touch $(_STATE)/iproute2.all_done
iproute2-install: $(_STAGE2) $(_STATE)/iproute2.all_done
cp $(_BUILD_IPROUTE2)/ip/ip $(_STAGE2)/sbin
cp $(_BUILD_IPROUTE2)/tc/tc $(_STAGE2)/sbin
iproute2-clean:
rm -f $(_STATE)/iproute2.*
iproute2-distclean: iproute2-clean
rm -rf $(_BUILD_IPROUTE2)
# #####################################################################
_PACKAGE_PPPD=$(_DOWNLOAD_DIR)/ppp-2.4.2.tar.gz
_DOWNLOAD_PPPD=ftp://ftp.samba.org/pub/ppp/ppp-2.4.2.tar.gz
_BUILD_PPPD=$(_SOURCE)/ppp-2.4.2
pppd: pppd-clean $(_STATE)/pppd.all_done
pppd-fetch: $(_PACKAGE_PPPD)
$(_PACKAGE_PPPD):
$(WGET) -P $(_DOWNLOAD_DIR) $(_DOWNLOAD_PPPD)
$(_STATE)/pppd.unpacked: $(_PACKAGE_PPPD)
tar -C $(_SOURCE) -xzf $(_PACKAGE_PPPD)
touch $(_STATE)/pppd.unpacked
$(_STATE)/pppd.configured: $(_STATE)/pppd.unpacked
(cd $(_BUILD_PPPD); $(CONFIGURE) --prefix=/usr);
sed -i -e "s/^FILTER=y/#FILTER=y/" $(_BUILD_PPPD)/pppd/Makefile
sed -i -e "s/^CC\t= gcc/#CC\t= gcc/" $(_BUILD_PPPD)/pppd/plugins/Makefile
sed -i -e "s/^\tgcc/\t\$$\(CC\)/" -e "s/^\tar/\t\$$\(AR\)/" $(_BUILD_PPPD)/pppd/plugins/rp-pppoe/Makefile
touch $(_STATE)/pppd.configured
$(_STATE)/pppd.compiled: $(_STATE)/pppd.configured
make -C $(_BUILD_PPPD) all
touch $(_STATE)/pppd.compiled
$(_STATE)/pppd.all_done: $(_STATE)/pppd.compiled
$(STRIP) --strip-all $(_BUILD_PPPD)/chat/chat
$(STRIP) --strip-all $(_BUILD_PPPD)/pppd/pppd
$(STRIP) --strip-all $(_BUILD_PPPD)/pppd/plugins/rp-pppoe/rp-pppoe.so
$(STRIP) --strip-all $(_BUILD_PPPD)/pppstats/pppstats
touch $(_STATE)/pppd.all_done
pppd-install: $(_STAGE2) $(_STATE)/pppd.all_done
cp $(_BUILD_PPPD)/chat/chat $(_STAGE2)/usr/bin
cp $(_BUILD_PPPD)/pppd/pppd $(_STAGE2)/usr/sbin
cp $(_BUILD_PPPD)/pppd/plugins/rp-pppoe/rp-pppoe.so $(_STAGE2)/etc/ppp/plugins/
cp $(_BUILD_PPPD)/pppstats/pppstats $(_STAGE2)/usr/bin
pppd-clean:
rm -f $(_STATE)/pppd.*
pppd-distclean: pppd-clean
rm -rf $(_BUILD_PPPD)
# #####################################################################
_STAGE1_REAL_TARGETS:=$(patsubst %,%-install,$(_STAGE1_TARGETS))
_STAGE1_FETCH_TARGETS:=$(patsubst %,%-fetch,$(_STAGE1_TARGETS))
_STAGE1_CLEAN_TARGETS:=$(patsubst %,%-clean,$(_STAGE1_TARGETS))
_STAGE1_DISTCLEAN_TARGETS:=$(patsubst %,%-distclean,$(_STAGE1_TARGETS))
$(_STAGE1):
mkdir -p $(_STAGE1)
cp -r $(_STAGE1_SKEL)/* $(_STAGE1)
$(_STAGE1_IMG):
mkdir -p $(_STAGE1_IMG)
stage1: $(_STAGE1) $(_STAGE1_IMG) $(_STAGE1_REAL_TARGETS)
$(_BUILD_CRAMFS)/mkcramfs $(_STAGE1) $(_STAGE1_IMG)/stage1.cramfs
$(_TOOLS)/trx -o $(_STAGE1_IMG)/firmware.trx \
$(_BUILD_KERNEL)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz \
$(_STAGE1_IMG)/stage1.cramfs
$(_TOOLS)/gen_image $(_STAGE1_IMG)/firmware.trx > $(_STAGE1_IMG)/firmware.img
stage1-fetch: $(_STAGE1_FETCH_TARGETS)
stage1-clean: $(_STAGE1_CLEAN_TARGETS)
rm -rf $(_STAGE1) $(_STAGE1_IMG)
stage1-distclean: $(_STAGE1_DISTCLEAN_TARGETS)
rm -rf $(_STAGE1) $(_STAGE1_IMG)
# #####################################################################
_STAGE2_REAL_TARGETS:=$(patsubst %,%-install,$(_STAGE2_TARGETS))
_STAGE2_FETCH_TARGETS:=$(patsubst %,%-fetch,$(_STAGE2_TARGETS))
_STAGE2_CLEAN_TARGETS:=$(patsubst %,%-clean,$(_STAGE2_TARGETS))
_STAGE2_DISTCLEAN_TARGETS:=$(patsubst %,%-distclean,$(_STAGE2_TARGETS))
$(_STAGE2):
mkdir -p $(_STAGE2)
cp -r $(_STAGE2_SKEL)/* $(_STAGE2)
stage2: $(_STAGE2) $(_STAGE2_REAL_TARGETS)
cp -r $(_STAGE2_SKEL)/* $(_STAGE2)
cp -r $(TOOLCHAIN)/lib/*.so* $(_STAGE2)/lib/
stage2-fetch: $(_STAGE2_FETCH_TARGETS)
stage2-clean: $(_STAGE2_CLEAN_TARGETS)
stage2-distclean: $(_STAGE2_DISTCLEAN_TARGETS)
rm -rf $(_STAGE2)
# #####################################################################
sync:
mount /dev/sda1 /mnt/usbdisk
rsync -a -c --delete --progress --stats $(_STAGE2)/ /mnt/usbdisk
umount /mnt/usbdisk