Commit 93543941 authored by Alexander F Rødseth's avatar Alexander F Rødseth Committed by Dylan Trotter

Add support for make install (#154)

parent 2dc8f1f4
......@@ -32,12 +32,14 @@ ifeq ($(PYTHON),)
endif
PYTHON_BIN := $(shell which $(PYTHON))
PYTHON_VER := $(word 2,$(shell $(PYTHON) -V 2>&1))
PY_DIR := build/lib/python2.7/site-packages
ifeq ($(filter 2.7.%,$(PYTHON_VER)),)
$(error unsupported Python version $(PYTHON_VER), Grumpy only supports 2.7.x. To use a different python binary such as python2, run: 'make PYTHON=python2 ...')
endif
PY_DIR := build/lib/python2.7/site-packages
PY_INSTALL_DIR := $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
export GOPATH := $(ROOT_DIR)/build
export PYTHONPATH := $(ROOT_DIR)/$(PY_DIR)
export PATH := $(ROOT_DIR)/build/bin:$(PATH)
......@@ -97,7 +99,7 @@ test: $(ACCEPT_PASS_FILES) $(ACCEPT_PY_PASS_FILES) $(COMPILER_PASS_FILES) $(COMP
precommit: cover gofmt lint test
.PHONY: all benchmarks clean cover gofmt golint lint precommit pylint run test
.PHONY: all benchmarks clean cover gofmt golint install lint precommit pylint run test
# ------------------------------------------------------------------------------
# grumpc compiler
......@@ -244,3 +246,18 @@ $(patsubst %,build/%.go,$(BENCHMARKS)): build/%.go: %.py $(COMPILER)
$(BENCHMARK_BINS): build/benchmarks/%_benchmark: build/benchmarks/%.go $(RUNTIME) $(STDLIB)
@mkdir -p $(@D)
@go build -o $@ $<
# ------------------------------------------------------------------------------
# Installation
# ------------------------------------------------------------------------------
install: $(RUNNER_BIN) $(COMPILER) $(RUNTIME) $(STDLIB)
# Binary executables
install -Dm755 build/bin/grumpc "$(DESTDIR)/usr/bin/grumpc"
install -Dm755 build/bin/grumprun "$(DESTDIR)/usr/bin/grumprun"
# Python module
install -d "$(DESTDIR)"{/usr/lib/go,"$(PY_INSTALL_DIR)"}
cp -rv --no-preserve=ownership "$(PY_DIR)/grumpy" "$(DESTDIR)$(PY_INSTALL_DIR)"
# Go package and sources
cp -rv --no-preserve=ownership build/pkg build/src "$(DESTDIR)/usr/lib/go/"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment