X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/14f5c350584f1b0f282cfe7724965fb44494b3eb..39b1fcd53263cb1513d56bd20d02a00a2c8fc914:/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile diff --git a/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile b/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile index 85a864674..0f4ffa63a 100644 --- a/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile +++ b/target/linux/adm5120-2.6/image/lzma-loader/src/Makefile @@ -3,7 +3,7 @@ # # Copyright 2001-2003, Broadcom Corporation # All Rights Reserved. -# +# # THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY # KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM # SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS @@ -16,62 +16,71 @@ # Copyright 2005 Oleg I. Vdovikin # Cleaned up, modified for lzma support, removed from kernel # +# Copyright 2007 Gabor Juhos +# Modified to support user defined entry point address. +# Added support for make targets with different names +# + +LOADADDR := 0x80001000 +LZMA_TEXT_START := 0x80500000 +LZMA_STARTUP_ORG:= 0 +LOADER_DATA := -TEXT_START := 0x80001000 -BZ_TEXT_START := 0x80300000 +CC := $(CROSS_COMPILE)gcc +LD := $(CROSS_COMPILE)ld +OBJCOPY := $(CROSS_COMPILE)objcopy +OBJDUMP := $(CROSS_COMPILE)objdump -OBJCOPY := $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S +BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug -S CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \ -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic \ -ffunction-sections -pipe -mlong-calls -fno-common \ -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -CFLAGS += -DLOADADDR=$(TEXT_START) -D_LZMA_IN_CB +CFLAGS += -DLOADADDR=$(LOADADDR) -ASFLAGS = $(CFLAGS) -D__ASSEMBLY__ -DBZ_TEXT_START=$(BZ_TEXT_START) +ASFLAGS = $(CFLAGS) -D__ASSEMBLY__ -DLZMA_STARTUP_ORG=$(LZMA_STARTUP_ORG) -SEDFLAGS := s/BZ_TEXT_START/$(BZ_TEXT_START)/;s/TEXT_START/$(TEXT_START)/ +LDFLAGS = -static --gc-sections -no-warn-mismatch +LDFLAGS += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START) -OBJECTS := head.o data.o +O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32) -all: loader.gz loader.elf +OBJECTS := head.o decompress.o board.o LzmaDecode.o + +ifneq ($(strip $(LOADER_DATA)),) +OBJECTS += data.o +CFLAGS += -DLZMA_WRAPPER=1 +else +CFLAGS += -D_LZMA_IN_CB +endif + +all: loader.bin # Don't build dependencies, this may die if $(CC) isn't gcc dep: install: -loader.gz: loader - gzip -nc9 $< > $@ - -loader.elf: loader.o - cp $< $@ +%.o : %.c + $(CC) $(CFLAGS) -c -o $@ $< -loader: loader.o - $(OBJCOPY) $< $@ +%.o : %.S + $(CC) $(ASFLAGS) -c -o $@ $< -loader.o: loader.lds $(OBJECTS) - $(LD) -static --gc-sections -no-warn-mismatch -T loader.lds -o $@ $(OBJECTS) +data.o: $(LOADER_DATA) + $(LD) -r -b binary --oformat $(O_FORMAT) -T lzma-data.lds -o $@ $< -loader.lds: loader.lds.in Makefile - @sed "$(SEDFLAGS)" < $< > $@ +loader.bin: loader.elf + $(OBJCOPY) $(BIN_FLAGS) $< $@ -data.o: data.lds decompress.image - $(LD) -no-warn-mismatch -T data.lds -r -o $@ -b binary decompress.image -b elf32-tradlittlemips +loader.elf: $(OBJECTS) + $(LD) $(LDFLAGS) -o $@ $(OBJECTS) -data.lds: - @echo "SECTIONS { .data : { code_start = .; *(.data) code_stop = .; }}" > $@ +mrproper: clean -decompress.image: decompress - $(OBJCOPY) $< $@ +clean: + rm -f *.gz *.elf *.bin *.o -decompress: decompress.lds decompress.o LzmaDecode.o - $(LD) -static --gc-sections -no-warn-mismatch -T decompress.lds -o $@ decompress.o LzmaDecode.o -decompress.lds: decompress.lds.in Makefile - @sed "$(SEDFLAGS)" < $< > $@ -mrproper: clean - -clean: - rm -f loader.gz loader decompress *.lds *.o *.image