File: rules

package info (click to toggle)
gnumach 2%3A1.8%2Bgit20241227-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 20,332 kB
  • sloc: ansic: 296,102; sh: 4,723; asm: 4,113; makefile: 472; awk: 46
file content (409 lines) | stat: -rwxr-xr-x 11,818 bytes parent folder | download | duplicates (2)
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#!/usr/bin/make -f
#
# Based on the work by Marcus Brinkmann <brinkmd@debian.org>
# Rewritten by Guillem Jover <guillem@debian.org>
#

include /usr/share/dpkg/pkg-info.mk

NOEPOCH_VERSION  := $(shell echo $(DEB_VERSION) | sed -e 's/.*://g')
TAR_VERSION      := $(shell echo $(NOEPOCH_VERSION) | sed -e 's/-.*//g')
UPSTREAM_VERSION := $(shell echo $(TAR_VERSION) | sed -e 's/\.dfsg.*//g')
NOGIT_VERSION    := $(shell echo $(UPSTREAM_VERSION) | sed -e 's/+git[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]//g')
MAJOR            := $(shell echo $(VERSION) | sed -e 's/\..*//g')

include /usr/share/dpkg/architecture.mk

ifeq (,$(filter custom,$(DEB_BUILD_OPTIONS)))
CUSTOM :=
VERSION := $(NOGIT_VERSION)
else
CUSTOM := .custom.$(shell date +'%Y%m%d')
VERSION := $(NOEPOCH_VERSION)$(CUSTOM)
endif

ifeq ($(DEB_HOST_ARCH_CPU),i386)
MACHINE         := 486
else
MACHINE         := $(DEB_HOST_ARCH_CPU)
endif

NCPUS		:= 8

pkg := gnumach-image-$(VERSION)-$(MACHINE)-up
pkg_dbg := gnumach-image-$(VERSION)-$(MACHINE)-up-dbg
pkg_udeb := kernel-image-$(VERSION)-$(MACHINE)-di
pkg_xen := gnumach-image-$(VERSION)-xen-$(MACHINE)
pkg_xen_dbg := gnumach-image-$(VERSION)-xen-$(MACHINE)-dbg
pkg_xen_udeb := kernel-image-$(VERSION)-xen-$(MACHINE)-di
pkg_pae := gnumach-image-$(VERSION)-$(MACHINE)-pae
pkg_pae_dbg := gnumach-image-$(VERSION)-$(MACHINE)-pae-dbg
pkg_smp := gnumach-image-$(VERSION)-$(MACHINE)-smp
pkg_smp_dbg := gnumach-image-$(VERSION)-$(MACHINE)-smp-dbg
pkg_common := gnumach-common
pkg_dev := gnumach-dev

ifneq ($(DEB_HOST_ARCH_CPU),arm64)
nopkg := -N$(pkg)
nopkg_dbg := -N$(pkg_dbg)
nopkg_udeb := -N$(pkg_udeb)

ifeq ($(DEB_HOST_ARCH_CPU),i386)
nopkg_pae := -N$(pkg_pae)
nopkg_pae_dbg := -N$(pkg_pae_dbg)
nopkg_smp := -N$(pkg_smp)
nopkg_smp_dbg := -N$(pkg_smp_dbg)
endif

ifneq ($(DEB_HOST_ARCH_CPU),arm64)
nopkg_xen := -N$(pkg_xen) -N$(pkg_xen_udeb)
nopkg_xen_dbg := -N$(pkg_xen_dbg)
endif
endif

D := $(CURDIR)/debian/tmp
D_DBG := $(D)-dbg
D_UDEB := $(D)-udeb
D_XEN := $(D)-xen
D_XEN_DBG := $(D)-xen-dbg
D_XEN_UDEB := $(D)-xen-udeb
D_PAE := $(D)-pae
D_PAE_DBG := $(D)-pae-dbg
D_SMP := $(D)-smp
D_SMP_DBG := $(D)-smp-dbg

export PARALLEL_HOME := $(CURDIR)/.parallel

CCASFLAGS = -fdebug-prefix-map=$(CURDIR)=.
CFLAGS = -ffile-prefix-map=$(CURDIR)=. -Wall -g -pipe -fno-strict-aliasing -no-pie -fno-PIE -fno-pie -Wformat -Werror=format-security
LDFLAGS = -no-pie

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
DEB_PARALLEL_JOBS ?= $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

ifneq (,$(DEB_PARALLEL_JOBS))
MAKEFLAGS += -j$(DEB_PARALLEL_JOBS)
endif

