mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
84 lines
2.3 KiB
Makefile
84 lines
2.3 KiB
Makefile
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--%}:
|
|
$(QQ)"$(MAKE)" -C ${@:ALL--%=%}
|
|
|
|
${DIRS:%=CLEAN--%}:
|
|
$(QQ)"$(MAKE)" -C ${@:CLEAN--%=%} clean
|
|
|
|
ifeq ($(strip $(SRC)),)
|
|
SRC := $(filter-out $(SRC_NOLTO), $(wildcard *.c))
|
|
endif
|
|
ifeq ($(strip $(SRCXX)),)
|
|
SRCXX := $(wildcard *.cpp)
|
|
endif
|
|
ifeq ($(strip $(ASMSRC)),)
|
|
ASMSRC := $(wildcard *.s)
|
|
endif
|
|
ifeq ($(strip $(ASSMSRC)),)
|
|
ASSMSRC := $(wildcard *.S)
|
|
endif
|
|
|
|
OBJC_LTO := $(SRC:%.c=$(BINDIR)/$(MODULE)/%.o)
|
|
OBJC_NOLTO := $(SRC_NOLTO:%.c=$(BINDIR)/$(MODULE)/%.o)
|
|
OBJC := $(OBJC_NOLTO) $(OBJC_LTO)
|
|
OBJCXX := $(SRCXX:%.cpp=$(BINDIR)/$(MODULE)/%.o)
|
|
ASMOBJ := $(ASMSRC:%.s=$(BINDIR)/$(MODULE)/%.o)
|
|
ASSMOBJ := $(ASSMSRC:%.S=$(BINDIR)/$(MODULE)/%.o)
|
|
|
|
OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ)
|
|
DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d)
|
|
|
|
$(BINDIR)/$(MODULE)/:
|
|
$(Q)mkdir -p $@
|
|
|
|
$(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/
|
|
|
|
$(BINDIR)/$(MODULE).a: $(OBJ) | ${DIRS:%=ALL--%}
|
|
$(Q)$(AR) $(ARFLAGS) $@ $?
|
|
|
|
|
|
CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
|
|
|
|
# compile and generate dependency info
|
|
|
|
$(OBJC_LTO): CFLAGS+=$(LTOFLAGS)
|
|
|
|
$(OBJC): $(BINDIR)/$(MODULE)/%.o: %.c $(RIOTBUILD_CONFIG_HEADER_C)
|
|
$(Q)$(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)
|
|
$(Q)$(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
|
|
$(Q)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
|
|
|
|
$(ASSMOBJ): $(BINDIR)/$(MODULE)/%.o: %.S
|
|
$(Q)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
|
|
|
|
# pull in dependency info for *existing* .o files
|
|
# deleted header files will be silently ignored
|
|
-include $(DEP)
|