| 1 |
jurij-guest |
3146 |
#
|
| 2 |
|
|
# This Makefile executes the unpack/build/binary targets for a single
|
| 3 |
|
|
# subarch, which is passed in the subarch variable. Empty subarch
|
| 4 |
|
|
# variable means that we are building for an arch without the subarch.
|
| 5 |
|
|
# Additionally, variables version, abiname and ktver are
|
| 6 |
|
|
# expected to be available (need to be exported from the parent process).
|
| 7 |
|
|
# It is possible to override the flavours by setting the flavours
|
| 8 |
jurij-guest |
3215 |
# variable.
|
| 9 |
jurij-guest |
3146 |
#
|
| 10 |
|
|
SHELL := sh -e
|
| 11 |
|
|
debver := $(version)-$(abiname)
|
| 12 |
|
|
uver := $(subst .,_,$(version))
|
| 13 |
|
|
debnum := -$(abiname)
|
| 14 |
|
|
kbpkg := kernel-kbuild-$(version)-$(abiname)
|
| 15 |
jurij-guest |
3204 |
# This will eventually have to be changed to a command, applying
|
| 16 |
|
|
# the debian's patches from the local tree (arch/patches?)
|
| 17 |
jurij-guest |
3146 |
kpatch := /usr/src/kernel-patches/all/$(version)/apply/debian $(version)-$(ktver)
|
| 18 |
|
|
DEBIAN_UPSTREAM_VERSION := $(version)
|
| 19 |
|
|
ifeq (,$(DEB_HOST_ARCH))
|
| 20 |
|
|
DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
|
| 21 |
|
|
DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
|
| 22 |
|
|
endif
|
| 23 |
|
|
export version debnum DEBIAN_UPSTREAM_VERSION
|
| 24 |
|
|
|
| 25 |
jurij-guest |
3198 |
karch := $(DEB_HOST_ARCH)
|
| 26 |
|
|
#
|
| 27 |
|
|
# Build the list of common config files to be included
|
| 28 |
|
|
#
|
| 29 |
jurij-guest |
3146 |
ifeq ($(subarch),none)
|
| 30 |
|
|
basedir := arch/$(karch)
|
| 31 |
jurij-guest |
3203 |
append :=
|
| 32 |
jurij-guest |
3146 |
else
|
| 33 |
|
|
basedir := arch/$(karch)/$(subarch)
|
| 34 |
jurij-guest |
3203 |
append := -$(subarch)
|
| 35 |
jurij-guest |
3146 |
endif
|
| 36 |
jurij-guest |
3198 |
default := $(basedir)/config.default
|
| 37 |
|
|
configs := $(notdir $(wildcard $(basedir)/config.*))
|
| 38 |
|
|
configs := $(filter-out config.common config.default, $(configs))
|
| 39 |
|
|
tkdir := kernel-source-$(version)
|
| 40 |
|
|
kdir := kernel-source-$(version)-$(subarch)
|
| 41 |
jurij-guest |
3146 |
ifndef flavours
|
| 42 |
|
|
flavours := $(patsubst config.%,%,$(configs))
|
| 43 |
|
|
endif
|
| 44 |
|
|
build_prefix := build-$(subarch)-
|
| 45 |
jurij-guest |
3203 |
|
| 46 |
jurij-guest |
3146 |
-include $(basedir)/Makefile.inc
|
| 47 |
jurij-guest |
3203 |
|
| 48 |
jurij-guest |
3146 |
#
|
| 49 |
|
|
# Here we construct the command lines for different make-kpkg
|
| 50 |
|
|
# calls (build, kernel-image, kernel-headers) based on the values
|
| 51 |
|
|
# of variables defined so far and provided by the arch/subarch
|
| 52 |
jurij-guest |
3215 |
# in Makefile.inc. @flavour@ in the expressions is going to be
|
| 53 |
|
|
# replaced by the flavour for which the command is run.
|
| 54 |
jurij-guest |
3146 |
#
|
| 55 |
|
|
kpkg_headers_cmd := HEADER_CLEAN_HOOK='$(CURDIR)/header-install-$(subarch)'
|
| 56 |
jurij-guest |
3203 |
kpkg_headers_cmd += make-kpkg --append-to-version $(debnum)$(append)
|
| 57 |
jurij-guest |
3215 |
kpkg_build_cmd := make-kpkg --append-to-version $(debnum)-@flavour@
|
| 58 |
jurij-guest |
3146 |
ifdef added_patches
|
| 59 |
|
|
kpkg_headers_cmd += --added_patches $(subst @uver@,$(uver),$(added_patches))
|
| 60 |
|
|
kpkg_build_cmd += --added_patches $(subst @uver@,$(uver),$(added_patches))
|
| 61 |
|
|
endif
|
| 62 |
|
|
ifdef build_subarch
|
| 63 |
jurij-guest |
3215 |
kpkg_build_cmd += --subarch @flavour@
|
| 64 |
jurij-guest |
3146 |
endif
|
| 65 |
|
|
ifdef headers_subarch
|
| 66 |
|
|
kpkg_headers_cmd += --subarch $(headers_subarch)
|
| 67 |
|
|
endif
|
| 68 |
|
|
ifdef build_makeflags
|
| 69 |
|
|
kpkg_build_cmd := MAKEFLAGS=$(build_makeflags) $(kpkg_build_cmd)
|
| 70 |
|
|
endif
|
| 71 |
jurij-guest |
3217 |
kpkg_image_cmd := $(image_prefix) $(kpkg_build_cmd) --initrd kernel_image
|
| 72 |
|
|
kpkg_image_cmd := $(strip $(kpkg_image_cmd))
|
| 73 |
jurij-guest |
3146 |
kpkg_build_cmd += build
|
| 74 |
|
|
kpkg_headers_cmd += kernel-headers
|
| 75 |
|
|
ifndef headers_dirs
|
| 76 |
|
|
headers_dirs = $(karch)
|
| 77 |
|
|
endif
|
| 78 |
jurij-guest |
3198 |
ifneq (no,$(include_common_config))
|
| 79 |
|
|
ccommon := arch/config.common
|
| 80 |
|
|
endif
|
| 81 |
|
|
ccommon += arch/$(karch)/config.common arch/$(karch)/$(subarch)/config.common
|
| 82 |
jurij-guest |
3146 |
#
|
| 83 |
jurij-guest |
3215 |
# Here we build lists of directories and stamps which we will depend on.
|
| 84 |
|
|
# For each class of such targets there is a pattern rule which will catch
|
| 85 |
|
|
# it and do the right thing.
|
| 86 |
jurij-guest |
3146 |
#
|
| 87 |
jurij-guest |
3215 |
bdirs := $(addprefix build-$(subarch)-, $(flavours))
|
| 88 |
|
|
bstamps := $(addprefix build-stamp-$(subarch)-, $(flavours))
|
| 89 |
|
|
istamps := $(addprefix install-stamp-$(subarch)-, $(flavours))
|
| 90 |
|
|
#
|
| 91 |
|
|
# Targets
|
| 92 |
|
|
#
|
| 93 |
jurij-guest |
3146 |
unpack: unpack-stamp-$(subarch)
|
| 94 |
jurij-guest |
3201 |
unpack-stamp-$(subarch): $(configs) header-install-$(subarch) $(bdirs)
|
| 95 |
jurij-guest |
3146 |
touch unpack-stamp-$(subarch)
|
| 96 |
jurij-guest |
3215 |
|
| 97 |
jurij-guest |
3146 |
build: build-stamp-$(subarch)
|
| 98 |
jurij-guest |
3215 |
build-stamp-$(subarch): unpack-stamp-$(subarch) $(bstamps)
|
| 99 |
jurij-guest |
3146 |
touch build-stamp-$(subarch)
|
| 100 |
|
|
|
| 101 |
|
|
binary-indep: build
|
| 102 |
jurij-guest |
3215 |
binary-arch: build headers-stamp $(istamps)
|
| 103 |
|
|
mv *.deb ..
|
| 104 |
|
|
|
| 105 |
|
|
install-stamp-$(subarch)-%: build-$(subarch)-% build-stamp-$(subarch)-%
|
| 106 |
|
|
cp -al $< install-$*;
|
| 107 |
jurij-guest |
3217 |
cd install-$*; $(subst @flavour@,$*,$(kpkg_image_cmd))
|
| 108 |
jurij-guest |
3215 |
cat install-$*/debian/files >> debian/files;
|
| 109 |
|
|
rm -rf install-$*;
|
| 110 |
|
|
touch install-stamp-$(subarch)-$*
|
| 111 |
|
|
|
| 112 |
|
|
headers-stamp: $(kdir)
|
| 113 |
jurij-guest |
3146 |
dh_testdir
|
| 114 |
|
|
dh_clean -k
|
| 115 |
|
|
dh_installdirs
|
| 116 |
|
|
cd $(kdir); $(kpkg_headers_cmd)
|
| 117 |
|
|
cat $(kdir)/debian/files >> debian/files
|
| 118 |
jurij-guest |
3215 |
touch headers-stamp
|
| 119 |
jurij-guest |
3146 |
|
| 120 |
|
|
binary: binary-indep binary-arch
|
| 121 |
|
|
|
| 122 |
|
|
header-install-$(subarch): header-install.in
|
| 123 |
|
|
sed -e 's,@kbpkg@,$(kbpkg),g' \
|
| 124 |
|
|
-e 's,@ksource_dir@,$(CURDIR)/$(kdir),g' \
|
| 125 |
|
|
-e 's,@headers_dirs@,$(headers_dirs),g' \
|
| 126 |
|
|
-e 's,@headers_extra@,$(headers_extra),g' \
|
| 127 |
|
|
header-install.in > header-install-$(subarch)
|
| 128 |
|
|
chmod u+x header-install-$(subarch)
|
| 129 |
jurij-guest |
3198 |
#
|
| 130 |
|
|
# The way to make the correct package names is to make a
|
| 131 |
|
|
# subarch-specific post-install script...
|
| 132 |
|
|
#
|
| 133 |
jurij-guest |
3203 |
post-install-$(subarch): post-install.in
|
| 134 |
jurij-guest |
3146 |
sed -e 's,@initrd_modules@,$(initrd_modules),' \
|
| 135 |
jurij-guest |
3203 |
-e 's,@append_subarch@,$(append),' \
|
| 136 |
|
|
post-install.in > post-install-$(subarch)
|
| 137 |
jurij-guest |
3146 |
#
|
| 138 |
|
|
# Generates the kernel config file for a subarch by merging
|
| 139 |
|
|
# the arch-independent config file (arch/config.common),
|
| 140 |
|
|
# arch-specific config file (arch/$(karch)/config.common),
|
| 141 |
|
|
# and subarch specific one (arch/$(karch)/config.subarch).
|
| 142 |
|
|
# It is possible to avoid the inclusion of the arch-indep
|
| 143 |
|
|
# config file by setting include_common_config = no in the
|
| 144 |
jurij-guest |
3198 |
# arch/$(karch)/Makefile.inc.
|
| 145 |
jurij-guest |
3146 |
#
|
| 146 |
|
|
config.%:
|
| 147 |
jurij-guest |
3215 |
@echo "configs=$(configs)"
|
| 148 |
jurij-guest |
3198 |
@echo "Generating configuration file $@:"
|
| 149 |
|
|
rm -f $@
|
| 150 |
|
|
for i in $(ccommon); do \
|
| 151 |
|
|
if [ -f $${i} ]; then \
|
| 152 |
|
|
cat $${i} >> $@; \
|
| 153 |
|
|
fi; \
|
| 154 |
|
|
done
|
| 155 |
|
|
# Flavour config file must be present
|
| 156 |
|
|
cat $(basedir)/$@ >> $@
|
| 157 |
jurij-guest |
3215 |
|
| 158 |
jurij-guest |
3203 |
$(kdir): post-install-$(subarch)
|
| 159 |
jurij-guest |
3146 |
dh_testdir
|
| 160 |
|
|
tar jxf /usr/src/$(tkdir).tar.bz2
|
| 161 |
|
|
mkdir -p $(tkdir)/debian
|
| 162 |
|
|
cp debian/changelog $(tkdir)/debian
|
| 163 |
|
|
cp debian/control $(tkdir)/debian
|
| 164 |
|
|
cp debian/copyright $(tkdir)/debian
|
| 165 |
|
|
cp $(default) $(tkdir)/.config
|
| 166 |
|
|
touch $(tkdir)/debian/official
|
| 167 |
jurij-guest |
3203 |
install post-install-$(subarch) $(tkdir)/debian/post-install
|
| 168 |
jurij-guest |
3146 |
cd $(tkdir) && $(kpatch)
|
| 169 |
jurij-guest |
3204 |
# Arch/subarch-specific patches
|
| 170 |
|
|
if [ -d $(basedir)/patches ] && \
|
| 171 |
|
|
[ -s $(basedir)/patches/list ]; then \
|
| 172 |
|
|
cd $(tkdir); \
|
| 173 |
|
|
for i in $$(cat ../$(basedir)/patches/list); do \
|
| 174 |
|
|
patch -p1 < ../$(basedir)/patches/$${i}; \
|
| 175 |
|
|
done; \
|
| 176 |
|
|
fi
|
| 177 |
jurij-guest |
3146 |
mv $(tkdir) $@
|
| 178 |
jurij-guest |
3215 |
#
|
| 179 |
|
|
# This target performs a build for a particular flavour. Note
|
| 180 |
|
|
# that in this file it should be always placed *before* the
|
| 181 |
|
|
# build-$(subarch)-% target, which creates the build directory.
|
| 182 |
|
|
#
|
| 183 |
|
|
build-stamp-$(subarch)-%: build-$(subarch)-%
|
| 184 |
|
|
dh_testdir
|
| 185 |
|
|
PATH=$$PWD/bin:$$PATH; \
|
| 186 |
|
|
cd $<; \
|
| 187 |
|
|
$(subst @flavour@,$*,$(kpkg_build_cmd)); \
|
| 188 |
|
|
$(if $(image_postproc),$(image_postproc),true);
|
| 189 |
|
|
touch build-stamp-$(subarch)-$*
|
| 190 |
|
|
#
|
| 191 |
|
|
# Creates a build directory for a particular flavour
|
| 192 |
|
|
#
|
| 193 |
|
|
build-$(subarch)-%: $(kdir) config.%
|
| 194 |
|
|
dh_testdir
|
| 195 |
jurij-guest |
3201 |
if [ ! -d $@ ]; then \
|
| 196 |
|
|
cp -al $(kdir) $@; \
|
| 197 |
jurij-guest |
3215 |
cp config.$* $@/.config; \
|
| 198 |
jurij-guest |
3201 |
fi
|
| 199 |
|
|
|
| 200 |
jurij-guest |
3146 |
.PHONY: build unpack binary-indep binary-arch binary
|