You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

ifeq (, $(__RIOTBUILD_FLAG))
$(error You cannot build a module on its own. Use "make" in your application's directory instead.)
unexport DIRS
DIRS := $(abspath ${DIRS})
MODULE ?= $(shell basename $(CURDIR))
.PHONY: all ${DIRS:%=ALL--%} ${DIRS:%=CLEAN--%}
all: $(BINDIR)$(MODULE).a ..nothing
clean:: ${DIRS:%=CLEAN--%}
"$(MAKE)" -C ${@:ALL--%=%}
"$(MAKE)" -C ${@:CLEAN--%=%} clean
ASMSRC = $(wildcard *.s)
ASSMSRC = $(wildcard *.S)
ifeq ($(strip $(SRC)),)
SRC = $(wildcard *.c)
OBJ = $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
DEP = $(SRC:%.c=$(BINDIR)$(MODULE)/%.d)
@mkdir -p $(BINDIR)$(MODULE)
$(AD)$(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ)
# pull in dependency info for *existing* .o files
# deleted header files will be silently ignored
-include $(OBJ:.o=.d)
# compile and generate dependency info
$(BINDIR)$(MODULE)/%.o: %.c
@mkdir -p $(BINDIR)$(MODULE)
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $(BINDIR)$(MODULE)/$*.o $(abspath $*.c)
$(BINDIR)$(MODULE)/%.o: %.s
@mkdir -p $(BINDIR)$(MODULE)
$(AD)$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$(MODULE)/$*.o
$(BINDIR)$(MODULE)/%.o: %.S
@mkdir -p $(BINDIR)$(MODULE)
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MD -MP -c -o $(BINDIR)$(MODULE)/$*.o $(abspath $*.S)