diff --git a/README b/README index c1cfd076c..01cafa578 100644 --- a/README +++ b/README @@ -46,42 +46,61 @@ this file include the setting of the following variables: include_common_config Setting it to 'no' will prevent the common kernel config from being - included for this particular architecture. + included for this particular architecture. Typical usage: -header_dirs + include_common_config := no + +headers_dirs This variable is substituted into the headers-install script, controlling which asm-* directories are included into the kernel-headers package. By default it is set to karch (see - above). For sparc, for example, if will have to be set to - 'sparc | sparc64' for the correct packages to be generated. See - headers-install file for details. + above). See header-install.in file for detail. Typical usage: + + headers_dirs := sparc | sparc64 -arch_makeflags +headers_subarch + + The subarch to pass to the --subarch option for the make-kpkg + call to build the kernel-headers. Typical usage: + + headers_subarch := sparc64 + +added_patches + + Setting this variable to non-empty value will cause an option + --added_patches to be added to the make-kpkg 'build' and + 'kernel-image' calls. The value of the variable will be + given as an argument for the --added-patchs option. The value + of this variable may contain a special string @uver@ which + is going to be expanded into the upstream kernel's version + with dots replaced by underscores (for example, 2_6_11 for the + kernel version 2.6.11). Typical usage: + + added_patches := debian,hppa-@uver@ + +build_subarch + + Setting this variable to non-empty value will cause an option + --subarch to be added to 'build' and 'kernel-image' make-kpkg + calls, followed by the flavour for which the kernel is built. + In general, if you wish to add subarch support for your + architecture, you should contact kernel-package maintainer + to ensure that the flavour name correctly maps onto a kernel + subarch name. Currently only mips and sparc are using this + facility, and both of them should be fine. Typical usage: + + build_subarch := yes + + Note that the value of this variable is ignored. + +build_makeflags This variable may contain the make flags settings for the make-kpkg invocation in the 'build' target. Currently it is only used by amd64, where it should be set to something like - arch_makeflags = 'CC=amd64-linux-gcc V=1" + build_makeflags := 'CC=amd64-linux-gcc V=1' -added_patches - - Setting this variable to non-empty value will cause an option - --added_patches to be added to the make-kpkg call in 'build' - target, followed by the contents of this variable. Currently - hppa is using it and it looks like ia64 have used it before. - -arch_with_subarch - - Setting this variable to non-empty value will cause an option - --subarch to be added to make-kpkg call in 'build' target, - followed by the flavour for which the kernel is built. NOTE - that the contents of this variable are completely ignored, - any non-empty value indicates that --subarch option should - be added. In general, if you wish to add subarch support for - your architecture, you should contact kernel-package maintainer - to ensure that the flavour name correctly maps onto a kernel - subarch name. Currently only mips and sparc are using this - facility, and both of them should be fine. + The value of the variable must be properly quoted. diff --git a/arch/i386/Makefile.inc b/arch/i386/Makefile.inc index 54cb8e161..c3c90ee83 100644 --- a/arch/i386/Makefile.inc +++ b/arch/i386/Makefile.inc @@ -2,6 +2,3 @@ # Variables # include_common_config = no -added_patches = blah -arch_with_subarch = yes -arch_makeflags = 'CC=gcc-2.95' diff --git a/debian/rules b/debian/rules index bc11b8e72..0532d3d45 100755 --- a/debian/rules +++ b/debian/rules @@ -1,101 +1,155 @@ #!/usr/bin/make -f # -version = 2.6.11 -abiname = 1 -ktver = 2 -kbuildver = 2.6-3 +# 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) -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) +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) + 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- + CROSS := $(DEB_HOST_ARCH)-linux- endif -karch = $(DEB_HOST_ARCH) +karch := $(DEB_HOST_ARCH) -controls = $(wildcard arch/*/control.in) -configs = $(notdir $(wildcard arch/$(karch)/config.*)) +controls := $(wildcard arch/*/control.in) +configs := $(notdir $(wildcard arch/$(karch)/config.*)) ifndef flavours - flavours = $(filter-out common, $(patsubst config.%,%,$(configs))) + flavours := $(filter-out common, $(patsubst config.%,%,$(configs))) endif -include arch/$(karch)/Makefile.inc - -ifndef header_dirs - header_dirs = $(karch) +# +# 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 # -# Unresolved issues: -# Where does the default config comes from? +# 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.out - for i in $(flavours); do \ - cp -al $(kdir) build-$$i; \ - cp config.$$i build-$$i/.config; \ - make -C build-$$i ARCH=$(karch) oldconfig; \ +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 -# 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? +# 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; \ - 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 ..; \ + 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.out config.* + rm -f *-stamp header-install 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 +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), @@ -123,7 +177,7 @@ config.%: cat $${include} > $@ @echo " done." # -# Prepare debian/control by cat'ing together all the +# 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:' diff --git a/header-install b/header-install.in similarity index 100% rename from header-install rename to header-install.in