#
##############################################################
-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
#############################################################
#
target_prepare:
$(MAKE) -C target prepare
+target_compile:
+ $(MAKE) -C target compile
+
target_install:
$(MAKE) -C target install
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
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:
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
--- /dev/null
+# 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
--- /dev/null
+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.
--- /dev/null
+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"
$(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
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:
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 $< $@
-
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)
$(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
#############################################################
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
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)