mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
3f59eefbaf
Creating all object files in one directory is bound to produce name clashes. RIOT developers may take care to use unique file names, but external packages surely don't. With this change all the objects of a module (e.g. `shell`) will be created in `bin/$(BOARD)/$(MODULE)`. I compared the final linker command before and after the change. The `.o` files (e.g. `startup.o`, `syscall.o` ...) are included in the same order. Neglecting the changed path name where the `.o` files reside, the linker command stays exactly the same. A major problem could be third party boards, because the location of the `startup.o` needs to the specified now in `boards/$(BOARD)/Makefile.include`, e.g. ```Makefile export UNDEF += $(BINDIR)msp430_common/startup.o ```
51 lines
1.5 KiB
Makefile
51 lines
1.5 KiB
Makefile
ASMSRC = $(wildcard *.s)
|
|
ASSMSRC = $(wildcard *.S)
|
|
ASMOBJ = $(ASMSRC:%.s=$(BINDIR)$(MODULE)/%.o)
|
|
ASMOBJ += $(ASSMSRC:%.S=$(BINDIR)$(MODULE)/%.o)
|
|
|
|
ifeq ($(strip $(SRC)),)
|
|
SRC = $(wildcard *.c)
|
|
endif
|
|
OBJ = $(SRC:%.c=$(BINDIR)$(MODULE)/%.o)
|
|
DEP = $(SRC:%.c=$(BINDIR)$(MODULE)/%.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,
|
|
# prepend path to dependency info file
|
|
$(BINDIR)$(MODULE)/%.o: %.c
|
|
@mkdir -p $(BINDIR)$(MODULE)
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -c $*.c -o $(BINDIR)$(MODULE)/$*.o
|
|
$(AD)$(CC) $(CFLAGS) $(INCLUDES) -MM $*.c |\
|
|
sed -e "1s|^|$(BINDIR)$(MODULE)/|" > $(BINDIR)$(MODULE)/$*.d
|
|
|
|
$(BINDIR)$(MODULE)/%.o: %.s
|
|
@mkdir -p $(BINDIR)$(MODULE)
|
|
$(AD)$(AS) $(ASFLAGS) $*.s -o $(BINDIR)$(MODULE)/$*.o
|
|
|
|
$(BINDIR)$(MODULE)/%.o: %.S
|
|
@mkdir -p $(BINDIR)$(MODULE)
|
|
$(AD)$(CC) -c $(CFLAGS) $*.S -o $(BINDIR)$(MODULE)/$*.o
|
|
|
|
# remove compilation products
|
|
clean::
|
|
$(AD)rm -f $(BINDIR)$(MODULE).a $(OBJ) $(DEP) $(ASMOBJ)
|