common_configure := \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--host=$(DEB_HOST_GNU_CPU)-gnu \
		--prefix=/usr \
		--exec-prefix=/ \
		--includedir=/usr/include/$(DEB_HOST_MULTIARCH) \
		--disable-net-group \
		--disable-pcmcia-group \
		--disable-wireless-group

ifeq ($(DEB_HOST_ARCH),hurd-amd64)
common_configure += \
		    --disable-user32
endif

debian/control: debian/control.stamp
debian/control.stamp: debian/control.in
ifneq (,$(filter custom,$(DEB_BUILD_OPTIONS)))
	@echo Building a custom kernel: "$(VERSION)"
else
	@echo Building a stock kernel: "$(VERSION)"
endif
	sed -e 's/@version@/$(VERSION)/g' < $< > debian/control
	touch $@

configure: configure.ac
	autoreconf -fi

# doconfigure <build directory suffix> <configure options...>
define doconfigure
build$(1)/config.status: configure
	dh_testdir
	-mkdir build$(1)
	cd build$(1) && PACKAGE_VERSION_SUFFIX=$(CUSTOM)$(1)-$(MACHINE) ../configure \
		CCASFLAGS="$(CCASFLAGS)" \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		$(common_configure) \
		$(2)

build$(1)-dbg/config.status: configure
	dh_testdir
	-mkdir build$(1)-dbg
	cd build$(1)-dbg && PACKAGE_VERSION_SUFFIX=$(CUSTOM)$(1)-$(MACHINE)-dbg ../configure --enable-kdb \
		CCASFLAGS="$(CCASFLAGS)" \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		$(common_configure) \
		$(2)
endef

$(eval $(call doconfigure,-up,))
$(eval $(call doconfigure,-xen,--enable-platform=xen))
$(eval $(call doconfigure,-pae,--enable-pae))
$(eval $(call doconfigure,-smp,--enable-apic --enable-ncpus=$(NCPUS)))

# _dobuild <build directory suffix> <-dbg build directory suffix>
define _dobuild
build-arch: build$(1)$(2)/stamp
build$(1)$(2)/stamp: build$(1)$(2)/config.status doc/mach.info
	dh_testdir
	$(MAKE) -C build$(1)$(2)
ifeq ($(DEB_HOST_ARCH_OS),linux)
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p $(PARALLEL_HOME)
	parallel --fg --semaphore --semaphorename gnumach-build $(MAKE) -C build$(1)$(2) check < /dev/null ; \
	RET=$$$$? ; cat build$(1)$(2)/tests/test-*.log build$(1)$(2)/test-suite.log ; exit $$$$RET
endif
endif
	touch $$@
endef

# _dobuild <build directory suffix>
define dobuild
$(eval $(call _dobuild,$1,))
  ifeq ($(filter pkg.gnumach.nodbg,$(DEB_BUILD_PROFILES)),)
$(eval $(call _dobuild,$1,-dbg))
  endif
endef

ifneq ($(DEB_HOST_ARCH_CPU),arm64)
ifeq ($(filter stage1,$(DEB_BUILD_PROFILES)),)

$(eval $(call dobuild,-up))

  ifeq ($(filter pkg.gnumach.onlyup,$(DEB_BUILD_PROFILES)),)

    ifneq ($(DEB_HOST_ARCH_CPU),arm64)
      ifeq ($(filter pkg.gnumach.noxen,$(DEB_BUILD_PROFILES)),)
$(eval $(call dobuild,-xen))
      endif
    endif

    ifeq ($(DEB_HOST_ARCH_CPU),i386)
      ifeq ($(filter pkg.gnumach.nopae,$(DEB_BUILD_PROFILES)),)
$(eval $(call dobuild,-pae))
      endif

      ifeq ($(filter pkg.gnumach.nosmp,$(DEB_BUILD_PROFILES)),)
$(eval $(call dobuild,-smp))
      endif
    endif

  endif

else
build-arch: build-up/config.status
endif
else
build-arch: build-up/config.status
endif

build-indep: build-arch
build: build-arch build-indep

doc/mach.info: build-up/config.status
	dh_testdir
	$(MAKE) -C build-up ../doc/mach.info

