ath79: lzma-loader: sync with ar71xx target
[openwrt/openwrt.git] / target / linux / ath79 / image / lzma-loader / src / Makefile
index 133bf6ee8f57a17d3635d900b49dac53d7dea42e..7773f027a24975bb7204b1dec141e3bd39092874 100644 (file)
@@ -21,7 +21,6 @@ LOADER_DATA   :=
 BOARD          :=
 FLASH_OFFS     :=
 FLASH_MAX      :=
-KERNEL_CMDLINE := rootfstype=squashfs
 
 CC             := $(CROSS_COMPILE)gcc
 LD             := $(CROSS_COMPILE)ld
@@ -34,15 +33,17 @@ BIN_FLAGS   := -O binary -R .reginfo -R .note -R .comment -R .mdebug \
 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 -ffreestanding -fhonour-copts \
+                 -fno-common -ffreestanding -fhonour-copts -nostartfiles \
                  -mabi=32 -march=mips32r2 \
                  -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap
 CFLAGS         += -D_LZMA_PROB32
+CFLAGS         += -flto
 
 ASFLAGS                = $(CFLAGS) -D__ASSEMBLY__
 
-LDFLAGS                = -static --gc-sections -no-warn-mismatch
-LDFLAGS                += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START)
+LDFLAGS                = -static -Wl,--gc-sections -Wl,-no-warn-mismatch
+LDFLAGS                += -Wl,-e,startup -T loader.lds -Wl,-Ttext,$(LZMA_TEXT_START)
+LDFLAGS                += -flto -fwhole-program
 
 O_FORMAT       = $(shell $(OBJDUMP) -i | head -2 | grep elf32)
 
@@ -87,7 +88,7 @@ data.o: $(LOADER_DATA)
        $(LD) -r -b binary --oformat $(O_FORMAT) -T lzma-data.lds -o $@ $<
 
 loader: $(OBJECTS)
-       $(LD) $(LDFLAGS) -o $@ $(OBJECTS)
+       $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS)
 
 loader.bin: loader
        $(OBJCOPY) $(BIN_FLAGS) $< $@
@@ -96,7 +97,7 @@ loader2.o: loader.bin
        $(LD) -r -b binary --oformat $(O_FORMAT) -o $@ $<
 
 loader.elf: loader2.o
-       $(LD) -e startup -T loader2.lds -Ttext $(LOADADDR) -o $@ $<
+       $(LD) -z max-page-size=0x1000 -e startup -T loader2.lds -Ttext $(LOADADDR) -o $@ $<
 
 mrproper: clean