#!/usr/bin/make -f # # Required variables # version := 2.6.11 abiname := 1 ktver := 2 kbuildver := 2.6-3 # # Generally nothing needs to be modified below this line # debver := $(version)-$(abiname) uver := $(subst .,_,$(version)) debnum := -$(abiname) bpkg := kernel-build-$(debver) kdir := kernel-source-$(version) kbpkg := kernel-kbuild-$(kbuildver) kpatch := /usr/src/kernel-patches/all/$(version)/apply/debian export DEBIAN_SRCTOP := $(CURDIR)/$(kdir) export 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 # # The CROSS variable is only used on sparc to call # the correct 'strip' binary on the kernel-image. # Not sure whether we really need it. # 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 # # Here we construct the command lines for different make-kpkg # calls (build, kernel-image, kernel-headers) based on the values # of variables defined so far and provided by the architecture # in Makefile.inc. Note that $$i in these expressions is going to # become a reference to the shell variable $i, which is expected # to have the current flavour. This is slightly evil, but saves # a lot of grief. # kpkg_headers_cmd := HEADER_CLEAN_HOOK='$(CURDIR)/header-install' make-kpkg kpkg_headers_cmd += --append-to-version $(debnum) kpkg_build_cmd := make-kpkg --append-to-version $(debnum)-$$i ifdef added_patches kpkg_headers_cmd += --added_patches $(subst @uver@,$(uver),$(added_patches)) kpkg_build_cmd += --added_patches $(subst @uver@,$(uver),$(added_patches)) endif ifdef build_subarch kpkg_build_cmd += --subarch $$i endif ifdef headers_subarch kpkg_headers_cmd += --subarch $(headers_subarch) endif ifdef build_makeflags kpkg_build_cmd := MAKEFLAGS=$(build_makeflags) $(kpkg_build_cmd) endif kpkg_image_cmd := $(kpkg_build_cmd) --initrd kernel_image kpkg_build_cmd += build kpkg_headers_cmd += kernel-headers ifndef headers_dirs headers_dirs = $(karch) endif # # Problems: # * What to do with default config? # TODO: # * Check that make oldconfig does not actually # change the config file. If it does, something # is wrong (missing/extra options, etc). # unpack: unpack-stamp unpack-stamp: $(kdir) $(configs) header-install for i in $(flavours); do \ cp -al $(kdir) build-$$i; \ cp config.$$i build-$$i/.config; \ make -C build-$$i ARCH=$(karch) oldconfig; \ done ln -s $$(command -v touch) bin/touch.orig touch unpack-stamp # # Problems: # * m68k,mips have no-op build targets # * sparc strips parts of the kernel after building # otherwise it is too big for silo to boot. # TODO: # * Implement optional stripping of the kernel # (for sparc). # * Check that it is really ok to call --subarch # with the name of the flavour. For mips which # is another --subarch user it should be fine. # build: build-stamp build-stamp: unpack-stamp dh_testdir PATH=$$PWD/bin:$$PATH; \ for i in $(flavours); do \ cd build-$$i; \ $(kpkg_build_cmd); \ cd ..; \ done touch build-stamp clean: rm -f *-stamp header-install config.* rm -rf $(kdir) build-* install-* bin/touch.orig dh_clean binary-indep: build # # Problems: # * sparc prepends the 'kernel-image' make-kpkg call # by 'sparc32' and 'sparc64', depending on the flavour. # Need to figure out the role of these binaries. # binary-arch: build dh_testdir dh_clean -k dh_installdirs cd $(kdir); $(kpkg_headers_cmd) mv $(kdir)/debian/files debian for i in $(flavours); do \ cp -al build-$$i install-$$i; \ cd install-$$i; \ $(kpkg_image_cmd); \ cd ..; \ cat install-$$i/debian/files >> debian/files \ rm -rf install-$$i done mv *.deb .. binary: binary-indep binary-arch header-install: header-install.in sed -e 's/@kbpkg@/$(kbpkg)/g' \ -e 's/@karch@/$(karch)/g' \ -e 's/@headers_dirs@/$(headers_dirs)/g' \ header-install.in > header-install chmod u+x header-install # # 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." # # Prepares 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."