Skip to content
This repository was archived by the owner on Mar 11, 2019. It is now read-only.

Commit 21df028

Browse files
committed
Make $GOFRONTEND configurable and check whether it exists
1 parent 67a807e commit 21df028

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OUT = $(BUILD)/$(PKG)
1212
.PHONY: all clean run mkdir test test-pkg
1313

1414
# Various common flags for GCC.
15-
FLAGS=-Os -g -Wall -Werror -fomit-frame-pointer -Igofrontend/libgo/runtime -Isrc/runtime
15+
FLAGS=-Os -g -Wall -Werror -fomit-frame-pointer -I$(GOFRONTEND)/libgo/runtime -Isrc/runtime
1616

1717
CFLAGS = $(FLAGS)
1818
GOFLAGS = $(FLAGS) -fno-split-stack
@@ -49,9 +49,12 @@ run: all
4949
# Find all the dependencies of the main package.
5050
PKGDEPS = $(shell go list -f '{{ join .Imports " " }}' ./src/$(PKG))
5151

52+
# Where the gofrontend is located (usually in the git submodule).
53+
GOFRONTEND = ./gofrontend
54+
5255
# Which sources should be used for Go dependencies.
5356
#PKGROOT = /usr/share/go-1.7/src
54-
PKGROOT = gofrontend/libgo/go
57+
PKGROOT = $(GOFRONTEND)/libgo/go
5558

5659
# Directories required during the build. Will be created by mkdir at the start.
5760
DIRS = \
@@ -111,7 +114,7 @@ SRC_C_TINYGO = \
111114
# built all at once, or there will be undefined variables and such.
112115
SRC_GO_RUNTIME += \
113116
src/runtime/runtime.go \
114-
gofrontend/libgo/go/runtime/error.go
117+
$(GOFRONTEND)/libgo/go/runtime/error.go
115118

116119
# Build a single runtime.o for all Go sources.
117120
$(BUILD)/pkg/runtime.o: $(SRC_GO_RUNTIME)
@@ -129,6 +132,11 @@ OBJ += $(OBJ_GO)
129132
OBJ += $(addprefix $(BUILD)/tinygo/,$(SRC_C_TINYGO:.c=.o))
130133
OBJ += $(addprefix $(BUILD)/libgo/,$(SRC_C_LIBGO:.c=.o))
131134

135+
ifeq ("$(wildcard $(GOFRONTEND)/libgo)","")
136+
$(info $(GOFRONTEND) does not exist - try running: git submodule update --init)
137+
$(error no gofrontend available)
138+
endif
139+
132140
# Make build directories. Must always run as the first command.
133141
mkdir:
134142
@mkdir -p $(DIRS)
@@ -152,7 +160,7 @@ $(BUILD)/pkg/unicode.o: $(shell go list -f '{{ range .GoFiles }}$(PKGROOT)/unico
152160

153161
# Build libgo C sources.
154162
# TODO: this uses gnu99 to work around undefined stack_t
155-
$(BUILD)/libgo/%.o: gofrontend/libgo/runtime/%.c
163+
$(BUILD)/libgo/%.o: $(GOFRONTEND)/libgo/runtime/%.c
156164
gcc $(CFLAGS) -std=gnu99 -c -o $@ $^
157165

158166
# Build tinygo C sources.

0 commit comments

Comments
 (0)