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-03-09 23:47:21 +01:00
|
|
|
ASMSRC = $(wildcard *.s)
|
2013-05-14 18:31:47 +02:00
|
|
|
ASSMSRC = $(wildcard *.S)
|
2014-02-15 12:31:43 +01:00
|
|
|
ASMOBJ = $(ASMSRC:%.s=$(BINDIR)$(MODULE)/%.o)
|
|
|
|
ASMOBJ += $(ASSMSRC:%.S=$(BINDIR)$(MODULE)/%.o)
|
2013-05-14 18:31:47 +02:00
|
|
|
|
2013-10-29 16:26:42 +01:00
|
|
|
ifeq ($(strip $(SRC)),)
|
|
|
|
SRC = $(wildcard *.c)
|
|
|
|
endif
|
2014-06-25 03:17:20 +02:00
|
|
|
|
|
|
|
ifeq ($(strip $(SRCXX)),)
|
|
|
|
SRCXX = $(wildcard *.cpp)
|
|
|
|
endif
|
|
|
|
|
|
|
|
OBJC = $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
|
|
|
|
OBJCXX = $(SRCXX:%.cpp=$(BINDIR)$(MODULE)/%.o)
|
|
|
|
|
|
|
|
OBJ = $(OBJC)
|
|
|
|
OBJ += $(OBJCXX)
|
|
|
|
|
2014-02-15 12:31:43 +01:00
|
|
|
DEP = $(SRC:%.c=$(BINDIR)$(MODULE)/%.d)
|
2014-06-25 03:17:20 +02:00
|
|
|
DEP += $(SRCXX:%.cpp=$(BINDIR)$(MODULE)/%.d)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-08-13 20:23:08 +02:00
|
|
|
$(BINDIR)$(MODULE)/:
|
|
|
|
$(AD)mkdir -p $@
|
|
|
|
|
|
|
|
$(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ) ${DIRS:%=ALL--%} $(BINDIR)$(MODULE)/
|
2014-01-03 19:00:41 +01:00
|
|
|
$(AD)$(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
|
|
|
# pull in dependency info for *existing* .o files
|
2014-06-18 23:25:07 +02:00
|
|
|
# deleted header files will be silently ignored
|
2013-02-06 13:20:21 +01:00
|
|
|
-include $(OBJ:.o=.d)
|
|
|
|
|
2014-06-18 23:25:07 +02:00
|
|
|
# compile and generate dependency info
|
2014-08-13 20:23:08 +02:00
|
|
|
$(BINDIR)$(MODULE)/%.o: %.c $(BINDIR)$(MODULE)/
|
2014-06-19 11:20:32 +02:00
|
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $(BINDIR)$(MODULE)/$*.o $(abspath $*.c)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-08-13 20:23:08 +02:00
|
|
|
$(BINDIR)$(MODULE)/%.o: %.cpp $(BINDIR)$(MODULE)/
|
2014-06-25 03:17:20 +02:00
|
|
|
$(AD)$(CXX) $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) $(INCLUDES) -MD -MP -c -o $(BINDIR)$(MODULE)/$*.o $(abspath $*.cpp)
|
|
|
|
|
2014-08-13 20:23:08 +02:00
|
|
|
$(BINDIR)$(MODULE)/%.o: %.s $(BINDIR)$(MODULE)/
|
2014-02-15 12:31:43 +01:00
|
|
|
$(AD)$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$(MODULE)/$*.o
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2014-08-13 20:23:08 +02:00
|
|
|
$(BINDIR)$(MODULE)/%.o: %.S $(BINDIR)$(MODULE)/
|
2014-06-19 11:20:32 +02:00
|
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $(BINDIR)$(MODULE)/$*.o $(abspath $*.S)
|