clean:
	dh_testdir

	rm -f debian/control.stamp
	
	rm -f machine
	rm -rf build-up build-xen build-pae build-smp build-up-dbg build-xen-dbg build-pae-dbg build-smp-dbg $(D_UDEB) $(D_XEN_UDEB) $(D_XEN) $(D_PAE) $(D_SMP) $(D_DBG) $(D_XEN_DBG) $(D_PAE_DBG) $(D_SMP_DBG)
	
	# Clean up autogenerated cruft
	rm -rf autom4te.cache build-aux
	rm -f aclocal.m4 config.h.in configure INSTALL Makefile.in
	rm -f doc/mach.info* doc/stamp-vti doc/version.texi
	find -name '*~' -o -name '*.rej' -o -name '*.orig' | xargs rm -f

	rm -f debian/gnumach-image-*.preinst
	rm -f debian/gnumach-image-*.prerm
	rm -f debian/gnumach-image-*.postinst
	rm -f debian/gnumach-image-*.postrm

	rm -rf $(PARALLEL_HOME)
	
	dh_clean

# _doinstall <build directory suffix> <DESTDIR>
define _doinstall
	$(MAKE) -C build$(1) install DESTDIR=$(2)
endef

# doinstall <first kernel filename suffix suffix> <second kernel filename suffix> <DESTDIR>
define doinstall
	$(call _doinstall,$(1)$(2),$(3))
	mv $(3)/boot/gnumach $(3)/boot/gnumach-$(VERSION)$(1)-$(MACHINE)$(2)
endef

ifeq ($(filter pkg.gnumach.nodbg,$(DEB_BUILD_PROFILES)),)
  define _doinstall_dbg
	$(call _doinstall,$(1)$(2)-dbg,$(3))
	mv $(3)/boot/gnumach $(3)/boot/gnumach-$(VERSION)$(1)-$(MACHINE)$(2)-dbg
  endef
else
  define _doinstall_dbg
  endef
endif


# doinstall_dbg <first kernel filename suffix> <second kernel filename suffix> <DESTDIR> <DEBUG DESTDIR>
define doinstall_dbg
	$(call doinstall,$(1),$(2),$(3))
	$(call _doinstall_dbg,$(1),$(2),$(4))
endef

# doinstall_dbg <first kernel filename suffix> <second kernel filename suffix> <DESTDIR> <DEBUG DESTDIR> <UDEB DESTDIR>
define doinstall_dbg_udeb
	$(call doinstall_dbg,$(1),$(2),$(3),$(4))
	mkdir -p $(5)/boot
	cp $(3)/boot/gnumach-$(VERSION)$(1)-$(MACHINE)$(2) $(5)/boot/gnumach
endef

install: build
	dh_testdir
	dh_testroot
	dh_prep -a
	-rm -rf $(D_DBG)
	dh_installdirs -a
	
ifneq ($(DEB_HOST_ARCH_CPU),arm64)
ifeq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
	$(call doinstall_dbg_udeb,,-up,$(D),$(D_DBG),$(D_UDEB))
	
  ifeq ($(filter pkg.gnumach.onlyup,$(DEB_BUILD_PROFILES)),)
    ifneq ($(DEB_HOST_ARCH_CPU),arm64)
      ifeq ($(filter pkg.gnumach.noxen,$(DEB_BUILD_PROFILES)),)
	$(call doinstall_dbg_udeb,-xen,,$(D_XEN),$(D_XEN_DBG),$(D_XEN_UDEB))
      endif
    endif
  
    ifeq ($(DEB_HOST_ARCH_CPU),i386)
      ifeq ($(filter pkg.gnumach.nopae,$(DEB_BUILD_PROFILES)),)
	$(call doinstall_dbg,,-pae,$(D_PAE),$(D_PAE_DBG))
      endif
  
      ifeq ($(filter pkg.gnumach.nosmp,$(DEB_BUILD_PROFILES)),)
	$(call doinstall_dbg,,-smp,$(D_SMP),$(D_SMP_DBG))
      endif
    endif
  endif

  ifeq ($(DEB_HOST_ARCH_OS),hurd)
	for script in preinst prerm postinst postrm ; do \
		for prefix in "" -xen ; do \
			for suffix in -up -pae -smp ; do \
				for dbg in "" -dbg ; do \
					sed -e "s/@VERSION@/$(VERSION)/g" \
					    -e "s/@RELEASE@/$(VERSION)$$prefix-$(MACHINE)$$suffix$$dbg/g" \
					    debian/gnumach-image.$$script.in \
						> debian/gnumach-image-$(VERSION)$$prefix-$(MACHINE)$$suffix$$dbg.$$script ; \
				done ; \
			done ; \
		done ; \
	done
  endif
else
	$(MAKE) -C build-up install-data \
		DESTDIR=$(D)
endif
else
	$(MAKE) -C build-up install-data \
		DESTDIR=$(D)
