Build: Add c++ build ability.
This commit is contained in:
parent
67a28afd24
commit
6bb235b676
30
Makefile
30
Makefile
@ -7,6 +7,7 @@ TARGET_FILE ?= $(APPLICATION).elf
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CPP = $(CROSS_COMPILE)cpp
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
|
||||
@ -19,8 +20,14 @@ CPP_FLAGS += $(addprefix -I, $(INCLUDES))
|
||||
C_SRCS = $(wildcard $(SRC_DIR)/*.c)
|
||||
C_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.c)
|
||||
C_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.c)
|
||||
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.o,$(C_SRCS)))
|
||||
OBJS = $(NRF_A_OBJS) $(NRF_C_OBJS) $(C_OBJS)
|
||||
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.c.o,$(C_SRCS)))
|
||||
|
||||
CC_SRCS = $(wildcard $(SRC_DIR)/*.cc)
|
||||
CC_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.cc)
|
||||
CC_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.cc)
|
||||
CC_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.cc,%.cc.o,$(CC_SRCS)))
|
||||
|
||||
OBJS = $(NRF_A_OBJS) $(NRF_C_OBJS) $(C_OBJS) $(CC_OBJS)
|
||||
|
||||
TARGET = $(BIN_DIR)/$(TARGET_FILE)
|
||||
TARGET_HEX = $(patsubst %.elf,%.hex,$(TARGET))
|
||||
@ -36,6 +43,11 @@ C_FLAGS += -Wall -Werror
|
||||
C_FLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||
C_FLAGS += -DPLATFORM_$(PLATFORM)
|
||||
|
||||
CXX_FLAGS += -O$(OPT) -g$(OPT)
|
||||
CXX_FLAGS += -Wall -Werror
|
||||
CXX_FLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||
CXX_FLAGS += -DPLATFORM_$(PLATFORM)
|
||||
|
||||
LIBS += c nosys m
|
||||
|
||||
include config/build/$(PLATFORM)/$(APPLICATION)/Makefile.$(APPLICATION)
|
||||
@ -44,7 +56,7 @@ include config/build/$(PLATFORM)/$(APPLICATION)/Makefile.$(APPLICATION)
|
||||
all: $(TARGET)
|
||||
|
||||
debug:
|
||||
@echo $(TARGET_HEX)
|
||||
@echo $(CC_OBJS)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(TARGET_HEX) $(TARGET_PACKAGE)
|
||||
@ -55,7 +67,7 @@ distclean:
|
||||
|
||||
$(TARGET): $(OBJS) $(THIS_MAKEFILE)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CC_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@
|
||||
$(CXX) $(CXX_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@
|
||||
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.elf
|
||||
$(SIZE) -x $@
|
||||
|
||||
@ -67,7 +79,15 @@ $(OBJ_DIR)/%.d: $(SRC_DIR)/%.c $(THIS_MAKEFILE)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(C_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(SRC_DIR)/%.c,$@)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(THIS_MAKEFILE)
|
||||
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.cc $(THIS_MAKEFILE)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(CXX_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(SRC_DIR)/%.cc,$@)
|
||||
|
||||
$(OBJ_DIR)/%.cc.o: $(SRC_DIR)/%.cc $(THIS_MAKEFILE)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) -c $(CPP_FLAGS) $(CXX_FLAGS) $< -o $@
|
||||
|
||||
$(OBJ_DIR)/%.c.o: $(SRC_DIR)/%.c $(THIS_MAKEFILE)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) -c $(CPP_FLAGS) $(C_FLAGS) $< -o $@
|
||||
|
||||
|
@ -23,6 +23,23 @@ C_FLAGS += -fno-builtin -fshort-enums
|
||||
C_FLAGS += -D__HEAP_SIZE=8192
|
||||
C_FLAGS += -D__HEAP_SIZE=8192
|
||||
|
||||
CXX_FLAGS += -DBOARD_PCA10040
|
||||
CXX_FLAGS += -DBSP_DEFINES_ONLY
|
||||
CXX_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
CXX_FLAGS += -DFLOAT_ABI_HARD
|
||||
CXX_FLAGS += -DNRF52
|
||||
CXX_FLAGS += -DNRF52832_XXAA
|
||||
CXX_FLAGS += -DNRF52_PAN_74
|
||||
CXX_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
||||
CXX_FLAGS += -DS132
|
||||
CXX_FLAGS += -DSOFTDEVICE_PRESENT
|
||||
CXX_FLAGS += -mcpu=$(CPU)
|
||||
CXX_FLAGS += -mthumb -mabi=aapcs
|
||||
CXX_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
CXX_FLAGS += -fno-builtin -fshort-enums
|
||||
CXX_FLAGS += -D__HEAP_SIZE=8192
|
||||
CXX_FLAGS += -D__HEAP_SIZE=8192
|
||||
|
||||
# Assembler flags common to all targets
|
||||
A_FLAGS += -g$(OPT)
|
||||
A_FLAGS += -mcpu=$(CPU)
|
||||
|
Loading…
Reference in New Issue
Block a user