-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathMakefile.hostTools
166 lines (144 loc) · 5.92 KB
/
Makefile.hostTools
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# --------------------------------------------------------------------------------------------------
# Makefile used to build the Legato framework development host tools.
#
# Tools build output is placed under $(LEGATO_ROOT)/build/tools
#
# The tools get installed in $(LEGATO_ROOT)/bin
#
# This Makefile is intended to run as part of a larger build system.
#
# Copyright (C) Sierra Wireless Inc.
# --------------------------------------------------------------------------------------------------
include utils.mk
export LEGATO_ROOT ?= $(CURDIR)
export BUILD_DIR := $(LEGATO_ROOT)/build/tools
KCONFIG_BUILD_DIR := $(LEGATO_ROOT)/build/tools/kconfig-frontends
export INSTALL_DIR := $(LEGATO_ROOT)/bin
NINJA_SCRIPT := $(BUILD_DIR)/build.ninja
NINJA_FLAGS =
# Add the framework's bin directory to the PATH environment variable.
export PATH := $(PATH):$(INSTALL_DIR)
# Tools architecture should generally match host's
export HOST_ARCH ?= $(shell uname -m)
export TOOLS_ARCH ?= $(HOST_ARCH)
export HOST_SYS ?= ${HOST_ARCH}-linux
# Scripts that are used during the Legato build process
SCRIPTS := $(wildcard $(LEGATO_ROOT)/framework/tools/scripts/*)
# NOTE: Ninja is used to build the mk tools.
.PHONY: tools
# Use HOST_CC and HOST_CXX when building the tools.
# Language server is temporarily disabled due to instability in npm. FARM-2822
tools: export CC := $(HOST_CC)
tools: export CXX := $(HOST_CXX)
tools: ninja $(NINJA_SCRIPT) symlinks mkPatch # languageServer
$(L) NINJA $(NINJA_SCRIPT)
$(Q)ninja $(NINJA_FLAGS) -f $(NINJA_SCRIPT)
.PHONY: tool-messages
tool-messages: ninja $(NINJA_SCRIPT)
$(L) NINJA $(NINJA_SCRIPT)
$(Q)ninja $(NINJA_FLAGS) -f $(NINJA_SCRIPT) messages
# Generate the ninja build script.
$(NINJA_SCRIPT): framework/tools/ninja-generator $(BUILD_DIR)
$(L) GEN $@
$(Q)framework/tools/ninja-generator
# ninja is called ninja-build on some distros (e.g., Fedora). Make sure ninja appears in the
# path as "ninja" by adding a symlink to the framework's bin directory if necessary.
.PHONY: ninja
ninja: $(INSTALL_DIR)
@echo -n "Using ninja installed at: " ;\
if ! which ninja ;\
then \
if which ninja-build ;\
then \
ln -s `which ninja-build` $(INSTALL_DIR)/ninja ;\
else \
echo "***ERROR: Ninja build tool not found." 1>&2 ;\
exit 1;\
fi;\
fi
# Create a bunch of symlinks from the install directory to the tools.
.PHONY: symlinks
symlinks: $(INSTALL_DIR)
$(Q)ln -sfr $(BUILD_DIR)/bin/mk $(INSTALL_DIR)/mk
$(Q)ln -sf mk $(INSTALL_DIR)/mkcomp
$(Q)ln -sf mk $(INSTALL_DIR)/mkexe
$(Q)ln -sf mk $(INSTALL_DIR)/mkapp
$(Q)ln -sf mk $(INSTALL_DIR)/mksys
$(Q)ln -sf mk $(INSTALL_DIR)/mkparse
$(Q)ln -sf mk $(INSTALL_DIR)/mkedit
$(Q)ln -sfr $(foreach script,$(SCRIPTS),$(script)) $(INSTALL_DIR)/
$(Q)ln -sfr $(LEGATO_ROOT)/framework/tools/ifgen/ifgen $(INSTALL_DIR)/
$(Q)ln -sfr $(LEGATO_ROOT)/3rdParty/ima-support-tools/ima-sign.sh $(INSTALL_DIR)/
$(Q)ln -sfr $(LEGATO_ROOT)/3rdParty/ima-support-tools/ima-gen-keys.sh $(INSTALL_DIR)/
# Get the paths of the node.js runtime and the TypeScript compiler.
NPM_PATH := $(shell which npm)
TSC_PATH := $(shell which tsc)
LANG_SERV_PATH = "$(LEGATO_ROOT)/framework/tools/mkTools/legatoLangServ"
.PHONY: languageServer
languageServer: $(INSTALL_DIR)
$(L) NPM $@
@# Check to see if node.js is installed, and if so, fetch the language server's dependencies.
$(Q)if [ ! -z "$(NPM_PATH)" ] ; \
then \
cd "$(LANG_SERV_PATH)" ; \
if [ -d "./node_modules" ] ; \
then \
npm update ; \
else \
npm install ; \
fi ; \
$(LANG_SERV_PATH)/node_modules/.bin/tsc -p "$(LANG_SERV_PATH)/tsconfig.json" \
--outDir "$(INSTALL_DIR)/languageServer" && \
cp -f "$(LEGATO_ROOT)/framework/tools/mkTools/legatoLangServ/package.json" "$(INSTALL_DIR)/languageServer/package.json" && \
cp -TR "$(LEGATO_ROOT)/framework/tools/mkTools/legatoLangServ/node_modules" "$(INSTALL_DIR)/languageServer/node_modules" ; \
fi
# Rule for creating directories.
$(BUILD_DIR) $(INSTALL_DIR):
$(Q)mkdir -p $@
.PHONY: mkPatch
mkPatch: $(BUILD_DIR) $(INSTALL_DIR)
$(L) MAKE $@
$(Q)$(MAKE) -C framework/tools/mkPatch
.PHONY: kconfig-frontends
# Use HOST_CC and HOST_CXX when building the kconfig-frontends.
kconfig-frontends: export CC := $(HOST_CC)
kconfig-frontends: export CXX := $(HOST_CXX)
kconfig-frontends: export AS :=
kconfig-frontends: export LD :=
kconfig-frontends: export STRIP :=
kconfig-frontends: export RANLIB :=
kconfig-frontends: export OBJCOPY :=
kconfig-frontends: export OBJDUMP :=
kconfig-frontends: export AR :=
kconfig-frontends: export NM :=
kconfig-frontends: $(INSTALL_DIR) $(KCONFIG_BUILD_DIR)/config.status
$(L) MAKE $@
$(Q)cd $(KCONFIG_BUILD_DIR) && make
$(L) INSTALL $@
$(Q)cd $(KCONFIG_BUILD_DIR) && make install $(VOUTPUT)
$(Q)ln -sfr $(BUILD_DIR)/bin/kconfig-conf $(INSTALL_DIR)/kconfig-conf
$(Q)ln -sfr $(BUILD_DIR)/bin/kconfig-mconf $(INSTALL_DIR)/kconfig-mconf
$(Q)ln -sfr $(BUILD_DIR)/bin/kconfig-nconf $(INSTALL_DIR)/kconfig-nconf
$(Q)ln -sfr $(BUILD_DIR)/bin/kconfig-tweak $(INSTALL_DIR)/kconfig-tweak
$(Q)ln -sfr $(BUILD_DIR)/bin/kconfig $(INSTALL_DIR)/kconfig
kconfig-set-value: $(INSTALL_DIR) $(LEGATO_ROOT)/framework/tools/scripts/kconfig-set-value
$(Q)ln -sfr $(LEGATO_ROOT)/framework/tools/scripts/kconfig-set-value \
$(INSTALL_DIR)/kconfig-set-value
$(KCONFIG_BUILD_DIR)/config.status: $(KCONFIG_BUILD_DIR)/configure
$(L) CONFIG kconfig-frontends
$(Q)mkdir -p $(KCONFIG_BUILD_DIR)
$(Q)cd $(KCONFIG_BUILD_DIR) && $(LEGATO_ROOT)/3rdParty/kconfig-frontends/configure \
--host=${HOST_SYS} \
--prefix=$(BUILD_DIR) \
--enable-mconf \
--enable-conf \
--enable-nconf \
--enable-utils $(VOUTPUT)
$(KCONFIG_BUILD_DIR)/configure.ac:
$(L) COPY kconfig-frontends
$(Q)rm -rf $(KCONFIG_BUILD_DIR)
$(Q)mkdir -p $(KCONFIG_BUILD_DIR)
$(Q)cp -R $(LEGATO_ROOT)/3rdParty/kconfig-frontends $(KCONFIG_BUILD_DIR)
$(KCONFIG_BUILD_DIR)/configure: $(KCONFIG_BUILD_DIR)/configure.ac
$(L) RECONF kconfig-frontends
$(Q)cd $(LEGATO_ROOT)/3rdParty/kconfig-frontends && autoreconf -fi $(VOUTPUT)