endif

binary: binary-indep binary-arch

binary-indep: install debian/control.stamp
	dh_testdir
	dh_testroot
	
	dh_install -i --sourcedir=$(D)
	
	dh_installdocs -i
	dh_installchangelogs -i -k ChangeLog
	dh_installinfo -i
	
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: install debian/control.stamp
	dh_testdir
	dh_testroot
	
	dh_install -a $(nopkg_dbg) $(nopkg_udeb) $(nopkg_xen) $(nopkg_xen_dbg) $(nopkg_pae) $(nopkg_pae_dbg) $(nopkg_smp) $(nopkg_smp_dbg) --sourcedir=$(D)

ifneq ($(DEB_HOST_ARCH_CPU),arm64)
	dh_install -p$(pkg) --sourcedir=$(D) boot
	dh_install -p$(pkg_dbg) --sourcedir=$(D_DBG) boot
	dh_install -p$(pkg_udeb) --sourcedir=$(D_UDEB) boot
ifneq ($(DEB_HOST_ARCH_CPU),arm64)
	dh_install -p$(pkg_xen) --sourcedir=$(D_XEN) boot
	dh_install -p$(pkg_xen_dbg) --sourcedir=$(D_XEN_DBG) boot
	dh_install -p$(pkg_xen_udeb) --sourcedir=$(D_XEN_UDEB) boot
endif
ifeq ($(DEB_HOST_ARCH_CPU),i386)
	dh_install -p$(pkg_pae) --sourcedir=$(D_PAE) boot
	dh_install -p$(pkg_pae_dbg) --sourcedir=$(D_PAE_DBG) boot
	dh_install -p$(pkg_smp) --sourcedir=$(D_SMP) boot
	dh_install -p$(pkg_smp_dbg) --sourcedir=$(D_SMP_DBG) boot
endif
	
	dh_installdocs -p$(pkg) README NEWS i386/README-Drivers
	dh_installdocs -p$(pkg_dbg) README NEWS i386/README-Drivers
ifneq ($(DEB_HOST_ARCH_CPU),arm64)
	dh_installdocs -p$(pkg_xen) README NEWS
	dh_installdocs -p$(pkg_xen_dbg) README NEWS
endif
ifeq ($(DEB_HOST_ARCH_CPU),i386)
	dh_installdocs -p$(pkg_pae) README NEWS
	dh_installdocs -p$(pkg_pae_dbg) README NEWS
	dh_installdocs -p$(pkg_smp) README NEWS
	dh_installdocs -p$(pkg_smp_dbg) README NEWS
endif
endif
	
	dh_installdocs -a
	dh_installchangelogs -a -k ChangeLog
	dh_installinfo -a
	
	dh_link -a
	dh_strip -a $(nopkg_dbg) $(nopkg_xen_dbg) $(nopkg_pae_dbg) $(nopkg_smp_dbg)
	dh_compress -a $(nopkg) $(nopkg_dbg) $(nopkg_udeb) $(nopkg_xen) $(nopkg_xen_dbg) $(nopkg_pae) $(nopkg_pae_dbg) $(nopkg_smp) $(nopkg_smp_dbg)
ifneq ($(DEB_HOST_ARCH_CPU),arm64)
	dh_compress -p$(pkg) boot/gnumach-$(VERSION)-$(MACHINE)-up
	dh_compress -p$(pkg_dbg) boot/gnumach-$(VERSION)-$(MACHINE)-up-dbg
	dh_compress -p$(pkg_udeb) boot/gnumach
ifneq ($(DEB_HOST_ARCH_CPU),arm64)
	dh_compress -p$(pkg_xen) boot/gnumach-$(VERSION)-xen-$(MACHINE)
	dh_compress -p$(pkg_xen_dbg) boot/gnumach-$(VERSION)-xen-$(MACHINE)-dbg
	dh_compress -p$(pkg_xen_udeb) boot/gnumach
endif
ifeq ($(DEB_HOST_ARCH_CPU),i386)
	dh_compress -p$(pkg_pae) boot/gnumach-$(VERSION)-$(MACHINE)-pae
	dh_compress -p$(pkg_pae_dbg) boot/gnumach-$(VERSION)-$(MACHINE)-pae-dbg
	dh_compress -p$(pkg_smp) boot/gnumach-$(VERSION)-$(MACHINE)-smp
	dh_compress -p$(pkg_smp_dbg) boot/gnumach-$(VERSION)-$(MACHINE)-smp-dbg
endif
endif
	dh_fixperms -a
	dh_installdeb -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

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