From 9b7d53550645d693afbb338258af6bcd7b7b2539 Mon Sep 17 00:00:00 2001 From: Fabian Herb Date: Sun, 7 Apr 2019 18:19:22 +0200 Subject: Make cxx files work with rules.mk --- rules.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rules.mk b/rules.mk index 05d04bd..e417d2f 100644 --- a/rules.mk +++ b/rules.mk @@ -4,6 +4,7 @@ # OPENCM3_DIR - duh # PROJECT - will be the basename of the output elf, eg usb-gadget0-stm32f4disco # CFILES - basenames only, eg main.c blah.c +# CXXFILES - same for C++ files. Must have cxx suffix! # DEVICE - the full device name, eg stm32f405ret6 # _or_ # LDSCRIPT - full path, eg ../../examples/stm32/f4/stm32f4-discovery/stm32f4-discovery.ld @@ -45,6 +46,7 @@ endif # Tool paths. PREFIX ?= arm-none-eabi- CC = $(PREFIX)gcc +CXX = $(PREFIX)g++ LD = $(PREFIX)gcc OBJCOPY = $(PREFIX)objcopy OBJDUMP = $(PREFIX)objdump @@ -56,6 +58,7 @@ OPENCM3_INC = $(OPENCM3_DIR)/include INCLUDES += $(patsubst %,-I%, . $(OPENCM3_INC) ) OBJS = $(CFILES:%.c=$(BUILD_DIR)/%.o) +OBJS += $(CXXFILES:%.cxx=$(BUILD_DIR)/%.o) OBJS += $(AFILES:%.S=$(BUILD_DIR)/%.o) GENERATED_BINS = $(PROJECT).elf $(PROJECT).bin $(PROJECT).map $(PROJECT).list $(PROJECT).lss @@ -130,7 +133,7 @@ $(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.o: %.cxx @printf " CXX\t$<\n" @mkdir -p $(dir $@) - $(Q)$(CC) $(TGT_CXXFLAGS) $(CXXFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $@ -c $< + $(Q)$(CXX) $(TGT_CXXFLAGS) $(CXXFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $@ -c $< $(BUILD_DIR)/%.o: %.S @printf " AS\t$<\n" -- cgit v1.2.3-70-g09d2