summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/Makefile
blob: 4da78c5f094654ec950bddd305c677bd8fd9ee93 (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
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
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

include ../../Make.inc

TARG=runtime

# Set SIZE to 32 or 64.
SIZE_386=32
SIZE_amd64=64
SIZE_arm=32
SIZE=$(SIZE_$(GOARCH))

# TODO(kaib): fix register allocation to honor extern register so we
# can enable optimizations again.
CFLAGS_arm=-N
CFLAGS_windows=-D__WINDOWS__
CFLAGS=-I$(GOOS) -I$(GOARCH) -I$(GOOS)/$(GOARCH) -wF $(CFLAGS_$(GOARCH)) $(CFLAGS_$(GOOS))

GOFILES=\
	debug.go\
	error.go\
	extern.go\
	mem.go\
	sig.go\
	softfloat64.go\
	type.go\
	version.go\
	version_$(GOOS).go\
	version_$(GOARCH).go\
	runtime_defs.go\

CLEANFILES+=version.go version_*.go

OFILES_windows=\
	syscall.$O\

# 386-specific object files
OFILES_386=\
	vlop.$O\
	vlrt.$O\

# arm-specific object files
OFILES_arm=\
	memset.$O\
	softfloat.$O\
	vlop.$O\
	vlrt.$O\

OFILES=\
	asm.$O\
	cgocall.$O\
	chan.$O\
	closure.$O\
	cpuprof.$O\
	float.$O\
	complex.$O\
	hashmap.$O\
	iface.$O\
	malloc.$O\
	mcache.$O\
	mcentral.$O\
	mem.$O\
	memmove.$O\
	mfinal.$O\
	mfixalloc.$O\
	mgc0.$O\
	mheap.$O\
	mprof.$O\
	msize.$O\
	print.$O\
	proc.$O\
	reflect.$O\
	rune.$O\
	runtime.$O\
	runtime1.$O\
	rt0.$O\
	sema.$O\
	signal.$O\
	sigqueue.$O\
	slice.$O\
	string.$O\
	symtab.$O\
	sys.$O\
	thread.$O\
	traceback.$O\
	$(OFILES_$(GOARCH))\
	$(OFILES_$(GOOS))\

HFILES=\
	cgocall.h\
	runtime.h\
	hashmap.h\
	malloc.h\
	stack.h\
	$(GOARCH)/asm.h\
	$(GOOS)/os.h\
	$(GOOS)/signals.h\
	$(GOOS)/$(GOARCH)/defs.h\

GOFILES+=$(GOFILES_$(GOOS))

# For use by cgo.
INSTALLFILES=$(pkgdir)/runtime.h $(pkgdir)/cgocall.h

# special, out of the way compiler flag that means "add runtime metadata to output"
GC+= -+

include ../../Make.pkg

$(pkgdir)/%.h: %.h
	@test -d $(QUOTED_GOROOT)/pkg && mkdir -p $(pkgdir)
	cp $< "$@"

clean: clean-local

clean-local:
	rm -f goc2c mkversion version.go */asm.h runtime.acid.* runtime_defs.go $$(ls *.goc | sed 's/goc$$/c/')

$(GOARCH)/asm.h: mkasmh.sh runtime.acid.$(GOARCH)
	./mkasmh.sh >$@.x
	mv -f $@.x $@

goc2c: goc2c.c
	quietgcc -o $@ $<

mkversion: mkversion.c
	quietgcc -o $@ -I "$(GOROOT)/include" $< "$(GOROOT)/lib/lib9.a"

version.go: mkversion
	GOROOT="$(GOROOT_FINAL)" ./mkversion >version.go

version_$(GOARCH).go:
	(echo 'package runtime'; echo 'const theGoarch = "$(GOARCH)"') >$@

version_$(GOOS).go:
	(echo 'package runtime'; echo 'const theGoos = "$(GOOS)"') >$@

%.c:	%.goc goc2c
	./goc2c "`pwd`/$<" > $@.tmp
	mv -f $@.tmp $@

%.$O:	$(GOARCH)/%.c $(HFILES)
	$(CC) $(CFLAGS) $<

%.$O:	$(GOOS)/%.c $(HFILES)
	$(CC) $(CFLAGS) $<

%.$O:	$(GOOS)/$(GOARCH)/%.c $(HFILES)
	$(CC) $(CFLAGS) $<

%.$O:	$(GOARCH)/%.s $(GOARCH)/asm.h
	$(AS) $<

%.$O:	$(GOOS)/$(GOARCH)/%.s $(GOARCH)/asm.h
	$(AS) $<

# for discovering offsets inside structs when debugging
runtime.acid.$(GOARCH): runtime.h proc.c
	$(CC) $(CFLAGS) -a proc.c >$@

# 386 traceback is really amd64 traceback
ifeq ($(GOARCH),386)
traceback.$O:	amd64/traceback.c
	$(CC) $(CFLAGS) $<
endif

runtime_defs.go: proc.c iface.c hashmap.c chan.c
	CC="$(CC)" CFLAGS="$(CFLAGS)" ./mkgodefs.sh $^ > $@.x
	mv -f $@.x $@