linux/debian/rules.real

349 lines
14 KiB
Plaintext

#
# 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 ltver are
# expected to be available (need to be exported from the parent process).
#
SHELL := bash -e
DEB_HOST_ARCH := $(shell dpkg-architecture -a'$(ARCH)' -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -a'$(ARCH)' -qDEB_HOST_GNU_TYPE)
DEB_BUILD_ARCH := $(shell dpkg-architecture -a'$(ARCH)' -qDEB_BUILD_ARCH)
export PYTHONPATH = $(CURDIR)/debian/lib/python
export DH_OPTIONS
#
# Build the list of common config files to be included
#
ifeq ($(SUBARCH),none)
basedir := debian/arch/$(ARCH)
else
basedir := debian/arch/$(ARCH)/$(SUBARCH)
endif
-include $(basedir)/Makefile.inc
include debian/rules.defs
#
# Here we construct the command lines for different make-kpkg
# calls (build, linux-image, linux-headers) based on the values
# of variables defined so far and provided by the arch/subarch
# in Makefile.inc. @flavour@ in the expressions is going to be
# replaced by the flavour for which the command is run.
#
kpkg_image := make-kpkg --append-to-version '$(KPKG_ABINAME)$(LOCALVERSION)'
kpkg_image += --arch '$(ARCH)'
kpkg_image += --stem linux
ifneq ($(INITRD),no)
kpkg_image += --initrd
endif
ifdef KPKG_SUBARCH
kpkg_image += --subarch '$(KPKG_SUBARCH)'
endif
ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
kpkg_image += --cross-compile='$(DEB_HOST_GNU_TYPE)'
endif
setup_env := env -u ABINAME -u ARCH -u SUBARCH -u FLAVOUR -u VERSION -u LOCALVERSION
setup_makeflags =
ifdef COMPILER
setup_makeflags += CC="$$$$(CROSS_COMPILE)$(COMPILER)"
endif
setup_env += MAKEFLAGS='$(setup_makeflags)'
#
# Targets
#
binary-arch-subarch: install-header-$(ARCH)-$(SUBARCH)
binary-arch-flavour: install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR) install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
binary-indep: install-doc install-patch install-source install-tree
build: $(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
setup-arch: $(STAMPS_DIR)/source
setup-subarch:
setup-flavour: $(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
#
# Generates the kernel config file for a subarch by merging
# the arch-independent config file (arch/config),
# arch-specific config file (arch/$(karch)/config),
# and subarch specific one (arch/$(karch)/$(subarch)/config).
#
config_common = debian/arch/config debian/arch/$(ARCH)/config
ifneq ($(SUBARCH),none)
config_common += debian/arch/$(ARCH)/$(SUBARCH)/config
endif
$(BUILD_DIR)/config.$(ARCH)-$(SUBARCH)-$(FLAVOUR): $(basedir)/config.$(FLAVOUR) $(config_common)
@echo "Generating configuration file $@:"
ocaml debian/bin/kconfig.ml -b "debian/arch" -a "$(ARCH)" -s "$(SUBARCH)" -f "$(FLAVOUR)" > '$@'
$(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: SOURCE_DIR=$(BUILD_DIR)/source
$(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: DIR = $(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION)
$(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2: $(STAMPS_DIR)/source
rm -rf '$@' '$(DIR)'
cp -al '$(SOURCE_DIR)' '$(DIR)'
chmod -R u+rw,go=rX '$(DIR)'
cd '$(BUILD_DIR)'; tar -cjf 'linux-source-$(UPSTREAM_VERSION).tar.bz2' 'linux-source-$(UPSTREAM_VERSION)'
rm -rf '$(DIR)'
define patch_cmd
cd '$(DIR)'; python2.4 '$(CURDIR)/debian/bin/apply.py' --overwrite-home='$(CURDIR)/debian/patches' --overwrite-source='$(SOURCE_VERSION)' --overwrite-revisions='$(REVISIONS)'
endef
srcfiles := $(filter-out debian, $(wildcard * .[^.]*))
$(STAMPS_DIR)/source: DIR=$(BUILD_DIR)/source
$(STAMPS_DIR)/source: debian/bin/apply.py
rm -rf '$(DIR)'
mkdir -p '$(DIR)'
cp -al $(srcfiles) '$(DIR)'
$(patch_cmd)
#make-kpkg does this when building kernel-source.
mv '$(DIR)/scripts/package/Makefile' '$(DIR)/scripts/package/Makefile.dist'
mv '$(DIR)/scripts/package/builddeb' '$(DIR)/scripts/package/builddeb.dist'
echo "# Dummy Makefile" > '$(DIR)/scripts/package/Makefile'
echo "all:" >> '$(DIR)/scripts/package/Makefile'
touch '$@'
$(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH): SOURCE_DIR=$(BUILD_DIR)/source
$(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH): DIR=$(BUILD_DIR)/source-$(ARCH)-$(SUBARCH)
$(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH): $(STAMPS_DIR)/source
rm -rf '$(DIR)'
cp -al '$(SOURCE_DIR)' '$(DIR)'
mkdir -p '$(DIR)/debian'
cp debian/changelog '$(DIR)/debian'
cp debian/copyright '$(DIR)/debian'
cp debian/control '$(DIR)/debian/control'
touch '$(DIR)/debian/official'
$(patch_cmd) -a $(ARCH) -s $(SUBARCH)
touch '$@'
#
# This target performs a build for a particular flavour. Note
# that in this file it should be always placed *before* the
# build-$(subarch)-% target, which creates the build directory.
#
$(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR): DIR=$(BUILD_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
$(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR): $(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
ln -fs "$$(command -v touch)" debian/build/touch.orig
cd '$(DIR)'; $(setup_env) PATH='$(CURDIR)/build:$(CURDIR)/bin:$(PATH)' $(kpkg_image) build
touch '$@'
$(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR): SOURCE_DIR=$(BUILD_DIR)/source-$(ARCH)-$(SUBARCH)
$(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR): DIR=$(BUILD_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
$(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR): $(BUILD_DIR)/config.$(ARCH)-$(SUBARCH)-$(FLAVOUR) $(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH)
rm -rf '$(DIR)'
cp -al '$(SOURCE_DIR)' '$(DIR)'
cp '$<' '$(DIR)/.config'
cd '$(DIR)'; $(setup_env) $(kpkg_image) configure
touch '$@'
install-base:
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol -- $(GENCONTROL_ARGS)
dh_md5sums
dh_builddeb
install-doc: SOURCE_DIR=$(BUILD_DIR)/source
install-doc: DIR=$(BUILD_DIR)/$@
install-doc: $(STAMPS_DIR)/source
rm -rf '$(DIR)'
cp -al '$(SOURCE_DIR)' '$(DIR)'
mkdir -p '$(DIR)/debian'
cp debian/changelog '$(DIR)/debian'
cp debian/copyright '$(DIR)/debian'
cp debian/control '$(DIR)/debian/control'
touch '$(DIR)/debian/official'
rm '$(DIR)/Makefile'
sed -e 's,^EXTRAVERSION.*$$,EXTRAVERSION =,' < '$(SOURCE_DIR)/Makefile' > '$(DIR)/Makefile'
cd '$(DIR)' && $(setup_env) make-kpkg --stem linux \
--config defconfig kernel-manual
cat '$(DIR)/debian/files' >> debian/files
@for i in $$(awk '{ print $$1; }' '$(DIR)/debian/files'); do \
echo "mv \"$(BUILD_DIR)/$$i\" .."; \
mv "$(BUILD_DIR)/$$i" ..; \
done
rm -rf '$(DIR)'
install-dummy:
dh_testdir
dh_testroot
dh_clean -d -k
dh_installchangelogs
dh_installdocs
$(MAKE) -f debian/rules.real install-base
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR): SOURCE_DIR=$(BUILD_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR): DIR=$(BUILD_DIR)/$@
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR): $(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
rm -rf '$(DIR)'
cp -al '$(SOURCE_DIR)' '$(DIR)'
ifdef IMAGE_POSTPROC
# Install the postproc script into the hook directory
install -d '$(DIR)/debian/image.d'
install 'debian/bin/$(IMAGE_POSTPROC)' '$(DIR)/debian/image.d'
endif
cd '$(DIR)'; $(setup_env) $(kpkg_image) kernel-image
cat '$(DIR)/debian/files' >> debian/files
@for i in $$(awk '{ print $$1; }' '$(DIR)/debian/files'); do \
echo "mv \"$(BUILD_DIR)/$$i\" .."; \
mv "$(BUILD_DIR)/$$i" ..; \
done
rm -rf '$(DIR)'
install-header-$(ARCH)-$(SUBARCH): PACKAGE_NAME = linux-headers-$(VERSION)-$(ABINAME)$(LOCALVERSION_HEADERS)
install-header-$(ARCH)-$(SUBARCH): DH_OPTIONS = -p$(PACKAGE_NAME)
install-header-$(ARCH)-$(SUBARCH): BASE_DIR = /usr/src/$(PACKAGE_NAME)
install-header-$(ARCH)-$(SUBARCH): SOURCE_DIR = $(BUILD_DIR)/source-$(ARCH)-$(SUBARCH)
install-header-$(ARCH)-$(SUBARCH): DIR = $(CURDIR)/debian/$(PACKAGE_NAME)/$(BASE_DIR)
install-header-$(ARCH)-$(SUBARCH): $(STAMPS_DIR)/source-$(ARCH)-$(SUBARCH)
dh_testdir
dh_testroot
dh_clean -k -d
cd $(SOURCE_DIR); \
( \
find . \
-path './Documentation/*' -prune -o \
-path './arch/*' -prune -o \
-path './include/asm*' -prune -o \
-path './scripts/*' -prune -o \
-path './include/*' -print -o \
\( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Rules.make' \) -print; \
find include/asm-generic -print; \
for i in $(KERNEL_HEADER_DIRS); do \
find arch/$$i \
\( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Rules.make' \) -print; \
find include/asm-$$i -print; \
done; \
) \
| \
cpio -pd --preserve-modification-time $(DIR)
$(MAKE) -f debian/rules.real install-base
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): REAL_VERSION = $(VERSION)-$(ABINAME)$(LOCALVERSION)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): PACKAGE_NAME = linux-headers-$(REAL_VERSION)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): PACKAGE_NAME_HEADERS = linux-headers-$(VERSION)-$(ABINAME)$(LOCALVERSION_HEADERS)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): DH_OPTIONS = -p$(PACKAGE_NAME)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): BASE_DIR = /usr/src/$(PACKAGE_NAME)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): SOURCE_DIR = $(BUILD_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): REF_DIR = $(BUILD_DIR)/source-$(ARCH)-$(SUBARCH)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): PACKAGE_DIR = $(CURDIR)/debian/$(PACKAGE_NAME)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): DIR = $(PACKAGE_DIR)/$(BASE_DIR)
install-header-$(ARCH)-$(SUBARCH)-$(FLAVOUR): $(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
dh_testdir
dh_testroot
dh_clean -k -d
mkdir -p "${DIR}/arch/${KERNEL_ARCH}/kernel"
mkdir -p "${DIR}/include"
cp -a ${SOURCE_DIR}/{.config,Module.symvers} "${DIR}"
# TODO
echo -${KPKG_ABINAME}$(LOCALVERSION) > "${DIR}/localversion"
cd ${SOURCE_DIR}; \
find . -mindepth 1 -maxdepth 1 \
! -name debian -a ! -name Documentation -a ! -name include -a \
! -name DEBIAN -a ! -name scripts -a ! -name arch -a ! -name '.*' -a \( \
-name Makefile -o -type d \) \
-printf "../${PACKAGE_NAME_HEADERS}/%f\n" | \
xargs ln -s --target-directory="${DIR}"
cd ${SOURCE_DIR}; \
find "arch/${KERNEL_ARCH}" -mindepth 1 -maxdepth 1 \( \
-type d -a ! -name include -a ! -name kernel -o \
-type f -a \( -name 'Makefile*' -o -name 'Kconfig*' \) \) \
-printf "../../../${PACKAGE_NAME_HEADERS}/%p\n" | \
xargs ln -s --target-directory="${DIR}/arch/${KERNEL_ARCH}"
[ -d "${SOURCE_DIR}/arch/${KERNEL_ARCH}/include" ] && \
cp -a "${SOURCE_DIR}/arch/${KERNEL_ARCH}/include" "${DIR}/arch/${KERNEL_ARCH}/include" || :
[ -f "${SOURCE_DIR}/arch/${KERNEL_ARCH}/kernel/asm-offsets.s" ] && \
ln -f "${SOURCE_DIR}/arch/${KERNEL_ARCH}/kernel/asm-offsets.s" "${DIR}/arch/${KERNEL_ARCH}/kernel" || :
ln -s "../../../../${PACKAGE_NAME_HEADERS}/arch/${KERNEL_ARCH}/kernel/Makefile" "${DIR}/arch/${KERNEL_ARCH}/kernel"
cd ${SOURCE_DIR}; \
find include -mindepth 1 -maxdepth 1 \
! -name config -a ! -name linux -a ! -name 'asm*' \
-printf "../../${PACKAGE_NAME_HEADERS}/%p\n" | \
xargs ln -s --target-directory="${DIR}/include"
cp -a ${SOURCE_DIR}/include/config "${DIR}/include"
ln -sf "asm-${KERNEL_ARCH}" "${DIR}/include/asm"
cd ${SOURCE_DIR}; \
for dir in linux asm-generic $(foreach t, $(KERNEL_HEADER_DIRS), asm-$(t)); do \
mkdir "${DIR}/include/$$dir"; \
for file in $$(find "include/$$dir" -mindepth 1 -maxdepth 1); do \
if [ -e ${CURDIR}/${REF_DIR}/$$file ]; then \
ln -s --target-directory="${DIR}/include/$$dir" "../../../${PACKAGE_NAME_HEADERS}/$$file"; \
elif [ -d ${CURDIR}/${SOURCE_DIR}/$$file ]; then \
cp -a "${CURDIR}/${SOURCE_DIR}/$$file" "${DIR}/include/$$dir"; \
else \
ln -f --target-directory="${DIR}/include/$$dir" "${CURDIR}/${SOURCE_DIR}/$$file"; \
fi \
done \
done
mkdir -p "${PACKAGE_DIR}/lib/modules/${REAL_VERSION}"
ln -s "/usr/src/${PACKAGE_NAME}" "${PACKAGE_DIR}/lib/modules/${REAL_VERSION}/build"
# Populate the scripts directory. The strategy here is to specify what
# *not* to copy, to make things a little bit more robust. We first create
# a file with exclude patterns, then copy everything minus excluded files.
#
tar $(foreach t, *.c *.h *.y *.l *.gperf *POTFILES.in .gitignore *lxdialog* *package* *.cc *.glade *_shipped, --exclude=$(t)) -chf - scripts | (cd "${DIR}"; umask 000; tar xsf -)
$(MAKE) -f debian/rules.real install-base
install-headers-all: DH_OPTIONS = -plinux-headers-$(VERSION)
install-headers-all:
dh_testdir
dh_testroot
dh_install $(DH_OPTIONS) debian/arch debian/lib debian/modules '/usr/src/linux-headers-$(VERSION)'
dh_installdocs $(DH_OPTIONS)
dh_installchangelogs $(DH_OPTIONS)
dh_python $(DH_OPTIONS) -V 2.4 /usr/src/linux-headers-$(VERSION)/lib/python
$(MAKE) -f debian/rules.real install-base DH_OPTIONS='$(DH_OPTIONS)'
install-patch: PACKAGE = linux-patch-debian-$(VERSION)
install-patch: pbase := /usr/src/kernel-patches/all/$(SOURCE_UPSTREAM)
install-patch: pfull := debian/$(PACKAGE)$(pbase)
install-patch: ptchs := $(notdir $(wildcard debian/patches-arch/*))
install-patch: DH_OPTIONS = -p$(PACKAGE)
install-patch:
dh_testdir
dh_testroot
dh_clean -d -k $(DH_OPTIONS)
dh_installdirs $(DH_OPTIONS) '$(pbase)/apply' '$(pbase)/debian' '$(pbase)/unpatch'
dh_install $(DH_OPTIONS) debian/patches/* '$(pbase)/debian'
# Install the debian patches
sed \
-e 's,@home@,$(pbase)/debian,' \
-e 's,@revisions@,$(REVISIONS),' \
-e 's,@source@,$(SOURCE_VERSION),' \
debian/bin/apply.py > '$(pfull)/apply/debian'
sed -e 's/@upstream@/$(SOURCE_UPSTREAM)/g' debian/bin/unpatch > '$(pfull)/unpatch/debian'
chmod 755 '$(pfull)/apply/debian' '$(pfull)/unpatch/debian'
chmod 644 '$(pfull)/debian/'*.patch
bzip2 -9 '$(pfull)/debian/'*.patch
dh_installdocs $(DH_OPTIONS)
dh_installchangelogs $(DH_OPTIONS)
$(MAKE) -f debian/rules.real install-base DH_OPTIONS='$(DH_OPTIONS)'
install-source: DH_OPTIONS = -plinux-source-$(VERSION)
install-source: $(BUILD_DIR)/linux-source-$(UPSTREAM_VERSION).tar.bz2
dh_testdir
dh_testroot
dh_install $(DH_OPTIONS) '$<' /usr/src
dh_installdocs $(DH_OPTIONS) README
dh_installchangelogs $(DH_OPTIONS)
$(MAKE) -f debian/rules.real install-base DH_OPTIONS='$(DH_OPTIONS)'
install-tree: DH_OPTIONS = -plinux-tree-$(VERSION)
install-tree:
$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='$(DH_OPTIONS)'