4091444016
- Add preliminary support for ARC architecture. Using "em_starterkit" board supported by Zephyr. Only build for this board is tested, not booted on a real device due to lack of access. There's no QEMU emulation support for ARC in Zephyr (yet) either. - Update README to cover different Zephyr architectures/boards. - Changed the arduino_101 paths to something more generic and adaptable - Made sure it compiles and runs on Arduino 101 JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
196 lines
5.9 KiB
Makefile
Executable File
196 lines
5.9 KiB
Makefile
Executable File
# Copyright © 2016 Intel Corporation
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
ifeq ($(.DEFAULT_GOAL),)
|
|
$(warning no default goal is set)
|
|
endif
|
|
|
|
ifeq ($(MAKECMDGOALS),qemu)
|
|
BOARD ?= qemu_x86
|
|
else
|
|
BOARD ?= arduino_101
|
|
BOARD_NAME ?= arduino_101
|
|
endif
|
|
|
|
ifeq ($(BOARD),qemu_x86)
|
|
BOARD_NAME ?= qemu_x86
|
|
endif
|
|
|
|
TARGET_ZEPHYR ?= ./targets/zephyr
|
|
SOURCE_DIR = $(TARGET_ZEPHYR)/src
|
|
|
|
TYPE ?= release
|
|
JERRYHEAP ?= 16
|
|
|
|
# Include functionality like regular expressions
|
|
# check Jerry script documentation
|
|
#
|
|
# -cp
|
|
# -cp_minimal
|
|
# -cp_minimal-mem_stats
|
|
# -mem_stats
|
|
# -mem_stress_test
|
|
|
|
ifndef ZEPHYR_BASE
|
|
$(error Missing Zephyr base, did you source zephyr-env.sh? )
|
|
endif
|
|
|
|
VARIETY ?= -cp_minimal
|
|
|
|
INTERM = build/$(BOARD)/obj-$(BOARD)
|
|
OUTPUT = build/$(BOARD)
|
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
EXT_CFLAGS := -fno-asynchronous-unwind-tables -fno-omit-frame-pointer
|
|
EXT_CFLAGS += -fno-stack-protector -fno-strict-overflow -ffreestanding
|
|
EXT_CFLAGS += -fno-reorder-functions -fno-defer-pop -fdata-sections
|
|
EXT_CFLAGS += -ffunction-sections -fno-inline-functions
|
|
|
|
# TODO @sergioamr Read the arch and cflags from zephyr
|
|
|
|
ifeq ($(BOARD),qemu_x86)
|
|
CONFIG_TOOLCHAIN_VARIANT = x86
|
|
CPU = x86
|
|
EXT_CFLAGS += -march=pentium
|
|
EXT_CFLAGS += -mpreferred-stack-boundary=2 -mno-sse
|
|
else ifeq ($(BOARD),qemu_cortex_m3)
|
|
CONFIG_TOOLCHAIN_VARIANT = arm
|
|
CPU = arm7-m
|
|
EXT_CFLAGS += -march=armv7-m -mthumb -mcpu=cortex-m3 -mabi=aapcs
|
|
else ifeq ($(BOARD),em_starterkit)
|
|
# TODO: Tested only to build, untested to boot
|
|
CONFIG_TOOLCHAIN_VARIANT = arc
|
|
CPU = arc
|
|
EXT_CFLAGS += -mARCv2EM -mav2em -mno-sdata
|
|
else
|
|
CONFIG_TOOLCHAIN_VARIANT = iamcu
|
|
CPU = lakemont
|
|
EXT_CFLAGS += -march=lakemont -mtune=lakemont -miamcu -msoft-float
|
|
EXT_CFLAGS += -mpreferred-stack-boundary=2 -mno-sse
|
|
endif
|
|
|
|
EXT_CFLAGS += -Wall -Wno-format-zero-length -Wno-pointer-sign
|
|
EXT_CFLAGS += -Werror=format -Werror=implicit-int -Wno-unused-but-set-variable
|
|
EXT_CFLAGS += -Wno-main -Wno-strict-aliasing
|
|
EXT_CFLAGS += -Wno-error=format=
|
|
|
|
EXT_CFLAGS += $(TOOLCHAIN_CFLAGS)
|
|
EXT_CFLAGS += $(LIB_INCLUDE_DIR)
|
|
EXT_CFLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
|
|
EXT_CFLAGS += -isystem $(shell $(CC) -print-file-name=include-fixed)
|
|
|
|
-include $(ZEPHYR_BASE)/boards/$(BOARD_NAME)/Makefile.board
|
|
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
|
|
|
|
ZEPHYR_LIBC_INC = $(subst -I,,$(TOOLCHAIN_CFLAGS))
|
|
LIB_INCLUDE_DIR += -L $(CURDIR)/$(OUTPUT)
|
|
|
|
EXTERNAL_LIB = $(INTERM)/lib$(TYPE).external$(VARIETY)-entry.a
|
|
ZEPHYR_BIN = $(OUTPUT)/zephyr/zephyr.strip
|
|
|
|
PREFIX = $(TYPE)$(VARIETY)
|
|
LIBS = $(TYPE).external$(VARIETY)-entry $(PREFIX).jerry-core $(PREFIX).jerry-libm.lib
|
|
|
|
BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(OUTPUT)" TARGET_ZEPHYR=$(TARGET_ZEPHYR)
|
|
|
|
.PHONY: all
|
|
all: jerry zephyr
|
|
|
|
$(EXTERNAL_LIB):
|
|
ifdef V
|
|
@echo "- JERRY SCRIPT -------------------------------------------------"
|
|
endif
|
|
mkdir -p $(INTERM)
|
|
mkdir -p $(OUTPUT)
|
|
cmake -B$(INTERM) -H./ \
|
|
-DENABLE_LTO=OFF \
|
|
-DENABLE_VALGRIND=OFF \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_VERBOSE_MAKEFILE=$(V) \
|
|
-DEXTERNAL_CMAKE_C_COMPILER=$(CC) \
|
|
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
|
|
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=$(CPU) \
|
|
-DEXTERNAL_MEM_HEAP_SIZE_KB=$(JERRYHEAP) \
|
|
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
|
|
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=lakemont \
|
|
-DEXTERNAL_LIBC_INTERFACE="$(ZEPHYR_LIBC_INC)" \
|
|
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
|
|
-DEXTERNAL_BUILD_ENTRY_FILE=$(SOURCE_DIR)/jerry-entry.c
|
|
|
|
make -C $(INTERM) $(TYPE).external$(VARIETY) V=1
|
|
cp `cat $(INTERM)/$(TYPE).external$(VARIETY)/list` $(OUTPUT)/.
|
|
cp $(EXTERNAL_LIB) $(OUTPUT)/.
|
|
|
|
$(ZEPHYR_BIN):
|
|
ifdef V
|
|
@echo "- ZEPHYR -------------------------------------------------------"
|
|
endif
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG)
|
|
@echo "Finished"
|
|
@file $(OUTPUT)/zephyr/zephyr.strip
|
|
@size $(OUTPUT)/zephyr/zephyr.strip
|
|
|
|
jerry: $(EXTERNAL_LIB)
|
|
@touch $(EXTERNAL_LIB)
|
|
|
|
zephyr: $(EXTERNAL_LIB) $(ZEPHYR_BIN)
|
|
@touch $(ZEPHYR_BIN)
|
|
|
|
qemu: $(EXTERNAL_LIB) $(ZEPHYR_BIN)
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) qemu
|
|
|
|
flash: $(EXTERNAL_LIB) $(OUTPUT)/zephyr/zephyr.strip
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) flash
|
|
|
|
usage:
|
|
help:
|
|
@echo Usage:
|
|
@echo showconfig Show parameters and configuration
|
|
@echo flash Flash into board
|
|
@echo all Compile jerryscript and zephyr
|
|
|
|
showconfig:
|
|
@echo "- CONFIGURATION ------------------------------------------------"
|
|
@echo "INTERM = $(INTERM)"
|
|
@echo "OUTPUT = $(OUTPUT)"
|
|
@echo "CC = $(CC) "
|
|
@echo "BOARD = $(ZEPHYR_BASE)/boards/$(BOARD)/Makefile.board "
|
|
@echo "TOOLCHAIN = $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT) "
|
|
@echo "TOOLCHAIN_CFLAGS = $(TOOLCHAIN_CFLAGS) "
|
|
@echo "CROSS_COMPILE = $(CROSS_COMPILE) "
|
|
@echo "TOOLCHAIN_LIBS = $(TOOLCHAIN_LIBS) "
|
|
@echo "LIBS = $(LIBS) "
|
|
@echo "LIB_INCLUDE_DIR = $(LIB_INCLUDE_DIR) "
|
|
@echo "BUILD_CONFIG = $(BUILD_CONFIG) "
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) showconfig
|
|
|
|
# TODO @sergioamr Temporal cleanup before finding why Zephyr is ignoring my
|
|
# outdir for the project
|
|
clean:
|
|
@echo "Clearing Jerryscript"
|
|
@rm -rf $(OUTPUT)
|
|
@rm -rf $(INTERM)
|
|
@rm -f $(SOURCE_DIR)/.*.o.cmd
|
|
@rm -f $(SOURCE_DIR)/*.o
|
|
@echo "Clearing Zephyr"
|
|
make -f $(TARGET_ZEPHYR)/Makefile clean
|
|
make -f $(TARGET_ZEPHYR)/Makefile pristine
|
|
|
|
mrproper:
|
|
make -f $(TARGET_ZEPHYR)/Makefile mrproper
|
|
|