1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/Makefile.base

80 lines
2.1 KiB
Makefile
Raw Normal View History

ifeq (, $(__RIOTBUILD_FLAG))
$(error You cannot build a module on its own. Use "make" in your application's directory instead.)
endif
unexport DIRS
DIRS := $(sort $(abspath ${DIRS}))
MODULE ?= $(shell basename $(CURDIR))
.PHONY: all ${DIRS:%=ALL--%} ${DIRS:%=CLEAN--%}
all: $(BINDIR)$(MODULE).a ..nothing
..nothing:
@:
clean:: ${DIRS:%=CLEAN--%}
${DIRS:%=ALL--%}:
"$(MAKE)" -C ${@:ALL--%=%}
${DIRS:%=CLEAN--%}:
"$(MAKE)" -C ${@:CLEAN--%=%} clean
2013-10-29 16:26:42 +01:00
ifeq ($(strip $(SRC)),)
2014-08-13 20:46:47 +02:00
SRC := $(wildcard *.c)
2013-10-29 16:26:42 +01:00
endif
ifeq ($(strip $(SRCXX)),)
2014-08-13 20:46:47 +02:00
SRCXX := $(wildcard *.cpp)
endif
ifeq ($(strip $(ASMSRC)),)
ASMSRC := $(wildcard *.s)
endif
ifeq ($(strip $(ASSMSRC)),)
ASSMSRC := $(wildcard *.S)
endif
2014-08-13 20:46:47 +02:00
OBJC := $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
OBJCXX := $(SRCXX:%.cpp=$(BINDIR)$(MODULE)/%.o)
ASMOBJ := $(ASMSRC:%.s=$(BINDIR)$(MODULE)/%.o)
ASSMOBJ := $(ASSMSRC:%.S=$(BINDIR)$(MODULE)/%.o)
2014-08-13 20:46:47 +02:00
OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ)
DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d)
2014-08-13 20:23:08 +02:00
$(BINDIR)$(MODULE)/:
$(AD)mkdir -p $@
$(BINDIR)$(MODULE).a $(OBJ): | $(BINDIR)$(MODULE)/
$(BINDIR)$(MODULE).a: $(OBJ) | ${DIRS:%=ALL--%}
$(AD)$(AR) $(ARFLAGS) $@ $?
2014-08-13 20:41:48 +02:00
CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
# compile and generate dependency info
2014-08-13 20:41:48 +02:00
$(OBJC): $(BINDIR)$(MODULE)/%.o: %.c $(RIOTBUILD_CONFIG_HEADER_C)
$(AD)$(CCACHE) $(CC) \
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
$(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
$(OBJCXX): $(BINDIR)$(MODULE)/%.o: %.cpp $(RIOTBUILD_CONFIG_HEADER_C)
$(AD)$(CCACHE) $(CXX) \
-DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \
-DRIOT_FILE_NOPATH=\"$(notdir $<)\" \
$(CXXFLAGS) $(INCLUDES) $(CXXINCLUDES) -MD -MP -c -o $@ $(abspath $<)
$(ASMOBJ): $(BINDIR)$(MODULE)/%.o: %.s
2014-08-13 20:41:48 +02:00
$(AD)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
$(ASSMOBJ): $(BINDIR)$(MODULE)/%.o: %.S
2014-08-13 20:41:48 +02:00
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
# pull in dependency info for *existing* .o files
# deleted header files will be silently ignored
2014-08-13 20:46:47 +02:00
-include $(DEP)