linux/debian/rules

297 lines
9.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/make -f
#
# Required variables. See README for a description of all the variables.
#
abiname := 1
#
# Generally nothing needs to be modified below this line
#
SHELL := sh -e
karch := $(shell dpkg-architecture -qDEB_HOST_ARCH)
srcver := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')
version := $(word 1,$(subst -, ,$(srcver)))
ltver := $(word 2,$(subst -, ,$(srcver)))
major_v := $(word 1,$(subst ., ,$(version)))
minor_v := $(word 2,$(subst ., ,$(version)))
major := $(major_v).$(minor_v)
release := $(version)-$(ltver)
uver := $(subst .,_,$(version))
#
# Construct depends and provides for the linux-tree
#
lt_depends += $(shell seq -f 'linux-source-$(version) (= $(version)-%g)' \
-s ' | ' 1 $(ltver))
lt_provides := $(shell seq -f 'linux-tree-$(version)-%g' -s ', ' 1 $(ltver))
#
# If we are not passed a subarchs variable, we obtain the complete
# subarch list as a list of subdirectories in arch/$(karch). We
# also export the flavours variables, which allows to control which
# flavours are built.
#
ifndef subarchs
subarchs := $(shell find debian/arch/$(karch) \
-mindepth 1 -maxdepth 1 -type d \
! -name '.svn' -printf '%f\n')
endif
ifeq (,$(subarchs))
subarchs := none
endif
#
# The following definition gets the list of relevant files in the top-level
# directory. At this point we cannot verify that we are in top-level dir
# (we probably are), so it should be referenced only in the targets which
# run dh_testdir in the beginning.
#
source_files = $(filter-out debian linux-source-$(version), $(shell echo *))
export version abiname ltver kbuildver flavours major uver
patch: debian/patch-stamp
debian/patch-stamp: debian/bin/apply
dh_testdir
chmod +x debian/bin/apply
override_version=$(release) home=debian/patches-debian debian/bin/apply
# make-kpkg does this when building kernel-source.
mv scripts/package/Makefile scripts/package/Makefile.dist
mv scripts/package/builddeb scripts/package/builddeb.dist
echo "# Dummy Makefile" > scripts/package/Makefile
echo "all:" >> scripts/package/Makefile
touch debian/patch-stamp
unpatch:
dh_testdir
if [ -e debian/patch-stamp ]; then \
override_version=$(release) home=debian/patches-debian \
debian/bin/apply $(version); \
cd scripts/package; \
mv Makefile.dist Makefile; \
mv builddeb.dist builddeb; \
fi
rm -f debian/patch-stamp
#
# linux-source package
#
spkg := linux-source-$(version)
sdir := debian/$(spkg)/usr/src
source: debian/source-stamp
debian/source-stamp: debian/patch-stamp
dh_testdir
dh_testroot
dh_installdirs -p$(spkg) /usr/src
# Link the files and create a tarball in correct location
mkdir $(spkg)
cp -al $(source_files) $(spkg)
tar -cjf $(sdir)/$(spkg).tar.bz2 $(spkg)
rm -rf $(spkg)
dh_installdocs -p$(spkg) README
dh_installchangelogs -p$(spkg)
dh_compress -p$(spkg)
dh_fixperms -p$(spkg)
dh_installdeb -p$(spkg)
dh_gencontrol -p$(spkg)
dh_md5sums -p$(spkg)
dh_builddeb -p$(spkg)
touch debian/source-stamp
#
# linux-tree package
#
tpkg := linux-tree-$(version)
tree: debian/tree-stamp
debian/tree-stamp:
dh_testdir
dh_testroot
dh_installdirs -p$(tpkg)
dh_installdocs -p$(tpkg)
dh_installchangelogs -p$(tpkg)
dh_compress -p$(tpkg)
dh_fixperms -p$(tpkg)
dh_installdeb -p$(tpkg)
dh_gencontrol -p$(tpkg)
dh_md5sums -p$(tpkg)
dh_builddeb -p$(tpkg)
touch debian/tree-stamp
#
# linux-patch-debian
#
ppkg := linux-patch-debian-$(version)
pbase := /usr/src/kernel-patches/all/$(version)
pfull := debian/$(ppkg)$(pbase)
pdirs := $(pbase) $(pbase)/apply $(pbase)/debian $(pbase)/unpatch
ptchs := $(notdir $(wildcard debian/patches-arch/*))
kptch := debian/$(ppkg).kpatches.arch
pcdir := debian/patches-arch
patch-debian: debian/patch-debian-stamp
debian/patch-debian-stamp: debian/bin/apply debian/bin/unpatch
dh_testdir
dh_testroot
dh_installdirs -p$(ppkg) $(pdirs)
dh_install -p$(ppkg) debian/patches-debian/* $(pbase)/debian
# Install the debian patches
sed 's/@version@/$(release)/g' debian/bin/apply > $(pfull)/apply/debian
sed 's/@upstream@/$(version)/g' debian/bin/unpatch > $(pfull)/unpatch/debian
chmod a+x $(pfull)/apply/debian $(pfull)/unpatch/debian
chmod -x $(pfull)/debian/*.patch
bzip2 -9 $(pfull)/debian/*.patch
# Now the arch/subarch-specific patches
for i in $(ptchs); do \
rm -f $(kptch); \
arch=$${i%%.*}; \
echo "Patch-name: $${arch}" >> $(kptch); \
echo "Patch-id: $${arch}_$(uver)" >> $(kptch); \
echo "Path-strip-level: 1" >> $(kptch); \
echo >> $(kptch); \
echo "Patch-file: $(pcdir)/$${i}" >> $(kptch); \
echo "Architecture: $${arch}" >> $(kptch); \
echo "Kernel-version: $(version)" >> $(kptch); \
dh_installkpatches -p$(ppkg); \
done
dh_fixperms -p$(ppkg)
dh_installdocs -p$(ppkg)
dh_installchangelogs -p$(ppkg)
dh_compress -p$(ppkg)
dh_installdeb -p$(ppkg)
dh_gencontrol -p$(ppkg)
dh_md5sums -p$(ppkg)
dh_builddeb -p$(ppkg)
touch debian/patch-debian-stamp
#
# linux-doc package
#
dbdir := debian/build-doc
dbddir := $(dbdir)/debian
doc: debian/doc-stamp
debian/doc-stamp: debian/patch-stamp
dh_testdir
dh_testroot
# Create a build tree
mkdir -p $(dbdir)
cp -al $(source_files) $(dbdir)
mkdir -p $(dbddir)
cp debian/changelog $(dbddir)
cp debian/control $(dbddir)
cp debian/copyright $(dbddir)
touch $(dbddir)/official
cd $(dbdir) && make-kpkg --stem linux kernel-doc
cat $(dbddir)/files >> debian/files
mv debian/*.deb ..
touch debian/doc-stamp
unpack: debian/unpack-stamp
debian/unpack-stamp: debian/patch-stamp
dh_testdir
cd debian; \
for i in $(subarchs); do \
$(MAKE) subarch=$${i} unpack; \
done
ln -s $$(command -v touch) debian/bin/touch.orig
touch debian/unpack-stamp
build: debian/build-stamp
debian/build-stamp: debian/unpack-stamp
dh_testdir
cd debian; \
for i in $(subarchs); do \
$(MAKE) subarch=$${i} build; \
done
touch debian/build-stamp
orig: ../orig/linux-$(major)-$(version)
rsync --delete --exclude debian --exclude .svn -av ../orig/linux-$(major)-$(version)/ .
../orig/linux-$(major)-$(version):
if [ -f "../linux-$(major)_$(version).orig.tar.gz" ]; then \
mkdir -p ../orig; \
tar -C ../orig -xzf ../linux-$(major)_$(version).orig.tar.gz; \
else \
echo "Can't find orig tarball." >&2; \
exit 1; \
fi
clean: unpatch
dh_testdir
rm -f version.Debian
rm -rf linux-source-$(version)
cd debian; \
rm -f *-stamp-* *-stamp config.* *.kpatches.arch; \
rm -f header-install-* post-install-* bin/touch.orig; \
rm -rf linux-source-* build-* install-*
dh_clean
binary-indep: source tree patch-debian doc
binary-arch: build
dh_testdir
cd debian; \
for i in $(subarchs); do \
$(MAKE) subarch=$${i} binary; \
done
binary: binary-indep binary-arch
#
# Makes the master debian/control file by substituting
# variable values into the template.
#
# I truly apologize for what I've created.. -dil
#
archs := $(shell find debian/arch/ -mindepth 1 -maxdepth 1 -type d ! -name '.svn' -printf '%f\n')
debian/control: $(wildcard debian/templates/control.*.in)
rm -f control.tmp 2>/dev/null
list_flavours() { \
find debian/arch/$$1/ -name 'config.*' \
! -name '*.svn*' -printf '%f\n' | \
sed 's/^config\.//'; \
}; \
get_all_headers_pkgs() { \
result=""; \
for flavour in `list_flavours $$1`; do \
if [ -z "$$result" ]; then \
comma=""; \
else \
comma=", "; \
fi; \
result="$${result}$${comma}linux-headers-$$2$(version)-$(abiname)-$$flavour"; \
done; \
echo $$result; \
}; \
all_headers_pkgs=`get_all_headers_pkgs`; \
substitute() { \
sa_tmp="debian/arch/$$2/*/config.$$3"; \
sa=""; \
[ -f $$sa_tmp ] && sa=$$(basename $$(dirname $$sa_tmp))-; \
all_headers_pkgs=`get_all_headers_pkgs $$2 $$sa`; \
class="$$3-class"; \
longclass=""; \
desc=""; \
[ -f "debian/arch/$$2/$$sa/desc.$$3" ] && . "debian/arch/$$2/$$sa/desc.$$3"; \
[ -z "$$longclass" ] && longclass="$$class"; \
cat debian/templates/control.$$1 | \
sed -e 's/@version@/$(version)/g' \
-e 's/@major@/$(major)/g' \
-e "s/@arch@/$$2/g" \
-e "s/@subarch@/$$sa/g" \
-e "s/@flavour@/$$3/g" \
-e "s#@class@#$$class#g" \
-e "s#@longclass@#$$longclass#g" \
-e 's/@ltver@/$(ltver)/g' \
-e 's/@srcver@/$(srcver)/g' \
-e 's/@lt_depends@/$(lt_depends)/g' \
-e 's/@lt_provides@/$(lt_provides)/g' \
-e 's/@abiname@/$(abiname)/g' \
-e "s/@allheaders@/$$all_headers_pkgs/g" | \
sed '/^[[:space:]]*$$/d' | \
sed 's/^Package:/\n&/g'; \
[ -z "$$4" ] || printf "$$desc\n"; \
}; \
substitute source.in "" "" >> control.tmp; \
substitute main.in "" "" >> control.tmp; \
substitute headers.in "" "" >> control.tmp; \
for a in $(archs); do \
for f in $$(list_flavours $$a); do \
substitute headers.flavour.in $$a $$f >> control.tmp; \
substitute image.in $$a $$f "1" >> control.tmp; \
done; \
done
mv control.tmp debian/control
.PHONY: clean build unpack binary-indep binary-arch binary patch unpatch source tree