2013-03-09 23:47:21 +01:00
|
|
|
ASMSRC = $(wildcard *.s)
|
2013-05-14 18:31:47 +02:00
|
|
|
ASSMSRC = $(wildcard *.S)
|
2013-03-09 23:47:21 +01:00
|
|
|
ASMOBJ = $(ASMSRC:%.s=$(BINDIR)%.o)
|
2013-05-14 18:31:47 +02:00
|
|
|
ASMOBJ += $(ASSMSRC:%.S=$(BINDIR)%.o)
|
|
|
|
|
2013-10-29 16:26:42 +01:00
|
|
|
ifeq ($(strip $(SRC)),)
|
|
|
|
SRC = $(wildcard *.c)
|
|
|
|
endif
|
2013-03-09 23:47:21 +01:00
|
|
|
OBJ = $(SRC:%.c=$(BINDIR)%.o)
|
|
|
|
DEP = $(SRC:%.c=$(BINDIR)%.d)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2013-11-23 17:22:27 +01:00
|
|
|
GIT_STRING := $(shell git describe --abbrev=4 --dirty=-`hostname`)
|
2013-11-27 17:21:55 +01:00
|
|
|
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
|
2013-11-23 17:22:27 +01:00
|
|
|
ifeq ($(strip $(GIT_VERSION)),)
|
|
|
|
GIT_VERSION := "UNKNOWN"
|
|
|
|
endif
|
|
|
|
export CFLAGS += -DVERSION=\"$(GIT_VERSION)\"
|
|
|
|
|
2013-08-08 15:44:44 +02:00
|
|
|
.PHONY: clean
|
|
|
|
|
2013-05-30 17:52:54 +02:00
|
|
|
$(BINDIR)$(MODULE).a: $(OBJ) $(ASMOBJ)
|
2014-01-03 19:00:41 +01:00
|
|
|
$(AD)$(AR) -rc $(BINDIR)$(MODULE).a $(OBJ) $(ASMOBJ)
|
2013-02-06 13:20:21 +01:00
|
|
|
|
|
|
|
# pull in dependency info for *existing* .o files
|
|
|
|
-include $(OBJ:.o=.d)
|
|
|
|
|
2014-02-26 09:18:42 +01:00
|
|
|
# compile and generate dependency info,
|
|
|
|
# prepend path to dependency info file
|
2013-02-06 13:20:21 +01:00
|
|
|
$(BINDIR)%.o: %.c
|
2014-01-03 19:00:41 +01:00
|
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$*.o
|
2014-02-26 09:18:42 +01:00
|
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MM $*.c |\
|
|
|
|
sed -e "1s|^|$(BINDIR)|" > $(BINDIR)$*.d
|
2013-02-06 13:20:21 +01:00
|
|
|
|
|
|
|
$(BINDIR)%.o: %.s
|
2014-01-03 19:00:41 +01:00
|
|
|
$(AD)$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$*.o
|
2013-02-06 13:20:21 +01:00
|
|
|
|
2013-05-14 18:31:47 +02:00
|
|
|
$(BINDIR)%.o: %.S
|
2014-01-03 19:00:41 +01:00
|
|
|
$(AD)$(CC) -c $(CFLAGS) $*.S -o $(BINDIR)$*.o
|
2013-05-14 18:31:47 +02:00
|
|
|
|
2013-02-06 13:20:21 +01:00
|
|
|
# remove compilation products
|
|
|
|
clean::
|
2014-01-03 19:00:41 +01:00
|
|
|
$(AD)rm -f $(BINDIR)$(MODULE).a $(OBJ) $(DEP) $(ASMOBJ)
|