Handle cases where ASM files have the same name as c, cpp files, leading to overriden .o

pull/4/head
Acanthostega 8 years ago
parent f2aa032de2
commit 22d757227d

@ -257,6 +257,7 @@ endif
# Arduino core sources. # Arduino core sources.
CORESRC = $(wildcard $(ARDUINO_CORE)/*.c) CORESRC = $(wildcard $(ARDUINO_CORE)/*.c)
CORECXXSRC = $(wildcard $(ARDUINO_CORE)/*.cpp) CORECXXSRC = $(wildcard $(ARDUINO_CORE)/*.cpp)
COREASMSRC = $(wildcard $(ARDUINO_CORE)/*.S)
# Arduino official library sources. # Arduino official library sources.
# 1.0.x: search in root and utility folders # 1.0.x: search in root and utility folders
@ -275,6 +276,7 @@ ALIBDIRS = $(wildcard \
) )
ALIBSRC = $(wildcard $(ALIBDIRS:%=%/*.c)) ALIBSRC = $(wildcard $(ALIBDIRS:%=%/*.c))
ALIBCXXSRC = $(wildcard $(ALIBDIRS:%=%/*.cpp)) ALIBCXXSRC = $(wildcard $(ALIBDIRS:%=%/*.cpp))
ALIBASMSRC = $(wildcard $(ALIBDIRS:%=%/*.S))
# All Arduino library sources. # All Arduino library sources.
ARDUINO_ALL_LIBS = $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*)) ARDUINO_ALL_LIBS = $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*))
@ -284,6 +286,7 @@ ALIBALLDIRS = $(wildcard \
) )
ALIBALLSRC = $(wildcard $(ALIBALLDIRS:%=%/*.c)) ALIBALLSRC = $(wildcard $(ALIBALLDIRS:%=%/*.c))
ALIBALLCXXSRC = $(wildcard $(ALIBALLDIRS:%=%/*.cpp)) ALIBALLCXXSRC = $(wildcard $(ALIBALLDIRS:%=%/*.cpp))
ALIBALLASMSRC = $(wildcard $(ALIBALLDIRS:%=%/*.S))
# User library sources. # User library sources.
ULIBDIRS = $(wildcard \ ULIBDIRS = $(wildcard \
@ -292,6 +295,7 @@ ULIBDIRS = $(wildcard \
) )
ULIBSRC = $(wildcard $(ULIBDIRS:%=%/*.c)) ULIBSRC = $(wildcard $(ULIBDIRS:%=%/*.c))
ULIBCXXSRC = $(wildcard $(ULIBDIRS:%=%/*.cpp)) ULIBCXXSRC = $(wildcard $(ULIBDIRS:%=%/*.cpp))
ULIBASMSRC = $(wildcard $(ULIBDIRS:%=%/*.S))
# User program sources. # User program sources.
SRC = $(wildcard *.c) SRC = $(wildcard *.c)
@ -347,33 +351,37 @@ CINCS = \
# Arduino core. # Arduino core.
COREOBJ = $(addprefix $(OUTPUT)/,$(notdir \ COREOBJ = $(addprefix $(OUTPUT)/,$(notdir \
$(CORESRC:.c=.o) \ $(CORESRC:.c=.c.o) \
$(CORECXXSRC:.cpp=.o) \ $(CORECXXSRC:.cpp=.cpp.o) \
$(COREASMSRC:.S=.S.o) \
)) ))
# Arduino libraries used. # Arduino libraries used.
ALIBOBJ = $(addprefix $(OUTPUT)/,$(notdir \ ALIBOBJ = $(addprefix $(OUTPUT)/,$(notdir \
$(ALIBSRC:.c=.o) \ $(ALIBSRC:.c=.c.o) \
$(ALIBCXXSRC:.cpp=.o) \ $(ALIBCXXSRC:.cpp=.cpp.o) \
$(ALIBASMSRC:.S=.S.o) \
)) ))
# All Arduino libraries. # All Arduino libraries.
ALIBALLOBJ = $(addprefix $(OUTPUT)/,$(notdir \ ALIBALLOBJ = $(addprefix $(OUTPUT)/,$(notdir \
$(ALIBALLSRC:.c=.o) \ $(ALIBALLSRC:.c=.c.o) \
$(ALIBALLCXXSRC:.cpp=.o) \ $(ALIBALLCXXSRC:.cpp=.cpp.o) \
$(ALIBALLASMSRC:.S=.S.o) \
)) ))
# User libraries used. # User libraries used.
ULIBOBJ = $(addprefix $(OUTPUT)/,$(notdir \ ULIBOBJ = $(addprefix $(OUTPUT)/,$(notdir \
$(ULIBSRC:.c=.o) \ $(ULIBSRC:.c=.c.o) \
$(ULIBCXXSRC:.cpp=.o) \ $(ULIBCXXSRC:.cpp=.cpp.o) \
$(ULIBASMSRC:.S=.S.o) \
)) ))
# User program. # User program.
OBJ = $(addprefix $(OUTPUT)/,$(notdir \ OBJ = $(addprefix $(OUTPUT)/,$(notdir \
$(SRC:.c=.o) \ $(SRC:.c=.c.o) \
$(CXXSRC:.cpp=.o) \ $(CXXSRC:.cpp=.cpp.o) \
$(ASRC:.S=.o) \ $(ASRC:.S=.S.o) \
)) ))
# All object files. # All object files.
@ -461,6 +469,7 @@ OPT_OTHER =
# Automatically enable build.extra_flags if needed # Automatically enable build.extra_flags if needed
# Used by Micro and other devices to fill in USB_PID and USB_VID # Used by Micro and other devices to fill in USB_PID and USB_VID
OPT_OTHER += -DUSB_VID=$(VID) -DUSB_PID=$(PID) OPT_OTHER += -DUSB_VID=$(VID) -DUSB_PID=$(PID)
OPT_OTHER += -fno-use-cxa-atexit
endif endif
# Final combined. # Final combined.
@ -516,7 +525,7 @@ AVRDUDE_FLAGS+= -P $(PORT)
# avrdude config file # avrdude config file
AVRDUDE_FLAGS+= -C /etc/avrdude.conf AVRDUDE_FLAGS+= -C /etc/avrdude.conf
#AVRDUDE_FLAGS+= -C $(ARDUINO_DIR)/hardware/tools/avrdude.conf #AVRDUDE_FLAGS+= -C $(ARDUINO_DIR)/hardware/tools/avr/etc/avrdude.conf
AVRDUDE_WRITE_FLASH = -U flash:w:$(OUTPUT)/$(PROJECT).hex:i AVRDUDE_WRITE_FLASH = -U flash:w:$(OUTPUT)/$(PROJECT).hex:i
@ -550,24 +559,24 @@ endif
.SUFFIXES: .cpp .c .S .o .a .SUFFIXES: .cpp .c .S .o .a
# Compile: create object files from C++ source files. # Compile: create object files from C++ source files.
%.o $(OUTPUT)/%.o: %.cpp %.cpp.o $(OUTPUT)/%.cpp.o: %.cpp
$(CXX) -o $@ -c $(CXXFLAGS) $< \ $(CXX) -o $@ -c $(CXXFLAGS) $< \
-MMD -MP -MF"$(@:%.o=%.d)" -MT"$@ $(@:%.o=%.S) $(@:%.o=%.d)" \ -MMD -MP -MF"$(@:%.cpp.o=%.d)" -MT"$@ $(@:%.cpp.o=%.S) $(@:%.cpp.o=%.d)" \
$(CINCS) $(CINCS)
if [ -f "$(notdir $(@:.o=.s))" -a ! -f "$(@:.o=.s)" ]; then \ if [ -f "$(notdir $(@:.cpp.o=.s))" -a ! -f "$(@:.cpp.o=.s)" ]; then \
mv "$(notdir $(@:.o=.s))" "$(dir $@)"; fi mv "$(notdir $(@:.cpp.o=.s))" "$(dir $@)"; fi
if [ -f "$(notdir $(@:.o=.ii))" -a ! -f "$(@:.o=.ii)" ]; then \ if [ -f "$(notdir $(@:.cpp.o=.ii))" -a ! -f "$(@:.cpp.o=.ii)" ]; then \
mv "$(notdir $(@:.o=.ii))" "$(dir $@)"; fi mv "$(notdir $(@:.cpp.o=.ii))" "$(dir $@)"; fi
# Compile: create object files from C source files. # Compile: create object files from C source files.
%.o $(OUTPUT)/%.o: %.c %.c.o $(OUTPUT)/%.c.o: %.c
$(CC) -o $@ -c $(CFLAGS) $< \ $(CC) -o $@ -c $(CFLAGS) $< \
-MMD -MP -MF"$(@:%.o=%.d)" -MT"$@ $(@:%.o=%.S) $(@:%.o=%.d)" \ -MMD -MP -MF"$(@:%.c.o=%.d)" -MT"$@ $(@:%.c.o=%.S) $(@:%.c.o=%.d)" \
$(CINCS) $(CINCS)
if [ -f "$(notdir $(@:.o=.s))" -a ! -f "$(@:.o=.s)" ]; then \ if [ -f "$(notdir $(@:.c.o=.s))" -a ! -f "$(@:.c.o=.s)" ]; then \
mv "$(notdir $(@:.o=.s))" "$(dir $@)"; fi mv "$(notdir $(@:.c.o=.s))" "$(dir $@)"; fi
if [ -f "$(notdir $(@:.o=.i))" -a ! -f "$(@:.o=.i)" ]; then \ if [ -f "$(notdir $(@:.c.o=.i))" -a ! -f "$(@:.c.o=.i)" ]; then \
mv "$(notdir $(@:.o=.i))" "$(dir $@)"; fi mv "$(notdir $(@:.c.o=.i))" "$(dir $@)"; fi
# Compile: create assembler files from C++ source files. # Compile: create assembler files from C++ source files.
%.S $(OUTPUT)/%.S: %.cpp %.S $(OUTPUT)/%.S: %.cpp
@ -582,9 +591,9 @@ endif
$(CINCS) $(CINCS)
# Assemble: create object files from assembler source files. # Assemble: create object files from assembler source files.
%.o $(OUTPUT)/%.o: %.S %.S.o $(OUTPUT)/%.S.o: %.S
$(CC) -o $@ -c $(ASFLAGS) $< \ $(CC) -o $@ -c $(ASFLAGS) $< \
-MMD -MP -MF"$(@:%.o=%.d)" -MT"$@ $(@:%.o=%.S) $(@:%.o=%.d)" \ -MMD -MP -MF"$(@:%.S.o=%.d)" -MT"$@ $(@:%.S.o=%.S) $(@:%.S.o=%.d)" \
$(CINCS) $(CINCS)
# Create extended listing file from object file. # Create extended listing file from object file.

Loading…
Cancel
Save