# # This Makefile executes the unpack/build/binary targets for a single # subarch, which is passed in the subarch variable. Empty subarch # variable means that we are building for an arch without the subarch. # Additionally, variables version, abiname and ktver are # expected to be available (need to be exported from the parent process). # It is possible to override the flavours by setting the flavours # variable. # SHELL := sh -e debver := $(version)-$(abiname) uver := $(subst .,_,$(version)) debnum := -$(abiname) bpkg := kernel-build-$(debver) kbpkg := kernel-kbuild-$(version)-$(abiname) kpatch := /usr/src/kernel-patches/all/$(version)/apply/debian $(version)-$(ktver) 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 export version debnum DEBIAN_UPSTREAM_VERSION karch := $(DEB_HOST_ARCH) ifeq ($(subarch),none) basedir := arch/$(karch) else basedir := arch/$(karch)/$(subarch) endif default := $(basedir)/config.default configs := $(notdir $(wildcard $(basedir)/config.*)) configs := $(filter-out config.common config.default, $(configs)) tkdir := kernel-source-$(version) kdir := kernel-source-$(version)-$(subarch) ifndef flavours flavours := $(patsubst config.%,%,$(configs)) endif build_prefix := build-$(subarch)- -include $(basedir)/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 arch/subarch # 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-$(subarch)' kpkg_headers_cmd += make-kpkg --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 # # 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-$(subarch) unpack-stamp-$(subarch): $(kdir) $(configs) header-install-$(subarch) for i in $(flavours); do \ cp -al $(kdir) build-$(subarch)-$$i; \ cp config.$$i build-$(subarch)-$$i/.config; \ done # Need to clean out configs so that there is no filename # clash with other subarches. rm -f $(configs) touch unpack-stamp-$(subarch) # # 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-$(subarch) build-stamp-$(subarch): unpack-stamp-$(subarch) dh_testdir PATH=$$PWD/bin:$$PATH; \ for i in $(flavours); do \ cd build-$(subarch)-$$i; \ $(kpkg_build_cmd); \ cd ..; \ done touch build-stamp-$(subarch) binary-indep: build binary-arch: build dh_testdir dh_clean -k dh_installdirs cd $(kdir); $(kpkg_headers_cmd) # # Hmm, is it right to just cat all the debian/files # together? Need to check it out... # cat $(kdir)/debian/files >> debian/files for i in $(flavours); do \ cp -al build-$(subarch)-$$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-$(subarch): header-install.in sed -e 's,@kbpkg@,$(kbpkg),g' \ -e 's,@ksource_dir@,$(CURDIR)/$(kdir),g' \ -e 's,@headers_dirs@,$(headers_dirs),g' \ -e 's,@headers_extra@,$(headers_extra),g' \ header-install.in > header-install-$(subarch) chmod u+x header-install-$(subarch) post-install: post-install.in sed -e 's,@initrd_modules@,$(initrd_modules),' \ post-install.in > post-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='$(basedir)/config.common'; \ subarch='$(basedir)/$@'; \ 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." # # TODO: subarch specific patches # $(kdir): post-install dh_testdir tar jxf /usr/src/$(tkdir).tar.bz2 mkdir -p $(tkdir)/debian cp debian/changelog $(tkdir)/debian cp debian/control $(tkdir)/debian cp debian/copyright $(tkdir)/debian cp $(default) $(tkdir)/.config touch $(tkdir)/debian/official install post-install $(tkdir)/debian cd $(tkdir) && $(kpatch) # Here we need to do the subarch-specific patching mv $(tkdir) $@ .PHONY: build unpack binary-indep binary-arch binary