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

48 lines
1.2 KiB
Makefile

ASMSRC = $(wildcard *.s)
ASSMSRC = $(wildcard *.S)
ASMOBJ = $(ASMSRC:%.s=$(BINDIR)%.o)
ASMOBJ += $(ASSMSRC:%.S=$(BINDIR)%.o)
ifeq ($(strip $(SRC)),)
SRC = $(wildcard *.c)
endif
OBJ = $(SRC:%.c=$(BINDIR)%.o)
DEP = $(SRC:%.c=$(BINDIR)%.d)
GIT_STRING := $(shell git describe --abbrev=4 --dirty=-`hostname`)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
ifeq ($(strip $(GIT_BRANCH)),master)
GIT_VERSION = $(GIT_STRING)
else
GIT_VERSION = $(shell echo $(GIT_STRING) $(GIT_BRANCH) | sed 's/ /-/')
endif
ifeq ($(strip $(GIT_VERSION)),)
GIT_VERSION := "UNKNOWN"
endif
export CFLAGS += -DVERSION=\"$(GIT_VERSION)\"
.PHONY: clean
$(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ)
@$(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ)
# pull in dependency info for *existing* .o files
-include $(OBJ:.o=.d)
# compile and generate dependency info
$(BINDIR)%.o: %.c
@$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o
@$(CC) $(CFLAGS) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d
@printf "$(BINDIR)"|cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d
$(BINDIR)%.o: %.s
@$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$*.o
$(BINDIR)%.o: %.S
@$(CC) -c $(CFLAGS) $*.S -o $(BINDIR)$*.o
# remove compilation products
clean::
@rm -f $(BINDIR)$(MODULE).a $(OBJ) $(DEP) $(ASMOBJ)