2020-08-17 12:45:53 +03:00
|
|
|
TARGET = target_lo
|
|
|
|
|
|
|
|
|
|
|
|
######################################
|
|
|
|
# building variables
|
|
|
|
######################################
|
|
|
|
# debug build?
|
|
|
|
DEBUG = 1
|
|
|
|
# optimization
|
|
|
|
OPT = -Og
|
|
|
|
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# paths
|
|
|
|
#######################################
|
2020-08-26 13:08:20 +03:00
|
|
|
PROJECT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
2020-08-17 12:45:53 +03:00
|
|
|
# Build path
|
|
|
|
BUILD_DIR = build
|
|
|
|
|
|
|
|
######################################
|
|
|
|
# source
|
|
|
|
######################################
|
2020-08-26 11:43:18 +03:00
|
|
|
C_SOURCES =
|
|
|
|
CPP_SOURCES =
|
|
|
|
C_DEFS =
|
2020-08-17 12:45:53 +03:00
|
|
|
|
2020-08-26 11:43:18 +03:00
|
|
|
# Target
|
2020-08-17 12:45:53 +03:00
|
|
|
|
2020-08-26 11:43:18 +03:00
|
|
|
C_SOURCES += Src/main.c
|
|
|
|
C_SOURCES += Src/flipper_hal.c
|
|
|
|
C_SOURCES += Src/lo_os.c
|
|
|
|
C_SOURCES += Src/lo_hal.c
|
|
|
|
|
2020-09-01 13:34:23 +03:00
|
|
|
# C_DEFS += -DFURI_DEBUG
|
2020-08-26 21:32:22 +03:00
|
|
|
|
2020-08-26 04:56:33 +03:00
|
|
|
# Core
|
|
|
|
|
2020-08-26 11:43:18 +03:00
|
|
|
CPP_SOURCES += ../core/app.cpp
|
|
|
|
|
2020-08-26 21:32:22 +03:00
|
|
|
C_SOURCES += ../core/log.c
|
|
|
|
C_SOURCES += ../core/tty_uart.c
|
2020-08-24 18:31:22 +03:00
|
|
|
C_SOURCES += ../core/furi.c
|
|
|
|
C_SOURCES += ../core/furi_ac.c
|
2020-08-26 04:56:33 +03:00
|
|
|
|
2020-09-09 19:12:09 +03:00
|
|
|
C_SOURCES += ../lib/u8g2/u8x8_d_st7565.c \
|
|
|
|
../lib/u8g2/u8g2_d_setup.c \
|
|
|
|
../lib/u8g2/u8g2_intersection.c \
|
|
|
|
../lib/u8g2/u8g2_setup.c \
|
|
|
|
../lib/u8g2/u8g2_d_memory.c \
|
|
|
|
../lib/u8g2/u8x8_cad.c \
|
|
|
|
../lib/u8g2/u8x8_byte.c \
|
|
|
|
../lib/u8g2/u8x8_gpio.c \
|
|
|
|
../lib/u8g2/u8x8_display.c \
|
|
|
|
../lib/u8g2/u8x8_setup.c \
|
|
|
|
../lib/u8g2/u8g2_hvline.c \
|
|
|
|
../lib/u8g2/u8g2_ll_hvline.c \
|
|
|
|
../lib/u8g2/u8g2_circle.c \
|
|
|
|
../lib/u8g2/u8g2_box.c \
|
|
|
|
../lib/u8g2/u8g2_buffer.c \
|
|
|
|
../lib/u8g2/u8g2_font.c \
|
|
|
|
../lib/u8g2/u8g2_fonts.c \
|
|
|
|
../lib/u8g2/u8x8_8x8.c \
|
|
|
|
../lib/u8g2/u8g2_bitmap.c
|
|
|
|
|
2020-08-26 04:56:33 +03:00
|
|
|
# System applications
|
|
|
|
|
|
|
|
ifeq ($(TEST), 1)
|
2020-08-24 18:31:22 +03:00
|
|
|
C_SOURCES += ../applications/tests/furiac_test.c
|
|
|
|
C_SOURCES += ../applications/tests/furi_record_test.c
|
|
|
|
C_SOURCES += ../applications/tests/test_index.c
|
2020-08-26 04:56:33 +03:00
|
|
|
C_DEFS += -DTEST
|
|
|
|
endif
|
|
|
|
|
2020-09-09 19:12:09 +03:00
|
|
|
ifneq ($(TEST), 1)
|
|
|
|
C_SOURCES += ../applications/display-u8g2/display-u8g2.c
|
|
|
|
endif
|
|
|
|
|
2020-08-26 11:43:18 +03:00
|
|
|
# Examples
|
2020-08-26 04:56:33 +03:00
|
|
|
|
2020-09-09 19:12:09 +03:00
|
|
|
# TODO example without condition
|
|
|
|
ifneq ($(TEST), 1)
|
|
|
|
C_SOURCES += ../applications/examples/u8g2_example.c
|
|
|
|
endif
|
|
|
|
|
2020-08-26 04:56:33 +03:00
|
|
|
ifeq ($(EXAMPLE_BLINK), 1)
|
|
|
|
C_SOURCES += ../applications/examples/blink.c
|
|
|
|
C_DEFS += -DEXAMPLE_BLINK
|
|
|
|
endif
|
2020-08-24 18:31:22 +03:00
|
|
|
|
2020-08-26 21:32:22 +03:00
|
|
|
ifeq ($(EXAMPLE_UART_WRITE), 1)
|
|
|
|
C_SOURCES += ../applications/examples/uart_write.c
|
|
|
|
C_DEFS += -DEXAMPLE_UART_WRITE
|
|
|
|
endif
|
|
|
|
|
2020-09-01 13:34:23 +03:00
|
|
|
ifeq ($(EXAMPLE_IPC), 1)
|
|
|
|
C_SOURCES += ../applications/examples/ipc.c
|
|
|
|
C_DEFS += -DEXAMPLE_IPC
|
|
|
|
endif
|
|
|
|
|
2020-08-26 11:43:18 +03:00
|
|
|
# User application
|
|
|
|
|
|
|
|
# Add C_SOURCES +=, C_DEFS += or CPP_SOURCES += here
|
|
|
|
|
2020-08-17 12:45:53 +03:00
|
|
|
#######################################
|
|
|
|
# binaries
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
CC = gcc
|
|
|
|
CPP = g++
|
|
|
|
AS =
|
|
|
|
CP = objcopy
|
|
|
|
SZ = size
|
|
|
|
HEX = $(CP) -O ihex
|
|
|
|
BIN = $(CP) -O binary -S
|
2020-08-26 13:08:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# Rust library
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
RUST_LIB_SRC = $(realpath $(PROJECT_DIR)/../core-rs)
|
|
|
|
RUST_LIB_NAME = flipper_core
|
|
|
|
RUST_LIB_TARGET = x86_64-unknown-linux-gnu
|
|
|
|
RUST_LIB_FLAGS = --target=$(RUST_LIB_TARGET)
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
RUST_LIB_PATH = $(RUST_LIB_SRC)/target/$(RUST_LIB_TARGET)/debug
|
|
|
|
else
|
|
|
|
RUST_LIB_FLAGS += --release
|
|
|
|
RUST_LIB_PATH = $(RUST_LIB_SRC)/target/$(RUST_LIB_TARGET)/release
|
|
|
|
endif
|
|
|
|
|
2020-08-31 22:33:38 +03:00
|
|
|
RUST_LIB_CMD = cd $(RUST_LIB_SRC) && cargo build -p flipper-core $(RUST_LIB_FLAGS)
|
2020-08-26 13:08:20 +03:00
|
|
|
|
2020-08-17 12:45:53 +03:00
|
|
|
#######################################
|
|
|
|
# CFLAGS
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
|
|
|
|
# C includes
|
|
|
|
C_INCLUDES = \
|
|
|
|
-IInc \
|
2020-08-24 18:31:22 +03:00
|
|
|
-I../applications \
|
2020-09-09 19:12:09 +03:00
|
|
|
-I../lib \
|
2020-08-26 13:08:20 +03:00
|
|
|
-I../core \
|
2020-08-31 22:33:38 +03:00
|
|
|
-I../core-rs/flipper-core/bindings
|
2020-08-17 12:45:53 +03:00
|
|
|
|
|
|
|
# compile gcc flags
|
2020-08-24 18:31:22 +03:00
|
|
|
CFLAGS = $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -pthread
|
2020-08-17 12:45:53 +03:00
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -g -gdwarf-2
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# Generate dependency information
|
|
|
|
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
|
|
|
|
|
|
|
|
CPPFLAGS = -fno-threadsafe-statics
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# LDFLAGS
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
# libraries
|
2020-08-26 13:08:20 +03:00
|
|
|
LIBS = -lc -lm -l$(RUST_LIB_NAME)
|
|
|
|
LIBDIR = -L$(RUST_LIB_PATH)
|
2020-08-24 18:31:22 +03:00
|
|
|
LDFLAGS = $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -pthread
|
2020-08-17 12:45:53 +03:00
|
|
|
|
|
|
|
# default action: build all
|
|
|
|
all: $(BUILD_DIR)/$(TARGET)
|
2020-08-26 04:56:33 +03:00
|
|
|
|
2020-09-09 19:12:09 +03:00
|
|
|
run: all
|
|
|
|
$(BUILD_DIR)/$(TARGET)
|
|
|
|
|
|
|
|
|
2020-08-31 22:33:38 +03:00
|
|
|
rust_lib:
|
|
|
|
$(RUST_LIB_CMD)
|
|
|
|
|
2020-08-26 04:56:33 +03:00
|
|
|
example_blink:
|
2020-09-01 13:34:23 +03:00
|
|
|
rm -f $(BUILD_DIR)/app.o
|
2020-09-09 19:12:09 +03:00
|
|
|
EXAMPLE_BLINK=1 make run
|
2020-08-26 21:32:22 +03:00
|
|
|
|
|
|
|
|
|
|
|
example_uart_write:
|
2020-09-01 13:34:23 +03:00
|
|
|
rm -f $(BUILD_DIR)/app.o
|
2020-09-09 19:12:09 +03:00
|
|
|
EXAMPLE_UART_WRITE=1 make run
|
2020-09-01 13:34:23 +03:00
|
|
|
|
|
|
|
example_ipc:
|
|
|
|
rm -f $(BUILD_DIR)/app.o
|
2020-09-09 19:12:09 +03:00
|
|
|
EXAMPLE_IPC=1 make run
|
2020-08-26 04:56:33 +03:00
|
|
|
|
|
|
|
test:
|
2020-09-01 13:34:23 +03:00
|
|
|
rm -f $(BUILD_DIR)/app.o
|
2020-08-26 04:56:33 +03:00
|
|
|
TEST=1 make
|
2020-09-07 17:35:18 +03:00
|
|
|
timeout --signal=9 5 $(BUILD_DIR)/$(TARGET)
|
2020-08-17 12:45:53 +03:00
|
|
|
|
2020-08-31 22:33:38 +03:00
|
|
|
.PHONY: all rust_lib example_blink example_uart_write test
|
2020-08-17 12:45:53 +03:00
|
|
|
|
|
|
|
#######################################
|
|
|
|
# build the application
|
|
|
|
#######################################
|
|
|
|
# list of objects
|
|
|
|
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
|
|
|
vpath %.c $(sort $(dir $(C_SOURCES)))
|
|
|
|
|
|
|
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
|
|
|
|
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
|
|
|
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
|
|
|
|
$(CPP) -c $(CFLAGS) $(CPPFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
|
|
|
|
2020-08-31 22:33:38 +03:00
|
|
|
$(RUST_LIB_PATH)/lib$(RUST_LIB_NAME).a: rust_lib
|
2020-08-26 13:08:20 +03:00
|
|
|
|
|
|
|
$(BUILD_DIR)/$(TARGET): $(RUST_LIB_PATH)/lib$(RUST_LIB_NAME).a $(OBJECTS) Makefile
|
2020-08-17 12:45:53 +03:00
|
|
|
$(CPP) $(OBJECTS) $(LDFLAGS) -o $@
|
|
|
|
$(SZ) $@
|
|
|
|
|
|
|
|
$(BUILD_DIR):
|
|
|
|
mkdir $@
|
|
|
|
|
|
|
|
#######################################
|
|
|
|
# clean up
|
|
|
|
#######################################
|
|
|
|
clean:
|
|
|
|
-rm -fR $(BUILD_DIR)
|
2020-08-26 13:08:20 +03:00
|
|
|
cd $(RUST_LIB_SRC) && cargo clean
|
2020-08-17 12:45:53 +03:00
|
|
|
|
|
|
|
#######################################
|
|
|
|
# dependencies
|
|
|
|
#######################################
|
|
|
|
-include $(wildcard $(BUILD_DIR)/*.d)
|
|
|
|
|
|
|
|
# *** EOF ***
|