4 WEEK := $(shell date +%Y%W)
5 RELEASE := $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }')
6 REVISION := $(shell echo "$(RELEASE)" | sed 's/\(.*\)-maemo\(.*\)/.10bfs\2/')
7 EXTRAVERSION := EXTRAVERSION=-bfs3
10 FLASHER_PACKAGE := kernel-bfs-flasher
11 #SOURCE_PACKAGE := $(PACKAGE)-source
12 KERNEL_PACKAGE := $(PACKAGE)-bfs
13 BOOTIMG_PACKAGE := $(PACKAGE)-bfs-bootimg
14 MODULES_PACKAGE := $(PACKAGE)-bfs-modules
15 HEADERS_PACKAGE := $(PACKAGE)-bfs-headers
16 KBUILD_PACKAGE := $(PACKAGE)-bfs-kbuild
17 LIBC_PACKAGE := linux-kernel-bfs-headers
19 BUILDTMP := $(CURDIR)/debian/build
20 #KSRC := $(BUILDTMP)/$(PACKAGE)
22 export KBUILD_OUTPUT = $(BUILDTMP)
24 DEFCONFIG := rx51power_defconfig
25 KVER = $(shell cat $(BUILDTMP)/include/config/kernel.release 2> /dev/null)
26 ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
27 INCLUDE_HEADERS_ARCH = asm-$(ARCH) config linux
28 INCLUDE_HEADERS = asm-$(ARCH) linux acpi asm-generic crypto drm Kbuild keys math-emu media mtd net pcmcia rdma rxrpc scsi sound video xen
29 RM_SCRIPTS = bloat-o-meter show_delta
30 DEBUG_MODULES = oprofile.ko
33 ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS)))
34 PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \
35 sed -e 's/.*parallel=\([0-9]\+\).*/\1/')
36 ifeq ($(DEB_BUILD_OPTIONS),$(PARALLEL_JOBS))
37 PARALLEL_JOBS := $(shell if [ -f /proc/cpuinfo ]; \
38 then echo `cat /proc/cpuinfo | grep 'processor' | wc -l`; \
41 NJOBS := -j$(PARALLEL_JOBS)
46 #$(MAKE) mrproper KBUILD_OUTPUT=$(CURDIR)
49 QUILT_PATCHES=debian/patches quilt push -a -q || test $$? = 2
50 cp debian/$(DEFCONFIG) arch/arm/configs/
52 cd $(KSRC) && $(MAKE) $(EXTRAVERSION) $(DEFCONFIG)
55 kernel-stamp: configure-stamp
56 echo "compile $(PRODUCT) kernel"
57 cd $(KSRC) && $(MAKE) $(NJOBS) $(EXTRAVERSION) zImage
60 modules-stamp: configure-stamp
61 echo "compile $(PRODUCT) kernel modules"
62 cd $(KSRC) && $(MAKE) $(NJOBS) $(EXTRAVERSION) modules
63 $(MAKE) -C $(KSRC) M=debian/joikuspot EXTRAVERSION=$(EXTRAVERSION) modules
66 modules-extra: configure-stamp
67 echo "compile $(PRODUCT) kernel EXTRA modules"
69 patch -p1 < $(CURDIR)/debian/modules-extra_config.patch && \
70 $(MAKE) $(EXTRAVERSION) oldconfig modules && \
71 patch -p1 -R < $(CURDIR)/debian/modules-extra_config.patch && \
72 $(MAKE) $(EXTRAVERSION) oldconfig
74 headers: kernel-stamp modules-stamp
82 -rm -f scripts/basic/{docproc,fixdep,hash} scripts/kconfig/mconf scripts/kconfig/*.o scripts/kconfig/lxdialog/*.o
83 rm -f modules/modversions.h modules/ksyms.ver debian/files conf.vars scripts/cramfs/cramfsck \
84 scripts/cramfs/mkcramfs applied_patches debian/buildinfo stamp-* .config* \
85 debian/$(FLASHER_PACKAGE).postinst debian/$(MODULES_PACKAGE).postinst debian/$(MODULES_PACKAGE).postrm
89 QUILT_PATCHES=debian/patches quilt pop -a -q -R || test $$? = 2
90 -rm arch/arm/configs/$(DEFCONFIG)
100 install -d -m 755 $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot
101 fiasco-gen -o $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot/zImage-$(RELEASE).fiasco -g \
102 -k $(BUILDTMP)/arch/arm/boot/zImage -v $(RELEASE)
103 chmod 644 $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot/zImage-$(RELEASE).fiasco
110 install -d -m 755 $(CURDIR)/debian/$(BOOTIMG_PACKAGE)/boot
111 install -c -m 644 $(BUILDTMP)/arch/arm/boot/zImage $(CURDIR)/debian/$(BOOTIMG_PACKAGE)/boot/zImage-$(RELEASE)
112 chmod 644 $(CURDIR)/debian/$(BOOTIMG_PACKAGE)/boot/zImage-$(RELEASE)
118 mkdir -p $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)
119 for f in $$(find $(BUILDTMP) -name "*.ko"); do \
120 install -c -m 644 $$f $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)/$$(basename $$f); \
121 strip --remove-section=.comment --remove-section=.note --strip-unneeded $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)/$$(basename $$f); \
123 #ln -sf $(KVER) $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/current
130 install -d -m755 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
131 install -p -o root -g root -m 644 $(BUILDTMP)/.config $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
132 install -p -o root -g root -m 644 $(KSRC)/Makefile $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
133 install -p -o root -g root -m 644 $(BUILDTMP)/Module.symvers $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
134 cd $(BUILDTMP) && install -p -o root -g root -m 644 -D include/config/auto.conf \
135 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/config/auto.conf
137 find arch/$(ARCH) $(foreach dir,$(INCLUDE_HEADERS),include/$(dir)) -name '*.h' \
138 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
140 find $(foreach dir,$(INCLUDE_HEADERS_ARCH),include/$(dir)) -name '*.h' \
141 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
143 find ./ -path "./debian" -prune -o -path "./.pc" -prune -o \( -name Makefile -or -name Kbuild -or -name Kconfig\* \) \
144 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
146 ln -sf asm-$(ARCH) $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/asm
148 rm -rf $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/scripts
149 ln -sf ../$(KBUILD_PACKAGE)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)
151 # cp -a $(KSRC)/include/asm-$(ARCH)/arch \
152 # $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/asm-$(ARCH)
154 cp $(BUILDTMP)/arch/$(ARCH)/kernel/asm-offsets.s \
155 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/arch/$(ARCH)/kernel
156 #install /lib/modules symlink
157 install -d -m 755 $(CURDIR)/debian/$(HEADERS_PACKAGE)/lib/modules/$(KVER)/
158 ln -sf /usr/src/$(HEADERS_PACKAGE) $(CURDIR)/debian/$(HEADERS_PACKAGE)/lib/modules/$(KVER)/build
160 install -d $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
161 cp -a $(KSRC)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
162 cp -a $(BUILDTMP)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
164 cd $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)/scripts && \
165 ( rm -f $(RM_SCRIPTS); chmod a-x mkcompile_h )
166 find $(CURDIR)/debian/$(HEADERS_PACKAGE) -name ".gitignore" -exec rm {} \;
168 install-libc-headers:
173 $(MAKE) headers_check ARCH=$(ARCH) && \
174 $(MAKE) headers_install ARCH=$(ARCH) INSTALL_HDR_PATH=$(CURDIR)/debian/$(LIBC_PACKAGE)/usr
177 install-modules-extra:
181 mkdir -p $(CURDIR)/debian/kernel-modules-extra/lib/modules/$(KVER)/extra
182 for f in $(MODULES_EXTRA); do \
183 install -c -m 644 $(BUILDTMP)/$$f \
184 $(CURDIR)/debian/kernel-modules-extra/lib/modules/$(KVER)/extra/$$(basename $$f); \
187 install-extra: install-modules-extra
190 install-arch: build-arch install-kernel install-bootimg install-modules install-headers install-libc-headers
193 build-arch: kernel-stamp modules-stamp headers
200 binary-indep: #install-indep
203 dh_installchangelogs -i
211 binary-arch: build-arch install-arch
213 binary-arch: install-libc-headers
216 -e 's,@VERSION@,$(RELEASE),g' \
217 -e 's,@KVER@,$(KVER),g' \
218 < $(CURDIR)/debian/$(FLASHER_PACKAGE).postinst.in \
219 > $(CURDIR)/debian/$(FLASHER_PACKAGE).postinst
221 -e 's,@KVER@,$(KVER),g' \
222 < $(CURDIR)/debian/$(MODULES_PACKAGE).postinst.in \
223 > $(CURDIR)/debian/$(MODULES_PACKAGE).postinst
225 -e 's,@KVER@,$(KVER),g' \
226 < $(CURDIR)/debian/$(MODULES_PACKAGE).postrm.in \
227 > $(CURDIR)/debian/$(MODULES_PACKAGE).postrm
230 dh_installchangelogs -s
234 dh_strip -p$(HEADERS_PACKAGE)
237 dh_fixperms -s --exclude /usr/src/kernel-headers
243 binary: binary-arch #binary-indep
244 .PHONY: build clean binary-indep binary-arch binary install