summaryrefslogtreecommitdiff
path: root/include.mk
diff options
context:
space:
mode:
Diffstat (limited to 'include.mk')
-rw-r--r--include.mk29
1 files changed, 21 insertions, 8 deletions
diff --git a/include.mk b/include.mk
index d2813a6..28eeaaa 100644
--- a/include.mk
+++ b/include.mk
@@ -28,6 +28,9 @@ include $(SPREADAVR_PATH)/defines.mk
## project-specific objects
SRC := $(OBJ:%.o=%.c)
DEP := $(SRC:%.c=%.d)
+CXX_SRC := $(CXX_OBJ:%.o=%.cpp)
+CXX_DEP := $(CXX_SRC:%.cpp=%.d)
+
OBJ_LIB := $(LIBS:%=lib-%.o)
SRC_LIB := $(LIBS:%=$(LIB_DIR)/%.c)
DEP_LIB := $(LIBS:%=lib-%.d)
@@ -68,31 +71,41 @@ clean-lufa:
## project-specific objects
-lib-%.d: $(LIB_DIR)/%.c Makefile
+%.d: %.c Makefile
@set -e; rm -f $@; \
$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
- sed 's,\($*\)\.o[ :]*,lib-\1.o $@ : ,g' < $@.$$$$ > $@; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$; echo '(re)building $@'
-%.d: %.c Makefile
+%.d: %.cpp Makefile
@set -e; rm -f $@; \
- $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+ $(CXX) -MM $(CXXFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$; echo '(re)building $@'
+lib-%.d: $(LIB_DIR)/%.c Makefile
+ @set -e; rm -f $@; \
+ $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,lib-\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$; echo '(re)building $@'
+
ifneq ($(MAKECMDGOALS),distclean)
-include $(DEP)
+-include $(CXX_DEP)
-include $(DEP_LIB)
endif
-lib-%.o: $(LIB_DIR)/%.c Makefile
+%.o: %.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
-%.o: %.c Makefile
+%.o: %.cpp Makefile
+ $(CXX) $(CXXFLAGS) -c $< -o $@
+
+lib-%.o: $(LIB_DIR)/%.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
-$(ELFFILE): $(OBJ) $(OBJ_LIB) $(EXTERNAL_LIBS:%=lib%.a)
- $(CC) $(LDFLAGS) $(OBJ) $(OBJ_LIB) $(EXTERNAL_LIBS:%=-l%) -o $@
+$(ELFFILE): $(OBJ) $(CXX_OBJ) $(OBJ_LIB) $(EXTERNAL_LIBS:%=lib%.a)
+ $(CC) $(LDFLAGS) $(OBJ) $(CXX_OBJ) $(OBJ_LIB) $(EXTERNAL_LIBS:%=-l%) -o $@
$(SIZE) $@
@echo ""