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_ciPARTICLE_FIRMWARE := $(CURDIR)/../particle/firmware
16425bb815Sopenharmony_ci
17425bb815Sopenharmony_ciJERRYDIR ?= $(CURDIR)
18425bb815Sopenharmony_ciJERRYHEAP  ?= 16
19425bb815Sopenharmony_ci
20425bb815Sopenharmony_ciBUILD_DIR  ?= $(JERRYDIR)/build/particle
21425bb815Sopenharmony_ci
22425bb815Sopenharmony_ciEXT_CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4
23425bb815Sopenharmony_ciEXT_CFLAGS += -Wno-error=format=
24425bb815Sopenharmony_ci
25425bb815Sopenharmony_ci.PHONY: jerrycore jerry-main flash clean
26425bb815Sopenharmony_ci
27425bb815Sopenharmony_ciPARTICLE_BUILD_CONFIG = \
28425bb815Sopenharmony_ci	 INCLUDE_DIRS=$(JERRYDIR)/jerry-core/include \
29425bb815Sopenharmony_ci	 LIBS=jerry-core \
30425bb815Sopenharmony_ci	 PLATFORM=photon \
31425bb815Sopenharmony_ci	 LIB_DIRS=$(BUILD_DIR)/lib \
32425bb815Sopenharmony_ci	 APPDIR=$(JERRYDIR)/targets/particle/source \
33425bb815Sopenharmony_ci	 TARGET_FILE=jerry_main \
34425bb815Sopenharmony_ci	 TARGET_DIR=$(BUILD_DIR) \
35425bb815Sopenharmony_ci	 LDFLAGS=--specs=nano.specs
36425bb815Sopenharmony_ci
37425bb815Sopenharmony_ciall: jerrycore jerry-main
38425bb815Sopenharmony_ci
39425bb815Sopenharmony_cijerrycore:
40425bb815Sopenharmony_ci	mkdir -p $(BUILD_DIR)
41425bb815Sopenharmony_ci	cmake -B$(BUILD_DIR) -H./ \
42425bb815Sopenharmony_ci	 -DCMAKE_SYSTEM_NAME=MCU \
43425bb815Sopenharmony_ci	 -DCMAKE_SYSTEM_PROCESSOR=armv7l \
44425bb815Sopenharmony_ci	 -DCMAKE_C_COMPILER=arm-none-eabi-gcc \
45425bb815Sopenharmony_ci	 -DCMAKE_C_COMPILER_WORKS=TRUE \
46425bb815Sopenharmony_ci	 -DENABLE_LTO=ON \
47425bb815Sopenharmony_ci	 -DENABLE_ALL_IN_ONE=OFF \
48425bb815Sopenharmony_ci	 -DJERRY_LIBM=OFF \
49425bb815Sopenharmony_ci	 -DJERRY_CMDLINE=OFF \
50425bb815Sopenharmony_ci	 -DJERRY_PROFILE=minimal \
51425bb815Sopenharmony_ci	 -DENABLE_STRIP=OFF \
52425bb815Sopenharmony_ci	 -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
53425bb815Sopenharmony_ci	 -DJERRY_GLOBAL_HEAP_SIZE=$(JERRYHEAP)
54425bb815Sopenharmony_ci
55425bb815Sopenharmony_ci	make -C$(BUILD_DIR) jerry-core
56425bb815Sopenharmony_ci
57425bb815Sopenharmony_cijerry-main: jerrycore
58425bb815Sopenharmony_ci	$(PARTICLE_BUILD_CONFIG) make -C$(PARTICLE_FIRMWARE) -f $(PARTICLE_FIRMWARE)/makefile
59425bb815Sopenharmony_ci
60425bb815Sopenharmony_ciflash:
61425bb815Sopenharmony_ci	$(PARTICLE_BUILD_CONFIG) make -C$(PARTICLE_FIRMWARE)/main -f $(PARTICLE_FIRMWARE)/main/makefile program-dfu
62425bb815Sopenharmony_ci
63425bb815Sopenharmony_ciclean:
64425bb815Sopenharmony_ci	$(PARTICLE_BUILD_CONFIG) make -C$(PARTICLE_FIRMWARE) -f $(PARTICLE_FIRMWARE)/makefile clean
65425bb815Sopenharmony_ci	rm -rf $(BUILD_DIR)
66