2014-05-15 17:12:42 +02:00
|
|
|
ifeq (, $(__RIOTBUILD_FLAG))
|
|
|
|
$(error You cannot build a module on its own. Use "make" in your application's directory instead.)
|
|
|
|
endif
|
|
|
|
|
2014-06-18 11:21:05 +02:00
|
|
|
unexport DIRS
|
2014-06-19 11:20:32 +02:00
|
|
|
DIRS := $(abspath ${DIRS})
|
2014-06-18 11:21:05 +02:00
|
|
|
|
2014-06-17 03:34:17 +02:00
|
|
|
MODULE ?= $(shell basename $(CURDIR))
|
|
|
|
|
2014-06-18 11:00:33 +02:00
|
|
|
.PHONY: all ${DIRS:%=ALL--%} ${DIRS:%=CLEAN--%}
|
2014-06-17 04:01:10 +02:00
|
|
|
|
2014-06-18 11:00:33 +02:00
|
|
|
all: $(BINDIR)$(MODULE).a ..nothing
|
|
|
|
|
|
|
|
..nothing:
|
|
|
|
@:
|
|
|
|
|
|
|
|
clean:: ${DIRS:%=CLEAN--%}
|
|
|
|
|
|
|
|
${DIRS:%=ALL--%}:
|
|
|
|
"$(MAKE)" -C ${@:ALL--%=%}
|
|
|
|
|
|
|
|
${DIRS:%=CLEAN--%}:
|
|
|
|
"$(MAKE)" -C ${@:CLEAN--%=%} clean
|
2014-06-17 04:01:10 +02:00
|
|
|
|
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
|
2014-06-25 03:17:20 +02:00
|
|
|
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)
|
2014-06-25 03:17:20 +02:00
|
|
|
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-06-25 03:17:20 +02:00
|
|
|
|
2014-08-13 20:46:47 +02:00
|
|
|
OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ)
|
|
|
|
DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-08-13 20:23:08 +02:00
|
|
|
$(BINDIR)$(MODULE)/:
|
|
|
|
$(AD)mkdir -p $@
|
|
|
|
|
2014-08-13 20:44:36 +02:00
|
|
|
$(BINDIR)$(MODULE).a: $(OBJ) ${DIRS:%=ALL--%} $(BINDIR)$(MODULE)/
|
|
|
|
$(AD)$(AR) -rcs $@ $(OBJ)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-08-13 20:41:48 +02:00
|
|
|
CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-06-18 23:25:07 +02:00
|
|
|
# compile and generate dependency info
|
2014-08-13 20:41:48 +02:00
|
|
|
|
2014-08-13 20:48:03 +02:00
|
|
|
$(OBJC): $(BINDIR)$(MODULE)/%.o: %.c $(BINDIR)$(MODULE)/
|
2014-08-13 20:41:48 +02:00
|
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-08-13 20:48:03 +02:00
|
|
|
$(OBJCXX): $(BINDIR)$(MODULE)/%.o: %.cpp $(BINDIR)$(MODULE)/
|
2014-08-13 20:41:48 +02:00
|
|
|
$(AD)$(CXX) $(CXXFLAGS) $(INCLUDES) -MD -MP -c -o $@ $(abspath $<)
|
2014-06-25 03:17:20 +02:00
|
|
|
|
2014-08-13 20:48:03 +02:00
|
|
|
$(ASMOBJ): $(BINDIR)$(MODULE)/%.o: %.s $(BINDIR)$(MODULE)/
|
2014-08-13 20:41:48 +02:00
|
|
|
$(AD)$(AS) $(ASFLAGS) -o $@ $(abspath $<)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-08-13 20:48:03 +02:00
|
|
|
$(ASSMOBJ): $(BINDIR)$(MODULE)/%.o: %.S $(BINDIR)$(MODULE)/
|
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)
|