aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2007-01-10 21:52:28 +0000
committerFelix Fietkau <nbd@openwrt.org>2007-01-10 21:52:28 +0000
commit7a6a6464971c69fa1026aeaf8fad5c79250230e9 (patch)
treea68bcf07bd0d15b68d1b990877a55002585690b9
parent927fb16abb41cfeeee4e97b4baed2d5ce036ca2e (diff)
downloadupstream-7a6a6464971c69fa1026aeaf8fad5c79250230e9.tar.gz
upstream-7a6a6464971c69fa1026aeaf8fad5c79250230e9.tar.bz2
upstream-7a6a6464971c69fa1026aeaf8fad5c79250230e9.zip
Add initial version of the new Image Builder It's still a bit rough in a few places, but it seems to work for Broadcom at least - other targets untested.
SVN-Revision: 6071
-rw-r--r--Config.in1
-rw-r--r--include/image.mk23
-rw-r--r--include/target.mk5
-rw-r--r--target/Makefile14
-rw-r--r--target/imagebuilder/Config.in10
-rw-r--r--target/imagebuilder/Makefile46
-rw-r--r--target/imagebuilder/files/Makefile147
-rw-r--r--target/linux/atheros-2.6/image/Makefile6
-rw-r--r--target/linux/ixp4xx-2.6/image/Makefile3
-rw-r--r--target/linux/magicbox-2.6/image/Makefile5
-rw-r--r--target/linux/rb532-2.6/image/Makefile8
-rw-r--r--target/linux/rdc-2.6/image/Makefile3
-rwxr-xr-xtarget/linux/uml-2.6/image/Makefile6
-rw-r--r--target/linux/x86-2.6/image/Makefile6
14 files changed, 263 insertions, 20 deletions
diff --git a/Config.in b/Config.in
index 18555a4325..2efd1ce25d 100644
--- a/Config.in
+++ b/Config.in
@@ -59,6 +59,7 @@ config SOURCE_FEEDS
Separate sources with spaces : " "
source "toolchain/Config.in"
+source "target/imagebuilder/Config.in"
source "target/sdk/Config.in"
menu "Target Images"
diff --git a/include/image.mk b/include/image.mk
index 702434ec86..4f638f0260 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -77,10 +77,15 @@ endef
define BuildImage
download:
prepare:
-compile: compile-targets
+ifneq ($(IB),1)
+ compile: compile-targets
$(call Build/Compile)
+else
+ compile:
+endif
-install: compile install-targets
+ifneq ($(IB),1)
+ install: compile install-targets
$(call Image/Prepare)
$(call Image/mkfs/prepare)
$(call Image/BuildKernel)
@@ -88,9 +93,21 @@ install: compile install-targets
$(call Image/mkfs/squashfs)
$(call Image/mkfs/tgz)
$(call Image/mkfs/ext2)
+else
+ install: compile install-targets
+ $(call Image/BuildKernel)
+ $(call Image/mkfs/jffs2)
+ $(call Image/mkfs/squashfs)
+ $(call Image/mkfs/tgz)
+ $(call Image/mkfs/ext2)
+endif
-clean: clean-targets
+ifneq ($(IB),1)
+ clean: clean-targets
$(call Build/Clean)
+else
+ clean:
+endif
compile-targets:
install-targets:
diff --git a/include/target.mk b/include/target.mk
index 042e85d326..17a41f7c49 100644
--- a/include/target.mk
+++ b/include/target.mk
@@ -7,6 +7,11 @@
include $(TMP_DIR)/.target.mk
+ifeq ($(IB),1)
+$(TMP_DIR)/.target.mk: $(TOPDIR)/.target.mk
+ $(CP) $< $@
+else
$(TMP_DIR)/.target.mk: $(TMP_DIR)/.targetinfo
$(SCRIPT_DIR)/gen_target_mk.pl < $(TMP_DIR)/.targetinfo > $@
+endif
diff --git a/target/Makefile b/target/Makefile
index 651c13f6ff..4853e3fbd2 100644
--- a/target/Makefile
+++ b/target/Makefile
@@ -12,25 +12,24 @@ all: install
$(BIN_DIR):
mkdir -p $(BIN_DIR)
-TARGETS-y := linux
-TARGETS-$(CONFIG_SDK) += sdk
-
linux-install: $(BIN_DIR)
image_install: linux-install
IMAGE_DIR:=linux/$(BOARD)-$(KERNEL)/image
-
download: $(patsubst %,%-download,$(TARGETS-y))
prepare: linux-prepare
compile: linux-compile image_compile
-install: image_clean $(patsubst %,%-install,$(TARGETS-y)) image_install
-clean: $(patsubst %,%-clean,$(TARGETS-y)) image_clean
+install: image_clean linux-install sdk_install image_install imagebuilder_install
+clean: linux-clean sdk-clean imagebuilder-clean image_clean
prereq: FORCE
$(MAKE) -C linux/$(BOARD)-$(KERNEL) prereq
$(MAKE) -C $(IMAGE_DIR) prereq
+sdk_install: FORCE
+ $(MAKE) -C sdk install
+
image_clean: FORCE
$(MAKE) -C $(IMAGE_DIR) clean
rm -f $(BIN_DIR)/openwrt-*
@@ -41,6 +40,9 @@ image_compile: FORCE
image_install: image_compile
$(MAKE) -C $(IMAGE_DIR) install
+imagebuilder_install: image_install
+ $(MAKE) -C imagebuilder install
+
%-clean: FORCE
$(MAKE) -C $(patsubst %-clean,%,$@) clean
%-download: FORCE
diff --git a/target/imagebuilder/Config.in b/target/imagebuilder/Config.in
new file mode 100644
index 0000000000..95aeb5d1a5
--- /dev/null
+++ b/target/imagebuilder/Config.in
@@ -0,0 +1,10 @@
+config IB
+ bool "Build the OpenWrt Image Builder"
+ depends !TARGET_ROOTFS_INITRAMFS
+ default y if ALL
+ help
+ This is essentially a stripped-down version of the buildroot
+ with precompiled packages, kernel image and image building tools.
+ You can use it to generate custom images without compiling anything
+
+
diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile
new file mode 100644
index 0000000000..470d045642
--- /dev/null
+++ b/target/imagebuilder/Makefile
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: Makefile 6070 2007-01-10 21:21:59Z nbd $
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/host.mk
+
+PKG_OS:=$(shell uname -s)
+PKG_CPU:=$(shell uname -m)
+
+IB_NAME:=OpenWrt-ImageBuilder-$(BOARD)-$(KERNEL)-for-$(PKG_OS)-$(PKG_CPU)
+IB_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
+
+all: compile
+
+$(BIN_DIR)/$(IB_NAME).tar.bz2:
+ rm -rf $(IB_BUILD_DIR)
+ mkdir -p $(IB_BUILD_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) $(IB_BUILD_DIR)/staging_dir_$(ARCH)/bin $(IB_BUILD_DIR)/target/linux
+ $(CP) \
+ $(INCLUDE_DIR) $(SCRIPT_DIR) $(PACKAGE_DIR) \
+ $(TOPDIR)/rules.mk $(TOPDIR)/.config \
+ $(TMP_DIR)/.target.mk \
+ ./files/Makefile \
+ $(IB_BUILD_DIR)/
+ $(CP) $(STAGING_DIR)/bin/* $(IB_BUILD_DIR)/staging_dir_$(ARCH)/bin
+ $(CP) $(TOPDIR)/target/linux/* $(IB_BUILD_DIR)/target/linux
+ rm -rf $(IB_BUILD_DIR)/target/linux/*/patches
+ -cp $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/* $(IB_BUILD_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) # don't copy subdirectories here
+ find $(IB_BUILD_DIR) -name .svn | xargs rm -rf
+ find $(IB_BUILD_DIR) -name CVS | xargs rm -rf
+ (cd $(BUILD_DIR); \
+ tar cfj $@ $(IB_NAME); \
+ )
+
+download:
+prepare:
+compile: $(BIN_DIR)/$(IB_NAME).tar.bz2
+install: compile
+
+clean:
+ rm -rf $(IB_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2
diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile
new file mode 100644
index 0000000000..720bcfa768
--- /dev/null
+++ b/target/imagebuilder/files/Makefile
@@ -0,0 +1,147 @@
+# Makefile for the OpenWrt Image Builder
+#
+# Copyright (C) 2006-2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+export TOPDIR=${CURDIR}
+
+all: help
+
+include rules.mk
+include .config
+
+SHELL:=/usr/bin/env bash
+export LC_ALL=C
+export LANG=C
+ifeq ($(KBUILD_VERBOSE),99)
+ MAKE:=3>/dev/null $(MAKE)
+endif
+export IS_TTY=$(shell tty -s && echo 1 || echo 0)
+
+# override variables from rules.mk
+PACKAGE_DIR:=$(TOPDIR)/packages
+IPKG:= \
+ IPKG_TMP="$(TOPDIR)/tmp/ipkgtmp" \
+ IPKG_INSTROOT="$(TARGET_DIR)" \
+ IPKG_CONF_DIR="$(TOPDIR)/tmp" \
+ IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
+ $(SCRIPT_DIR)/ipkg -force-defaults
+
+
+define Profile/Default
+ ID:=
+ NAME:=
+ PACKAGES:=
+endef
+
+define Profile
+ $(eval $(call Profile/Default))
+ $(eval $(call Profile/$(1)))
+ ifneq ($(ID),)
+ ifeq ($(PROFILE),)
+ PROFILE:=$(ID)
+ endif
+ $(ID)_NAME:=$(NAME)
+ $(ID)_PACKAGES:=$(PACKAGES)
+ PROFILE_LIST += \
+ echo '$(ID):'; echo ' $(NAME)';
+ endif
+endef
+
+include .target.mk
+
+define Helptext
+Available Commands:
+ help: This help text
+ info: Show a list of available target profiles
+ clean: Remove images and temporary build files
+ image: Build an image (see below for more information).
+
+Building images:
+ By default 'make image' will create an image with the default
+ target profile and package set. You can use the following parameters
+ to change that:
+
+ make image PROFILE="<profilename>" # override the default target profile
+ make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
+ make image FILES="<path>" # include extra files from <path>
+
+endef
+$(eval $(call shexport,Helptext))
+
+help: FORCE
+ echo "$$$(call shvar,Helptext)"
+
+info: FORCE
+ echo 'Current Target: "$(BOARDNAME)"'
+ echo 'Available Profiles:'
+ echo; $(PROFILE_LIST)
+
+$(TOPDIR)/tmp/ipkg.conf: FORCE
+ @mkdir -p $(TOPDIR)/tmp
+ @echo 'dest root /' > $@
+ @echo 'src packages file:$(TOPDIR)/packages' >> $@
+
+BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(PACKAGES) $($(PROFILE)_PACKAGES) kernel)
+BUILD_PACKAGES:=$(patsubst base-files,base-files-$(BOARD)-$(KERNEL),$(BUILD_PACKAGES))
+
+image: $(TOPDIR)/tmp/ipkg.conf
+ if [ -z "$($(PROFILE)_NAME)" ]; then \
+ echo Profile $(PROFILE) not found.; \
+ echo 'Use "make info" to get a list of available target profiles'; \
+ false; \
+ fi
+ echo 'Building images for $(BOARDNAME) - $($(PROFILE)_NAME)'
+ echo 'Packages: $(BUILD_PACKAGES)'
+ echo
+ rm -rf $(TARGET_DIR)
+ mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR)
+ $(MAKE) package_index
+ $(MAKE) package_install
+ifneq ($(FILES),)
+ $(MAKE) copy_files
+endif
+ $(MAKE) package_postinst
+ $(MAKE) build_image
+
+package_index: FORCE
+ @echo
+ @echo Building package index...
+ (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages) >/dev/null 2>/dev/null
+ $(IPKG) update
+
+package_install: FORCE
+ @echo
+ @echo Installing packages...
+ $(IPKG) install $(BUILD_PACKAGES)
+
+copy_files: FORCE
+ @echo
+ @echo Copying extra files
+ $(CP) $(FILES)/* $(TARGET_DIR)/
+
+package_postinst: FORCE
+ @echo
+ @echo Activating init scripts
+ ( \
+ cd $(BUILD_DIR)/root; \
+ for script in ./etc/init.d/*; do \
+ grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
+ IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \
+ done; \
+ )
+
+build_image: FORCE
+ @echo
+ @echo Building images...
+ $(NO_TRACE_MAKE) -C target/linux/$(BOARD)-$(KERNEL)/image install IB=1
+
+clean:
+ rm -rf tmp $(TARGET_DIR)
+
+.PHONY: FORCE
+.SILENT: help info image
+%: ;
diff --git a/target/linux/atheros-2.6/image/Makefile b/target/linux/atheros-2.6/image/Makefile
index fb8cf3ced2..80e3335920 100644
--- a/target/linux/atheros-2.6/image/Makefile
+++ b/target/linux/atheros-2.6/image/Makefile
@@ -7,8 +7,12 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
+define Image/Prepare
+ cp $(KDIR)/linux-*/vmlinux $(KDIR)/vmlinux.elf
+endef
+
define Image/BuildKernel
- cp $(KDIR)/linux-*/vmlinux $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
+ cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
$(STAGING_DIR)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7
dd if=$(KDIR)/vmlinux.bin.l7 of=$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.lzma bs=65536 conv=sync
diff --git a/target/linux/ixp4xx-2.6/image/Makefile b/target/linux/ixp4xx-2.6/image/Makefile
index 9359c5b11e..cbbb29b6b9 100644
--- a/target/linux/ixp4xx-2.6/image/Makefile
+++ b/target/linux/ixp4xx-2.6/image/Makefile
@@ -24,10 +24,11 @@ define Build/Clean
endef
define Image/Prepare
+ cp $(LINUX_DIR)/arch/arm/boot/zImage $(KDIR)/zImage
endef
define Image/BuildKernel
- cp $(LINUX_DIR)/arch/arm/boot/zImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-zImage
+ cp $(KDIR)/zImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-zImage
# $(shell BIN_DIR=$(BIN_DIR) $(TOPDIR)/scripts/arm-magic.sh)
BIN_DIR=$(BIN_DIR) $(TOPDIR)/scripts/arm-magic.sh
endef
diff --git a/target/linux/magicbox-2.6/image/Makefile b/target/linux/magicbox-2.6/image/Makefile
index 10f71df2a9..77ff88f521 100644
--- a/target/linux/magicbox-2.6/image/Makefile
+++ b/target/linux/magicbox-2.6/image/Makefile
@@ -11,10 +11,11 @@ define Build/Clean
endef
define Image/Prepare
+ cp $(LINUX_DIR)/arch/ppc/boot/images/uImage $(KDIR)/uImage
endef
define Image/BuildKernel
- cp $(LINUX_DIR)/arch/ppc/boot/images/uImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-uImage
+ cp $(KDIR)/uImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-uImage
endef
define Image/Build
@@ -23,7 +24,7 @@ endef
define Image/Build/jffs2-64k
( \
- dd if=$(LINUX_DIR)/arch/ppc/boot/images/uImage bs=65536 conv=sync; \
+ dd if=$(KDIR)/uImage bs=65536 conv=sync; \
dd if=$(KDIR)/root.$(1) bs=65536 conv=sync; \
) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
endef
diff --git a/target/linux/rb532-2.6/image/Makefile b/target/linux/rb532-2.6/image/Makefile
index 4e1c1addd1..706b672e74 100644
--- a/target/linux/rb532-2.6/image/Makefile
+++ b/target/linux/rb532-2.6/image/Makefile
@@ -29,13 +29,13 @@ define Build/Clean
endef
define Image/Prepare
- $(STAGING_DIR)/bin/patch-cmdline $(LINUX_DIR)/vmlinux 'root=/dev/cfa2 '
$(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
+ cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+ $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
+ cp $(LINUX_DIR)/vmlinux $(KDIR)/vmlinux.elf
endef
define Image/BuildKernel
- cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
- $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
$(CP) $(KDIR)/loader.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
endef
@@ -52,7 +52,7 @@ root=/dev/cfa2 rootfstype=ext2
endef
define Image/Build
- $(STAGING_DIR)/bin/patch-cmdline $(LINUX_DIR)/vmlinux '$(strip $(call Image/cmdline/$(1))) '
+ $(STAGING_DIR)/bin/patch-cmdline $(KDIR)/vmlinux.elf '$(strip $(call Image/cmdline/$(1))) '
./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin 4 $(LINUX_DIR)/vmlinux 16 $(KDIR)/root.$(1)
endef
diff --git a/target/linux/rdc-2.6/image/Makefile b/target/linux/rdc-2.6/image/Makefile
index 13c8718430..078e754e10 100644
--- a/target/linux/rdc-2.6/image/Makefile
+++ b/target/linux/rdc-2.6/image/Makefile
@@ -11,11 +11,12 @@ define Build/Clean
endef
define Image/Prepare
+ $(CP) $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/bzImage
endef
define Image/Build
touch $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
- $(STAGING_DIR)/bin/airlink -b 0 -j $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
+ $(STAGING_DIR)/bin/airlink -b 0 -j $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
endef
$(eval $(call BuildImage))
diff --git a/target/linux/uml-2.6/image/Makefile b/target/linux/uml-2.6/image/Makefile
index 6af4b8b816..b7bd9e9e65 100755
--- a/target/linux/uml-2.6/image/Makefile
+++ b/target/linux/uml-2.6/image/Makefile
@@ -7,9 +7,13 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
+define Image/Prepare
+ cp $(LINUX_DIR)/linux $(KDIR)/vmlinux.elf
+endef
+
define Image/Build
cp $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
- cp $(LINUX_DIR)/linux $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
+ cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
endef
$(eval $(call BuildImage))
diff --git a/target/linux/x86-2.6/image/Makefile b/target/linux/x86-2.6/image/Makefile
index e1425676dd..44c2ff7e3b 100644
--- a/target/linux/x86-2.6/image/Makefile
+++ b/target/linux/x86-2.6/image/Makefile
@@ -49,10 +49,14 @@ ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
endef
endif
+define Image/Prepare
+ cp $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/bzImage
+endef
+
define Image/Build
$(call Image/Build/grub,$(1))
cp $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).fs
- cp $(LINUX_DIR)/arch/i386/boot/bzImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz
+ cp $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz
endef
$(eval $(call BuildImage))