diff options
author | Felix Fietkau <nbd@openwrt.org> | 2006-06-04 21:57:59 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2006-06-04 21:57:59 +0000 |
commit | bd5e0bc352fdafd494be6f403a8a075ec1dcdbf8 (patch) | |
tree | 4e4ebb4786454272f73ed7e3ea76e57ea789de41 /target | |
parent | 453ddad41bafe6f4c9bf043ddf4d7f00f04353b4 (diff) | |
download | master-187ad058-bd5e0bc352fdafd494be6f403a8a075ec1dcdbf8.tar.gz master-187ad058-bd5e0bc352fdafd494be6f403a8a075ec1dcdbf8.tar.bz2 master-187ad058-bd5e0bc352fdafd494be6f403a8a075ec1dcdbf8.zip |
target/linux/image rewrite
git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@3905 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/Config.in | 8 | ||||
-rw-r--r-- | target/linux/Makefile | 87 | ||||
-rw-r--r-- | target/linux/image/Makefile | 42 | ||||
-rw-r--r-- | target/linux/image/ar7/Makefile | 122 | ||||
-rw-r--r-- | target/linux/image/aruba/Makefile | 62 | ||||
-rw-r--r-- | target/linux/image/au1000/Makefile | 72 | ||||
-rw-r--r-- | target/linux/image/brcm/Makefile | 172 | ||||
-rw-r--r-- | target/linux/image/brcm/lzma-loader/Makefile | 20 | ||||
-rw-r--r-- | target/linux/image/brcm/lzma-loader/src/Makefile | 5 | ||||
-rw-r--r-- | target/linux/image/generic/Makefile | 5 | ||||
-rw-r--r-- | target/linux/image/image.mk | 53 | ||||
-rw-r--r-- | target/linux/image/jffs2.mk | 42 | ||||
-rw-r--r-- | target/linux/image/jffs2/Makefile | 2 | ||||
-rw-r--r-- | target/linux/image/squashfs.mk | 38 | ||||
-rw-r--r-- | target/linux/image/tgz.mk | 17 | ||||
-rw-r--r-- | target/linux/image/x86/Makefile | 35 | ||||
-rw-r--r-- | target/linux/image/xscale/Makefile | 34 |
17 files changed, 260 insertions, 556 deletions
diff --git a/target/linux/Config.in b/target/linux/Config.in index 540e2b7364..9bcb61cd24 100644 --- a/target/linux/Config.in +++ b/target/linux/Config.in @@ -1,4 +1,10 @@ menu "Target Root Filesystem" + config TARGET_ROOTFS_INITRAMFS + bool "ramdisk" + default n + depends LINUX_2_6 + help + Embed the rootfs into the kernel (initramfs) config TARGET_ROOTFS_JFFS2 bool "jffs2" @@ -16,7 +22,7 @@ menu "Target Root Filesystem" config TARGET_ROOTFS_TGZ bool "tgz" - default y + default y if !LINUX_2_4_BRCM && !LINUX_2_6_BRCM && !LINUX_2_6_ARUBA && !LINUX_2_4_AR531X help Build a compressed tar archive of the the root filesystem diff --git a/target/linux/Makefile b/target/linux/Makefile index 46b162c7e6..af3e3bd26f 100644 --- a/target/linux/Makefile +++ b/target/linux/Makefile @@ -3,77 +3,13 @@ include $(TOPDIR)/rules.mk PKG_OS:=$(shell uname -s) PKG_CPU:=$(shell uname -m) -IB_NAME:=OpenWrt-ImageBuilder-$(PKG_OS)-$(PKG_CPU) -IB_DIR:=$(BUILD_DIR)/$(IB_NAME) - define kernel_template - -$(1)/$(2)-clean: - $(MAKE) -C $(2)-$(1) BOARD="$(2)" clean - -$(1)/$(2)-prepare: - $(MAKE) -C $(2)-$(1) BOARD="$(2)" prepare - -$(1)/$(2)-compile: - $(MAKE) -C $(2)-$(1) BOARD="$(2)" compile - -$(1)/$(2)-rebuild: - $(MAKE) -C $(2)-$(1) BOARD="$(2)" rebuild - -$(1)/$(2)-install: - $(MAKE) -C $(2)-$(1) BOARD="$(2)" install - -$(1)/$(2)-image: $(1)/$(2)-install - $(MAKE) -C image KERNEL="$(1)" BOARD="$(2)" install - -$(1)/$(2)-install-ib: - $(MAKE) -C image KERNEL="$(1)" BOARD="$(2)" IB_DIR="$(IB_DIR)" install-ib - echo '$$$$(eval $$$$(call image_template,$(2),$(1)))' >> $(IB_DIR)/kernel.mk - - ifeq ($(CONFIG_LINUX_$(3)),y) -clean: $(1)/$(2)-clean -prepare: $(1)/$(2)-prepare -compile: $(1)/$(2)-compile -rebuild: $(1)/$(2)-rebuild -$(BIN_DIR)/$(IB_NAME).tar.bz2 install: $(1)/$(2)-image -install-ib: $(1)/$(2)-install-ib +KERNEL:=$(1) +BOARD:=$(2) endif - -.PHONY: $(1)/$(2)-clean $(1)/$(2)-prepare $(1)/$(2)-compile $(1)/$(2)-rebuild $(1)/$(2)-install $(1)/$(2)-image $(1)/$(2)-install-ib endef -.PHONY: clean prepare compile rebuild install imagebuilder install-ib - -install-ib: - -$(BIN_DIR)/$(IB_NAME).tar.bz2: - rm -rf $(IB_DIR) - mkdir -p $(IB_DIR)/packages - mkdir -p $(IB_DIR)/scripts - $(CP) ./imagebuilder/* $(IB_DIR)/ - $(CP) $(TOPDIR)/bin/packages/*.ipk $(IB_DIR)/packages/ - $(CP) $(TOPDIR)/scripts/ipkg $(IB_DIR)/scripts/ - $(MAKE) install-ib - $(CP) $(TOPDIR)/rules.mk $(IB_DIR) - $(CP) ./image $(IB_DIR)/ - $(CP) $(TOPDIR)/.config $(IB_DIR)/ - find $(IB_DIR) -name .svn | xargs rm -rf - find $(IB_DIR) -name CVS | xargs rm -rf - (cd $(BUILD_DIR); tar c $(IB_NAME) | bzip2 -c > $(BIN_DIR)/$(IB_NAME).tar.bz2) - -ifeq ($(CONFIG_PACKAGE_IMAGEBUILDER),y) -install: $(BIN_DIR)/$(IB_NAME).tar.bz2 -endif - -prepare: - $(MAKE) -C image prepare -compile: - $(MAKE) -C image compile -install: -rebuild: -clean: - $(eval $(call kernel_template,2.4,brcm,2_4_BRCM)) $(eval $(call kernel_template,2.4,ar7,2_4_AR7)) $(eval $(call kernel_template,2.4,x86,2_4_X86)) @@ -84,3 +20,22 @@ $(eval $(call kernel_template,2.6,aruba,2_6_ARUBA)) $(eval $(call kernel_template,2.6,au1000,2_6_AU1000)) $(eval $(call kernel_template,2.6,xscale,2_6_XSCALE)) $(eval $(call kernel_template,2.6,sibyte,2_6_SIBYTE)) + +export BOARD +export KERNEL + +prepare: + $(MAKE) -C $(BOARD)-$(KERNEL) prepare + +compile: + $(MAKE) -C $(BOARD)-$(KERNEL) compile + +install: + $(MAKE) -C $(BOARD)-$(KERNEL) install + $(MAKE) -C image/$(BOARD) install + +clean: + $(MAKE) -C $(BOARD)-$(KERNEL) clean + +image/%: + $(MAKE) -C image $(patsubst image/%,%,$@) diff --git a/target/linux/image/Makefile b/target/linux/image/Makefile deleted file mode 100644 index a5141cb542..0000000000 --- a/target/linux/image/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -include $(TOPDIR)/rules.mk - -KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) - -ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y) -include ./jffs2.mk -endif - -ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS_LZMA),y) -include ./squashfs.mk -endif - -ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y) -include ./tgz.mk -endif - -prepare: FORCE - $(MAKE) prepare-targets -compile: FORCE - $(MAKE) compile-targets -install: FORCE - $(MAKE) install-targets - -$(BOARD)-compile: FORCE - $(MAKE) -C $(BOARD) prepare - $(MAKE) -C $(BOARD) compile - -install-ib: FORCE - -$(MAKE) -C $(BOARD) IB_DIR="$(IB_DIR)" install-ib - mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) - $(CP) $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/kernel[-_]*.ipk $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/ - -install-prepare: FORCE - find $(BUILD_DIR)/root -type f -not -perm +0100 | xargs chmod 0644 - find $(BUILD_DIR)/root -type f -perm +0100 | xargs chmod 0755 - find $(BUILD_DIR)/root -type d | xargs chmod 0755 - mkdir -p $(BUILD_DIR)/root/tmp - chmod 0777 $(BUILD_DIR)/root/tmp - -rebuild: clean prepare compile install -clean: FORCE - $(MAKE) clean-targets diff --git a/target/linux/image/ar7/Makefile b/target/linux/image/ar7/Makefile index cb29ced02d..4ac6d3015f 100644 --- a/target/linux/image/ar7/Makefile +++ b/target/linux/image/ar7/Makefile @@ -1,12 +1,8 @@ -include $(TOPDIR)/rules.mk - -KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) +include ../image.mk PKG_BUILD_DIR:=$(BUILD_DIR)/ar7loader -ifeq ($(IB),) LOADADDR := 0x94020000 -KERNEL_ENTRY := 0x${shell nm $(KDIR)/linux-$(KERNEL)*/vmlinux | grep kernel_entry | cut -d' ' -f1} OUTPUT_FORMAT := elf32-tradlittlemips CFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \ @@ -15,18 +11,6 @@ CFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \ -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap \ -DLOADADDR=$(LOADADDR) - -$(PKG_BUILD_DIR): - mkdir -p $(PKG_BUILD_DIR) - -$(PKG_BUILD_DIR)/zimage.script: src/zimage.script.in - sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \ - -e 's/@@LOADADDR@@/$(LOADADDR)/' <$< >$@ - -$(PKG_BUILD_DIR)/ld.script: src/ld.script.in - sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \ - -e 's/@@LOADADDR@@/$(LOADADDR)/' <$< >$@ - $(PKG_BUILD_DIR)/cksum.o: $(PKG_BUILD_DIR)/cksum.c $(HOSTCC) -o $@ $< @@ -45,24 +29,35 @@ $(PKG_BUILD_DIR)/loader.o: src/loader.c $(STAGING_DIR)/bin/srec2bin: src/srec2bin.c $(HOSTCC) -o $@ $< -$(KDIR)/vmlinux.lzma: $(KDIR)/vmlinux - cat $^ | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $@ || (rm -f $@ && false) -$(KDIR)/vmlinux.bin: $(KDIR)/vmlinux.lzma compile - $(TARGET_CROSS)ld -T $(PKG_BUILD_DIR)/zimage.script -r -b binary $< -o $(KDIR)/zimage.o - $(TARGET_CROSS)ld -static -G 0 --defsym kernel_entry=$(KERNEL_ENTRY) -T $(PKG_BUILD_DIR)/ld.script \ +define Build/Compile + mkdir -p $(PKG_BUILD_DIR) + sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \ + -e 's/@@LOADADDR@@/$(LOADADDR)/' \ + < src/zimage.script.in \ + > $(PKG_BUILD_DIR)/zimage.script + sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \ + -e 's/@@LOADADDR@@/$(LOADADDR)/' \ + < src/ld.script.in \ + > $(PKG_BUILD_DIR)/ld.script + $(MAKE) $(PKG_BUILD_DIR)/loader.o $(PKG_BUILD_DIR)/LzmaDecode.o $(STAGING_DIR)/bin/srec2bin +endef + +define Build/Clean + rm -rf $(PKG_BUILD_DIR) +endef + +define Image/Prepare + cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma + $(TARGET_CROSS)ld -T $(PKG_BUILD_DIR)/zimage.script -r -b binary $(KDIR)/vmlinux.lzma -o $(KDIR)/zimage.o + $(TARGET_CROSS)ld -static -G 0 --defsym kernel_entry=0x$${shell nm $(KDIR)/linux-*/vmlinux | grep kernel_entry | cut -d' ' -f1} -T $(PKG_BUILD_DIR)/ld.script \ $(PKG_BUILD_DIR)/loader.o \ $(PKG_BUILD_DIR)/LzmaDecode.o \ $(KDIR)/zimage.o \ -o $(KDIR)/loader $(TARGET_CROSS)objcopy -O srec $(KDIR)/loader $(KDIR)/ram_zimage.sre - $(STAGING_DIR)/bin/srec2bin $(KDIR)/ram_zimage.sre $@ - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin: $(KDIR)/vmlinux.bin -endif - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin: - $(CP) $(KDIR)/vmlinux.bin $@ + $(STAGING_DIR)/bin/srec2bin $(KDIR)/ram_zimage.sre $(KDIR)/vmlinux.bin +endef ifeq ($(FS),jffs2-8MB) ALIGN:=bs=131072 conv=sync @@ -71,56 +66,29 @@ ifeq ($(FS),jffs2-4MB) ALIGN:=bs=65536 conv=sync endif -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin - dd if=$< $(ALIGN) > $@ - cat $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/root.$(FS) >> $@ - -define pattern_template -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin - (dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin) | \ - $(STAGING_DIR)/bin/addpattern -p $(1) $(2) -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin +define Image/Build/CyberTAN + (dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin) | \ + $(STAGING_DIR)/bin/addpattern -p $(3) -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(4).bin endef -define sercomm_template -$(BIN_DIR)/openwrt-$(1)-$(KERNEL)-$(FS).img: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin - cat sercomm/adam2.bin "$$^" > "$$@.tmp" - dd if=sercomm/$(1) of="$$@.tmp" bs=$$$$((0x3e0000 - 80)) seek=1 conv=notrunc - $(STAGING_DIR)/bin/dgfirmware -f -w "$$@" "$$@.tmp" - rm -f "$$@.tmp" - -install: $(BIN_DIR)/openwrt-$(1)-$(KERNEL)-$(FS).img +define Image/Build/sErCoMm + cat sercomm/adam2.bin "$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin" > "$(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(3).img" + dd if=sercomm/$(2) of="$(KDIR)/dgfw.tmp" bs=$$$$((0x3e0000 - 80)) seek=1 conv=notrunc + $(STAGING_DIR)/bin/dgfirmware -f -w "$(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(3).img" "$(KDIR)/dgfw.tmp" + rm -f "$(KDIR)/dgfw.tmp" endef -$(eval $(call sercomm_template,dg834)) -$(eval $(call sercomm_template,jdr454wb)) - -$(eval $(call pattern_template,AG1B)) -$(eval $(call pattern_template,WA22)) -$(eval $(call pattern_template,WAG2)) -$(eval $(call pattern_template,WA21)) -$(eval $(call pattern_template,WA31,-b)) -$(eval $(call pattern_template,WA32,-b)) - -ifeq ($(IB),) -clean: - rm -rf $(PKG_BUILD_DIR) - rm -f $(BIN_DIR)/openwrt-$(BOARD)* - -prepare: $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/zimage.script $(PKG_BUILD_DIR)/ld.script -compile: prepare $(PKG_BUILD_DIR)/loader.o $(PKG_BUILD_DIR)/LzmaDecode.o $(STAGING_DIR)/bin/srec2bin -else -clean: -prepare: -compile: -endif +define Image/Build + dd if=$(KDIR)/vmlinux.bin $(ALIGN) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin + cat $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/root.$(1) >> $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin + $(call Image/Build/CyberTAN,$(1),AG1B,AG1B,$(1)) + $(call Image/Build/CyberTAN,$(1),WA21,WA21,$(1)) + $(call Image/Build/CyberTAN,$(1),WA22,WA22,$(1)) + $(call Image/Build/CyberTAN,$(1),WAG2,WAG2,$(1)) + $(call Image/Build/CyberTAN,$(1),WA31,WA31 -b,$(1)) + $(call Image/Build/CyberTAN,$(1),WA32,WA32 -b,$(1)) + $(call Image/Build/sErCoMm,$(1),dg834,$(1)) + $(call Image/Build/sErCoMm,$(1),jdr454wb,$(1)) +endef -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin -install-ib: - mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) - $(CP) $(KDIR)/vmlinux.bin $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/ - mkdir -p $(IB_DIR)/staging_dir_$(ARCH) - $(CP) $(STAGING_DIR)/bin/addpattern $(IB_DIR)/staging_dir_$(ARCH)/bin/ - $(CP) $(STAGING_DIR)/bin/dgfirmware $(IB_DIR)/staging_dir_$(ARCH)/bin/ - +$(eval $(call BuildImage)) diff --git a/target/linux/image/aruba/Makefile b/target/linux/image/aruba/Makefile index 7ca076acc3..9a4bc67dee 100644 --- a/target/linux/image/aruba/Makefile +++ b/target/linux/image/aruba/Makefile @@ -1,4 +1,4 @@ -include $(TOPDIR)/rules.mk +include ../image.mk LOADADDR = 0x81000000 # RAM start + 16M KERNEL_ENTRY = 0x80100000 @@ -10,57 +10,25 @@ LOADER_MAKEOPTS= \ KERNEL_ENTRY=$(KERNEL_ENTRY) \ RAMSIZE=$(RAMSIZE) -KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) - -lzma-loader-clean: FORCE +define Build/Clean $(MAKE) -C ../generic/lzma-loader $(LOADER_MAKEOPTS) clean +endef -lzma-loader-prepare: FORCE - $(MAKE) -C ../generic/lzma-loader $(LOADER_MAKEOPTS) prepare - -lzma-loader-compile: $(KDIR)/vmlinux.lzma lzma-loader-prepare +define Image/Prepare + cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma $(MAKE) -C ../generic/lzma-loader $(LOADER_MAKEOPTS) compile +endef -ifeq ($(IB),) -$(KDIR)/vmlinux.lzma: $(KDIR)/vmlinux - cat $^ | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $@ || (rm -f $@ && false) - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).ari: $(KDIR)/vmlinux.lzma -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).ari -endif - -ifeq ($(KERNEL),2.6) -FSNAME:=$(patsubst jffs2-%,jffs2,$(FS)) - -ifeq ($(FS),jffs2-4MB) -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).ari: $(KDIR)/loader.elf - ./addVersion -n ArubaOS $(KDIR)/loader.elf $@ version - +define Image/Build + ./addVersion -n ArubaOS $(KDIR)/loader.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).ari version ifneq ($(CONFIG_ARUBA_RAMDISK),y) -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).ari $(KDIR)/root.$(FS) - @dd if=$< of=$@.tmp bs=655360 conv=sync - @cat $(KDIR)/root.$(FS) >> $@.tmp - @dd if=$@.tmp of=$@ bs=3604480 conv=sync - @rm -f $@.tmp - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FSNAME).bin -endif - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).ari +ifeq ($(1),jffs2-64k) endif + @dd if=$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).ari of=$(KDIR)/image.tmp bs=655360 conv=sync + @cat $(KDIR)/root.$(FS) >> $(KDIR)/image.tmp + @dd if=$(KDIR)/image.tmp of=$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(patsubst jffs2-%,jffs2,$(1)).bin bs=3604480 conv=sync + @rm -f $(KDIR)/image.tmp endif +endef -ifeq ($(IB),) -clean: lzma-loader-clean -prepare: lzma-loader-prepare -compile: lzma-loader-compile -else -clean: -prepare: -compile: -endif -install-ib: - mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin - mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) - $(CP) $(KDIR)/loader.elf $(IB_DIR)/build_$(ARCH)/ - $(CP) $(KDIR)/vmlinux.lzma $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/ +$(eval $(call BuildImage)) diff --git a/target/linux/image/au1000/Makefile b/target/linux/image/au1000/Makefile index 2c9b1c05df..2607ed9eb3 100644 --- a/target/linux/image/au1000/Makefile +++ b/target/linux/image/au1000/Makefile @@ -1,4 +1,4 @@ -include $(TOPDIR)/rules.mk +include ../image.mk LOADADDR = 0x8108c8f4 # RAM start + 16M KERNEL_ENTRY = 0x80100000 # Default kernel entry in arch/mips/Makefile @@ -10,67 +10,19 @@ LOADER_MAKEOPTS= \ KERNEL_ENTRY=$(KERNEL_ENTRY) \ RAMSIZE=$(RAMSIZE) -KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) - -lzma-loader-clean: FORCE +define Build/Clean $(MAKE) -C ../generic/lzma-loader $(LOADER_MAKEOPTS) clean +endef -lzma-loader-prepare: FORCE - $(MAKE) -C ../generic/lzma-loader $(LOADER_MAKEOPTS) prepare - -lzma-loader-compile: $(KDIR)/vmlinux.lzma lzma-loader-prepare +define Image/Prepare + cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma $(MAKE) -C ../generic/lzma-loader $(LOADER_MAKEOPTS) compile +endef -ifeq ($(IB),) -$(KDIR)/vmlinux.lzma: $(KDIR)/vmlinux - cat $^ | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $@ || (rm -f $@ && false) - -install: $(KDIR)/vmlinux.lzma -endif - -ifeq ($(FS),jffs2-8MB) - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FSNAME).bin: $(KDIR)/root.$(FS) - $(TARGET_CROSS)objcopy -O srec -I binary --adjust-vma 0xbe000000 $(KDIR)/root.$(FS) $(KDIR)/root.srec - grep -v S7 $(KDIR)/root.srec > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img - grep -v S0 $(LINUX_DIR)/arch/mips/boot/compressed/images/zImage.flash.srec >> $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FSNAME).bin -endif - -ifeq ($(FS),tgz) - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tar.gz: $(KDIR)/root.tar.gz - $(CP) $^ $@ - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tar.gz - -endif - -ifeq ($(FS),squashfs) -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FSNAME).bin: $(KDIR)/root.$(FS) - $(TARGET_CROSS)objcopy -O srec -I binary --adjust-vma 0xbe000000 $(KDIR)/root.$(FS) $(KDIR)/root.srec - grep -v S7 $(KDIR)/root.srec > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img - grep -v S0 $(LINUX_DIR)/arch/mips/boot/compressed/images/zImage.flash.srec >> $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img - -endif - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz: $(KDIR)/zImage.flash - $(CP) $^ $@ +define Image/Build + $(TARGET_CROSS)objcopy -O srec -I binary --adjust-vma 0xbe000000 $(KDIR)/root.$(1) $(KDIR)/root.srec + grep -v S7 $(KDIR)/root.srec > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img + grep -v S0 $(LINUX_DIR)/arch/mips/boot/compressed/images/zImage.flash.srec >> $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img +endef -ifeq ($(IB),) -clean: lzma-loader-clean -prepare: lzma-loader-prepare -compile: lzma-loader-compile -else -clean: -prepare: -compile: -endif -install-ib: - mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin - mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) - $(CP) $(KDIR)/loader.elf $(IB_DIR)/build_$(ARCH)/ - $(CP) $(KDIR)/vmlinux.lzma $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/ - $(TARGET_CROSS)objcopy -O srec -I binary --adjust-vma 0xbe000000 $(KDIR)/loader.elf $(KDIR)/loader.srec - grep -v S0 $(KDIR)/loader.srec > $(KDIR)/kernel.srec +$(eval $(call BuildImage)) diff --git a/target/linux/image/brcm/Makefile b/target/linux/image/brcm/Makefile index 7e328470ae..1d8e7ea261 100644 --- a/target/linux/image/brcm/Makefile +++ b/target/linux/image/brcm/Makefile @@ -1,23 +1,4 @@ -include $(TOPDIR)/rules.mk - -KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) - -lzma-loader-clean: FORCE - $(MAKE) -C lzma-loader clean - -lzma-loader-prepare: FORCE - $(MAKE) -C lzma-loader prepare - -lzma-loader-compile: lzma-loader-prepare - $(MAKE) -C lzma-loader compile - -ifeq ($(IB),) -$(KDIR)/vmlinux.lzma: $(KDIR)/vmlinux - cat $^ | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $@ || (rm -f $@ && false) - -$(KDIR)/loader.tmp.gz: compile -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx: $(KDIR)/vmlinux.lzma -endif +include ../image.mk ifeq ($(FS),jffs2-8MB) TRXALIGN:=-a 0x20000 @@ -25,111 +6,56 @@ endif ifeq ($(FS),jffs2-4MB) TRXALIGN:=-a 0x10000 endif -# see ticket #155 ifeq ($(FS),squashfs) +# see ticket #155 TRXALIGN:=-a 1024 endif +define Build/Compile + rm -f $(KDIR)/loader.gz + $(MAKE) -C lzma-loader \ + BUILD_DIR="$(KDIR)" \ + TARGET="$(KDIR)" \ + install + echo -ne "\\x00" >> $(KDIR)/loader.gz +endef -$(KDIR)/loader.tmp.gz: - $(CP) $(BUILD_DIR)/loader.gz $@ - echo -ne "\\x00" >> $@ - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx: $(KDIR)/loader.tmp.gz - $(STAGING_DIR)/bin/trx -o $@ $(KDIR)/loader.tmp.gz $(KDIR)/vmlinux.lzma $(TRXALIGN) $(KDIR)/root.$(FS) - -ifeq ($(KERNEL),2.6) -FSNAME:=$(patsubst jffs2-%,jffs2,$(FS)) - -ifneq ($(FS),jffs2-4MB) -$(BIN_DIR)/openwrt-wgt634u-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - dd if=$(BUILD_DIR)/loader.elf of=$@ bs=131072 conv=sync - cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx >> $@ - -$(BIN_DIR)/openwrt-wrt54gs-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54S -v v4.70.6 -i $< -o $@ -g - -install: $(BIN_DIR)/openwrt-wgt634u-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54gs-$(KERNEL)-$(FSNAME).bin - -endif - -ifneq ($(FS),jffs2-8MB) -$(BIN_DIR)/openwrt-wrt54g3g-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54F -v v1.99.5 -i $< -o $@ -g - -$(BIN_DIR)/openwrt-wrt54g-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54G -v v4.20.6 -i $< -o $@ -g - -$(BIN_DIR)/openwrt-wrt54gs_v4-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54s -v v1.05.2 -i $< -o $@ -g - -install: $(BIN_DIR)/openwrt-wrt54g-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54gs_v4-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54g3g-$(KERNEL)-$(FSNAME).bin - -endif -endif - -ifeq ($(KERNEL),2.4) -FSNAME:=$(patsubst jffs2-%,jffs2,$(FS)) - -# ifeq ($(FS),squashfs) -# $(BIN_DIR)/openwrt-wap54g-$(KERNEL)-$(FSNAME).trx: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx -# $(CP) $< $@ -# echo -ne '\x01' >> $@ -# -# install: $(BIN_DIR)/openwrt-wap54g-$(KERNEL)-$(FSNAME).trx -# endif - -ifneq ($(FS),jffs2-8MB) -$(BIN_DIR)/openwrt-wrt54g3g-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54F -v v1.99.5 -i $< -o $@ -g - -$(BIN_DIR)/openwrt-wrt54g-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54G -v v4.20.6 -i $< -o $@ -g - -$(BIN_DIR)/openwrt-wrt54gs_v4-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54s -v v1.05.2 -i $< -o $@ -g - -$(BIN_DIR)/openwrt-wr850g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/motorola-bin -1 $< $@ - -$(BIN_DIR)/openwrt-wa840g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/motorola-bin -2 $< $@ - -$(BIN_DIR)/openwrt-we800g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/motorola-bin -3 $< $@ - -install: $(BIN_DIR)/openwrt-wrt54g-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54gs_v4-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wrt54g3g-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wr850g-$(FSNAME).bin $(BIN_DIR)/openwrt-wa840g-$(FSNAME).bin $(BIN_DIR)/openwrt-we800g-$(FSNAME).bin -endif - -ifneq ($(FS),jffs2-4MB) -$(BIN_DIR)/openwrt-wgt634u-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - dd if=$(BUILD_DIR)/loader.elf of=$@ bs=131072 conv=sync - cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx >> $@ - -$(BIN_DIR)/openwrt-wrt54gs-$(KERNEL)-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54S -v v4.70.6 -i $< -o $@ -g - -$(BIN_DIR)/openwrt-wrtsl54gs-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx - $(STAGING_DIR)/bin/addpattern -4 -p W54U -v v2.00.0 -i $< -o $@ -g - -install: $(BIN_DIR)/openwrt-wrt54gs-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wgt634u-$(KERNEL)-$(FSNAME).bin $(BIN_DIR)/openwrt-wrtsl54gs-$(FSNAME).bin -endif -endif - -ifeq ($(IB),) -clean: lzma-loader-clean -prepare: lzma-loader-prepare -compile: lzma-loader-compile -else -clean: -prepare: -compile: -endif -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx -install-ib: - mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin - $(CP) $(STAGING_DIR)/bin/addpattern $(STAGING_DIR)/bin/trx $(STAGING_DIR)/bin/motorola-bin $(IB_DIR)/staging_dir_$(ARCH)/bin - mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) - $(CP) $(BUILD_DIR)/loader.gz $(IB_DIR)/build_$(ARCH)/ - $(CP) $(BUILD_DIR)/loader.elf $(IB_DIR)/build_$(ARCH)/ - $(CP) $(KDIR)/vmlinux.lzma $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/ +define Build/Clean + $(MAKE) -C lzma-loader clean +endef + +define Image/Prepare + cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma +endef + +define Image/Build/wgt634u + dd if=$(KDIR)/loader.elf of=$(BIN_DIR)/openwrt-wgt634u-$(KERNEL)-$(2).bin bs=131072 conv=sync + cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx >> $(BIN_DIR)/openwrt-wgt634u-$(KERNEL)-$(2).bin +endef + +define Image/Build/CyberTAN + $(STAGING_DIR)/bin/addpattern -4 -p $(3) -v v$(4) -i $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(5).bin +endef + +define Image/Build/Motorola + $(STAGING_DIR)/bin/motorola-bin -$(3) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(4).bin +endef + +define Image/Build + $(STAGING_DIR)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx $(KDIR)/loader.gz $(KDIR)/vmlinux.lzma $(TRXALIGN) $(KDIR)/root.$(1) +ifneq ($(1),jffs2-128k) + $(call Image/Build/CyberTAN,$(1),wrt54g3g,W54F,1.99.5,$(patsubst jffs2-%,jffs2,$(1))) + $(call Image/Build/CyberTAN,$(1),wrt54g,W54G,4.40.1,$(patsubst jffs2-%,jffs2,$(1))) + $(call Image/Build/CyberTAN,$(1),wrt54gs_v4,W54s,1.09.1,$(patsubst jffs2-%,jffs2,$(1))) + $(call Image/Build/Motorola,$(1),wa840g,2,$(patsubst jffs2-%,jffs2,$(1))) + $(call Image/Build/Motorola,$(1),we800g,3,$(patsubst jffs2-%,jffs2,$(1))) +endif +ifneq ($(1),jffs2-64k) + $(call Image/Build/CyberTAN,$(1),wrt54gs,W54S,4.80.1,$(patsubst jffs2-%,jffs2,$(1))) + $(call Image/Build/CyberTAN,$(1),wrtsl54gs,W54U,2.00.5,$(patsubst jffs2-%,jffs2,$(1))) + $(call Image/Build/wgt634u,$(1),$(patsubst jffs2-%,jffs2,$(1))) +endif + $(call Image/Build/Motorola,$(1),wr850g,1,$(1)) +endef + +$(eval $(call BuildImage)) diff --git a/target/linux/image/brcm/lzma-loader/Makefile b/target/linux/image/brcm/lzma-loader/Makefile index 1d7b6a3196..3fa00fa4d9 100644 --- a/target/linux/image/brcm/lzma-loader/Makefile +++ b/target/linux/image/brcm/lzma-loader/Makefile @@ -2,10 +2,8 @@ include $(TOPDIR)/rules.mk -PKG_NAME := loader -PKG_VERSION := 0.04 - -PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) +PKG_NAME := lzma-loader +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) $(PKG_BUILD_DIR)/.prepared: mkdir $(PKG_BUILD_DIR) @@ -16,17 +14,15 @@ $(PKG_BUILD_DIR)/loader.gz: $(PKG_BUILD_DIR)/.prepared $(MAKE) -C $(PKG_BUILD_DIR) CC=$(TARGET_CC) \ LD=$(TARGET_CROSS)ld CROSS_COMPILE=$(TARGET_CROSS) -$(BUILD_DIR)/loader.gz: $(PKG_BUILD_DIR)/loader.gz - $(CP) $< $@ - -$(BUILD_DIR)/loader.elf: $(PKG_BUILD_DIR)/loader.o - $(CP) $< $@ - source: prepare: $(PKG_BUILD_DIR)/.prepared -compile: $(BUILD_DIR)/loader.gz $(BUILD_DIR)/loader.elf +compile: $(PKG_BUILD_DIR)/loader.gz install: +ifneq ($(TARGET),) +install: compile + $(CP) $(PKG_BUILD_DIR)/loader.gz $(PKG_BUILD_DIR)/loader.elf $(TARGET)/ +endif + clean: rm -rf $(PKG_BUILD_DIR) - rm -f $(BUILD_DIR)/loader.gz diff --git a/target/linux/image/brcm/lzma-loader/src/Makefile b/target/linux/image/brcm/lzma-loader/src/Makefile index 92916d8cb3..85a864674b 100644 --- a/target/linux/image/brcm/lzma-loader/src/Makefile +++ b/target/linux/image/brcm/lzma-loader/src/Makefile @@ -34,7 +34,7 @@ SEDFLAGS := s/BZ_TEXT_START/$(BZ_TEXT_START)/;s/TEXT_START/$(TEXT_START)/ OBJECTS := head.o data.o -all: loader.gz +all: loader.gz loader.elf # Don't build dependencies, this may die if $(CC) isn't gcc dep: @@ -44,6 +44,9 @@ install: loader.gz: loader gzip -nc9 $< > $@ +loader.elf: loader.o + cp $< $@ + loader: loader.o $(OBJCOPY) $< $@ diff --git a/target/linux/image/generic/Makefile b/target/linux/image/generic/Makefile new file mode 100644 index 0000000000..f87fb116dd --- /dev/null +++ b/target/linux/image/generic/Makefile @@ -0,0 +1,5 @@ +include ../image.mk + +# use default targets for everything + +$(eval $(call BuildImage)) diff --git a/target/linux/image/image.mk b/target/linux/image/image.mk new file mode 100644 index 0000000000..61ad9ff264 --- /dev/null +++ b/target/linux/image/image.mk @@ -0,0 +1,53 @@ +include $(TOPDIR)/rules.mk + +KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) + +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y) +ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y) +include $(TOPDIR)/target/linux/image/jffs2.mk +endif + +ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS_LZMA),y) +include $(TOPDIR)/target/linux/image/squashfs.mk +endif + +ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y) +include $(TOPDIR)/target/linux/image/tgz.mk +endif +endif + +define Image/mkfs/prepare/default + find $(BUILD_DIR)/root -type f -not -perm +0100 | xargs chmod 0644 + find $(BUILD_DIR)/root -type f -perm +0100 | xargs chmod 0755 + find $(BUILD_DIR)/root -type d | xargs chmod 0755 + mkdir -p $(BUILD_DIR)/root/tmp + chmod 0777 $(BUILD_DIR)/root/tmp +endef + +define Image/mkfs/prepare + $(call Image/mkfs/prepare/default) +endef + +define BuildImage +compile: + $(call Build/Compile) + +install: + $(call Image/Prepare) + $(call Image/mkfs/prepare) + $(call Image/mkfs/jffs2) + $(call Image/mkfs/squashfs) + $(call Image/mkfs/tgz) + +clean: + $(call Build/Clean) +endef + +compile-targets: +install-targets: +clean-targets: + +prepare: +compile: compile-targets +install: compile install-targets +clean: clean-targets diff --git a/target/linux/image/jffs2.mk b/target/linux/image/jffs2.mk index c1d07a22b2..dd5edd01c0 100644 --- a/target/linux/image/jffs2.mk +++ b/target/linux/image/jffs2.mk @@ -4,41 +4,23 @@ else JFFS2OPTS := --pad --big-endian --squash endif -#JFFS2OPTS += -Xlzo -msize -Xlzari +define Image/mkfs/jffs2 + rm -rf $(BUILD_DIR)/root/jffs + + $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x10000 -o $(KDIR)/root.jffs2-64k -d $(BUILD_DIR)/root + $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $(KDIR)/root.jffs2-128k -d $(BUILD_DIR)/root -jffs2-prepare: FORCE - $(MAKE) -C jffs2 prepare + $(call Image/Build,jffs2-64k) + $(call Image/Build,jffs2-128k) +endef -jffs2-compile: prepare-targets - $(MAKE) -C jffs2 compile +$(STAGING_DIR)/bin/mkfs.jffs2: + $(MAKE) -C $(TOPDIR)/target/linux/image/jffs2 compile jffs2-clean: FORCE - $(MAKE) -C jffs2 clean + $(MAKE) -C $(TOPDIR)/target/linux/image/jffs2 clean rm -f $(KDIR)/root.jffs2* -$(KDIR)/root.jffs2-4MB: install-prepare - @rm -rf $(BUILD_DIR)/root/jffs - $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x10000 -o $@ -d $(BUILD_DIR)/root - -$(KDIR)/root.jffs2-8MB: install-prepare - @rm -rf $(BUILD_DIR)/root/jffs - $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $@ -d $(BUILD_DIR)/root - -ifeq ($(IB),) -jffs2-install: compile-targets $(BOARD)-compile -endif - -jffs2-install: $(KDIR)/root.jffs2-4MB $(KDIR)/root.jffs2-8MB FORCE - $(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-4MB" - $(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-8MB" - -jffs2-install-ib: compile-targets FORCE - mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin - $(CP) $(STAGING_DIR)/bin/mkfs.jffs2 $(IB_DIR)/staging_dir_$(ARCH)/bin - -prepare-targets: jffs2-prepare -compile-targets: jffs2-compile -install-targets: jffs2-install -install-ib: jffs2-install-ib +compile-targets: $(STAGING_DIR)/bin/mkfs.jffs2 clean-targets: jffs2-clean diff --git a/target/linux/image/jffs2/Makefile b/target/linux/image/jffs2/Makefile index 0273d52fd1..b673c438a6 100644 --- a/target/linux/image/jffs2/Makefile +++ b/target/linux/image/jffs2/Makefile @@ -25,5 +25,5 @@ prepare: $(MTD_DIR)/.unpacked compile: $(MTD_DIR)/util/mkfs.jffs2 $(STAGING_DIR)/bin/mkfs.jffs2 install: clean: FORCE - rm -rf $(MTD_DIR) + rm -rf $(MTD_DIR) $(STAGING_DIR)/bin/mkfs.jffs2 diff --git a/target/linux/image/squashfs.mk b/target/linux/image/squashfs.mk index 184330cfe7..6890daec68 100644 --- a/target/linux/image/squashfs.mk +++ b/target/linux/image/squashfs.mk @@ -1,36 +1,22 @@ ifneq ($(CONFIG_BIG_ENDIAN),y) -endian := le +ENDIAN := le else -endian := be +ENDIAN := be endif -squashfs-prepare: FORCE - $(MAKE) -C squashfs prepare - -squashfs-compile: prepare-targets - $(MAKE) -C squashfs compile +$(STAGING_DIR)/bin/mksquashfs-lzma: + $(MAKE) -C $(TOPDIR)/target/linux/image/squashfs compile squashfs-clean: FORCE - $(MAKE) -C squashfs clean + $(MAKE) -C $(TOPDIR)/target/linux/image/squashfs clean rm -f $(KDIR)/root.squashfs -$(KDIR)/root.squashfs: install-prepare +define Image/mkfs/squashfs @mkdir -p $(BUILD_DIR)/root/jffs - $(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $@ -nopad -noappend -root-owned -$(endian) - -ifeq ($(IB),) -squashfs-install: compile-targets $(BOARD)-compile -endif + $(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $(KDIR)/root.squashfs -nopad -noappend -root-owned -$(ENDIAN) + $(call Image/Build,squashfs) +endef -squashfs-install: $(KDIR)/root.squashfs FORCE - $(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="squashfs" - -squashfs-install-ib: compile-targets - mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin - $(CP) $(STAGING_DIR)/bin/mksquashfs-lzma $(IB_DIR)/staging_dir_$(ARCH)/bin - -prepare-targets: squashfs-prepare -compile-targets: squashfs-compile -install-targets: squashfs-install -install-ib: squashfs-install-ib -clean: squashfs-clean +FILESYSTEMS += squashfs +compile-targets: $(STAGING_DIR)/bin/mksquashfs-lzma +clean-targets: squashfs-clean diff --git a/target/linux/image/tgz.mk b/target/linux/image/tgz.mk index 506ab891ae..39adb69257 100644 --- a/target/linux/image/tgz.mk +++ b/target/linux/image/tgz.mk @@ -1,14 +1,3 @@ -$(KDIR)/root.tar.gz: FORCE - tar -zcf $@ --owner=root --group=root -C $(BUILD_DIR)/root/ . - -ifeq ($(BOARD),x86) -install: tgz-install - -tgz-install: $(KDIR)/root.tar.gz - $(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="tgz" -endif - -prepare-targets: -compile-targets: -install-targets: $(KDIR)/root.tar.gz - +define Image/mkfs/tgz + tar -zcf $(BIN_DIR)/openwrt-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ . +endef diff --git a/target/linux/image/x86/Makefile b/target/linux/image/x86/Makefile index 8035d722f8..69f9bf470e 100644 --- a/target/linux/image/x86/Makefile +++ b/target/linux/image/x86/Makefile @@ -1,31 +1,8 @@ -include $(TOPDIR)/rules.mk +include ../image.mk -KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) +define Image/Build + cp $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img + cp $(KDIR)/vmlinux $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz +endef - -ifeq ($(FS),jffs2-8MB) -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img: $(KDIR)/root.$(FS) - $(CP) $^ $@ - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img -endif - - -ifeq ($(FS),tgz) -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tar.gz: $(KDIR)/root.tar.gz - $(CP) $^ $@ - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tar.gz -endif - - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz: $(KDIR)/bzImage - $(CP) $^ $@ - -clean: -prepare: -compile: -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz -install-ib: FORCE - mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) - $(CP) $(KDIR)/bzImage $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/ +$(eval $(call BuildImage)) diff --git a/target/linux/image/xscale/Makefile b/target/linux/image/xscale/Makefile index cc47c25aba..09616d409f 100644 --- a/target/linux/image/xscale/Makefile +++ b/target/linux/image/xscale/Makefile @@ -1,30 +1,10 @@ -include $(TOPDIR)/rules.mk +include ../image.mk -KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD) - -ifeq ($(FS),jffs2-8MB) -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img: $(KDIR)/root.$(FS) - $(CP) $^ $@ - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).img -endif - - -ifeq ($(FS),tgz) -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tar.gz: $(KDIR)/root.tar.gz - $(CP) $^ $@ - -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tar.gz +define Image/Build +ifneq ($(FS),jffs2-64k) + cp $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img + cp $(KDIR)/vmlinux $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz endif +endef - -$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz: $(KDIR)/vmlinux - $(CP) $^ $@ - -clean: -prepare: -compile: -install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz -install-ib: FORCE - mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) - $(CP) $(KDIR)/bzImage $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/ +$(eval $(call BuildImage)) |