forked from reshadi/jakets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
142 lines (110 loc) · 4.04 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
ifndef JAKETS__INCLUDE_BARRIER_
JAKETS__INCLUDE_BARRIER_ = 1
# The following code will be use in almost all of the project makefiles
# before we include any new makefile, the current makefile will be the last
# item in the MAKEFILE_LIST variable. However, the $(dir ) function always
# adds / at the end of the result.
# to make the usage of this variable mroe readable and elegant, we add
# and extra / at the end to differentiate it from / in the middle of the path
# thre relpace // with nothing.
JAKETS__DIR := $(subst //,,$(dir $(lastword $(MAKEFILE_LIST)))/)
EXPECTED_NODE_VERSION=v5.8.0
###################################################################################################
# setup platform dependent variables
#
SHELL := /bin/bash
UNAME := $(shell uname)
PLATFORM := linux-x64
ifeq ($(UNAME), Linux)
NULL = /dev/null
else ifeq ($(UNAME), Darwin)
NULL = /dev/null
PLATFORM = darwin-x64
else
# ifeq($(UNAME), MINGW32_NT-6.2)
NULL = Out-Null
endif
#
###################################################################################################
NODE := node
NPM := npm
NODE_MODULES__DIR=$(JAKETS__DIR)/node_modules
NODE__DIR =
NODE__BIN =
NODE_VERSION = $(shell $(NODE) --version 2>$(NULL))
ifneq "$(NODE_VERSION)" "$(EXPECTED_NODE_VERSION)"
NODE_VERSION = $(EXPECTED_NODE_VERSION)
NODE__DIR = $(NODE_MODULES__DIR)/nodejs
# NODE__DIR = $(NODE_MODULES__DIR)/node-$(NODE_VERSION)
NODE__BIN_DIR = $(NODE__DIR)/bin
NODE__BIN = $(NODE__BIN_DIR)/$(NODE)
NODE__DIST_NAME = node-$(NODE_VERSION)-$(PLATFORM).tar.gz
export PATH := $(PWD)/$(NODE__BIN_DIR):$(PATH)
endif
JAKE = $(NODE_MODULES__DIR)/.bin/jake
#One can use the following local file to overwrite the above settings
-include LocalPaths.mk
###################################################################################################
# setup and rules in the current working directory
#
# default: run_jake
jts_run_jake: jts_compile_jake
$(JAKE)
j-%: jts_compile_jake
$(JAKE) $*
#The following is auto generated to make sure local Jakefile.ts dependencies are captured properly
-include Jakefile.mk
$(JAKE_TASKS):%: j-%
jts_compile_jake: jts_setup
#
###################################################################################################
###################################################################################################
# setup in jakets directory
#
jts_setup: $(JAKE)
$(JAKE) --jakefile $(JAKETS__DIR)/Jakefile.js jts:setup
$(JAKE) jts:generate_dependencies
$(JAKE): $(NODE__BIN)
cd $(JAKETS__DIR) && \
$(NPM) install jake shelljs && \
touch $@
_jts_get_node: $(NODE__BIN)
$(NODE__BIN): $(NODE__DIR)/$(NODE__DIST_NAME)
cd $(NODE__DIR) && \
tar xvf * --strip-components=1
touch $@
$(NODE__DIR)/$(NODE__DIST_NAME): $(JAKETS__DIR)/Makefile
rm -rf $(NODE__DIR)
mkdir -p $(NODE__DIR)
wget --directory-prefix=$(NODE__DIR) https://nodejs.org/dist/$(NODE_VERSION)/$(NODE__DIST_NAME)
touch $@
#
###################################################################################################
###################################################################################################
# Rules for debugging/validation
#
# Each makefile that wants to show the variables of the makefile can do the following
# Create a phony target that depends on the print-% where % is replaced by the name of variables
# Example:
.PHONY: show_vars
show_vars: $(patsubst %,print-%, \
JAKETS__DIR \
NODE__DIR \
NODE__BIN \
NODE_VERSION \
NODE__DIST_NAME \
NODE \
NPM \
TSC \
TSD \
JAKE \
BOWER \
PATH \
)
@echo ----------------------------------------------------------------^^^jakets^^^
print-%:
$(info ----------------------------------------------------------------)
$(info $* = $($*))
#
###################################################################################################
endif