LEFT | RIGHT |
1 # Copyright 2009 The Go Authors. All rights reserved. | 1 # Copyright 2009 The Go Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style | 2 # Use of this source code is governed by a BSD-style |
3 # license that can be found in the LICENSE file. | 3 # license that can be found in the LICENSE file. |
4 | 4 |
5 # Makefile included by all other Go makefiles. | 5 # Makefile included by all other Go makefiles. |
6 | 6 |
7 # Clear variables that must come from Makefiles, | 7 # Clear variables that must come from Makefiles, |
8 # not the environment. | 8 # not the environment. |
9 LIB:= | 9 LIB:= |
10 TARG:= | 10 TARG:= |
11 GOFILES:= | 11 GOFILES:= |
12 HFILES:= | 12 HFILES:= |
13 OFILES:= | 13 OFILES:= |
14 YFILES:= | 14 YFILES:= |
15 | 15 |
16 # GOROOT must be set. | 16 # GOROOT must be set. |
17 ifeq ($(GOROOT),) | 17 ifeq ($(GOROOT),) |
18 $(error $$GOROOT is not set; use gomake or set $$GOROOT in your environment) | 18 $(error $$GOROOT is not set; use gomake or set $$GOROOT in your environment) |
19 endif | 19 endif |
20 | 20 |
21 # Set up GOROOT_FINAL, GOARCH, GOOS if needed. | 21 # Set up GOROOT_FINAL, GOARCH, GOOS if needed. |
22 GOROOT_FINAL?=$(GOROOT) | 22 GOROOT_FINAL?=$(GOROOT) |
23 | 23 |
| 24 ifeq ($(GOHOSTOS),) |
| 25 GOHOSTOS:=$(shell uname | tr A-Z a-z | sed 's/mingw/windows/; s/.*windows.*/wind
ows/') |
| 26 endif |
| 27 |
24 ifeq ($(GOOS),) | 28 ifeq ($(GOOS),) |
25 GOOS:=${shell uname | tr A-Z a-z | sed 's/mingw/windows/; s/windows.*/windows/'} | 29 GOOS:=$(GOHOSTOS) |
26 endif | 30 endif |
27 | 31 |
28 ifeq ($(GOOS),darwin) | 32 ifeq ($(GOOS),darwin) |
29 else ifeq ($(GOOS),freebsd) | 33 else ifeq ($(GOOS),freebsd) |
30 else ifeq ($(GOOS),linux) | 34 else ifeq ($(GOOS),linux) |
31 else ifeq ($(GOOS),nacl) | 35 else ifeq ($(GOOS),nacl) |
32 else ifeq ($(GOOS),tiny) | 36 else ifeq ($(GOOS),tiny) |
33 else ifeq ($(GOOS),plan9) | 37 else ifeq ($(GOOS),plan9) |
34 else ifeq ($(GOOS),windows) | 38 else ifeq ($(GOOS),windows) |
35 else | 39 else |
36 $(error Invalid $$GOOS '$(GOOS)'; must be darwin, freebsd, linux, nacl, tiny, pl
an9, or windows) | 40 $(error Invalid $$GOOS '$(GOOS)'; must be darwin, freebsd, linux, nacl, tiny, pl
an9, or windows) |
37 endif | 41 endif |
38 | 42 |
39 ifeq ($(GOARCH),) | 43 ifeq ($(GOHOSTARCH),) |
40 ifeq ($(GOOS),darwin) | 44 ifeq ($(GOHOSTOS),darwin) |
41 # Even on 64-bit platform, darwin uname -m prints i386. | 45 # Even on 64-bit platform, darwin uname -m prints i386. |
42 # Check for amd64 with sysctl instead. | 46 # Check for amd64 with sysctl instead. |
43 GOARCH:=${shell if sysctl machdep.cpu.extfeatures | grep EM64T >/dev/null; then
echo amd64; else uname -m | sed 's/i386/386/'; fi} | 47 GOHOSTARCH:=${shell if sysctl machdep.cpu.extfeatures | grep EM64T >/dev/null; t
hen echo amd64; else uname -m | sed 's/i386/386/'; fi} |
44 else | 48 else |
45 # Ask uname -m for the processor. | 49 # Ask uname -m for the processor. |
46 GOARCH:=${shell uname -m | sed 's/^..86$$/386/; s/^.86$$/386/; s/x86_64/amd64/;
s/arm.*/arm/'} | 50 GOHOSTARCH:=${shell uname -m | sed 's/^..86$$/386/; s/^.86$$/386/; s/x86_64/amd6
4/; s/arm.*/arm/'} |
47 endif | 51 endif |
| 52 endif |
| 53 |
| 54 ifeq ($(GOARCH),) |
| 55 GOARCH:=$(GOHOSTARCH) |
| 56 endif |
| 57 |
| 58 # darwin requires GOHOSTARCH match GOARCH |
| 59 ifeq ($(GOOS),darwin) |
| 60 GOHOSTARCH:=$(GOARCH) |
48 endif | 61 endif |
49 | 62 |
50 ifeq ($(GOARCH),386) | 63 ifeq ($(GOARCH),386) |
51 O:=8 | 64 O:=8 |
52 else ifeq ($(GOARCH),amd64) | 65 else ifeq ($(GOARCH),amd64) |
53 O:=6 | 66 O:=6 |
54 else ifeq ($(GOARCH),arm) | 67 else ifeq ($(GOARCH),arm) |
55 | 68 |
56 O:=5 | 69 O:=5 |
57 ifeq ($(GOOS),linux) | 70 ifeq ($(GOOS),linux) |
58 else | 71 else |
59 $(error Invalid $$GOOS '$(GOOS)' for GOARCH=arm; must be linux) | 72 $(error Invalid $$GOOS '$(GOOS)' for GOARCH=arm; must be linux) |
60 endif | 73 endif |
61 | 74 |
62 else | 75 else |
63 $(error Invalid $$GOARCH '$(GOARCH)'; must be 386, amd64, or arm) | 76 $(error Invalid $$GOARCH '$(GOARCH)'; must be 386, amd64, or arm) |
64 endif | 77 endif |
65 | 78 |
66 # Save for recursive make to avoid recomputing. | 79 # Save for recursive make to avoid recomputing. |
67 export GOARCH GOOS | 80 export GOARCH GOOS GOHOSTARCH GOHOSTOS |
68 | 81 |
69 # ugly hack to deal with whitespaces in $GOROOT | 82 # ugly hack to deal with whitespaces in $GOROOT |
70 nullstring := | 83 nullstring := |
71 space := $(nullstring) # a space at the end | 84 space := $(nullstring) # a space at the end |
72 QUOTED_GOROOT:=$(subst $(space),\ ,$(GOROOT)) | 85 QUOTED_GOROOT:=$(subst $(space),\ ,$(GOROOT)) |
73 | 86 |
74 # default GOBIN | 87 # default GOBIN |
75 ifndef GOBIN | 88 ifndef GOBIN |
76 GOBIN=$(QUOTED_GOROOT)/bin | 89 GOBIN=$(QUOTED_GOROOT)/bin |
77 endif | 90 endif |
(...skipping 17 matching lines...) Expand all Loading... |
95 LANG:= | 108 LANG:= |
96 LC_ALL:=C | 109 LC_ALL:=C |
97 LC_CTYPE:=C | 110 LC_CTYPE:=C |
98 GREP_OPTIONS:= | 111 GREP_OPTIONS:= |
99 GREP_COLORS:= | 112 GREP_COLORS:= |
100 export LANG LC_ALL LC_CTYPE GREP_OPTIONS GREP_COLORS | 113 export LANG LC_ALL LC_CTYPE GREP_OPTIONS GREP_COLORS |
101 | 114 |
102 go-env: | 115 go-env: |
103 @echo export GOARCH=$(GOARCH) | 116 @echo export GOARCH=$(GOARCH) |
104 @echo export GOOS=$(GOOS) | 117 @echo export GOOS=$(GOOS) |
| 118 @echo export GOHOSTARCH=$(GOHOSTARCH) |
| 119 @echo export GOHOSTOS=$(GOHOSTOS) |
105 @echo export O=$O | 120 @echo export O=$O |
106 @echo export AS="$(AS)" | 121 @echo export AS="$(AS)" |
107 @echo export CC="$(CC)" | 122 @echo export CC="$(CC)" |
108 @echo export GC="$(GC)" | 123 @echo export GC="$(GC)" |
109 @echo export LD="$(LD)" | 124 @echo export LD="$(LD)" |
110 @echo export OS="$(OS)" | 125 @echo export OS="$(OS)" |
111 @echo export CFLAGS="$(CFLAGS)" | 126 @echo export CFLAGS="$(CFLAGS)" |
112 @echo export LANG="$(LANG)" | 127 @echo export LANG="$(LANG)" |
113 @echo export LC_ALL="$(LC_ALL)" | 128 @echo export LC_ALL="$(LC_ALL)" |
114 @echo export LC_CTYPE="$(LC_CTYPE)" | 129 @echo export LC_CTYPE="$(LC_CTYPE)" |
115 @echo export GREP_OPTIONS="$(GREP_OPTIONS)" | 130 @echo export GREP_OPTIONS="$(GREP_OPTIONS)" |
116 @echo export GREP_COLORS="$(GREP_COLORS)" | 131 @echo export GREP_COLORS="$(GREP_COLORS)" |
117 @echo MAKE_GO_ENV_WORKED=1 | 132 @echo MAKE_GO_ENV_WORKED=1 |
118 | 133 |
119 # Don't let the targets in this file be used | 134 # Don't let the targets in this file be used |
120 # as the default make target. | 135 # as the default make target. |
121 .DEFAULT_GOAL:= | 136 .DEFAULT_GOAL:= |
LEFT | RIGHT |