36479ddc1a
The 'external' toolchain file does nothing but transitively sets some cmake system variables from values received on the command line, and forcibly sets the C compiler. However, the same cmake system variables can be directly set via the command line, together with the C compiler, and specifying a toolchain is not a must. Thus, this patch drops the superfluous 'external' toolchain file and updates cmake-based targets to invoke cmake in a simpler form. Related changes in this commit: - While updating the cmake invocations, all the command line arguments have been reviewed and simplified (removed those, which did not change the defaults). - Removed unnecessary forced C compiler settings from some toolchain files (and/or changed them to setting the "compiler works" flag to true, thus keeping cmake's compiler identification logic but disabling some of its overzealous compiler sanity checks). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
173 lines
5.3 KiB
Makefile
173 lines
5.3 KiB
Makefile
# Copyright JS Foundation and other contributors, http://js.foundation
|
|
#
|
|
# 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
|
|
|
|
BOARD ?= arduino_101
|
|
export BOARD
|
|
|
|
TARGET_ZEPHYR ?= ./targets/zephyr
|
|
TARGET_ZEPHYR_SRC_DIR = $(TARGET_ZEPHYR)/src
|
|
|
|
COMPONENTS ?= jerry-core jerry-ext
|
|
JERRYHEAP ?= 16
|
|
JERRYPROFILE ?= minimal
|
|
|
|
# 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
|
|
|
|
INTERM = build/$(BOARD)/obj-$(BOARD)
|
|
OUTPUT = build/$(BOARD)/zephyr
|
|
|
|
include $(OUTPUT)/Makefile.export
|
|
|
|
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
|
|
|
|
EXT_CFLAGS += $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(subst -I,-isystem,$(ZEPHYRINCLUDE))
|
|
|
|
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 -Wno-old-style-declaration
|
|
EXT_CFLAGS += -Wno-error=format=
|
|
EXT_CFLAGS += -D_XOPEN_SOURCE=700
|
|
|
|
EXT_CFLAGS += -Wno-error=conversion
|
|
|
|
EXTERNAL_LIB = $(INTERM)/lib/libjerry-core.a $(INTERM)/lib/libjerry-ext.a
|
|
|
|
LIBS = jerry-core jerry-ext
|
|
|
|
BUILD_CONFIG = O="$(OUTPUT)" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(INTERM)/lib" TARGET_ZEPHYR=$(TARGET_ZEPHYR)
|
|
|
|
.PHONY: all
|
|
all: zephyr
|
|
|
|
$(EXTERNAL_LIB):
|
|
ifdef V
|
|
@echo "- JERRY SCRIPT -------------------------------------------------"
|
|
endif
|
|
mkdir -p $(INTERM)
|
|
mkdir -p $(OUTPUT)
|
|
cmake -B$(INTERM) -H./ \
|
|
-DCMAKE_SYSTEM_NAME=Zephyr \
|
|
-DCMAKE_C_COMPILER="$(subst ccache ,,$(CC))" \
|
|
-DCMAKE_C_COMPILER_WORKS=TRUE \
|
|
-DENABLE_LTO=OFF \
|
|
-DENABLE_ALL_IN_ONE=OFF \
|
|
-DJERRY_LIBC=OFF \
|
|
-DJERRY_CMDLINE=OFF \
|
|
-DFEATURE_PROFILE=$(JERRYPROFILE) \
|
|
-DFEATURE_ERROR_MESSAGES=ON \
|
|
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
|
-DCMAKE_VERBOSE_MAKEFILE=$(V) \
|
|
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \
|
|
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
|
|
$(EXT_JERRY_FLAGS)
|
|
|
|
make -C $(INTERM) $(COMPONENTS) V=1
|
|
|
|
$(OUTPUT)/Makefile.export: $(OUTPUT)/include/config/auto.conf
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) outputexports
|
|
|
|
$(OUTPUT)/include/config/auto.conf:
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) initconfig
|
|
|
|
zephyr: jerry
|
|
ifdef V
|
|
@echo "- ZEPHYR -------------------------------------------------------"
|
|
endif
|
|
+make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG)
|
|
@echo "Finished"
|
|
@file $(OUTPUT)/zephyr.strip
|
|
@size $(OUTPUT)/zephyr.strip
|
|
|
|
jerry: $(EXTERNAL_LIB)
|
|
@touch $(EXTERNAL_LIB)
|
|
|
|
GENERIC_TARGETS = qemu qemugdb flash debug debugserver
|
|
KCONFIG_TARGETS = \
|
|
initconfig config nconfig menuconfig xconfig gconfig \
|
|
oldconfig silentoldconfig defconfig savedefconfig \
|
|
allnoconfig allyesconfig alldefconfig randconfig \
|
|
listnewconfig olddefconfig
|
|
CLEAN_TARGETS = mrproper
|
|
|
|
$(GENERIC_TARGETS): jerry
|
|
$(CLEAN_TARGETS): clean
|
|
|
|
$(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
|
|
ifdef V
|
|
@echo "- ZEPHYR -------------------------------------------------------"
|
|
endif
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) $@
|
|
|
|
dfu-x86: all
|
|
@- dfu-util -a x86_app -D build/$(BOARD)/zephyr/zephyr.bin; \
|
|
if [ $$? -eq 0 ] ; then echo "\nYour program will launch in 5 seconds." ; \
|
|
else echo "\nProgram didn't flash, try pressing the reset buttons \nand wait a second for the bootloader to load, \nor flash again the factory bootloader."; fi
|
|
|
|
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 "BUILD_CONFIG = $(BUILD_CONFIG) "
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) showconfig
|
|
|
|
clean:
|
|
ifdef V
|
|
@echo "- CLEANING JERRY SCRIPT ----------------------------------------"
|
|
endif
|
|
rm -rf $(INTERM) $(TARGET_ZEPHYR_SRC_DIR)/*.o
|
|
ifdef V
|
|
@echo "- CLEANING ZEPHYR ----------------------------------------------"
|
|
endif
|
|
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) clean
|
|
|
|
pristine: clean
|
|
ifdef V
|
|
@echo "- CLEANING BUILD DIRECTORY -------------------------------------"
|
|
endif
|
|
rm -rf build/
|