From b6defb27cbb3f978cbf66f92f4379eeb1318b83a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 20 Apr 2005 17:01:30 +0000 Subject: [PATCH] add openwrt image builder to sdk SVN-Revision: 688 --- openwrt/Makefile | 10 ++- openwrt/package/Makefile | 4 +- openwrt/package/sdk/Makefile | 72 ++++++++++++++----- openwrt/package/sdk/files/Makefile.ib | 61 ++++++++++++++++ openwrt/package/sdk/files/README.ImageBuilder | 8 +++ openwrt/package/sdk/files/sysconf | 4 ++ openwrt/target/Makefile | 2 +- openwrt/target/jffs2/Makefile | 17 +---- openwrt/target/jffs2/jffs2root.mk | 7 +- openwrt/target/squashfs-lzma/Makefile | 6 +- .../target/squashfs-lzma/squashfslzmaroot.mk | 7 +- 11 files changed, 156 insertions(+), 42 deletions(-) create mode 100644 openwrt/package/sdk/files/Makefile.ib create mode 100644 openwrt/package/sdk/files/README.ImageBuilder create mode 100644 openwrt/package/sdk/files/sysconf diff --git a/openwrt/Makefile b/openwrt/Makefile index e966188187..cd94233149 100644 --- a/openwrt/Makefile +++ b/openwrt/Makefile @@ -61,8 +61,11 @@ toolchain_install: # ############################################################## -package_install: toolchain - $(MAKE) -C package compile install +package_compile: target_compile + $(MAKE) -C package compile + +package_install: package_compile toolchain + $(MAKE) -C package install ############################################################# # @@ -91,6 +94,9 @@ package_index: target_prepare: $(MAKE) -C target prepare +target_compile: + $(MAKE) -C target compile + target_install: $(MAKE) -C target install diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile index bd938800d3..4008d434cb 100644 --- a/openwrt/package/Makefile +++ b/openwrt/package/Makefile @@ -66,6 +66,8 @@ package-$(BR2_PACKAGE_LIBPQ) += postgresql DEV_LIBS:=tcp_wrappers glib ncurses openssl pcre popt zlib libnet libpcap mysql postgresql iptables matrixssl lzo gmp fuse portmap libelf DEV_LIBS_COMPILE:=$(patsubst %,%-compile,$(DEV_LIBS)) +SDK_DEFAULT_PACKAGES:=busybox dnsmasq iptables wireless-tools dropbear bridge +SDK_DEFAULT_COMPILE:=$(patsubst %,%-compile,$(SDK_DEFAULT_PACKAGES)) all: compile install clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m)) linux-clean @@ -106,7 +108,7 @@ ifeq ($(BR2_PACKAGE_SNORT_PGSQL),y) snort-compile: postgresql-compile endif -sdk-compile: $(DEV_LIBS_COMPILE) +sdk-compile: $(DEV_LIBS_COMPILE) $(SDK_DEFAULT_COMPILE) $(patsubst %,%-prepare,$(package-y) $(package-m) $(package-)): linux-install %-prepare: diff --git a/openwrt/package/sdk/Makefile b/openwrt/package/sdk/Makefile index b42dda4e42..dba08cabfc 100644 --- a/openwrt/package/sdk/Makefile +++ b/openwrt/package/sdk/Makefile @@ -6,36 +6,76 @@ PKG_OS:=$(shell uname -s) PKG_CPU:=$(shell uname -m) PKG_RELEASE:=1 -PKG_NAME:=OpenWrt-SDK-$(PKG_OS)-$(PKG_CPU)-$(PKG_RELEASE) +SDK_NAME:=OpenWrt-SDK-$(PKG_OS)-$(PKG_CPU)-$(PKG_RELEASE) +IB_NAME:=OpenWrt-ImageBuilder-$(PKG_OS)-$(PKG_CPU)-$(PKG_RELEASE) -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME) +IB_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME) all: compile -$(BIN_DIR)/$(PKG_NAME).tar.bz2: +$(BIN_DIR)/$(SDK_NAME).tar.bz2: (cd $(STAGING_DIR); \ rm -rf info man share; \ cd usr; \ rm -rf doc info man share; \ ) - rm -rf $(PKG_BUILD_DIR) - mkdir -p $(PKG_BUILD_DIR)/dl $(PKG_BUILD_DIR)/examples $(PKG_BUILD_DIR)/package - cp -a $(STAGING_DIR) $(SCRIPT_DIR) $(TOPDIR)/docs $(PKG_BUILD_DIR)/ - cp -a $(TOPDIR)/package/strace $(TOPDIR)/package/iproute2 $(PKG_BUILD_DIR)/examples - cp $(TOPDIR)/rules.mk $(PKG_BUILD_DIR)/ - cp ./files/Makefile.sdk $(PKG_BUILD_DIR)/Makefile - cp ./files/README.SDK $(PKG_BUILD_DIR)/ - cp ./files/depend.mk $(PKG_BUILD_DIR)/package/ - egrep '^BR2_(ARCH|WGET|STAGING|JLEVEL|LARGEFILE|TARGET_OPT)' $(TOPDIR)/.config > $(PKG_BUILD_DIR)/.config - find $(PKG_BUILD_DIR) -name CVS | xargs rm -rf + rm -rf $(SDK_BUILD_DIR) + mkdir -p $(SDK_BUILD_DIR)/dl $(SDK_BUILD_DIR)/examples $(SDK_BUILD_DIR)/package + cp -a $(STAGING_DIR) $(SCRIPT_DIR) $(TOPDIR)/docs $(SDK_BUILD_DIR)/ + cp -a $(TOPDIR)/package/strace $(TOPDIR)/package/iproute2 $(SDK_BUILD_DIR)/examples + cp $(TOPDIR)/rules.mk $(SDK_BUILD_DIR)/ + cp ./files/Makefile.sdk $(SDK_BUILD_DIR)/Makefile + cp ./files/README.SDK $(SDK_BUILD_DIR)/ + cp ./files/depend.mk $(SDK_BUILD_DIR)/package/ + egrep '^BR2_(ARCH|WGET|STAGING|JLEVEL|LARGEFILE|TARGET_OPT)' $(TOPDIR)/.config > $(SDK_BUILD_DIR)/.config + find $(SDK_BUILD_DIR) -name CVS | xargs rm -rf (cd $(BUILD_DIR); \ - tar cfj $@ $(PKG_NAME); \ + tar cfj $@ $(SDK_NAME); \ + ) + +$(BIN_DIR)/$(IB_NAME).tar.bz2: + rm -rf $(IB_BUILD_DIR) + mkdir -p $(IB_BUILD_DIR)/build + (cd $(BUILD_DIR); \ + cp buildroot-kernel-image loader.gz $(IB_BUILD_DIR)/build; \ + ) + mkdir -p $(IB_BUILD_DIR)/utils + (cd $(STAGING_DIR)/bin; \ + cp addpattern trx motorola-bin sed mkfs.jffs2 mksquashfs-lzma $(IB_BUILD_DIR)/utils; \ + ) + mkdir -p $(IB_BUILD_DIR)/include + mkdir -p $(IB_BUILD_DIR)/packages + (cd $(PACKAGE_DIR); \ + cp busybox_* kmod-brcm-* kmod-wlcompat* dnsmasq_* iptables_* dropbear_* kmod-diag_* \ + wireless-tools_* zlib* bridge_* ppp_* ppp-pppoe* kmod-ppp* openwrt-utils* $(IB_BUILD_DIR)/packages/; \ + ) + egrep '^[^(include|prepare|compile|install)]' < $(TOPDIR)/target/jffs2/Makefile > $(IB_BUILD_DIR)/include/jffs2.mk + egrep '^[^(include|prepare|compile|install)]' < $(TOPDIR)/target/squashfs-lzma/Makefile > $(IB_BUILD_DIR)/include/squashfs-lzma.mk + cp ./files/README.ImageBuilder $(IB_BUILD_DIR)/ + cp ./files/Makefile.ib $(IB_BUILD_DIR)/Makefile + cp -a $(TOPDIR)/target/default/target_skeleton $(IB_BUILD_DIR)/ + for target_dir in etc jffs dev proc tmp lib usr/lib usr/sbin; do \ + mkdir -p $(IB_BUILD_DIR)/target_skeleton/$$target_dir; \ + done + cp -a ./files/sysconf $(IB_BUILD_DIR)/target_skeleton/etc/ + cp -a $(TARGET_DIR)/lib/*.so* $(IB_BUILD_DIR)/target_skeleton/lib/ + cp -a $(BUILD_DIR)/libshared/libshared.so $(IB_BUILD_DIR)/target_skeleton/usr/lib/ + cp -a $(BUILD_DIR)/libnvram/libnvram.so $(IB_BUILD_DIR)/target_skeleton/usr/lib/ + cp -a $(BUILD_DIR)/libnvram/nvram $(IB_BUILD_DIR)/target_skeleton/usr/sbin/ + cp -a $(BUILD_DIR)/linksys-wlconf/wlconf $(IB_BUILD_DIR)/target_skeleton/usr/sbin/ + -$(STRIP) $(IB_BUILD_DIR)/target_skeleton/usr/lib/* $(IB_BUILD_DIR)/target_skeleton/usr/sbin/* + ln -sf /tmp/resolv.conf $(IB_BUILD_DIR)/target_skeleton/etc/resolv.conf + ln -sf /tmp $(IB_BUILD_DIR)/target_skeleton/var + find $(IB_BUILD_DIR) -name CVS | xargs rm -rf + (cd $(BUILD_DIR); \ + tar cfj $@ $(IB_NAME); \ ) source: prepare: -compile: $(BIN_DIR)/$(PKG_NAME).tar.bz2 +compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2 $(BIN_DIR)/$(IB_NAME).tar.bz2 install: clean: - rm -rf $(PKG_BUILD_DIR) + rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.bz2 $(BIN_DIR)/$(IB_NAME).tar.bz2 diff --git a/openwrt/package/sdk/files/Makefile.ib b/openwrt/package/sdk/files/Makefile.ib new file mode 100644 index 0000000000..9fbfeee510 --- /dev/null +++ b/openwrt/package/sdk/files/Makefile.ib @@ -0,0 +1,61 @@ +# OpenWrt SDK Makefile +TOPDIR:=${shell pwd} +BIN_DIR:=$(TOPDIR)/bin +BUILD_DIR:=$(TOPDIR)/build +TARGET_PATH := $(TOPDIR)/utils +MKFS_JFFS2:=$(TOPDIR)/utils/mkfs.jffs2 +IMAGE:=$(BUILD_DIR)/root_fs +TARGET_DIR:=$(TOPDIR)/root +SED:=PATH="$(TARGET_PATH)" sed -i -e +PACKAGE_DIR=$(TOPDIR)/packages +IPKG:=IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(BUILD_DIR)/etc $(TARGET_DIR)/bin/ipkg -force-defaults -force-depends + +all: build + +include ./include/jffs2.mk +include ./include/squashfs-lzma.mk + +IMAGE_TARGETS := $(JFFS2_TARGETS) $(SQUASHFS_TARGETS) +TARGET_FS:=squashfs jffs2 + +define IMAGE_template +$(BIN_DIR)/openwrt-wrt54g-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-4MB,$(1)).trx + PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g + $(SED) "1s,^W54S,W54G," $$@ + +$(BIN_DIR)/openwrt-wrt54gs-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-8MB,$(1)).trx + PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g + +IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54g-$(1).bin +IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54gs-$(1).bin + + +$(BIN_DIR)/openwrt-motorola-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-8MB,$(1)).trx + PATH=$(TARGET_PATH) motorola-bin $$< $$@ + +IMAGE_TARGETS += $(BIN_DIR)/openwrt-motorola-$(1).bin +endef + +$(foreach fs,$(TARGET_FS),$(eval $(call IMAGE_template,$(fs)))) + +$(IMAGE_TARGETS): $(TARGET_DIR) $(BIN_DIR) packages_install + +$(BIN_DIR): + mkdir -p $@ + +$(TARGET_DIR): + mkdir -p $@ + cp -a $(TOPDIR)/target_skeleton/* $(TARGET_DIR)/ + +$(BUILD_DIR)/etc/ipkg.conf: + mkdir -p $(BUILD_DIR)/etc + echo -e 'dest root /\noption offline_root $(TARGET_DIR)' > $@ + +packages_install: $(TARGET_DIR) $(BUILD_DIR)/etc/ipkg.conf + for package in $(PACKAGE_DIR)/*.ipk; do \ + $(IPKG) install $$package; \ + done + +build: clean $(IMAGE_TARGETS) +clean: + rm -rf $(TARGET_DIR) $(BIN_DIR) $(IMAGE)-* $(BUILD_DIR)/etc diff --git a/openwrt/package/sdk/files/README.ImageBuilder b/openwrt/package/sdk/files/README.ImageBuilder new file mode 100644 index 0000000000..7bf89392a0 --- /dev/null +++ b/openwrt/package/sdk/files/README.ImageBuilder @@ -0,0 +1,8 @@ +This is the OpenWrt Image Builder. You can use it to make customized +OpenWrt Images without having to compile anything. + +Just put all the extra packages you need in packages/ and make changes +to target_skeleton if you like. + +After that run 'make' and it will build the OpenWrt images in the bin/ +directory. diff --git a/openwrt/package/sdk/files/sysconf b/openwrt/package/sdk/files/sysconf new file mode 100644 index 0000000000..326a5823df --- /dev/null +++ b/openwrt/package/sdk/files/sysconf @@ -0,0 +1,4 @@ +BR2_SYSCONF_TELNET_FAILSAFE_ONLY=y +BR2_SYSCONF_FAILSAFE_IP="192.168.1.1" +BR2_SYSCONF_FAILSAFE_NETMASK="255.255.255.0" +BR2_SYSCONF_FAILSAFE_MAC="00:00:BA:DC:0D:ED" diff --git a/openwrt/target/Makefile b/openwrt/target/Makefile index 437609a28b..c3d99b6526 100644 --- a/openwrt/target/Makefile +++ b/openwrt/target/Makefile @@ -74,7 +74,7 @@ $(BIN_DIR): $(INSTALL_TARGET_DIRS): lzma-loader-compile $(IMAGE_TARGETS): $(patsubst %,%-install,$(TARGET_DIRS)) -compile: $(patsubst %,%-compile,$(TARGET_DIRS)) +compile: $(patsubst %,%-compile,jffs2 squashfs-lzma lzma-loader) install: utils-install lzma-install $(LINUX_IMAGE) $(patsubst %,%-install,$(TARGET_DIRS)) $(IMAGE_TARGETS) clean: $(patsubst %,%-clean,$(TARGET_DIRS)) image_clean diff --git a/openwrt/target/jffs2/Makefile b/openwrt/target/jffs2/Makefile index 0e14ac6f2a..5925a9e123 100644 --- a/openwrt/target/jffs2/Makefile +++ b/openwrt/target/jffs2/Makefile @@ -2,13 +2,13 @@ include $(TOPDIR)/rules.mk include ./jffs2root.mk -TARGETS:= $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx $(BIN_DIR)/openwrt-generic-jffs2-8MB.trx +JFFS2_TARGETS:= $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx $(BIN_DIR)/openwrt-generic-jffs2-8MB.trx JFFS2OPTS := --pad --little-endian --squash -d $(TARGET_DIR) #JFFS2OPTS += -Xlzo -msize -Xlzari prepare: $(MTD_DIR)/.unpacked compile: mtd -install: compile $(TARGETS) +install: compile $(JFFS2_TARGETS) clean: jffs2root-dirclean $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx: @@ -21,16 +21,3 @@ $(BIN_DIR)/openwrt-generic-jffs2-8MB.trx: PATH=$(TARGET_PATH) trx -o $@ $(BUILD_DIR)/loader.gz \ $(LINUX_IMAGE) -a 0x20000 $(IMAGE)-8MB.jffs2 -$(BIN_DIR)/openwrt-wrt54g-jffs2.bin: $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx - PATH=$(TARGET_PATH) addpattern -2 -i $< -o $@ -g - $(SED) "1s,^W54S,W54G," $@ - -$(BIN_DIR)/openwrt-wrt54gs-jffs2.bin: $(BIN_DIR)/openwrt-generic-jffs2-8MB.trx - PATH=$(TARGET_PATH) addpattern -2 -i $< -o $@ -g - -$(BIN_DIR)/openwrt-motorola-jffs2-4MB.bin: $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx - PATH=$(TARGET_PATH) motorola-bin $< $@ - -$(BIN_DIR)/openwrt-motorola-jffs2-8MB.bin: $(BIN_DIR)/openwrt-generic-jffs2-8MB.trx - PATH=$(TARGET_PATH) motorola-bin $< $@ - diff --git a/openwrt/target/jffs2/jffs2root.mk b/openwrt/target/jffs2/jffs2root.mk index c1d31e4106..6ed7a375c6 100644 --- a/openwrt/target/jffs2/jffs2root.mk +++ b/openwrt/target/jffs2/jffs2root.mk @@ -8,7 +8,7 @@ MTD_DIR:=$(BUILD_DIR)/mtd-20050122.orig MTD_SOURCE=mtd_20050122.orig.tar.gz MTD_SITE=http://ftp.debian.org/debian/pool/main/m/mtd MTD_MD5SUM:=1f42c2cae08eb9e7b52d0c188f8d6338 -MKFS_JFFS2=$(shell which mkfs.jffs2 2>/dev/null || echo $(MTD_DIR)/util/mkfs.jffs2) +MKFS_JFFS2=$(MTD_DIR)/util/mkfs.jffs2 $(DL_DIR)/$(MTD_SOURCE): $(SCRIPT_DIR)/download.pl $(DL_DIR) $(MTD_SOURCE) $(MTD_MD5SUM) $(MTD_SITE) @@ -20,7 +20,10 @@ $(MTD_DIR)/.unpacked: $(DL_DIR)/$(MTD_SOURCE) $(MTD_DIR)/util/mkfs.jffs2: $(MTD_DIR)/.unpacked $(MAKE) LINUXDIR=$(LINUX_DIR) -C $(MTD_DIR)/util -mtd: $(MKFS_JFFS2) +$(STAGING_DIR)/bin/mkfs.jffs2: $(MTD_DIR)/util/mkfs.jffs2 + cp $< $@ + +mtd: $(MTD_DIR)/util/mkfs.jffs2 $(STAGING_DIR)/bin/mkfs.jffs2 ############################################################# diff --git a/openwrt/target/squashfs-lzma/Makefile b/openwrt/target/squashfs-lzma/Makefile index 8da08b3909..2664ed7e21 100644 --- a/openwrt/target/squashfs-lzma/Makefile +++ b/openwrt/target/squashfs-lzma/Makefile @@ -1,16 +1,16 @@ include $(TOPDIR)/rules.mk include ./squashfslzmaroot.mk -TARGETS:=$(BIN_DIR)/openwrt-generic-squashfs.trx +SQUASHFS_TARGETS:=$(BIN_DIR)/openwrt-generic-squashfs.trx prepare: $(SQUASHFSLZMA_DIR)/.unpacked compile: squashfslzma -install: $(TARGETS) +install: $(SQUASHFS_TARGETS) clean: squashfslzmaroot-dirclean $(BIN_DIR)/openwrt-generic-squashfs.trx: @mkdir -p $(TARGET_DIR)/jffs - $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma $(TARGET_DIR) $(IMAGE).squashfslzma -noappend -root-owned -le + PATH=$(TARGET_PATH) mksquashfs-lzma $(TARGET_DIR) $(IMAGE).squashfslzma -noappend -root-owned -le PATH=$(TARGET_PATH) trx -o $@ $(BUILD_DIR)/loader.gz \ $(LINUX_IMAGE) $(IMAGE).squashfslzma diff --git a/openwrt/target/squashfs-lzma/squashfslzmaroot.mk b/openwrt/target/squashfs-lzma/squashfslzmaroot.mk index ca493d7782..11b2b76bea 100644 --- a/openwrt/target/squashfs-lzma/squashfslzmaroot.mk +++ b/openwrt/target/squashfs-lzma/squashfslzmaroot.mk @@ -16,10 +16,13 @@ $(SQUASHFSLZMA_DIR)/.unpacked: $(DL_DIR)/$(SQUASHFSLZMA_SOURCE) patch -d $(SQUASHFSLZMA_DIR) -p1 < squashfs2.0-tools-lzma.patch touch $(SQUASHFSLZMA_DIR)/.unpacked -$(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs: $(SQUASHFSLZMA_DIR)/.unpacked +$(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma: $(SQUASHFSLZMA_DIR)/.unpacked $(MAKE) -C $(SQUASHFSLZMA_DIR)/squashfs-tools mksquashfs-lzma LZMAPATH=$(BUILD_DIR)/lzma -squashfslzma: $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs +$(STAGING_DIR)/bin/mksquashfs-lzma: $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma + cp $< $@ + +squashfslzma: $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma $(STAGING_DIR)/bin/mksquashfs-lzma squashfslzma-source: $(DL_DIR)/$(SQUASHFSLZMA_SOURCE) -- 2.30.2