comment "Extra stuff"
source "package/sdk/Config.in"
+config BR2_PACKAGE_IMAGEBUILDER
+ bool "OpenWrt Image Builder"
+ default y if CONFIG_DEVEL
+ help
+ Build an OpenWrt Image Builder.
+ This package contains the necessary (precompiled) tools and all packages to generate
+ firmware images from package lists, without having to use the full buildroot.
+ Useful for building images with custom scripts or extra packages.
+
endmenu
source "package/Sysconf.in"
$(IPKG_LIBC):
$(SCRIPT_DIR)/make-ipkg-dir.sh $(IDIR_LIBC) ipkg/uclibc.control $(LIBC_VERSION)-$(PKG_RELEASE) $(ARCH)
mkdir -p $(IDIR_LIBC)/lib
- cp -fpR $(STAGING_DIR)/lib/ld-uClibc*.so $(IDIR_LIBC)/lib/
+ cp $(STAGING_DIR)/lib/ld-uClibc*.so.* $(IDIR_LIBC)/lib/
for file in c crypt dl m nsl resolv rt uClibc util; do \
- cp -fpR $(STAGING_DIR)/lib/lib$$file*.so $(IDIR_LIBC)/lib/; \
+ cp $(STAGING_DIR)/lib/lib$$file*.so.* $(IDIR_LIBC)/lib/; \
done
-$(STRIP) $(IDIR_LIBC)/lib/*
$(IPKG_BUILD) $(IDIR_LIBC) $(PACKAGE_DIR)
$(MAKE) -C $(patsubst %-rebuild,%,$@) rebuild
%-install: %-compile
$(MAKE) -C $(patsubst %-install,%,$@) install
-
+linux-imagebuilder:
+ $(MAKE) -C linux imagebuilder
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:
$(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 ($(BR2_LINUX_$(3)),y)
clean: $(1)/$(2)-clean
prepare: $(1)/$(2)-prepare
compile: $(1)/$(2)-compile
rebuild: $(1)/$(2)-rebuild
-install: $(1)/$(2)-image
+kernel-install: $(1)/$(2)-image
+install-ib: $(1)/$(2)-install-ib
endif
-.PHONY: $(1)/$(2)-clean $(1)/$(2)-prepare $(1)/$(2)-compile $(1)/$(2)-rebuild $(1)/$(2)-install
+.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 kernel-install
+
+install-ib:
+
+$(BIN_DIR)/$(IB_NAME).tar.bz2: kernel-install
+ rm -rf $(IB_DIR)
+ mkdir -p $(IB_DIR)/packages
+ mkdir -p $(IB_DIR)/scripts
+ cp -dpR ./imagebuilder/* $(IB_DIR)/
+ cp -dpR $(TOPDIR)/bin/packages/*.ipk $(IB_DIR)/packages/
+ cp $(TOPDIR)/scripts/ipkg $(IB_DIR)/scripts/
+ $(MAKE) install-ib
+ cp $(TOPDIR)/rules.mk $(IB_DIR)
+ cp -dpR ./image $(IB_DIR)/
+ cp $(TOPDIR)/.config $(IB_DIR)/
+ find $(IB_DIR) -name CVS | xargs rm -rf
+ (cd $(BUILD_DIR); tar c $(IB_NAME) | bzip2 -c > $(BIN_DIR)/$(IB_NAME).tar.bz2)
+
+ifeq ($(BR2_PACKAGE_IMAGEBUILDER),y)
+install: $(BIN_DIR)/$(IB_NAME).tar.bz2
+endif
+
prepare:
$(MAKE) -C image prepare
compile:
$(MAKE) -C image compile
-install:
+install: kernel-install
rebuild:
clean:
include $(TOPDIR)/rules.mk
-ifeq ($(BOARD),)
-BOARD:=brcm
-endif
-
KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
ifeq ($(BR2_TARGET_ROOTFS_JFFS2),y)
endif
prepare:
-compile:
-install:
$(MAKE) -C $(BOARD) prepare
+compile:
$(MAKE) -C $(BOARD) compile
+install:
+
+install-ib:
+ -$(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)/
+
rebuild: clean prepare compile install
clean:
include $(TOPDIR)/rules.mk
-KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-brcm
+KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
lzma-loader-clean:
$(MAKE) -C lzma-loader clean
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)
+$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx: $(KDIR)/vmlinux.lzma
+endif
+
ifeq ($(FS),jffs2-8MB)
TRXALIGN:=-a 0x20000
endif
ifeq ($(FS),jffs2-4MB)
TRXALIGN:=-a 0x10000
endif
-$(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx: $(KDIR)/vmlinux.lzma
+$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx:
$(STAGING_DIR)/bin/trx -o $@ $(BUILD_DIR)/loader.gz $(KDIR)/vmlinux.lzma $(TRXALIGN) $(KDIR)/root.$(FS)
FSNAME:=$(patsubst jffs2-%,jffs2,$(FS))
ifneq ($(FS),jffs2-8MB)
-$(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin: $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
+$(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
$(STAGING_DIR)/bin/addpattern -4 -p W54G -v v4.20.6 -i $< -o $@ -g
install: $(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin
endif
ifneq ($(FS),jffs2-4MB)
-$(BIN_DIR)/openwrt-wrt54gs-$(FSNAME).bin: $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
+$(BIN_DIR)/openwrt-wrt54gs-$(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-wrt54gs-$(FSNAME).bin
endif
-$(BIN_DIR)/openwrt-motorola-$(FS).bin: $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
+$(BIN_DIR)/openwrt-motorola-$(FS).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
$(STAGING_DIR)/bin/motorola-bin $< $@
install: $(BIN_DIR)/openwrt-motorola-$(FS).bin
endif
+ifeq ($(IB),)
clean: lzma-loader-clean
prepare: lzma-loader-prepare
compile: lzma-loader-compile
-install: compile $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
-
+install: compile $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
+else
+clean:
+prepare:
+compile:
+install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
+endif
+install-ib:
+ mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin
+ cp -dpR $(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 -dpR $(BUILD_DIR)/loader.gz $(IB_DIR)/build_$(ARCH)/
+ cp -dpR $(KDIR)/vmlinux.lzma $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/
$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-4MB"
$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-8MB"
+jffs2-install-ib:
+ mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin
+ cp $(STAGING_DIR)/bin/mkfs.jffs2 $(IB_DIR)/staging_dir_$(ARCH)/bin
+
prepare: jffs2-prepare
compile: jffs2-compile
install: jffs2-install
+install-ib: jffs2-install-ib
clean: jffs2-clean
$(KDIR)/root.squashfs:
@mkdir -p $(KDIR)/root/jffs
- $(STAGING_DIR)/bin/mksquashfs-lzma $(KDIR)/root $@ -noappend -nopad -root-owned -le
+ $(STAGING_DIR)/bin/mksquashfs-lzma $(KDIR)/root $@ -nopad -noappend -root-owned -le
squashfs-install: $(KDIR)/root.squashfs
$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="squashfs"
+
+squashfs-install-ib:
+ mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin
+ cp $(STAGING_DIR)/bin/mksquashfs-lzma $(IB_DIR)/staging_dir_$(ARCH)/bin
prepare: squashfs-prepare
compile: squashfs-compile
install: squashfs-install
+install-ib: squashfs-install-ib
+clean: squashfs-clean
tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
+$(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
+ @mkdir -p $(STAMP_DIR)
+ @$(MAKE) $(TARGETS)
+ ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
+ $(MAKE) -C $(TOPDIR)/target/linux/package \
+ $(KPKG_MAKEOPTS) \
+ compile
+ touch $@
+
$(TARGET_MODULES_DIR):
-mkdir -p $(TARGET_MODULES_DIR)
source: $(DL_DIR)/$(LINUX_SOURCE)
prepare: $(LINUX_DIR)/.configured
-compile: $(LINUX_DIR)/.modules_done $(TARGETS)
- ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
- $(MAKE) -C $(TOPDIR)/target/linux/package \
- $(KPKG_MAKEOPTS) \
- compile
+compile: $(STAMP_DIR)/.linux-compile
install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
rm -rf $(LINUX_BUILD_DIR)/root*
[ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true
mostlyclean:
+ rm -f $(STAMP_DIR)/.linux-compile
rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
$(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean
$(MAKE) compile
clean:
+ rm -f $(STAMP_DIR)/.linux-compile
rm -rf $(LINUX_BUILD_DIR)
rm -f $(TARGETS)
$(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.drivers-unpacked
$(LINUX_DIR)/.modules_done: $(LINUX_DIR)/.drivers-unpacked
-$(LINUX_DIR)/.drivers-unpacked: $(LINUX_DIR)/.unpacked
+$(LINUX_DIR)/.drivers-unpacked: $(LINUX_DIR)/.unpacked $(DL_DIR)/$(LINUX_BINARY_WL_DRIVER) $(DL_DIR)/$(LINUX_ET_DRIVER)
-mkdir -p $(BUILD_DIR)
zcat $(DL_DIR)/$(LINUX_BINARY_WL_DRIVER) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
zcat $(DL_DIR)/$(LINUX_ET_DRIVER) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
uClibc-compile: gcc-prepare
gcc-compile: uClibc-install
-$(STAMP_DIR):
- mkdir -p $(STAMP_DIR)
+TOOLCHAIN_STAMP_DIR:=$(STAGING_DIR)/stampfiles
+
+$(TOOLCHAIN_STAMP_DIR):
+ mkdir -p $(TOOLCHAIN_STAMP_DIR)
$(STAGING_DIR):
@mkdir -p $(STAGING_DIR)/lib
$(TOOL_BUILD_DIR):
@mkdir -p $(TOOL_BUILD_DIR)
-%-prepare: $(STAMP_DIR) $(STAGING_DIR) $(TOOL_BUILD_DIR)
- @[ -f $(STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
- @touch $(STAMP_DIR)/.toolchain_$@
+%-prepare: $(TOOLCHAIN_STAMP_DIR) $(STAGING_DIR) $(TOOL_BUILD_DIR)
+ @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
+ @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
%-compile: %-prepare
- @[ -f $(STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-compile,%,$@) compile
- @touch $(STAMP_DIR)/.toolchain_$@
+ @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-compile,%,$@) compile
+ @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
%-install: %-compile
- @[ -f $(STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-install,%,$@) install
- @touch $(STAMP_DIR)/.toolchain_$@
+ @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-install,%,$@) install
+ @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
%-clean:
@$(MAKE) -C $(patsubst %-clean,%,$@) clean
- @rm -f $(STAMP_DIR)/.toolchain_$(patsubst %-clean,%,$@)-*
+ @rm -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$(patsubst %-clean,%,$@)-*