Skip to content

Commit 32ab2a1

Browse files
committed
build: add install target for linux systems
Signed-off-by: leongross <leon.gross@9elements.com>
1 parent 1fd75ff commit 32ab2a1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

GNUmakefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# aliases
33
all: tinygo
44

5+
#SHELL := /usr/bin/env bash
6+
57
# Default build and source directories, as created by `make llvm-build`.
68
LLVM_BUILDDIR ?= llvm-build
79
LLVM_PROJECTDIR ?= llvm-project
@@ -36,6 +38,10 @@ GOTESTPKGS ?= ./builder ./cgo ./compileopts ./compiler ./interp ./transform .
3638
# tinygo binary for tests
3739
TINYGO ?= $(call detect,tinygo,tinygo $(CURDIR)/build/tinygo)
3840

41+
# isntalltion location defaults
42+
INSTALL_LOCAL_DIR ?= $(HOME)/go/bin/
43+
INSTALL_SYSTEM_DIR ?= /usr/bin/
44+
3945
# Check for ccache if the user hasn't set it to on or off.
4046
ifeq (, $(CCACHE))
4147
# Use CCACHE for LLVM if possible
@@ -972,3 +978,16 @@ lint:
972978
spell:
973979
# Check for typos in comments. Skip git submodules etc.
974980
go run github.com/client9/misspell/cmd/misspell -i 'ackward,devided,extint,inbetween,programmmer,rela' $$( find . -depth 1 -type d | egrep -w -v 'lib|llvm|src/net' )
981+
982+
install: tinygo build/tinygo$(EXE)
983+
ifeq ($(OS),Windows_NT)
984+
$(error Windows install not supported)
985+
exit 1
986+
else
987+
ifeq ($(INSTALL_LOCAL),)
988+
@if [ -d $(INSTALL_SYSTEM_DIR) ]; then cp build/tinygo $(INSTALL_SYSTEM_DIR); else echo "unable to find local installation directory $(INSTALL_SYSTEM_DIR). Specify custom directory by setting 'INSTALL_SYSTEM_DIR'"; exit 1; fi
989+
else
990+
@if [ -d $(INSTALL_LOCAL_DIR) ]; then cp build/tinygo $(INSTALL_LOCAL_DIR); else echo "unable to find local installation directory $(INSTALL_LOCAL_DIR). Specify custom directory by setting 'INSTALL_LOCAL_DIR'"; exit 1; fi
991+
endif
992+
endif
993+

0 commit comments

Comments
 (0)