Browse Source

Changed RIOT/Makefile.include, Makefile.base, Makefile.cflags, and native/Makefile.include to compile C and C++ files.

dev/timer
Pham Huu Dang Nhat 9 years ago
parent
commit
f7398f61ff
  1. 17
      Makefile.base
  2. 3
      Makefile.cflags
  3. 9
      Makefile.include
  4. 5
      boards/native/Makefile.include

17
Makefile.base

@ -30,8 +30,19 @@ ASMOBJ += $(ASSMSRC:%.S=$(BINDIR)$(MODULE)/%.o)
ifeq ($(strip $(SRC)),)
SRC = $(wildcard *.c)
endif
OBJ = $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
ifeq ($(strip $(SRCXX)),)
SRCXX = $(wildcard *.cpp)
endif
OBJC = $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
OBJCXX = $(SRCXX:%.cpp=$(BINDIR)$(MODULE)/%.o)
OBJ = $(OBJC)
OBJ += $(OBJCXX)
DEP = $(SRC:%.c=$(BINDIR)$(MODULE)/%.d)
DEP += $(SRCXX:%.cpp=$(BINDIR)$(MODULE)/%.d)
$(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ) ${DIRS:%=ALL--%}
@mkdir -p $(BINDIR)$(MODULE)
@ -46,6 +57,10 @@ $(BINDIR)$(MODULE)/%.o: %.c
@mkdir -p $(BINDIR)$(MODULE)
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $(BINDIR)$(MODULE)/$*.o $(abspath $*.c)
$(BINDIR)$(MODULE)/%.o: %.cpp
@mkdir -p $(BINDIR)$(MODULE)
$(AD)$(CXX) $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) $(INCLUDES) -MD -MP -c -o $(BINDIR)$(MODULE)/$*.o $(abspath $*.cpp)
$(BINDIR)$(MODULE)/%.o: %.s
@mkdir -p $(BINDIR)$(MODULE)
$(AD)$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$(MODULE)/$*.o

3
Makefile.cflags

@ -29,3 +29,6 @@ ifeq ($(shell $(CC) -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-de
# duplicated parameters don't hurt
CFLAGS += -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-definition -Werror=old-style-definition
endif
# Unwanted flags for c++
CXXUWFLAGS += -std=gnu99 -std=c99 -Wstrict-prototypes -Wold-style-definition

9
Makefile.include

@ -90,14 +90,19 @@ BASELIBS += $(USEPKG:%=${BINDIR}%.a)
export ELFFILE ?= $(BINDIR)$(APPLICATION).elf
export HEXFILE ?= $(ELFFILE:.elf=.hex)
# variables used to complie and link c++
export CPPMIX ?= $(if $(wildcard *.cpp),1,)
export CXXUWFLAGS
export CXXEXFLAGS
## make script for your application. Build RIOT-base here!
all: ..build-message $(USEPKG:%=${BINDIR}%.a) $(APPDEPS)
$(AD)DIRS="$(DIRS)" "$(MAKE)" -C $(CURDIR) -f $(RIOTBASE)/Makefile.application
ifeq (,$(RIOTNOLINK))
ifeq ($(BUILDOSXNATIVE),1)
$(AD)$(LINK) $(UNDEF) -o $(ELFFILE) $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
$(AD)$(if $(CPPMIX),$(CXX),$(LINK)) $(UNDEF) -o $(ELFFILE) $(BASELIBS) $(LINKFLAGS) -Wl,-no_pie
else
$(AD)$(LINK) $(UNDEF) -o $(ELFFILE) -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(BINDIR)$(APPLICATION).map $(LINKFLAGS)
$(AD)$(if $(CPPMIX),$(CXX),$(LINK)) $(UNDEF) -o $(ELFFILE) -Wl,--start-group $(BASELIBS) -lm -Wl,--end-group -Wl,-Map=$(BINDIR)$(APPLICATION).map $(LINKFLAGS)
endif
$(AD)$(SIZE) $(ELFFILE)
$(AD)$(OBJCOPY) $(OFLAGS) $(ELFFILE) $(HEXFILE)

5
boards/native/Makefile.include

@ -10,6 +10,7 @@ export ELF = $(BINDIR)$(APPLICATION).elf
# toolchain:
export PREFIX =
export CC ?= $(PREFIX)gcc
export CXX ?= $(PREFIX)g++
export AR ?= $(PREFIX)ar
export AS ?= $(PREFIX)as
export LINK ?= $(PREFIX)gcc
@ -31,6 +32,10 @@ export CFLAGS += -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32
endif
endif
# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
export CXXEXFLAGS +=
export LINKFLAGS += -m32
ifeq ($(shell uname -s),FreeBSD)
ifeq ($(shell uname -m),amd64)

Loading…
Cancel
Save