mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
7229287e47
The old way was error prone due to it's use of a fixed path file and confusing. closes #775
48 lines
1.3 KiB
Makefile
48 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
|
|
@# prepend path to dependency info file
|
|
$(AD)sed -i -e "1s|^|$(BINDIR)|" $(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)
|