2010-08-18 08:08:49 -06:00
|
|
|
# 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.
|
|
|
|
|
2010-08-24 18:00:33 -06:00
|
|
|
# Makefile included by all other Go makefiles.
|
2010-09-11 21:41:40 -06:00
|
|
|
|
|
|
|
# Clear variables that must come from Makefiles,
|
|
|
|
# not the environment.
|
|
|
|
LIB:=
|
|
|
|
TARG:=
|
|
|
|
GOFILES:=
|
|
|
|
HFILES:=
|
|
|
|
OFILES:=
|
|
|
|
YFILES:=
|
2010-08-18 08:08:49 -06:00
|
|
|
|
2010-08-24 18:00:33 -06:00
|
|
|
# GOROOT must be set.
|
2010-08-18 08:08:49 -06:00
|
|
|
ifeq ($(GOROOT),)
|
2010-08-24 18:00:33 -06:00
|
|
|
$(error $$GOROOT is not set; use gomake or set $$GOROOT in your environment)
|
2010-08-18 08:08:49 -06:00
|
|
|
endif
|
|
|
|
|
2010-08-24 18:00:33 -06:00
|
|
|
# Set up GOROOT_FINAL, GOARCH, GOOS if needed.
|
|
|
|
GOROOT_FINAL?=$(GOROOT)
|
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
ifeq ($(GOOS),)
|
|
|
|
GOOS:=${shell uname | tr A-Z a-z}
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(GOOS),darwin)
|
|
|
|
else ifeq ($(GOOS),freebsd)
|
|
|
|
else ifeq ($(GOOS),linux)
|
|
|
|
else ifeq ($(GOOS),nacl)
|
2010-09-08 23:14:38 -06:00
|
|
|
else ifeq ($(GOOS),tiny)
|
2010-08-18 08:08:49 -06:00
|
|
|
else ifeq ($(GOOS),windows)
|
|
|
|
else
|
2010-09-08 23:14:38 -06:00
|
|
|
$(error Invalid $$GOOS '$(GOOS)'; must be darwin, freebsd, linux, nacl, tiny, or windows)
|
2010-08-18 08:08:49 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(GOARCH),)
|
|
|
|
ifeq ($(GOOS),darwin)
|
|
|
|
# Even on 64-bit platform, darwin uname -m prints i386.
|
|
|
|
# Check for amd64 with sysctl instead.
|
|
|
|
GOARCH:=${shell if sysctl machdep.cpu.extfeatures | grep EM64T >/dev/null; then echo amd64; else uname -m | sed 's/i386/386/'; fi}
|
|
|
|
else
|
|
|
|
# Ask uname -m for the processor.
|
|
|
|
GOARCH:=${shell uname -m | sed 's/^..86$$/386/; s/^.86$$/386/; s/x86_64/amd64/'}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(GOARCH),386)
|
|
|
|
O:=8
|
|
|
|
else ifeq ($(GOARCH),amd64)
|
|
|
|
O:=6
|
|
|
|
else ifeq ($(GOARCH),arm)
|
2010-09-11 21:41:40 -06:00
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
O:=5
|
2010-09-11 21:41:40 -06:00
|
|
|
ifeq ($(GOOS),linux)
|
|
|
|
else
|
|
|
|
$(error Invalid $$GOOS '$(GOOS)' for GOARCH=arm; must be linux)
|
|
|
|
endif
|
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
else
|
|
|
|
$(error Invalid $$GOARCH '$(GOARCH)'; must be 386, amd64, or arm)
|
|
|
|
endif
|
|
|
|
|
2010-08-24 18:00:33 -06:00
|
|
|
# Save for recursive make to avoid recomputing.
|
2010-08-18 08:08:49 -06:00
|
|
|
export GOARCH GOOS
|
|
|
|
|
2010-08-24 18:00:33 -06:00
|
|
|
# ugly hack to deal with whitespaces in $GOROOT
|
|
|
|
nullstring :=
|
|
|
|
space := $(nullstring) # a space at the end
|
|
|
|
QUOTED_GOROOT:=$(subst $(space),\ ,$(GOROOT))
|
|
|
|
|
|
|
|
# default GOBIN
|
|
|
|
ifndef GOBIN
|
|
|
|
GOBIN=$(QUOTED_GOROOT)/bin
|
|
|
|
endif
|
|
|
|
QUOTED_GOBIN=$(subst $(space),\ ,$(GOBIN))
|
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
AS=${O}a
|
|
|
|
CC=${O}c
|
|
|
|
GC=${O}g
|
|
|
|
LD=${O}l
|
|
|
|
OS=568vq
|
|
|
|
CFLAGS=-FVw
|
|
|
|
|
2010-08-24 18:00:33 -06:00
|
|
|
HOST_CC=quietgcc
|
|
|
|
HOST_LD=quietgcc
|
|
|
|
HOST_O=o
|
|
|
|
HOST_YFLAGS=-d
|
|
|
|
HOST_CFLAGS=-ggdb -I"$(GOROOT)/include" -O2 -fno-inline
|
|
|
|
PWD=$(shell pwd)
|
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
go-env:
|
|
|
|
@echo export GOARCH=$(GOARCH)
|
|
|
|
@echo export GOOS=$(GOOS)
|
|
|
|
@echo export O=$O
|
|
|
|
@echo export AS="$(AS)"
|
|
|
|
@echo export CC="$(CC)"
|
|
|
|
@echo export GC="$(GC)"
|
|
|
|
@echo export LD="$(LD)"
|
|
|
|
@echo export OS="$(OS)"
|
|
|
|
@echo export CFLAGS="$(CFLAGS)"
|
|
|
|
@echo MAKE_GO_ENV_WORKED=1
|
|
|
|
|
|
|
|
# Don't let the targets in this file be used
|
|
|
|
# as the default make target.
|
|
|
|
.DEFAULT_GOAL:=
|