@@ -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
1717CFLAGS = $(FLAGS )
1818GOFLAGS = $(FLAGS ) -fno-split-stack
@@ -49,9 +49,12 @@ run: all
4949# Find all the dependencies of the main package.
5050PKGDEPS = $(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.
5760DIRS = \
@@ -111,7 +114,7 @@ SRC_C_TINYGO = \
111114# built all at once, or there will be undefined variables and such.
112115SRC_GO_RUNTIME += \
113116src/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)
129132OBJ += $(addprefix $(BUILD ) /tinygo/,$(SRC_C_TINYGO:.c=.o ) )
130133OBJ += $(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.
133141mkdir :
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
156164gcc $(CFLAGS ) -std=gnu99 -c -o $@ $^
157165
158166# Build tinygo C sources.
0 commit comments