1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#! /usr/bin/make -f
# Name of package
package := ibcs-module
arch := $(shell dpkg --print-architecture)
date := $(shell date +"%a, %d %b %Y %H:%M:%S %z")
# KSRC is the location of the kernel source. This is the default value,
# when make-kpkg is used it will supply to real value
KSRC = /usr/src/linux
# KDREV is the package-revision, as given to make-kpkg by the user.
# Just put a simply default value in here which we use when we test
# the packagebuilding without make-kpkg
KDREV = "test"
# Now we need to get the kernel-version somehow
kversion = $(shell sed -ne '1,5s/VERSION = //p' $(KSRC)/Makefile )
kplevel = $(shell sed -ne '1,5s/PATCHLEVEL = //p' $(KSRC)/Makefile )
ksublevel = $(shell sed -ne '1,5s/SUBLEVEL = //p' $(KSRC)/Makefile )
kextra = $(shell sed -ne '1,5s/EXTRAVERSION = //p' $(KSRC)/Makefile )
KVERS = $(kversion).$(kplevel).$(ksublevel)$(kextra)
# We also need the package version
pversion = $(shell sed -ne '1s/.*(\(.*\)).*/\1/p' debian/changelog)
# MODDIR is the place where the final .deb package should be made. This is the
# default value, when make-kpkg is used it will supply to real value
MOD_DIR = .
prefix := debian/tmp
modules := $(prefix)/lib/$(KVERS)/misc
docs := $(prefix)/usr/share/doc/$(package)-$(KVERS)
debian := $(prefix)/DEBIAN
install = install -o root -g root
# Lets define the standard targets first
.PHONY: binary
binary: binary-indep binary-arch
# For binary-indep we do nothing as it's all been done. Woo hoo hoo (BNL)
.PHONY: binary-indep
binary-indep: binary-source binary-common
# For binary-arch we do nothing so autobuilder don't try to build the
# kernel modules.
.PHONY: binary-arch
binary-arch:
# The kdist_configure target is called by make-kpkg modules_config. It
# should configure the module so it is ready for compilation (mostly
# useful for calling configure)
.PHONY: kdist_config
kdist_config:
# the kdist_image target is called by make-kpkg modules_image. It is
# responsible for compiling the module and creating the package. It
# should also clean up after making the module. Please note we use a
# seperate binary-modules target to make testing the package building
# easier
.PHONY: kdist_image
kdist_image:
$(MAKE) $(MFLAGS) -f debian/rules binary-modules
$(MAKE) $(MFLAGS) -f debian/rules clean
# the kdist_clean target is called by make-kpkg modules_clean. It is
# responsible for cleaning up any changes that have been made by the
# other kdist_commands (except for the .deb files created).
.PHONY: kdist_clean
kdist_clean:
$(MAKE) $(MFLAGS) -f debian/rules clean
.PHONY: clean
clean:
-$(MAKE) $(MFLAGS) -C iBCSemul clean KERNEL=$(KSRC) CONFIG=CONFIG.$(arch)
-$(MAKE) $(MFLAGS) -C devtrace clean KERNEL=$(KSRC) CONFIG=CONFIG.$(arch)
-rm -rf debian/tmp debian/subst debian/files
# the binary-modules target creates the kernmod-modules-XXX package.
.PHONY: binary-modules
binary-modules:
# Perform some simple tests
test -f debian/control -a -f debian/rules
test `id -u` -eq 0
-rm -rf $(prefix)
# Initialize some things
$(MAKE) $(MFLAGS) -C iBCSemul KERNEL=$(KSRC) CONFIG=CONFIG.$(arch)
$(MAKE) $(MFLAGS) -C devtrace KERNEL=$(KSRC) CONFIG=CONFIG.$(arch)
$(install) -d $(modules)
$(install) iBCSemul/iBCS $(modules)/iBCSemul.o
$(install) devtrace/devtrace $(modules)/devtrace.o
$(install) -d $(docs)
$(install) -m 644 debian/copyright $(docs)
$(install) -m 644 debian/changelog $(docs)/changelog.Debian
gzip -9f $(docs)/changelog.Debian
$(install) -d $(debian)
$(install) -m 755 debian/postinst $(debian)
$(install) -m 755 debian/prerm $(debian)
perl -pi -e 's!\$${kvers}!$(KVERS)!g' \
$(debian)/postinst $(debian)/prerm
# Generate the package
echo "bvers=$(pversion)" > debian/substvars
echo "pvers=$(pversion)+$(KDREV)" >> debian/substvars
echo "krev=$(KDREV)" >> debian/substvars
echo "kmaint=$(KMAINT)" >> debian/substvars
echo "kemail=$(KEMAIL)" >> debian/substvars
echo "kdate=$(date)" >> debian/substvars
dpkg-gencontrol -v$(pversion)+$(KDREV) -isp -Vkvers=$(KVERS)
dpkg --build $(prefix) $(MOD_DIR)/..
|