Skip to content

Adapted the makefiles to the new build system #1232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions targets/zephyr/Makefile.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ endif
TARGET_ZEPHYR ?= ./targets/zephyr
TARGET_ZEPHYR_SRC_DIR = $(TARGET_ZEPHYR)/src

TYPE ?= release
TYPE ?= jerry-core
JERRYHEAP ?= 16

# Include functionality like regular expressions
Expand All @@ -44,27 +44,20 @@ ifndef ZEPHYR_BASE
$(error Missing Zephyr base, did you source zephyr-env.sh? )
endif

# -cp is required for user-friendly error messages in REPL
VARIETY ?= -cp_minimal

INTERM = build/$(BOARD)/obj-$(BOARD)
OUTPUT = build/$(BOARD)

-include $(ZEPHYR_BASE)/boards/$(BOARD_NAME)/Makefile.board
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)

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
CPU = i686
EXT_CFLAGS += -march=pentium
EXT_CFLAGS += -mpreferred-stack-boundary=2 -mno-sse
else ifeq ($(BOARD),$(filter $(BOARD),qemu_cortex_m3 frdm_k64f))
Expand All @@ -78,31 +71,36 @@ CPU = arc
EXT_CFLAGS += -mARCv2EM -mav2em -mno-sdata
else
CONFIG_TOOLCHAIN_VARIANT = iamcu
CPU = lakemont
CPU = i686
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-main -Wno-strict-aliasing -Wno-old-style-declaration
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)
# Pass2
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)

CC = $(CROSS_COMPILE)gcc

ZEPHYR_LIBC_INC = $(subst -I,,$(TOOLCHAIN_CFLAGS))
LIB_INCLUDE_DIR += -L $(CURDIR)/$(OUTPUT)

EXTERNAL_LIB = $(INTERM)/lib$(TYPE).external$(VARIETY)-entry.a
# TODO: Order of includes seems to have changed and time_t seems to be defined differently. Temporary disable the conversion and sign-conversion until we find what is happening
# this will generate warnings on the default date port.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds quite odd. Let us know if you find out what happens there.

EXT_CFLAGS += -Wno-error=conversion -Wno-error=sign-conversion
EXT_CFLAGS += $(LIB_INCLUDE_DIR)
EXT_CFLAGS += $(TOOLCHAIN_CFLAGS)

EXTERNAL_LIB = $(INTERM)/lib/libjerry-core.a
ZEPHYR_BIN = $(OUTPUT)/zephyr/zephyr.strip

PREFIX = $(TYPE)$(VARIETY)
LIBS = $(TYPE).external$(VARIETY)-entry $(PREFIX).jerry-core $(PREFIX).jerry-libm.lib
LIBS = jerry-core

BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(OUTPUT)" TARGET_ZEPHYR=$(TARGET_ZEPHYR)
BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(INTERM)/lib" TARGET_ZEPHYR=$(TARGET_ZEPHYR)

.PHONY: all
all: jerry zephyr
Expand All @@ -114,23 +112,24 @@ endif
mkdir -p $(INTERM)
mkdir -p $(OUTPUT)
cmake -B$(INTERM) -H./ \
-DENABLE_LTO=OFF \
-DENABLE_VALGRIND=OFF \
-DENABLE_LTO=OFF \
-DFEATURE_VALGRIND=OFF \
-DFEATURE_PROFILE=minimal \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE=$(V) \
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \
-DEXTERNAL_CMAKE_C_COMPILER=$(CC) \
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=$(CPU) \
-DEXTERNAL_MEM_HEAP_SIZE_KB=$(JERRYHEAP) \
-DCOMPILER_DEFAULT_LIBC=OFF \
-DJERRY_CMDLINE=OFF \
-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=$(TARGET_ZEPHYR_SRC_DIR)/jerry-entry.c
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \
-DFEATURE_SNAPSHOT_EXEC=OFF \
-DENABLE_ALL_IN_ONE=OFF \
-DJERRY_LIBC=OFF

make -C $(INTERM) $(TYPE).external$(VARIETY) V=1
cp `cat $(INTERM)/$(TYPE).external$(VARIETY)/list` $(OUTPUT)/.
cp $(EXTERNAL_LIB) $(OUTPUT)/.
make -C $(INTERM) $(TYPE)$(VARIETY) V=1

$(ZEPHYR_BIN):
ifdef V
Expand All @@ -153,6 +152,9 @@ qemu: $(EXTERNAL_LIB) $(ZEPHYR_BIN)
flash: $(EXTERNAL_LIB) $(OUTPUT)/zephyr/zephyr.strip
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) flash

debugserver:
make -f $(TARGET_ZEPHYR)/Makefile BOARD=$(BOARD_NAME) debugserver

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." ; \
Expand All @@ -178,10 +180,9 @@ showconfig:
@echo "LIBS = $(LIBS) "
@echo "LIB_INCLUDE_DIR = $(LIB_INCLUDE_DIR) "
@echo "BUILD_CONFIG = $(BUILD_CONFIG) "
@echo "ZEPHYR_LIBC_INC = $(ZEPHYR_LIBC_INC) "
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)
Expand Down