-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (41 loc) · 1.07 KB
/
Makefile
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
# prerequisite: GOROOT and GOARCH must be defined
# defines $(GC) (compiler), $(LD) (linker) and $(O) (architecture)
include $(GOROOT)/src/Make.$(GOARCH)
# name of the package (library) being built
TARG=bert
# source files in package
GOFILES=\
bert.go
# test files for this package
GOTESTFILES=\
bert_test.go
# build "main" executable
main: package
$(GC) -I_obj main.go
$(LD) -L_obj -o $@ main.$O
@echo "Done. Executable is: $@"
clean:
rm -rf *.[$(OS)o] *.a [$(OS)].out _obj _test _testmain.go main
package: _obj/$(TARG).a
# create a Go package file (.a)
_obj/$(TARG).a: _go_.$O
@mkdir -p _obj/$(dir)
rm -f _obj/$(TARG).a
gopack grc $@ _go_.$O
# create Go package for for tests
_test/$(TARG).a: _gotest_.$O
@mkdir -p _test/$(dir)
rm -f _test/$(TARG).a
gopack grc $@ _gotest_.$O
# compile
_go_.$O: $(GOFILES)
$(GC) -o $@ $(GOFILES)
# compile tests
_gotest_.$O: $(GOFILES) $(GOTESTFILES)
$(GC) -o $@ $(GOFILES) $(GOTESTFILES)
# targets needed by gotest
importpath:
@echo $(TARG)
testpackage: _test/$(TARG).a
testpackage-clean:
rm -f _test/$(TARG).a _gotest_.$O