1425bb815Sopenharmony_ci# Copyright JS Foundation and other contributors, http://js.foundation
2425bb815Sopenharmony_ci#
3425bb815Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
4425bb815Sopenharmony_ci# you may not use this file except in compliance with the License.
5425bb815Sopenharmony_ci# You may obtain a copy of the License at
6425bb815Sopenharmony_ci#
7425bb815Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
8425bb815Sopenharmony_ci#
9425bb815Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
10425bb815Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS
11425bb815Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12425bb815Sopenharmony_ci# See the License for the specific language governing permissions and
13425bb815Sopenharmony_ci# limitations under the License.
14425bb815Sopenharmony_ci
15425bb815Sopenharmony_ci# Build and output directories
16425bb815Sopenharmony_ciBUILD_DIR  ?= build/riotstm32f4
17425bb815Sopenharmony_ciCOPYTARGET ?= targets/riot-stm32f4/bin
18425bb815Sopenharmony_ci
19425bb815Sopenharmony_ci# JerryScript configuration
20425bb815Sopenharmony_ciJERRYHEAP  ?= 16
21425bb815Sopenharmony_ci
22425bb815Sopenharmony_ci# To be defined on the command line of make if Clang is available via a
23425bb815Sopenharmony_ci# different name (e.g., clang-N.M)
24425bb815Sopenharmony_ciCC ?= clang
25425bb815Sopenharmony_ci
26425bb815Sopenharmony_ci# Cross-compilation settings for Clang
27425bb815Sopenharmony_ciEXT_CFLAGS := -target arm-none-eabi
28425bb815Sopenharmony_ciEXT_CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4
29425bb815Sopenharmony_ciEXT_CFLAGS += -isystem /usr/arm-none-eabi/include
30425bb815Sopenharmony_ciEXT_CFLAGS += $(addprefix -isystem $(lastword $(sort $(wildcard /usr/lib/gcc/arm-none-eabi/*/))), include include-fixed)
31425bb815Sopenharmony_ciEXT_CFLAGS += -nostdinc
32425bb815Sopenharmony_ci
33425bb815Sopenharmony_ci# For ABI compatibility with RIOT-OS
34425bb815Sopenharmony_ciEXT_CFLAGS += -fshort-enums
35425bb815Sopenharmony_ci
36425bb815Sopenharmony_ci
37425bb815Sopenharmony_ci.PHONY: libjerry riot-jerry flash clean
38425bb815Sopenharmony_ci
39425bb815Sopenharmony_ciall: libjerry riot-jerry
40425bb815Sopenharmony_ci
41425bb815Sopenharmony_cilibjerry:
42425bb815Sopenharmony_ci	mkdir -p $(BUILD_DIR)
43425bb815Sopenharmony_ci	cmake -B$(BUILD_DIR) -H./ \
44425bb815Sopenharmony_ci	 -DCMAKE_SYSTEM_NAME=RIOT \
45425bb815Sopenharmony_ci	 -DCMAKE_SYSTEM_PROCESSOR=armv7l \
46425bb815Sopenharmony_ci	 -DCMAKE_C_COMPILER=$(CC) \
47425bb815Sopenharmony_ci	 -DCMAKE_C_COMPILER_WORKS=TRUE \
48425bb815Sopenharmony_ci	 -DENABLE_LTO=OFF \
49425bb815Sopenharmony_ci	 -DENABLE_ALL_IN_ONE=OFF \
50425bb815Sopenharmony_ci	 -DJERRY_LIBM=OFF \
51425bb815Sopenharmony_ci	 -DJERRY_CMDLINE=OFF \
52425bb815Sopenharmony_ci	 -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
53425bb815Sopenharmony_ci	 -DJERRY_GLOBAL_HEAP_SIZE=$(JERRYHEAP)
54425bb815Sopenharmony_ci	make -C$(BUILD_DIR) jerry-core jerry-port-default-minimal jerry-ext
55425bb815Sopenharmony_ci
56425bb815Sopenharmony_ci	mkdir -p $(COPYTARGET)
57425bb815Sopenharmony_ci	cp $(BUILD_DIR)/lib/libjerry-core.a $(COPYTARGET)
58425bb815Sopenharmony_ci	cp $(BUILD_DIR)/lib/libjerry-port-default-minimal.a $(COPYTARGET)
59425bb815Sopenharmony_ci	cp $(BUILD_DIR)/lib/libjerry-ext.a $(COPYTARGET)
60425bb815Sopenharmony_ci
61425bb815Sopenharmony_ciriot-jerry: libjerry
62425bb815Sopenharmony_ci	make -f ./targets/riot-stm32f4/Makefile
63425bb815Sopenharmony_ci
64425bb815Sopenharmony_ciflash: libjerry
65425bb815Sopenharmony_ci	make -f ./targets/riot-stm32f4/Makefile flash
66425bb815Sopenharmony_ci
67425bb815Sopenharmony_ciclean:
68425bb815Sopenharmony_ci	rm -rf $(COPYTARGET)
69425bb815Sopenharmony_ci	rm -rf $(BUILD_DIR)
70425bb815Sopenharmony_ci	make -f ./targets/riot-stm32f4/Makefile clean
71