mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
47 lines
1.3 KiB
Makefile
47 lines
1.3 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)
|
|
$(AD)$(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
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MM $*.c > $(BINDIR)$*.d
|
|
@printf "$(BINDIR)"|cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d
|
|
|
|
$(BINDIR)%.o: %.s
|
|
$(AD)$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$*.o
|
|
|
|
$(BINDIR)%.o: %.S
|
|
$(AD)$(CC) -c $(CFLAGS) $*.S -o $(BINDIR)$*.o
|
|
|
|
# remove compilation products
|
|
clean::
|
|
$(AD)rm -f $(BINDIR)$(MODULE).a $(OBJ) $(DEP) $(ASMOBJ)
|