linux/debian/rules

158 lines
4.8 KiB
Makefile
Executable File

#!/usr/bin/make -f
#
# Required variables
#
version := 2.6.11
abiname := 1
ltver := 5
#
# Generally nothing needs to be modified below this line
#
SHELL := sh -e
controls := $(wildcard debian/arch/*/control.in debian/arch/*/*/control.in)
karch := $(shell dpkg-architecture -qDEB_HOST_ARCH)
major := $(basename $(version))
srcver := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')
release := $(version)-$(ltver)
#
# 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) \
-type d -mindepth 1 -maxdepth 1 \
! -name '.svn' ! -name 'patches' \
-printf '%f\n')
endif
ifeq (,$(subarchs))
subarchs := none
endif
export version abiname ltver kbuildver flavours
patch: debian/patch-stamp
debian/patch-stamp: debian/bin/apply
dh_testdir
override_version=$(release) home=debian/patches 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/bin/apply $(version); \
cd scripts/package; \
mv Makefile.dist Makefile; \
mv builddeb.dist builddeb; \
fi
rm -f debian/patch-stamp
#
# Since we do not have separate build/install targets for the
# source, the stamp magic is somewhat redundant. At least, it
# will prevent rebuilding the package from an uncleaned tmpdir.
#
spkg := linux-source-$(version)
sdir := debian/$(spkg)/usr/src
tpkg := linux-tree-$(version)-$(ltver)
files = $(filter-out debian, $(shell echo *))
source: debian/source-stamp
debian/source-stamp: debian/patch-stamp
dh_testdir
dh_testroot
dh_installdirs -p$(spkg) /usr/share/doc /usr/src
# Link the files and create a tarball in correct location
mkdir $(spkg)
cp -al $(files) $(spkg)
tar -cjf $(sdir)/$(spkg).tar.bz2 $(spkg)
rm -rf $(spkg)
dh_fixperms -p$(spkg)
dh_installdocs -p$(spkg) README debian/README.Debian
dh_installchangelogs -p$(spkg)
dh_compress -p$(spkg)
dh_installdeb -p$(spkg)
dh_gencontrol -p$(spkg)
dh_builddeb -p$(spkg)
unpack: debian/linux-source-$(version).tar.bz2 unpack-stamp
unpack-stamp:
dh_testdir
for i in $(subarchs); do \
cd debian; \
$(MAKE) -f Makefile.subarch subarch=$${i} unpack; \
done
ln -s $$(command -v touch) debian/bin/touch.orig
touch unpack-stamp
build: build-stamp
build-stamp: unpack-stamp
dh_testdir
for i in $(subarchs); do \
cd debian; \
$(MAKE) -f Makefile.subarch subarch=$${i} build; \
done
touch build-stamp
clean: unpatch
dh_testdir
rm -f version.Debian
rm -rf linux-source-$(version)
cd debian; \
rm -f *-stamp-* *-stamp config.*; \
rm -f header-install-* post-install-* bin/touch.orig; \
rm -rf kernel-source-* build-* install-*
dh_clean
binary-indep: build
binary-arch: build
dh_testdir
for i in $(subarchs); do \
cd debian; \
$(MAKE) -f Makefile.subarch subarch=$${i} binary; \
done
binary: binary-indep binary-arch
#
# Makes the master debian/control file by substituting
# variable values into the template.
#
debian/control: debian/templates/control.main.in
cat debian/templates/control.main.in | \
sed -e 's/@version@/$(version)/g' \
-e 's/@major@/$(major)/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' | \
sed '/^[[:space:]]*$$/d' | \
sed 's/^Package:/\n&/g' > debian/control
#
# If we ended up here, either we need to perform the linux-source
# build, or use the existing linux-source to unpack the kernels.
# This can be controlled by the use_existing_source variable.
#
debian/linux-source-$(version).tar.bz2: debian/Makefile.source
dh_testdir
if [ '$(use_existing_source)' = 'yes' ]; then \
ln -s /usr/src/linux-source-$(version).tar.bz2 \
debian/linux-source-$(version).tar.bz2; \
else \
$(MAKE) -f debian/Makefile.source binary; \
fi
.PHONY: clean build unpack binary-indep binary-arch binary patch unpatch source