summaryrefslogtreecommitdiff
path: root/mdb/debian/rules
blob: fc613201334d86c64216c3b1ad13cbacc96eac5d (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
128
129
130
131
132
#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DH_VERBOSE = 1

cmd := \
	mdb \

man := \
	usr/src/man/man1/mdb.1 \
	usr/src/man/man1/adb.1

modules := mdb \
	mdb_ks libc libnvpair libumem libsysevent \
	libuutil libproc genunix

ifeq (amd64,$(DEB_HOST_ARCH_CPU))
dirs += $(modules:%=usr/src/cmd/mdb/intel/ia32/%)
dirs += $(modules:%=usr/src/cmd/mdb/intel/amd64/%)
endif

unpack: unpack-stamp
unpack-stamp:
	dh_testdir
	dh_illumos_gate --build  -- \
		usr/src/common/ctf \
		usr/src/uts/intel/promif \
		usr/src/common/util \
		$(cmd:%=usr/src/cmd/%) \
		$(man) \


	# Buggy and unused:
	echo > usr/src/Makefile.msg.targ

	echo 'export YACC=/usr/bin/sgs-yacc' >> usr/env.sh
	echo 'export LEX=/usr/bin/sgs-lex' >> usr/env.sh

	# GCC still does not support -msave-args, and I'm not sure
	# if this option is good at all:
	echo 'export SAVEARGS=' >> usr/env.sh

	touch $@

patch: patch-stamp
patch-stamp: unpack-stamp
	dh_testdir
	[ ! -f debian/patches/series ] || QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2
	touch $@

unpatch:
	dh_testdir
	[ ! -f debian/patches/series ] || QUILT_PATCHES=debian/patches quilt pop -a -f || test $$? = 2
	rm -f patch-stamp

dirs-stamp: unpack-stamp
	. usr/env.sh; mkdir -p \
		debian/tmp/usr/bin \
		debian/tmp/usr/include/sys \
		debian/tmp$$DEB_LIBDIR_32 \
		debian/tmp$$DEB_LIBDIR_64 \
		debian/tmp$$DEB_USRLIBDIR_32 \
		debian/tmp$$DEB_USRLIBDIR_64

ifeq (amd64,$(DEB_HOST_ARCH_CPU))
	mkdir -p debian/tmp/usr/bin/amd64
	mkdir -p debian/tmp/usr/bin/i86
	ln -sf amd64/mdb debian/tmp/usr/bin/mdb
endif
	# libncurses workaround:
	# libcurses.so is a linker script for GNU ld.
	# The linker we have to use (SunOS ld) does not understand it.
	# So we create symbolic links for libncurses.so.5 under debian/tmp.
	# Also note that we've patched mdb to explicitly link with libtinfo 
	ln -sf /lib32/libncurses.so.5 debian/tmp/usr/lib32/libcurses.so
	ln -sf /lib/$(DEB_HOST_MULTIARCH)/libncurses.so.5 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libcurses.so
	touch $@

headers-stamp: patch-stamp dirs-stamp
	dh_illumos_make  -m sunmake usr/src/cmd/mdb/ -t install_h
	# GCC takes ./usr/src/cmd/mdb/common/modules/genunix/thread.h by accident,
	# we need "real" thread.h
	ln -sf /usr/include/thread.h debian/tmp/usr/include/thread.h
	touch $@

install: install-stamp

install-stamp: build-stamp
	touch $@

build build-arch build-indep: build-stamp
build-stamp: dirs-stamp patch-stamp headers-stamp
	dh_illumos_make -m sunmake --native \
		usr/src/cmd/mdb/tools
	dh_illumos_make -m sunmake \
		$(dirs)
	touch $@

binary binary-arch binary-indep: binary-stamp
binary-stamp: install-stamp
	dh_testdir
	dh_testroot
	dh_installdirs
	dh_install -p mdb usr/bin/mdb
ifeq (illumos-amd64,$(DEB_HOST_ARCH))
	dh_install -p mdb usr/bin/amd64/mdb
	dh_install -p mdb32 usr/bin/i86/mdb
endif
	dh_install --list-missing
	dh_installman
	dh_installdocs
	dh_installexamples
	dh_installchangelogs
	dh_bash-completion
	dh_link
	dh_compress -X /examples/
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_strip
	dh_gencontrol
	dh_md5sums
	dh_builddeb
	touch $@

clean: unpatch
	dh_testdir
	dh_testroot
	rm -rf usr .pc
	dh_clean