File: rules

package info (click to toggle)
kernel-image-2.2.10-powerpc-apus 2.2.10-11
  • links: PTS
  • area: main
  • in suites: potato
  • size: 524 kB
  • ctags: 12
  • sloc: perl: 924; makefile: 170; sh: 40
file content (203 lines) | stat: -rwxr-xr-x 9,162 bytes parent folder | download
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/make -f
#
# kernel-image and -header package builder 
#
# Copyright (c) 1999 Hartmut Koptein <koptein@debian.org>
#
# This is free software under the GNU General Public License.
#
# Feb. 1999: initial version
# Dez. 1999: changed to kernel-image

Arch      := $(shell dpkg --print-architecture)
Package   := $(shell perl -e 'print <> =~ /(\S*)\s/' debian/changelog)
PKG_VER   := $(shell perl -e 'print <> =~ /\((.*)\)/' debian/changelog)
PKG_UPVER := $(shell perl -e 'print <> =~ /\((.*)-[^-]*\)/' debian/changelog)
Version   := $(shell head -1 debian/changelog | sed 's/^kernel-image-\(.*\)-powerpc-apus.*$$/\1/')

DDIR      := $(shell pwd)/debian
KDIR      := $(shell pwd)/kernel-source-$(Version)
KIMG      := kernel-image-$(Version)
KHEAD     := kernel-headers-$(Version)-apus

Subarchs  = apus # chrp pmac prep common mbx

#
#
build: build-stamp
build-stamp:
	$(checkdir)
	@echo -n "Uncompressing the kernel source tarball : ... "
	@if [ -r /usr/src/kernel-source-$(Version).tar.bz2 ] ; then	\
		tar Ixf /usr/src/kernel-source-$(Version).tar.bz2 ;	\
		echo "done."; \
	elif [ -r /usr/src/kernel-source-$(Version).tar.gz ] ; then	\
		tar zxf /usr/src/kernel-source-$(Version).tar.gz ;	\
		echo "done."; \
	fi 
	@echo "Applying the linux patch : ... "
	@if [ -r linux-$(Version).diff.gz ] ; then \
                zcat linux-$(Version).diff.gz | patch -d kernel-source-$(Version) -l -s -p1 &>linux-$(Version).log; \
                echo "Removing empty files after patching" ; \
                find . -type f -size 0 -exec rm {} \; -print; \
		echo "done."; \
        fi
	@echo "Applying the apus patch : ... "
	@if [ -r apus-$(Version).diff.gz ] ; then \
                zcat apus-$(Version).diff.gz | patch -d kernel-source-$(Version) -l -s -p0 &>apus-$(Version).log; \
                echo "Removing empty files after patching" ; \
                find . -type f -size 0 -exec rm {} \; -print; \
		echo "done."; \
        fi
	@echo "Applying the pm2fb patch : ... "
	@if [ -r pm2fb-$(Version).diff.gz ] ; then \
                zcat pm2fb-$(Version).diff.gz | patch -d kernel-source-$(Version) -l -s -p0 &>pm2fb-$(Version).log; \
                echo "Removing empty files after patching" ; \
                find . -type f -size 0 -exec rm {} \; -print; \
		echo "done."; \
        fi
	@echo "Applying the bootstrap patch : ... "
	@if [ -r bootstrap-$(Version).diff.gz ] ; then \
                zcat bootstrap-$(Version).diff.gz | patch -d kernel-source-$(Version) -l -s -p0 &>bootstrap-$(Version).log; \
                echo "Removing empty files after patching" ; \
                find . -type f -size 0 -exec rm {} \; -print; \
		echo "done."; \
        fi
	@echo "Applying the vmapus patch : ... "
	@if [ -r vmapus-$(Version).diff.gz ] ; then \
                zcat vmapus-$(Version).diff.gz | patch -d kernel-source-$(Version) -l -s -p0 &>vmapus-$(Version).log; \
                echo "Removing empty files after patching" ; \
                find . -type f -size 0 -exec rm {} \; -print; \
		echo "done."; \
        fi
	@echo "Applying the affs patch : ... "
	@if [ -r affs-$(Version).diff.gz ] ; then \
                zcat affs-$(Version).diff.gz | patch -d kernel-source-$(Version) -l -s -p0 &>affs-$(Version).log; \
                echo "Removing empty files after patching" ; \
                find . -type f -size 0 -exec rm {} \; -print; \
		echo "done."; \
        fi
	touch build-stamp
	touch build-stamp

#
# The clean target
#
clean:
	$(checkdir)
	-rm -rf debian/tmp debian/files* debian/control.new debian/substvars
	-rm -rf kernel-source-$(Version)
	-rm -f *-stamp core *-$(Version).log
	-rm -rf debian/kernel-image* debian/kernel-headers*

