summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/cgo/Makefile
blob: dc9ffb41190228edc451bfa4344f15444142c4e1 (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
# Copyright 2010 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

ENABLED:=1

ifeq ($(GOARCH),arm)
ENABLED:=0
endif

TARG=runtime/cgo

GOFILES=\
	cgo.go\

ifeq ($(ENABLED),1)

# Unwarranted chumminess with Make.pkg's cgo rules.
# Do not try this at home.
CGO_OFILES=\
	$(GOARCH).o\
	$(GOOS)_$(GOARCH).o\
	util.o\

OFILES=\
	iscgo.$O\
	callbacks.$O\
	_cgo_import.$O\
	$(CGO_OFILES)\

CGO_LDFLAGS=-lpthread

ifeq ($(GOOS),freebsd)
OFILES+=\
	freebsd.$O\

endif

endif

include ../../../Make.pkg

ifeq ($(ENABLED),1)
_cgo_defun.c:
	echo >$@

_cgo_main.c:
	echo 'int main() { return 0; }' >$@
endif

$(GOARCH).o: $(GOARCH).S
	$(HOST_CC) $(_CGO_CFLAGS_$(GOARCH)) -g -O2 -fPIC -o $@ -c $^

$(GOOS)_$(GOARCH).o: $(GOOS)_$(GOARCH).c
	$(HOST_CC) $(_CGO_CFLAGS_$(GOARCH)) -g -O2 -fPIC -o $@ -c $^

%.o: %.c
	$(HOST_CC) $(_CGO_CFLAGS_$(GOARCH)) -g -O2 -fPIC -o $@ -c $^