-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
81 lines (65 loc) · 2.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.DEFAULT_GOAL := help
.PHONY: configure build-libc build-swig develop build-libc-swig build
.PHONY: test test-ci help
# Compilation output
.ONESHELL:
SHELL := /bin/bash
MKFILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST)))
REPO_ROOT = $(dir $(MKFILE_PATH))
GOPATH_DIR = gopath
SKYLIBC_DIR ?= $(GOPATH_DIR)/src/github.com/skycoin/libskycoin
SKYCOIN_DIR ?= $(SKYLIBC_DIR)/vendor/github.com/skycoin/skycoin
SKYBUILD_DIR = $(SKYLIBC_DIR)/build
BUILDLIBC_DIR = $(SKYBUILD_DIR)/libskycoin
LIBC_DIR = $(SKYLIBC_DIR)/lib/cgo
LIBSWIG_DIR = lib/skycoin/ext
BUILD_DIR = build
BIN_DIR = $(SKYLIBC_DIR)/bin
INCLUDE_DIR = $(SKYLIBC_DIR)/include
FULL_PATH_LIB = $(REPO_ROOT)/$(BUILDLIBC_DIR)
LIB_FILES = $(shell find $(SKYLIBC_DIR)/lib/cgo -type f -name "*.go")
SRC_FILES = $(shell find $(SKYCOIN_DIR)/src -type f -name "*.go")
SWIG_FILES = $(shell find $(LIBSWIG_DIR) -type f -name "*.i")
HEADER_FILES = $(shell find $(INCLUDE_DIR) -type f -name "*.h")
RUBY_CLIENT_DIR = lib/skyapi
ifeq ($(shell uname -s),Linux)
TEMP_DIR = tmp
else ifeq ($(shell uname -s),Darwin)
TEMP_DIR = $TMPDIR
endif
configure: ## Configure build environment
mkdir -p $(BUILD_DIR)/usr/tmp $(BUILD_DIR)/usr/lib $(BUILD_DIR)/usr/include
mkdir -p $(BUILDLIBC_DIR) $(BIN_DIR) $(INCLUDE_DIR)
build-libc: configure ## Build libskycoin C client library
GOPATH="$(REPO_ROOT)/$(GOPATH_DIR)" make -C $(SKYLIBC_DIR) clean-libc
GOPATH="$(REPO_ROOT)/$(GOPATH_DIR)" make -C $(SKYLIBC_DIR) build-libc
rm -f $(LIBSWIG_DIR)/libskycoin.h
rm -f $(LIBSWIG_DIR)/swig.h
cp -f $(SKYLIBC_DIR)/include/swig.h $(LIBSWIG_DIR)
grep -v _Complex $(SKYLIBC_DIR)/include/libskycoin.h > $(LIBSWIG_DIR)/libskycoin.h
build-swig: ## Generate Ruby C module from SWIG interfaces
#Generate structs.i from skytypes.gen.h
rm -f $(LIBSWIG_DIR)/structs.i
cp $(INCLUDE_DIR)/skytypes.gen.h $(LIBSWIG_DIR)/structs.i
{ \
if [[ "$$(uname -s)" == "Darwin" ]]; then \
sed -i '.kbk' 's/#/%/g' $(LIBSWIG_DIR)/structs.i ;\
else \
sed -i 's/#/%/g' $(LIBSWIG_DIR)/structs.i ;\
fi \
}
rm -f ext/libskycoin_ruby_wrap.c
swig -ruby -autorename -globalmodule -w501,505,401,302,509,451 -I$(LIBSWIG_DIR)/include -I$(INCLUDE_DIR) -outdir $(LIBSWIG_DIR) $(LIBSWIG_DIR)/libskycoin_ruby.i
build-libc-swig: build-libc build-swig
build: build-libc-swig ## Build Libruby package
cd $(LIBSWIG_DIR) && ruby extconf.rb
test-ci: build-libc build-swig ## Run tests on (Travis) CI build
test: build-libc build-swig develop ## Run project test suite
clean: #Clean all
make -C $(SKYLIBC_DIR) clean-libc
find . -path "*.gem" -delete
package: ## Build skyapi and skycoin gems
(cd ./lib/skyapi && gem build sky_api.gemspec)
(cd ./lib/skycoin && gem build skycoin.gemspec)
help: ## List available commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'