diff --git a/apps/Makefile b/apps/Makefile index 4fa225033b..278e1c7118 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -107,9 +107,23 @@ $(OBJDIR)/rombox.bin : $(OBJDIR)/rombox.elf $(OBJDIR)/rockbox.asm: $(OBJDIR)/rockbox.bin $(TOOLSDIR)/sh2d -sh1 $< > $@ -$(BUILDDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin +# +# If there's a flashfile defined for this target (rockbox.ucl for Archos +# models) Then check if the mkfirmware script fails, as then it is (likely) +# because the image is too big and we need to create a compressed image +# instead. +# +$(BUILDDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin $(FLASHFILE) @echo "Build firmware file" - $(SILENT)$(MKFIRMWARE) $< $@ + $(SILENT)($(MKFIRMWARE) $< $@; \ + stat=$$?; \ + if test -n "$(FLASHFILE)"; then \ + if test "$$stat" -ne 0; then \ + echo "Image too big, making a compressed version!"; \ + $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \ + $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \ + fi \ + fi ) else # this is a simulator build diff --git a/firmware/decompressor/Makefile b/firmware/decompressor/Makefile index 4136eafdb7..5e4e73912e 100644 --- a/firmware/decompressor/Makefile +++ b/firmware/decompressor/Makefile @@ -7,43 +7,46 @@ # $Id$ # -CC = sh-elf-gcc -LD = sh-elf-ld -AR = sh-elf-ar -AS = sh-elf-as -OC = sh-elf-objcopy - -TOOLSDIR=../../tools -OBJDIR := . -# FIXME: get proper value from build system -MEMORYSIZE = 2 +ifndef V +SILENT=@ +endif LDS := link.lds LINKFILE = $(OBJDIR)/linkage.lds OBJS := $(OBJDIR)/decompressor.o $(OBJDIR)/uclimage.o $(OBJDIR)/startup.o - -CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns +CFLAGS = $(GCCOPTS) all: $(OBJDIR)/compressed.bin $(OBJDIR)/compressed.bin : $(OBJDIR)/compressed.elf @echo "OBJCOPY "`basename $@` - @$(OC) -O binary $< $@ + $(SILENT)$(OC) -O binary $< $@ $(OBJDIR)/compressed.elf : $(OBJS) $(LINKFILE) - @echo "LD rockbox.elf" - @$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/compressed.map + @echo "LD `basename $@`" + $(SILENT)$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/compressed.map $(LINKFILE): $(LDS) @echo "Build LDS file" - @cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@ + $(SILENT)cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@ -$(OBJDIR)/decompressor.o : $(OBJDIR)/uclimage.h +$(OBJDIR)/decompressor.o : decompressor.c $(OBJDIR)/uclimage.c + $(SILENT)mkdir -p `dirname $@` + @echo "CC $<" + $(SILENT)$(CC) $(CFLAGS) -I$(OBJDIR) -c $< -o $@ -$(OBJDIR)/uclimage.c : $(OBJDIR)/rockbox.ucl $(TOOLSDIR)/ucl2src.pl +$(OBJDIR)/startup.o : startup.S + $(SILENT)mkdir -p `dirname $@` + @echo "AS $<" + $(SILENT)$(CC) $(CFLAGS) -c $< -o $@ + +$(OBJDIR)/uclimage.o : $(OBJDIR)/uclimage.c + $(SILENT)mkdir -p `dirname $@` + @echo "CC `basename $<`" + $(SILENT)$(CC) $(CFLAGS) -c $< -o $@ + +$(OBJDIR)/uclimage.c : $(FLASHFILE) $(TOOLSDIR)/ucl2src.pl + $(SILENT)mkdir -p `dirname $@` @echo "UCL2SRC" - @perl -s $(TOOLSDIR)/ucl2src.pl -p=uclimage $< $@ + $(SILENT)perl -s $(TOOLSDIR)/ucl2src.pl -p=$(OBJDIR)/uclimage $< -$(OBJDIR)/uclimage.h : $(OBJDIR)/rockbox.ucl $(TOOLSDIR)/ucl2src.pl - @echo "UCL2SRC" - @perl -s $(TOOLSDIR)/ucl2src.pl -p=uclimage $< $@