rendered paste body#####################################################################################
#
# vim: noexpandtab
#
#####################################################################################
# .SILENT:
ifeq ($(KERNEL_LAYOUT),)
# KERNEL_LAYOUT := 8mb_26
KERNEL_LAYOUT := arm926
endif
##########################################################################################
LINUX_KERNEL_VERSION := 2.6.13.1
CP := cp
MAKE := make
FILESYSTEM := filesystem
export INSTALL_MOD_PATH := $(shell echo `pwd`/$(FILESYSTEM))
##########################################################################################
ifeq ($(KERNEL_LAYOUT),arm926)
ARCH := arm
CROSS_COMPILE ?= arm-elf-linux-
else
ARCH := mips
CROSS_COMPILE ?= mipsel-uclibc-linux-
endif
##########################################################################################
SWITCH_KERNEL ?= ../arch/kernel_switch_subproject
SWITCH_KERNEL_PARAM ?= j
SUB_PROJET_LIST := atm power vinax cpmac emac audio Piglet ahci stick_and_surf ubik2 \
isdn_fon isdn_fon2 isdn_fon3 isdn_fon4 isdn_fon5 isdn_fon6 flash_update \
oss_audio avm rfcntl lzma
export PATH := $(HOME)/bin/$(KERNEL_LAYOUT)/bin:$(AR7BIN_HOME)/$(KERNEL_LAYOUT)/bin:$(PATH)
KERNEL_BUILD_PARAMS := ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
LZMA_LIB := kernel/linux-$(LINUX_KERNEL_VERSION)/fs/squashfs/lzma_decode.a
##########################################################################################
all: $(LZMA_LIB)
$(CP) Config.$(KERNEL_LAYOUT) kernel/linux-$(LINUX_KERNEL_VERSION)/.config
$(MAKE) -C kernel/linux-$(LINUX_KERNEL_VERSION) $(KERNEL_BUILD_PARAMS)
if ! diff -q Config.$(KERNEL_LAYOUT) kernel/linux-$(LINUX_KERNEL_VERSION)/.config ; then \
LinesDatediff=`diff -au Config.$(KERNEL_LAYOUT) kernel/linux-$(LINUX_KERNEL_VERSION)/.config | grep -e '^[-+]' | grep -v '^---' | grep -v '^+++' | grep -e '[[:digit:]]\+:[[:digit:]][[:digit:]]:[[:digit:]][[:digit:]] [[:digit:]][[:digit:]]' | wc -l`; \
LinesDiff=`diff -au Config.$(KERNEL_LAYOUT) kernel/linux-$(LINUX_KERNEL_VERSION)/.config | grep -e '^[-+]' | grep -v '^---' | grep -v '^+++'| wc -l`; \
if [ $$LinesDiff -gt $$LinesDatediff ] ; then \
$(ECHO) " >> more than a date-diff, updating Config.$(KERNEL_LAYOUT)" ;\
$(CP) kernel/linux-$(LINUX_KERNEL_VERSION)/.config Config.$(KERNEL_LAYOUT) ; \
else \
$(ECHO) " >> ignoring simple date-diff between 'Config.$(KERNEL_LAYOUT)' and 'kernel/linux-$(LINUX_KERNEL_VERSION)/.config'" ;\
fi; \
fi
##########################################################################################
menuconfig:
-$(CP) Config.$(KERNEL_LAYOUT) kernel/linux-$(LINUX_KERNEL_VERSION)/.config
$(MAKE) -C kernel/linux-$(LINUX_KERNEL_VERSION) $(KERNEL_BUILD_PARAMS) menuconfig
$(CP) kernel/linux-$(LINUX_KERNEL_VERSION)/.config Config.$(KERNEL_LAYOUT)
##########################################################################################
oldconfig:
$(CP) Config.$(KERNEL_LAYOUT) kernel/linux-$(LINUX_KERNEL_VERSION)/.config
$(MAKE) -C kernel/linux-$(LINUX_KERNEL_VERSION) $(KERNEL_BUILD_PARAMS) include/linux/autoconf.h
##########################################################################################
clean:
rm -f $(LZMA_LIB)
$(MAKE) -C kernel/linux-$(LINUX_KERNEL_VERSION) clean $(KERNEL_BUILD_PARAMS)
##########################################################################################
distclean:
rm -f $(LZMA_LIB)
$(MAKE) -C kernel/linux-$(LINUX_KERNEL_VERSION) distclean $(KERNEL_BUILD_PARAMS)
##########################################################################################
lieferung:
$(MAKE) external_URLs
$(MAKE) clean
$(MAKE) all
$(MAKE) install
##########################################################################################
external_URLs:
ifneq ($(NO_SVN),1)
for i in $(SUB_PROJET_LIST) ; do \
sh $(SWITCH_KERNEL) $$i `pwd`/kernel/linux-$(LINUX_KERNEL_VERSION) $(KERNEL_LAYOUT) $(SWITCH_KERNEL_PARAM) || exit 1 ; \
done
endif
##########################################################################################
svn_status:
ifneq ($(NO_SVN),1)
svn status -qu .
for i in $(SUB_PROJET_LIST) ; do \
sh $(SWITCH_KERNEL) $$i `pwd`/kernel/linux-$(LINUX_KERNEL_VERSION) $(KERNEL_LAYOUT) status || exit 1 ; \
done
endif
##########################################################################################
$(LZMA_LIB):
ifeq ($(KERNEL_LAYOUT),arm926)
$(MAKE) -C lzma lzma_decode.a CROSS_COMPILE=$(CROSS_COMPILE) \
USE_CFLAGS="-D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing \
-fno-common -ffreestanding -falign-functions=4 -falign-labels=4 -falign-loops=4 -falign-jumps=4 \
-fomit-frame-pointer -g 0 -fno-pic -finline-limit=100000 -Wa, -mthumb -mthumb-interwork -mapcs-32 -mlittle-endian\
"
else
$(MAKE) -C lzma lzma_decode.a CROSS_COMPILE=$(CROSS_COMPILE) \
USE_CFLAGS="-D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing \
-fno-common -ffreestanding -falign-functions=4 -falign-labels=4 -falign-loops=4 -falign-jumps=4 \
-fomit-frame-pointer -g -G 0 -mno-abicalls -fno-pic -finline-limit=100000 -mabi=32 -march=mips32 -Wa,-32 \
-Wa,-march=mips32 -Wa,-mips32 -Wa,--trap"
cp lzma/lzma_decode.a $@
endif
##########################################################################################
kernel.version.h:
##########################################################################################
install: update_h_files
$(MAKE) -C kernel/linux-$(LINUX_KERNEL_VERSION) $(KERNEL_BUILD_PARAMS) modules_install
$(CROSS_COMPILE)objcopy -S -O binary kernel/linux-$(LINUX_KERNEL_VERSION)/vmlinux vmlinux; \
rm -f lha.options
echo -e "-l \c" >>lha.options
grep 'A _text' kernel/linux-$(LINUX_KERNEL_VERSION)/System.map | sed -e's/\(.*\) A .*/0x\1/g' | tr '\n' ' ' >>lha.options
echo -e "-e \c" >>lha.options
grep 'T kernel_entry' kernel/linux-$(LINUX_KERNEL_VERSION)/System.map | sed -e's/\(.*\) T .*/0x\1/g' | tr '\n' ' ' >>lha.options
echo 'MODUL_NAME=_$(KERNEL_LAYOUT)_kernel' >>kernel.version.h
echo 'DESCRIPTION=Kernel for $(KERNEL_LAYOUT)' >>kernel.version.h
echo 'VERSION=$(KERNEL_VERSION)' >>kernel.version.h
echo "DATE=`date +\"%d.%m.%Y-%X\"`" >>kernel.version.h
tar czpf kernel.$(KERNEL_LAYOUT).`echo $(KERNEL_VERSION) | tr ':' '-'`.tar.gz vmlinux lha.options ./filesystem kernel.version.h
find . -name 'kernel.*.tar.gz' -mtime +7 -maxdepth 1 -exec rm {} \;
rm -f kernel.version.h
rm -f install
echo '#! /bin/sh' >>install
echo 'echo "########################################################################"' >>install
echo 'echo "#"' >>install
echo "echo \"# Install script for $(KERNEL_LAYOUT)\"" >>install
echo 'echo "#"' >>install
echo 'echo "########################################################################"' >>install
echo 'rm -rf kernel.install' >>install
echo 'mkdir kernel.install' >>install
echo 'cd kernel.install' >>install
echo 'if [ "$${install_path}" = "" ] ; then' >>install
echo ' install_path=.' >>install
echo 'fi' >>install
echo 'if [ "$${filesystem}" = "" ] ; then' >>install
echo ' filesystem=filesystem' >>install
echo 'fi' >>install
echo "echo unpack archive \"kernel.$(KERNEL_LAYOUT).$(KERNEL_VERSION).tar.gz\" ..." >>install
echo "tar xzf ../kernel.$(KERNEL_LAYOUT).`echo $(KERNEL_VERSION) | tr ':' '-'`.tar.gz" >>install
echo -e "source_files=\"\c" >>install
find ./filesystem/lib/modules ./filesystem/include | sed -e 's/\(.*\)$$/ \1\\/g' >>install
echo -e "\"" >>install
# echo -e 'find ../$${install_path}/$${filesystem}/lib/modules/$(LINUX_KERNEL_VERSION)-ohio -name \x27*.ko\x27 -exec rm -f {} \;' >>install
echo 'for i in $${source_files} ; do ' >>install
echo ' destfile=`echo $$i | sed -e "s/.*modules\/\(.*\)/$${filesystem}\/lib\/modules\/\1/g"`' >>install
echo ' rm -f ../$${install_path}/destfile' >>install
echo ' if [ ! -d ../$${install_path}/`dirname $${destfile}` ] ; then' >>install
echo ' echo create "`dirname $${destfile}`" ...' >>install
echo ' mkdir -p ../$${install_path}/`dirname $${destfile}`' >>install
echo ' fi' >>install
echo ' echo install "$${destfile}"' >>install
echo ' install --mode=444 $$i ../$${install_path}/$${destfile}' >>install
echo 'done' >>install
# echo 'rm -f ../$${install_path}/image/kernel.image ../$${install_path}/image/kernel.image.urlader' >>install
# echo 'echo install "image/kernel.image"' >>install
# echo 'install --mode=444 kernel.image ../$${install_path}/image' >>install
# echo 'echo install "image/kernel.image.urlader"' >>install
# echo 'install --mode=444 kernel.image.urlader ../$${install_path}/image' >>install
echo 'echo install "kernel.version.h"' >>install
echo 'install --mode=444 kernel.version.h ../$${filesystem_path}/.version' >>install
echo 'echo install done' >>install
chmod +x install
cp kernel/linux-$(LINUX_KERNEL_VERSION)/System.map .
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
update_h_files:
if [ `id -n -u` = ar7bin ] ; then \
make .update_h_files || exit 1 ; \
fi
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
.update_h_files:
echo "update h files in compiler path ..." ; \
rm -rf $(AR7BIN_HOME)/$(KERNEL_LAYOUT)/include/asm
rm -rf $(AR7BIN_HOME)/$(KERNEL_LAYOUT)/include/linux
target_home=`pwd` ; \
( cd $$target_home/kernel/linux-$(LINUX_KERNEL_VERSION)/include && \
tar --create --gzip --file=$$target_home/h-files.tar.gz --exclude '.svn*' --exclude 'route.h' . && \
cd $(AR7BIN_HOME)/$(KERNEL_LAYOUT)/include && \
tar --extract --gunzip --file=$$target_home/h-files.tar.gz \
) ; \
rm -f $$target_home/h-files.tar.gz
.PHONY: install kernel.version.h lieferung distclean clean menuconfig all