#
#
binary-indep: checkroot build
binary-arch: checkroot build
	$(checkdir)
	cp -f debian/control.head debian/control.new

	for subarch in $(Subarchs) ; do                                    \
		subarch=$$(basename $$subarch) ;                           \
		mkdir -p $(DDIR)/$(KIMG)-$$subarch/boot ;   \
		mkdir -p $(DDIR)/$(KIMG)-$$subarch/usr/share/doc/$(KIMG)-$$subarch ; \
		cat debian/confs/control.$$subarch >> debian/control.new ; \
	done

	for subarch in $(Subarchs) ; do                                    \
	    subarch=$$(basename $$subarch) ;                               \
	    cp config/$$subarch kernel-source-$(Version)/.config ;         \
	    case $$subarch in						   \
		apus)							   \
		    ( cd $(KDIR); $(MAKE) clean; $(MAKE) oldconfig; $(MAKE) dep;   \
			$(MAKE) vmapus.gz; $(MAKE) modules ) ;             \
		    ;;                                                     \
		*)							   \
		    ( cd $(KDIR); $(MAKE) clean; $(MAKE) oldconfig; $(MAKE) dep;   \
			$(MAKE) zImage; $(MAKE) modules ) ;                \
		    ;;                                                     \
	    esac;							   \
	    cp $(KDIR)/.config $(DDIR)/$(KIMG)-$$subarch/boot/config-$(Version)        ; \
	    cp $(KDIR)/System.map $(DDIR)/$(KIMG)-$$subarch/boot/System.map-$(Version) ; \
	    case $$subarch in                                              \
		apus)                                                      \
		    cp $(KDIR)/vmapus.gz                                   \
		       $(DDIR)/$(KIMG)-apus/boot/vmlinuz-$(Version)        \
		    ;;                                                     \
	        chrp)                                                      \
		    cp $(KDIR)/arch/ppc/chrpboot/zImage                    \
		       $(DDIR)/$(KIMG)-chrp/boot/vmlinuz-$(Version);       \
		    cp addons/QuikDefault                                  \
		       $(DDIR)/$(KIMG)-chrp/usr/share/doc/$(KIMG)-chrp     \
		    ;;                                                     \
	    	common)                                                    \
		    cp $(KDIR)/arch/ppc/boot/zImage                        \
		       $(DDIR)/$(KIMG)-common/boot/vmlinuz-$(Version)      \
		    ;;                                                     \
	    	mbx)                                                       \
		    cp $(KDIR)/arch/ppc/boot/zImage                        \
		       $(DDIR)/$(KIMG)-mbx/boot/vmlinuz-$(Version)         \
		    ;;                                                     \
	    	pmac)                                                      \
		    cp $(KDIR)/arch/ppc/coffboot/vmlinux.coff              \
			$(DDIR)/$(KIMG)-pmac/boot/vmlinux.coff-$(Version); \
		    cp $(KDIR)/vmlinux                                     \
			$(DDIR)/$(KIMG)-pmac/boot/vmlinux-$(Version);      \
		    cp addons/QuikDefault                                  \
			$(DDIR)/$(KIMG)-pmac/usr/share/doc/$(KIMG)-pmac    \
		    ;;                                                     \
	    	prep)                                                      \
		    cp $(KDIR)/arch/ppc/boot/zImage                        \
			$(DDIR)/$(KIMG)-prep/boot/vmlinuz-$(Version)       \
		    ;;                                                     \
	    esac;                                                          \
	    (cd $(KDIR) ; \
	        $(MAKE) INSTALL_MOD_PATH=$(DDIR)/$(KIMG)-$$subarch modules_install; \
	    ) ; \
	    touch build-$$subarch-stamp; \
	done

	sed -e 's/=V/$(Version)/g' debian/control.new > debian/control

	mkdir -p debian/$(KHEAD)/usr/src/$(KHEAD)/include
	mkdir -p debian/$(KHEAD)/usr/share/doc/$(KHEAD)
	mkdir debian/$(KHEAD)/DEBIAN
	sed -e 's/=V/$(Version)/g' debian/header.postinst > debian/$(KHEAD)/DEBIAN/postinst
	sed -e 's/=V/$(Version)/g' debian/header.postrm > debian/$(KHEAD)/DEBIAN/postrm
	chmod 755 debian/$(KHEAD)/DEBIAN/post*
	cp -rfd $(KDIR)/include/* \
		debian/$(KHEAD)/usr/src/$(KHEAD)/include
	cp addons/LinkPolicy debian/changelog debian/copyright \
		debian/$(KHEAD)/usr/share/doc/$(KHEAD)

	for subarch in $(Subarchs) ; do                                            \
		subarch=$$(basename $$subarch) ;                                   \
		chmod 644 debian/$(KIMG)-$$subarch/boot/*;                         \
		mkdir debian/$(KIMG)-$$subarch/DEBIAN ;                            \
		sed -e 's/=V/$(Version)/g' debian/image.postinst > debian/$(KIMG)-$$subarch/DEBIAN/postinst ; \
		sed -e 's/=V/$(Version)/g' debian/image.postrm > debian/$(KIMG)-$$subarch/DEBIAN/postrm ; \
		sed -e 's/=V/$(Version)/g' debian/image.preinst > debian/$(KIMG)-$$subarch/DEBIAN/preinst ; \
		sed -e 's/=V/$(Version)/g' debian/image.prerm > debian/$(KIMG)-$$subarch/DEBIAN/prerm ; \
		chmod 755 debian/$(KIMG)-$$subarch/DEBIAN/{pre*,post*} ;           \
		cp debian/changelog debian/copyright                               \
			debian/$(KIMG)-$$subarch/usr/share/doc/$(KIMG)-$$subarch ; \
		chown -R root.root debian/$(KIMG)-$$subarch ;                      \
		dpkg-gencontrol -p$(KIMG)-$$subarch -Pdebian/$(KIMG)-$$subarch ;   \
		dpkg --build debian/$(KIMG)-$$subarch .. ;                         \
	done
	dpkg-gencontrol -p$(KHEAD) -Pdebian/$(KHEAD)
	dpkg --build debian/$(KHEAD) ..
	dpkg-genchanges > ../$(KIMG)-powerpc-apus_$(PKG_VER)_powerpc.changes


define checkdir
	test -f debian/rules
endef

checkroot:
	$(checkdir)
	test root = "`whoami`"


binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary unpack