1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/Makefile.base

71 lines
1.8 KiB
Makefile
Raw Normal View History

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
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
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)
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-08-13 20:46:47 +02:00
OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ)
DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d)
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)
2014-08-13 20:41:48 +02:00
CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
# 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 $<)
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-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 $<)
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)