software: run the assembler ourselves to prevent future time wastage due to breakage of our custom Clang toolchain

This commit is contained in:
Sebastien Bourdeauducq 2013-01-10 17:20:31 +01:00
parent c490917aec
commit c5c29199be
3 changed files with 27 additions and 12 deletions

View File

@ -27,6 +27,9 @@ bios-rescue.elf: linker-rescue.ld $(OBJECTS) libs
%.o: %.c %.o: %.c
$(compile-dep) $(compile-dep)
%.o: %.S
$(assemble)
libs: libs:
make -C $(M2DIR)/software/libbase make -C $(M2DIR)/software/libbase

View File

@ -2,29 +2,33 @@ TARGET_PREFIX=lm32-elf
CLANG=clang -target lm32 CLANG=clang -target lm32
CC_normal := $(CLANG) CC_normal := $(CLANG)
AS_normal := $(TARGET_PREFIX)-as
AR_normal := $(TARGET_PREFIX)-ar AR_normal := $(TARGET_PREFIX)-ar
LD_normal := $(TARGET_PREFIX)-ld LD_normal := $(TARGET_PREFIX)-ld
OBJCOPY_normal := $(TARGET_PREFIX)-objcopy OBJCOPY_normal := $(TARGET_PREFIX)-objcopy
RANLIB_normal := $(TARGET_PREFIX)-ranlib RANLIB_normal := $(TARGET_PREFIX)-ranlib
CC_quiet = @echo " CC " $@ && $(CLANG) CC_quiet = @echo " CC " $@ && $(CLANG)
AS_quiet = @echo " AS " $@ && $(TARGET_PREFIX)-as
AR_quiet = @echo " AR " $@ && $(TARGET_PREFIX)-ar AR_quiet = @echo " AR " $@ && $(TARGET_PREFIX)-ar
LD_quiet = @echo " LD " $@ && $(TARGET_PREFIX)-ld LD_quiet = @echo " LD " $@ && $(TARGET_PREFIX)-ld
OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(TARGET_PREFIX)-objcopy OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(TARGET_PREFIX)-objcopy
RANLIB_quiet = @echo " RANLIB " $@ && $(TARGET_PREFIX)-ranlib RANLIB_quiet = @echo " RANLIB " $@ && $(TARGET_PREFIX)-ranlib
ifeq ($(V),1) ifeq ($(V),1)
CC = $(CC_normal) CC = $(CC_normal)
AR = $(AR_normal) AS = $(AS_normal)
LD = $(LD_normal) AR = $(AR_normal)
OBJCOPY = $(OBJCOPY_normal) LD = $(LD_normal)
RANLIB = $(RANLIB_normal) OBJCOPY = $(OBJCOPY_normal)
RANLIB = $(RANLIB_normal)
else else
CC = $(CC_quiet) CC = $(CC_quiet)
AR = $(AR_quiet) AS = $(AS_quiet)
LD = $(LD_quiet) AR = $(AR_quiet)
OBJCOPY = $(OBJCOPY_quiet) LD = $(LD_quiet)
RANLIB = $(RANLIB_quiet) OBJCOPY = $(OBJCOPY_quiet)
RANLIB = $(RANLIB_quiet)
endif endif
# Toolchain options # Toolchain options
@ -37,12 +41,17 @@ LDFLAGS = -nostdlib -nodefaultlibs
# compile and generate dependencies, based on # compile and generate dependencies, based on
# http://scottmcpeak.com/autodepend/autodepend.html # http://scottmcpeak.com/autodepend/autodepend.html
define compile-dep = define compile-dep
$(CC) -c $(CFLAGS) $< -o $*.o $(CC) -c $(CFLAGS) $< -o $*.ts -S
@$(CC_normal) -MM $(CFLAGS) $< > $*.d @$(CC_normal) -MM $(CFLAGS) $< > $*.d
@mv -f $*.d $*.d.tmp @mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \ @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp @rm -f $*.d.tmp
@$(AS_normal) -o $*.o $*.ts
endef
define assemble
$(AS) -o $*.o $<
endef endef

View File

@ -15,6 +15,9 @@ libbase.a: $(OBJECTS)
%.o: %.c %.o: %.c
$(compile-dep) $(compile-dep)
%.o: %.S
$(assemble)
.PHONY: clean .PHONY: clean
clean: clean: