4 WEEK := $(shell date +%Y%W)
5 RELEASE := $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }')
6 #REVISION := $(shell echo "$(RELEASE)" | sed 's/\(.*\)-\(.*\)/\2/')
7 #no need to update modules so often, api is quite stable between weekly releases
9 #EXTRAVERSION := EXTRAVERSION-$(REVISION)
12 FLASHER_PACKAGE := kernel-flasher-maemo
13 #SOURCE_PACKAGE := $(PACKAGE)-source
14 KERNEL_PACKAGE := $(PACKAGE)-maemo
15 MODULES_PACKAGE := $(PACKAGE)-modules-maemo
16 HEADERS_PACKAGE := $(PACKAGE)-headers-maemo
17 KBUILD_PACKAGE := $(PACKAGE)-kbuild
18 DEBUG_PACKAGE := $(PACKAGE)-debug
19 DEBUG_MODULES_PACKAGE := $(PACKAGE)-modules-debug
20 LIBC_PACKAGE := linux-kernel-headers-maemo
22 BUILDTMP := $(CURDIR)/debian/build
23 #KSRC := $(BUILDTMP)/$(PACKAGE)
25 export KBUILD_OUTPUT = $(BUILDTMP)
27 DEFCONFIG := rx51maemo_defconfig
28 KVER = $(shell cat $(BUILDTMP)/include/config/kernel.release 2> /dev/null)
29 ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
30 INCLUDE_HEADERS = acpi asm-generic crypto drm Kbuild keys math-emu media mtd net pcmcia rdma rxrpc scsi sound video xen
31 INCLUDE_HEADERS_ARCH = asm-$(ARCH) config linux
32 RM_SCRIPTS = bloat-o-meter show_delta
33 DEBUG_MODULES = oprofile.ko
35 FIASCOURL = "http://repository.maemo.org/pool/fremantle/non-free/s/sdk-fiasco-gen/sdk-fiasco-gen_2.8.2.0.1+0m5_armel.deb"
37 ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS)))
38 PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \
39 sed -e 's/.*parallel=\([0-9]\+\).*/\1/')
40 ifeq ($(DEB_BUILD_OPTIONS),$(PARALLEL_JOBS))
41 PARALLEL_JOBS := $(shell if [ -f /proc/cpuinfo ]; \
42 then echo `cat /proc/cpuinfo | grep 'processor' | wc -l`; \
45 NJOBS := -j$(PARALLEL_JOBS)
52 QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2
53 cp debian/$(DEFCONFIG) arch/arm/configs/
55 cd $(KSRC) && $(MAKE) $(EXTRAVERSION) $(DEFCONFIG)
58 kernel-stamp: configure-stamp
59 echo "compile $(PRODUCT) kernel"
60 cd $(KSRC) && $(MAKE) $(NJOBS) $(EXTRAVERSION) zImage
63 modules-stamp: configure-stamp
64 echo "compile $(PRODUCT) kernel modules"
65 cd $(KSRC) && $(MAKE) $(NJOBS) $(EXTRAVERSION) modules
68 modules-extra: configure-stamp
69 echo "compile $(PRODUCT) kernel EXTRA modules"
71 patch -p1 < $(CURDIR)/debian/modules-extra_config.patch && \
72 $(MAKE) $(EXTRAVERSION) oldconfig modules && \
73 patch -p1 -R < $(CURDIR)/debian/modules-extra_config.patch && \
74 $(MAKE) $(EXTRAVERSION) oldconfig
76 headers: kernel-stamp modules-stamp
84 -rm -f scripts/basic/{docproc,fixdep,hash} scripts/kconfig/mconf
85 rm -f modules/modversions.h modules/ksyms.ver debian/files conf.vars scripts/cramfs/cramfsck \
86 scripts/cramfs/mkcramfs applied_patches debian/buildinfo stamp-* .config* \
87 debian/$(FLASHER_PACKAGE).postinst
91 QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2
92 -rm arch/arm/configs/$(DEFCONFIG)
102 install -d -m 755 $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot
103 #wget -Odebian/fiasco.deb $(FIASCOURL) && dpkg-deb -x debian/fiasco.deb debian/fiasco
104 #debian/fiasco/usr/bin/fiasco-gen -o $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot/zImage-$(RELEASE).fiasco -g \
105 # -k $(KSRC)/arch/arm/boot/zImage -v $(RELEASE)
106 fiasco-gen -o $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot/zImage-$(RELEASE).fiasco -g \
107 -k $(BUILDTMP)/arch/arm/boot/zImage -v $(RELEASE)
108 #rm -rf debian/fiasco debian/fiasco.deb
109 chmod 644 $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot/zImage-$(RELEASE).fiasco
115 mkdir -p $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)
116 for f in $$(find $(BUILDTMP) -name "*.ko"); do \
117 install -c -m 644 $$f $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)/$$(basename $$f); \
118 strip --remove-section=.comment --remove-section=.note --strip-unneeded $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)/$$(basename $$f); \
120 #ln -sf $(KVER) $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/current
127 install -d -m755 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
128 install -p -o root -g root -m 644 $(BUILDTMP)/.config $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
129 install -p -o root -g root -m 644 $(KSRC)/Makefile $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
130 install -p -o root -g root -m 644 $(BUILDTMP)/Module.symvers $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
131 cd $(BUILDTMP) && install -p -o root -g root -m 644 -D include/config/auto.conf \
132 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/config/auto.conf
134 find arch/$(ARCH) $(foreach dir,$(INCLUDE_HEADERS),include/$(dir)) -name '*.h' \
135 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
137 find $(foreach dir,$(INCLUDE_HEADERS_ARCH),include/$(dir)) -name '*.h' \
138 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
140 find ./ -path "./debian" -prune -o -path "./.pc" -prune -o \( -name Makefile -or -name Kbuild -or -name Kconfig\* \) \
141 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
143 ln -sf asm-$(ARCH) $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/asm
145 rm -rf $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/scripts
146 ln -sf ../$(KBUILD_PACKAGE)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)
148 # cp -a $(KSRC)/include/asm-$(ARCH)/arch \
149 # $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/asm-$(ARCH)
151 cp $(BUILDTMP)/arch/$(ARCH)/kernel/asm-offsets.s \
152 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/arch/$(ARCH)/kernel
153 #install /lib/modules symlink
154 install -d -m 755 $(CURDIR)/debian/$(HEADERS_PACKAGE)/lib/modules/$(KVER)/
155 ln -sf /usr/src/$(HEADERS_PACKAGE) $(CURDIR)/debian/$(HEADERS_PACKAGE)/lib/modules/$(KVER)/build
157 install -d $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
158 cp -a $(KSRC)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
160 cd $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)/scripts && \
161 ( rm -f $(RM_SCRIPTS); chmod a-x mkcompile_h )
163 install-libc-headers:
168 $(MAKE) headers_check ARCH=$(ARCH) && \
169 $(MAKE) headers_install ARCH=$(ARCH) INSTALL_HDR_PATH=$(CURDIR)/debian/$(LIBC_PACKAGE)/usr
172 install-modules-extra:
176 mkdir -p $(CURDIR)/debian/kernel-modules-extra/lib/modules/$(KVER)/extra
177 for f in $(MODULES_EXTRA); do \
178 install -c -m 644 $(BUILDTMP)/$$f \
179 $(CURDIR)/debian/kernel-modules-extra/lib/modules/$(KVER)/extra/$$(basename $$f); \
182 install-extra: install-modules-extra
185 install-arch: build-arch install-kernel install-modules install-headers install-libc-headers
188 build-arch: kernel-stamp modules-stamp headers
195 binary-indep: #install-indep
198 dh_installchangelogs -i
206 binary-arch: build-arch install-arch
208 binary-arch: install-libc-headers
211 -e 's,@VERSION@,$(RELEASE),g' \
212 -e 's,@KVER@,$(KVER),g' \
213 < $(CURDIR)/debian/$(FLASHER_PACKAGE).postinst.in \
214 > $(CURDIR)/debian/$(FLASHER_PACKAGE).postinst
217 dh_installchangelogs -s
220 dh_strip -p$(HEADERS_PACKAGE)
223 dh_fixperms -s --exclude /usr/src/kernel-headers
229 binary: binary-indep binary-arch
230 .PHONY: build clean binary-indep binary-arch binary install