summaryrefslogtreecommitdiff
path: root/src/libcgo/Makefile
blob: 254e4622d584c16242e094495253eb2b76d8a4c8 (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
# 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.

all: libcgo.so

install: $(GOROOT)/pkg/$(GOOS)_$(GOARCH)/libcgo.so

OFILES=\
	$(GOOS)_$(GOARCH).o\
	$(GOARCH).o\
	util.o\

CFLAGS_386=-m32
CFLAGS_amd64=-m64

LDFLAGS_linux=-shared -lpthread -lm
LDFLAGS_darwin=-dynamiclib -Wl,-undefined,dynamic_lookup /usr/lib/libpthread.dylib
LDFLAGS_freebsd=-pthread -shared -lm

%.o: %.c
	gcc $(CFLAGS_$(GOARCH)) -O2 -fPIC -o $@ -c $*.c

%.o: %.S
	gcc $(CFLAGS_$(GOARCH)) -O2 -fPIC -o $@ -c $*.S

libcgo.so: $(OFILES)
	gcc $(CFLAGS_$(GOARCH)) -o libcgo.so $(OFILES) $(LDFLAGS_$(GOOS))

$(GOROOT)/pkg/$(GOOS)_$(GOARCH)/libcgo.so: libcgo.so
	cp libcgo.so $@

clean:
	rm -f *.o *.so