4 WEEK := $(shell date +%Y%W)
5 RELEASE := $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }')
6 REVISION := $(shell echo "$(RELEASE)" | sed 's/\(.*\)-maemo\(.*\)/.10power\2/')
7 #REVISION := $(shell echo "$(RELEASE)" | sed 's/\(.*\)-maemo\(.*\)/.10powerusb\2/')
8 EXTRAVERSION := EXTRAVERSION=$(REVISION)
11 FLASHER_PACKAGE := kernel-power-flasher
12 #SOURCE_PACKAGE := $(PACKAGE)-source
13 KERNEL_PACKAGE := $(PACKAGE)-power
14 BOOTIMG_PACKAGE := $(PACKAGE)-power-bootimg
15 MODULES_PACKAGE := $(PACKAGE)-power-modules
16 HEADERS_PACKAGE := $(PACKAGE)-power-headers
17 KBUILD_PACKAGE := $(PACKAGE)-power-kbuild
18 LIBC_PACKAGE := linux-kernel-power-headers
20 BUILDTMP := $(CURDIR)/debian/build
21 #KSRC := $(BUILDTMP)/$(PACKAGE)
23 export KBUILD_OUTPUT = $(BUILDTMP)
25 DEFCONFIG := rx51power_defconfig
26 KVER = $(shell cat $(BUILDTMP)/include/config/kernel.release 2> /dev/null)
27 ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
28 INCLUDE_HEADERS_ARCH = asm-$(ARCH) config linux
29 INCLUDE_HEADERS = asm-$(ARCH) linux acpi asm-generic crypto drm Kbuild keys math-emu media mtd net pcmcia rdma rxrpc scsi sound video xen
30 RM_SCRIPTS = bloat-o-meter show_delta
31 DEBUG_MODULES = oprofile.ko
34 ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS)))
35 PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \
36 sed -e 's/.*parallel=\([0-9]\+\).*/\1/')
37 ifeq ($(DEB_BUILD_OPTIONS),$(PARALLEL_JOBS))
38 PARALLEL_JOBS := $(shell if [ -f /proc/cpuinfo ]; \
39 then echo `cat /proc/cpuinfo | grep 'processor' | wc -l`; \
42 NJOBS := -j$(PARALLEL_JOBS)
47 #$(MAKE) mrproper KBUILD_OUTPUT=$(CURDIR)
50 QUILT_PATCHES=debian/patches quilt push -a -q || test $$? = 2
51 cp debian/$(DEFCONFIG) arch/arm/configs/
53 cd $(KSRC) && $(MAKE) $(EXTRAVERSION) $(DEFCONFIG)
56 kernel-stamp: configure-stamp
57 echo "compile $(PRODUCT) kernel"
58 cd $(KSRC) && $(MAKE) $(NJOBS) $(EXTRAVERSION) zImage
61 modules-stamp: configure-stamp
62 echo "compile $(PRODUCT) kernel modules"
63 cd $(KSRC) && $(MAKE) $(NJOBS) $(EXTRAVERSION) modules
64 $(MAKE) -C $(KSRC) M=debian/joikuspot EXTRAVERSION=$(EXTRAVERSION) modules
67 modules-extra: configure-stamp
68 echo "compile $(PRODUCT) kernel EXTRA modules"
70 patch -p1 < $(CURDIR)/debian/modules-extra_config.patch && \
71 $(MAKE) $(EXTRAVERSION) oldconfig modules && \
72 patch -p1 -R < $(CURDIR)/debian/modules-extra_config.patch && \
73 $(MAKE) $(EXTRAVERSION) oldconfig
75 headers: kernel-stamp modules-stamp
83 -rm -f scripts/basic/{docproc,fixdep,hash} scripts/kconfig/mconf scripts/kconfig/*.o scripts/kconfig/lxdialog/*.o
84 rm -f modules/modversions.h modules/ksyms.ver debian/files conf.vars scripts/cramfs/cramfsck \
85 scripts/cramfs/mkcramfs applied_patches debian/buildinfo stamp-* .config* \
86 debian/$(FLASHER_PACKAGE).postinst debian/$(MODULES_PACKAGE).postinst debian/$(MODULES_PACKAGE).postrm
90 QUILT_PATCHES=debian/patches quilt pop -a -q -R || test $$? = 2
91 -rm arch/arm/configs/$(DEFCONFIG)
101 install -d -m 755 $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot
102 fiasco-gen -o $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot/zImage-$(RELEASE).fiasco -g \
103 -k $(BUILDTMP)/arch/arm/boot/zImage -v $(RELEASE)
104 chmod 644 $(CURDIR)/debian/$(KERNEL_PACKAGE)/boot/zImage-$(RELEASE).fiasco
111 install -d -m 755 $(CURDIR)/debian/$(BOOTIMG_PACKAGE)/boot
112 install -c -m 644 $(BUILDTMP)/arch/arm/boot/zImage $(CURDIR)/debian/$(BOOTIMG_PACKAGE)/boot/zImage-$(RELEASE)
113 chmod 644 $(CURDIR)/debian/$(BOOTIMG_PACKAGE)/boot/zImage-$(RELEASE)
119 mkdir -p $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)
120 for f in $$(find $(BUILDTMP) -name "*.ko"); do \
121 install -c -m 644 $$f $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)/$$(basename $$f); \
122 strip --remove-section=.comment --remove-section=.note --strip-unneeded $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/$(KVER)/$$(basename $$f); \
124 #ln -sf $(KVER) $(CURDIR)/debian/$(MODULES_PACKAGE)/lib/modules/current
131 install -d -m755 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
132 install -p -o root -g root -m 644 $(BUILDTMP)/.config $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
133 install -p -o root -g root -m 644 $(KSRC)/Makefile $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
134 install -p -o root -g root -m 644 $(BUILDTMP)/Module.symvers $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/
135 cd $(BUILDTMP) && install -p -o root -g root -m 644 -D include/config/auto.conf \
136 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/config/auto.conf
138 find arch/$(ARCH) $(foreach dir,$(INCLUDE_HEADERS),include/$(dir)) -name '*.h' \
139 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
141 find $(foreach dir,$(INCLUDE_HEADERS_ARCH),include/$(dir)) -name '*.h' \
142 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
144 find ./ -path "./debian" -prune -o -path "./.pc" -prune -o \( -name Makefile -or -name Kbuild -or -name Kconfig\* \) \
145 -exec install -D -m644 {} $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/{} \;
147 ln -sf asm-$(ARCH) $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/asm
149 rm -rf $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/scripts
150 ln -sf ../$(KBUILD_PACKAGE)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)
152 # cp -a $(KSRC)/include/asm-$(ARCH)/arch \
153 # $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/include/asm-$(ARCH)
155 cp $(BUILDTMP)/arch/$(ARCH)/kernel/asm-offsets.s \
156 $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(HEADERS_PACKAGE)/arch/$(ARCH)/kernel
157 #install /lib/modules symlink
158 install -d -m 755 $(CURDIR)/debian/$(HEADERS_PACKAGE)/lib/modules/$(KVER)/
159 ln -sf /usr/src/$(HEADERS_PACKAGE) $(CURDIR)/debian/$(HEADERS_PACKAGE)/lib/modules/$(KVER)/build
161 install -d $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
162 cp -a $(KSRC)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
163 cp -a $(BUILDTMP)/scripts $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)
165 cd $(CURDIR)/debian/$(HEADERS_PACKAGE)/usr/src/$(KBUILD_PACKAGE)/scripts && \
166 ( rm -f $(RM_SCRIPTS); chmod a-x mkcompile_h )
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