linux/debian/rules

152 lines
5.1 KiB
Makefile
Executable File

#!/usr/bin/make -f
#
version = 2.6.11
abiname = 1
ktver = 2
kbuildver = 2.6-3
#
# Generally nothing needs to be modified below this line
#
debver = $(version)-$(abiname)
debnum = -$(abiname)
appvan = --append_to_version $(debnum)
bpkg = kernel-build-$(debver)
kdir = kernel-source-$(version)
kbpkg = kernel-kbuild-$(kbuildver)
kpatch = /usr/src/kernel-patches/all/$(version)/apply/debian
DEBIAN_SRCTOP = $(CURDIR)/$(kdir)
DEBIAN_UPSTREAM_VERSION = $(version)
ifeq (,$(DEB_HOST_ARCH))
DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_BUILD_ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
endif
ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
CROSS = $(DEB_HOST_ARCH)-linux-
endif
karch = $(DEB_HOST_ARCH)
controls = $(wildcard arch/*/control.in)
configs = $(notdir $(wildcard arch/$(karch)/config.*))
ifndef flavours
flavours = $(filter-out common, $(patsubst config.%,%,$(configs)))
endif
-include arch/$(karch)/Makefile.inc
ifndef header_dirs
header_dirs = $(karch)
endif
#
# Unresolved issues:
# Where does the default config comes from?
#
unpack: unpack-stamp
unpack-stamp: $(kdir) $(configs) header-install.out
for i in $(flavours); do \
cp -al $(kdir) build-$$i; \
cp config.$$i build-$$i/.config; \
make -C build-$$i ARCH=$(karch) oldconfig; \
done
# cp default $(kdir)/.config
ln -s $$(command -v touch) bin/touch.orig
touch unpack-stamp
#
# Subarch usage:
# Currently only mips and sparc are calling make-kpkg
# with --subarch. mips is just using the names of the
# flavours, while for sparc it is more complicated.
# After looking at /usr/share/kernel-package/rules, I
# believe that everything will work correctly in sparc
# if use flavour as an argument to subarch.
#
# Unresolved issues:
# m68k,mips have no-op build targets
# How to handle subarch (mips, sparc)?
# What's the deal with sparc trying to strip
# the kernel and copy System.map?
#
build: build-stamp
build-stamp: unpack-stamp
dh_testdir
PATH=$$PWD/bin:$$PATH; \
for i in $(flavours); do \
cd build-$$i; \
OPTS="--append_to_version $(debnum)-$$i"; \
if [ -n '$(added_patches)' ]; then \
OPTS="$${OPTS} --added_patches $(added_patches)"; \
fi; \
if [ -n '$(arch_with_subarch)' ]; then \
OPTS="$${OPTS} --subarch $$i"; \
fi; \
MAKEFLAGS='$(arch_makeflags)' make-kpkg $${OPTS}; \
cd ..; \
done
touch build-stamp
clean:
rm -f *-stamp header-install.out config.*
rm -rf $(kdir) build-* install-* bin/touch.orig
dh_clean
header-install.out: header-install
sed -e 's/@kbpkg@/$(kbpkg)/g' \
-e 's/@karch@/$(karch)/g' \
-e 's/@header_dirs@/$(header_dirs)/g' \
header-install > header-install.out
chmod u+x header-install.out
#
# Generates the kernel config file for a subarch by merging
# the arch-independent config file (arch/config.common),
# arch-specific config file (arch/$(karch)/config.common),
# and subarch specific one (arch/$(karch)/config.subarch).
# It is possible to avoid the inclusion of the arch-indep
# config file by setting include_common_config = no in the
# arch/$(karch)/Makefile.inc. Absense of any of the above
# files is ignored.
#
config.%:
@echo -n "Generating configuration file $@ ..."
@arch='arch/$(karch)/config.common'; \
subarch='arch/$(karch)/$@'; \
include=''; \
if [ '$(include_common_config)' != 'no' ]; then \
include='arch/config.common'; \
fi; \
if [ -f "$${arch}" ]; then \
include="$${include} $${arch}"; \
fi; \
if [ -f "$${subarch}" ]; then \
include="$${include} $${subarch}"; \
fi; \
cat $${include} > $@
@echo " done."
#
# Prepare debian/control by cat'ing together all the
# control files, substituting variables, removing all
# empty lines and inserting a newline before every
# line starting with 'Package:'
#
debian/control:
cat debian/control.in $(controls) | \
sed -e 's/@karch@/$(karch)/g' \
-e 's/@version@/$(version)/g' \
-e 's/@ktver@/$(ktver)/g' \
-e 's/@abiname@/$(abiname)/g' \
-e 's/@kbpkg@/$(kbpkg)/g' | \
sed '/^[[:space:]]*$$/d' | \
sed 's/^Package:/\n&/g' > debian/control
$(kdir):
@echo -n "Unpacking kernel source $(version) ..."
@tar jxf /usr/src/kernel-source-$(version).tar.bz2
@cd $(kdir) && $(kpatch) $(version)-$(ktver)
@mkdir -p $(kdir)/debian
@cp debian/changelog $(kdir)/debian
@cp debian/control $(kdir)/debian
@cp debian/copyright $(kdir)/debian
@touch $(kdir)/debian/official
@install post-install $(kdir)/debian
@echo " done."