Allow compilation of c++ files (extension .cpp)
This commit is contained in:
parent
5991c3e3db
commit
87903b2e89
|
@ -65,7 +65,7 @@ CONTIKI_SOURCEFILES += $(CONTIKIFILES)
|
|||
CONTIKIDIRS += ${addprefix $(CONTIKI)/core/,dev lib net net/mac net/rime \
|
||||
net/rpl sys cfs ctk lib/ctk loader . }
|
||||
|
||||
oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}}
|
||||
oname = ${patsubst %.cpp,%.o,${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}}}
|
||||
|
||||
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}}
|
||||
|
||||
|
@ -117,16 +117,18 @@ endif
|
|||
### Verbosity control. Use make V=1 to get verbose builds.
|
||||
|
||||
ifeq ($(V),1)
|
||||
TRACE_CC =
|
||||
TRACE_LD =
|
||||
TRACE_AR =
|
||||
TRACE_AS =
|
||||
TRACE_CC =
|
||||
TRACE_CXX =
|
||||
TRACE_LD =
|
||||
TRACE_AR =
|
||||
TRACE_AS =
|
||||
Q=
|
||||
else
|
||||
TRACE_CC = @echo " CC " $<
|
||||
TRACE_LD = @echo " LD " $@
|
||||
TRACE_AR = @echo " AR " $@
|
||||
TRACE_AS = @echo " AS " $<
|
||||
TRACE_CC = @echo " CC " $<
|
||||
TRACE_CXX = @echo " CXX " $<
|
||||
TRACE_LD = @echo " LD " $@
|
||||
TRACE_AR = @echo " AR " $@
|
||||
TRACE_AS = @echo " AS " $<
|
||||
Q=@
|
||||
endif
|
||||
|
||||
|
@ -145,8 +147,9 @@ CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \
|
|||
SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \
|
||||
$(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDS) ${dir $(target_makefile)}
|
||||
|
||||
vpath %.c $(SOURCEDIRS)
|
||||
vpath %.S $(SOURCEDIRS)
|
||||
vpath %.c $(SOURCEDIRS)
|
||||
vpath %.cpp $(SOURCEDIRS)
|
||||
vpath %.S $(SOURCEDIRS)
|
||||
|
||||
CFLAGS += ${addprefix -I,$(SOURCEDIRS) $(CONTIKI)}
|
||||
|
||||
|
@ -162,7 +165,7 @@ endif
|
|||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include ${addprefix $(OBJECTDIR)/,$(CONTIKI_SOURCEFILES:.c=.d) \
|
||||
$(PROJECT_SOURCEFILES:.c=.d)}
|
||||
$(PROJECT_OBJECTFILES:.o=.d)}
|
||||
endif
|
||||
|
||||
### See http://make.paulandlesley.org/autodep.html#advanced
|
||||
|
@ -201,6 +204,13 @@ $(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
|||
@$(FINALIZE_DEPENDENCY)
|
||||
endif
|
||||
|
||||
ifndef CUSTOM_RULE_CPP_TO_OBJECTDIR_O
|
||||
$(OBJECTDIR)/%.o: %.cpp | $(OBJECTDIR)
|
||||
$(TRACE_CXX)
|
||||
$(Q)$(CXX) $(CFLAGS) -MMD -c $< -o $@
|
||||
@$(FINALIZE_DEPENDENCY)
|
||||
endif
|
||||
|
||||
ifndef CUSTOM_RULE_S_TO_OBJECTDIR_O
|
||||
$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR)
|
||||
$(TRACE_AS)
|
||||
|
@ -213,6 +223,12 @@ ifndef CUSTOM_RULE_C_TO_O
|
|||
$(Q)$(CC) $(CFLAGS) -c $< -o $@
|
||||
endif
|
||||
|
||||
ifndef CUSTOM_RULE_CPP_TO_O
|
||||
%.o: %.cpp
|
||||
$(TRACE_CXX)
|
||||
$(Q)$(CXX) $(CFLAGS) -c $< -o $@
|
||||
endif
|
||||
|
||||
|
||||
ifndef CUSTOM_RULE_C_TO_CO
|
||||
%.co: %.c
|
||||
|
@ -256,6 +272,8 @@ endif
|
|||
# the match-anything rule below instead.
|
||||
%: %.c
|
||||
|
||||
%: %.cpp
|
||||
|
||||
# Match-anything pattern rule to allow the project makefiles to
|
||||
# abstract from the actual binary name. It needs to contain some
|
||||
# command in order to be a rule, not just a prerequisite.
|
||||
|
|
|
@ -90,6 +90,7 @@ CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|||
|
||||
### Compiler definitions
|
||||
CC = avr-gcc
|
||||
CXX = avr-g++
|
||||
LD = avr-gcc
|
||||
AS = avr-as
|
||||
AR = avr-ar
|
||||
|
@ -130,6 +131,12 @@ $(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
|||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJECTDIR)/%.o: %.cpp | $(OBJECTDIR)
|
||||
$(CXX) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.ko: %.o
|
||||
$(STRIP) -K _init -K _fini --strip-unneeded -g -x $< -o $@
|
||||
|
||||
|
|
Loading…
Reference in a new issue