mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
182b603a01
This fixes an error which was introduced by commit
346313bf07
The timestamp of directories is updated when a file inside a directory
is changed.
Therefore, make decides a target needs to be rebuilt, whenever that
target depends on its parent directory, because the directory is
always newer than the file inside.
http://www.gnu.org/savannah-checkouts/gnu/make/manual/html_node/Prerequisite-Types.html
Occasionally, however, you have a situation where you want to
impose a specific ordering on the rules to be invoked without
forcing the target to be updated if one of those rules is
executed. In that case, you want to define order-only
prerequisites. Order-only prerequisites can be specified by
placing a pipe symbol (|) in the prerequisites list: any
prerequisites to the left of the pipe symbol are normal; any
prerequisites to the right are order-only:
targets : normal-prerequisites | order-only-prerequisites
74 lines
1.7 KiB
Makefile
74 lines
1.7 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 := $(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
|
|
|
|
ifeq ($(strip $(SRC)),)
|
|
SRC := $(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 := $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
|
|
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)/:
|
|
$(AD)mkdir -p $@
|
|
|
|
$(BINDIR)$(MODULE).a $(OBJ): | $(BINDIR)$(MODULE)/
|
|
|
|
$(BINDIR)$(MODULE).a: $(OBJ) | ${DIRS:%=ALL--%}
|
|
$(AD)$(AR) -rcs $@ $(OBJ)
|
|
|
|
|
|
CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
|
|
|
|
# compile and generate dependency info
|
|
|
|
$(OBJC): $(BINDIR)$(MODULE)/%.o: %.c
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
|
|
|
|
$(OBJCXX): $(BINDIR)$(MODULE)/%.o: %.cpp
|
|
$(AD)$(CXX) $(CXXFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
|
|
|
|
$(ASMOBJ): $(BINDIR)$(MODULE)/%.o: %.s
|
|
$(AD)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
|
|
|
|
$(ASSMOBJ): $(BINDIR)$(MODULE)/%.o: %.S
|
|
$(AD)$(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)
|