summaryrefslogtreecommitdiff
path: root/uts/debian/rules
blob: 5e02c43a72935630130eb43b51cea797a04245c0 (plain)
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
#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
export DH_VERBOSE = 1
VERSION := $(shell dpkg-parsechangelog | perl -ne '/Version:\s+(.+)-[^-]+/ && print $$1')

%:
	dh $@

BUILD = build-tree
ROOT = $(BUILD)/root

ILLUMOS_GATE = illumos-gate

$(ILLUMOS_GATE):
	dh_illumos_gate --checkout --destdir=$(ILLUMOS_GATE)

.PHONY: create-orig test-orig
create-orig: $(ILLUMOS_GATE)
	dh_illumos_gate --create-orig --build \
		-X /doc/ \
		$(ILLUMOS_GATE)/usr/src/uts \
		$(ILLUMOS_GATE)/usr/src/common \
		$(ILLUMOS_GATE)/usr/src/lib/gss_mechs/mech_krb5/include/k5-int-pkinit.h \
		$(ILLUMOS_GATE)/usr/src/lib/gss_mechs/mech_krb5/include/preauth_plugin.h \
		$(ILLUMOS_GATE)/usr/src/lib/gss_mechs/mech_krb5/include/autoconf.h \
		$(ILLUMOS_GATE)/usr/src/lib/gss_mechs/mech_krb5/krb5/krb/int-proto.h

test-orig: create-orig
	./debian/rules clean
	rm -rf usr .pc
	tar xf ../uts_$(VERSION).orig.tar.xz --strip=1
	quilt push -a
	./debian/rules build
	fakeroot ./debian/rules binary

ifeq (illumos-amd64,$(DEB_HOST_ARCH))
libarch := amd64
kernelarch := amd64
else ifeq (illumos-i386,$(DEB_HOST_ARCH))
libarch := i386
kernelarch := ia32
else
$(error $(DEB_HOST_ARCH) is not supported)
endif

# building with GNU make is broken
make := -m 'sunmake'

override_dh_auto_configure:
	dh_illumos_gate --configure --destdir=$(BUILD) --root=$(ROOT)

	find $(BUILD)/usr/src/uts/common/sys/lvm -name \*.x \
		-exec ./debian/fix.x.pl {} \;

	# this shell script generates assembler source files
	# and passes that source to as.
	# Default output format is expected to be 32-bit:
	echo "export ELFWRAP='$(CURDIR)/debian/elfwrap -32'" >> $(BUILD)/usr/env.sh

	# We need a wrapper for GNU CPP to undefine some macros.
	# The wrapper is debian/cpp
	echo "export RPCGEN='rpcgen -Y $(CURDIR)/debian'" >> $(BUILD)/usr/env.sh

	# We need these versions for mdb:
	echo 'export YACC=/usr/bin/sgs-yacc' >> $(BUILD)/usr/env.sh
	echo 'export LEX=/usr/bin/sgs-lex' >> $(BUILD)/usr/env.sh

	# GCC does not support -msave-args for a while:
	echo 'export SAVEARGS=' >> $(BUILD)/usr/env.sh

	# Use GNU ld for helper programs (due to changes in crt1.o)
	# and sun ld for kernel modules
	sed -i /LD_ALTEXEC/d $(BUILD)/usr/env.sh
	echo 'export LD=sunld' >> $(BUILD)/usr/env.sh

	echo 'export DEF_BUILDS$(DEB_HOST_ARCH_BITS)=obj$(DEB_HOST_ARCH_BITS)' >> $(BUILD)/usr/env.sh
	echo 'export ALL_BUILDS$(DEB_HOST_ARCH_BITS)=obj$(DEB_HOST_ARCH_BITS)' >> $(BUILD)/usr/env.sh

# Disable 32-bit builds on 64-bit host, and vice versa
ifeq (64,$(DEB_HOST_ARCH_BITS))
	echo "export DEF_BUILDS32=''" >> $(BUILD)/usr/env.sh
	echo "export ALL_BUILDS32=''" >> $(BUILD)/usr/env.sh
else ifeq (32,$(DEB_HOST_ARCH_BITS))
	echo "export DEF_BUILDS64=''" >> $(BUILD)/usr/env.sh
	echo "export ALL_BUILDS64=''" >> $(BUILD)/usr/env.sh
else
$(error DEB_HOST_ARCH_BITS is not defined or holds something wrong) 
endif

override_dh_strip:
	: # we don't strip the kernel
override_dh_makeshlibs:
	: # there are no shared libs
override_dh_shlibdeps:
	: # there are no shared libs

override_dh_auto_build:
	mkdir -p \
		$(ROOT)/etc \
		$(ROOT)/etc/security \
		$(ROOT)/boot \
		$(ROOT)/boot/solaris
	dh_illumos_make $(BUILD)/usr/src/uts -t install_h $(make)
	dh_illumos_make --ctf $(BUILD)/usr/src/uts $(make)
	# sanity check:
	objdump -p $(ROOT)/kernel/fs/amd64/dev | grep 'NEEDED *fs/devfs'

override_dh_auto_install:
	rm -rf debian/tmp
	cp -a $(ROOT) debian/tmp
	set -x; for p in `grep -E -v '^(#|$$)' debian/notpacked`; do \
		rm -rf debian/tmp/$$p || exit 1; \
	done

override_dh_install:
	dh_install --fail-missing
	debian/abi-check debian/ref debian/uts-dev

override_dh_installdeb:
	(cd debian/illumos-kernel && find kernel platform usr/kernel \
		-type f -name \*.conf) > debian/illumos-kernel.conffiles
	dh_installdeb

override_dh_auto_clean:
	rm -rf $(BUILD)