summaryrefslogtreecommitdiff
path: root/Makefile.joyent
blob: cab0a759868f9603026bd1a3b1c8f8d996ac60f2 (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
#
# Copyright (c) 2012 Joyent, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

PROTO_AREA =	$(PWD)/../../../proto
KERNEL_SOURCE =	$(PWD)/../../illumos
MDB_SOURCE =	$(KERNEL_SOURCE)/usr/src/cmd/mdb
CTFBINDIR=	$(KERNEL_SOURCE)/usr/src/tools/proto/*/opt/onbld/bin/i386
CSTYLE =	$(KERNEL_SOURCE)/usr/src/tools/scripts/cstyle
CC =		$(PROTO_AREA)/usr/bin/gcc
INSTALL =	/usr/sbin/install

QEMU_CPPFLAGS = \
	-DTARGET_PHYS_ADDR_BITS=64 \
	-D__EXTENSIONS__

DMOD_CPPFLAGS = \
	$(QEMU_CPPFLAGS) \
	-D_KERNEL \
	-DTEXT_DOMAIN="SUNW_OST_OSCMD" \
	-D_TS_ERRNO \
	-D_ELF64 \
	-Ui386 \
	-U__i386 \
	-isystem $(PROTO_AREA)/usr/include \
	-I. \
	-Ihw

ALWAYS_CFLAGS = \
	-fident \
	-fno-builtin \
	-nodefaultlibs \
	-Wall \
	-Werror \
	-fno-inline-functions

USER_CFLAGS = \
	-finline \
	-gdwarf-2 \
	-std=gnu89

DMOD_CFLAGS = \
	$(ALWAYS_CFLAGS) \
	$(USER_CFLAGS) \
	-m64 \
	-fno-strict-aliasing \
	-fno-unit-at-a-time \
	-fno-optimize-sibling-calls \
	-O2 \
	-fno-inline-small-functions \
	-fno-inline-functions-called-once \
	-mtune=opteron \
	-ffreestanding \
	-fPIC

DMOD_LDFLAGS = \
	-m64 \
	-shared \
	-nodefaultlibs \
	-Wl,-M$(KERNEL_SOURCE)/usr/src/common/mapfiles/common/map.pagealign \
	-Wl,-M$(KERNEL_SOURCE)/usr/src/common/mapfiles/common/map.noexdata \
	-Wl,-ztext \
	-Wl,-zdefs \
	-Wl,-M$(MDB_SOURCE)/common/modules/conf/mapfile-extern \
	-L$(PROTO_AREA)/lib \
	-L$(PROTO_AREA)/usr/lib

DMOD_LIBS = \
	-lc

DMOD_SRCS = \
	qemu_mdb.c

world: qemu qemu.so

config-host.mak:
	PATH=$(CTFBINDIR):$(PATH) CONFIGURE_ONLY=1 ./build.sh

qemu: config-host.mak
	echo "Building world"
	PATH=$(CTFBINDIR):$(PATH) V=1 gmake all

qemu.so: $(DMOD_SRCS)
	$(CC) $(DMOD_CPPFLAGS) $(DMOD_CFLAGS) $(DMOD_LDFLAGS) -o $@ \
	    $(DMOD_SRCS) $(DMOD_LIBS)
		

update:
	git pull --rebase

manifest:
	cp manifest $(DESTDIR)/$(DESTNAME)

install: world
	DESTDIR=$(DESTDIR) PATH=$(CTFBINDIR):$(PATH) V=1 gmake install
	$(INSTALL) -f $(DESTDIR)/usr/lib/mdb/proc/amd64/ qemu.so

clean:
	gmake clean
	rm -f qemu.so config-host.mak

xref:
	find . -type f -name '*.[ch]' > cscope.files
	cscope-fast -bq

check:
	$(CSTYLE) qemu_mdb.c

.PHONY: manifest xref check clean