sync whiterussian sdk with kamikaze
authorFelix Fietkau <nbd@openwrt.org>
Mon, 11 Jun 2007 15:15:00 +0000 (15:15 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 11 Jun 2007 15:15:00 +0000 (15:15 +0000)
SVN-Revision: 7567

27 files changed:
openwrt/package/sdk/files/Makefile
openwrt/package/sdk/files/include/depends.mk [new file with mode: 0644]
openwrt/package/sdk/files/include/host-build.mk
openwrt/package/sdk/files/include/host.mk
openwrt/package/sdk/files/include/image.mk
openwrt/package/sdk/files/include/netfilter.mk [deleted file]
openwrt/package/sdk/files/include/package-defaults.mk [new file with mode: 0644]
openwrt/package/sdk/files/include/package-dumpinfo.mk [new file with mode: 0644]
openwrt/package/sdk/files/include/package-ipkg.mk [new file with mode: 0644]
openwrt/package/sdk/files/include/package.mk
openwrt/package/sdk/files/include/prereq.mk
openwrt/package/sdk/files/include/quilt.mk [new file with mode: 0644]
openwrt/package/sdk/files/include/scan.mk [new file with mode: 0644]
openwrt/package/sdk/files/include/shell.sh
openwrt/package/sdk/files/include/unpack.mk
openwrt/package/sdk/files/include/verbose.mk
openwrt/package/sdk/files/package/Makefile
openwrt/package/sdk/files/scripts/config.guess [changed mode: 0644->0755]
openwrt/package/sdk/files/scripts/config.pl [new file with mode: 0755]
openwrt/package/sdk/files/scripts/download.pl
openwrt/package/sdk/files/scripts/flash.sh [deleted file]
openwrt/package/sdk/files/scripts/gen_deps.pl [deleted file]
openwrt/package/sdk/files/scripts/ipkg
openwrt/package/sdk/files/scripts/ipkg-make-index.sh [changed mode: 0644->0755]
openwrt/package/sdk/files/scripts/metadata.pl [new file with mode: 0755]
openwrt/package/sdk/files/scripts/rstrip.sh
openwrt/package/sdk/files/scripts/timestamp.pl

index ba488e380c9ebfbd1a0b9245af0a543b54e02799..0c0944882e978ad8dd57a0b32def78e6c31e7ae2 100644 (file)
@@ -17,7 +17,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-RELEASE:=Kamikaze
+RELEASE:=White Russian
 #VERSION:=2.0 # uncomment for final release
 
 #--------------------------------------------------------------
@@ -32,19 +32,11 @@ export DEVELOPER
 
 all: world
 
-.pkginfo: FORCE
-ifneq ($(shell ./scripts/timestamp.pl -p .pkginfo package Makefile),.pkginfo)
-       @echo Collecting package info...
-       @-for dir in package/*/; do \
-               echo Source-Makefile: $${dir}Makefile; \
-               $(MAKE) --no-print-dir DUMP=1 -C $$dir 2>&- || true; \
-       done > $@
-endif
+tmp/.packageinfo: FORCE
+       mkdir -p tmp/info
+       $(MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(wildcard package/*/Makefile include/package*.mk include/kernel.mk)" SCAN_EXTRA=""
 
-pkginfo-clean: FORCE
-       -rm -f .pkginfo .config.in
-
-package/%: .pkginfo FORCE
+package/%: tmp/.packageinfo FORCE
        $(MAKE) -C package $(patsubst package/%,%,$@) SDK=1
 
 download: FORCE
@@ -60,7 +52,7 @@ world: FORCE
        )
 
 clean: FORCE
-       rm -rf build_* bin
+       rm -rf build_* bin tmp/.packageinfo tmp/info
 
 distclean: clean
        rm -rf dl .pkg*
diff --git a/openwrt/package/sdk/files/include/depends.mk b/openwrt/package/sdk/files/include/depends.mk
new file mode 100644 (file)
index 0000000..1e01d35
--- /dev/null
@@ -0,0 +1,29 @@
+# 
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# define a dependency on a subtree
+# parameters:
+#      1: directory
+#      2: directory dependency
+#      3: tempfile for file listings
+#      4: find options
+
+DEP_FINDPARAMS := -type f -not -name ".*" -and -not -path "*.svn*" 
+define rdep
+  $(foreach file,$(shell find $(1) $(DEP_FINDPARAMS) -and -not -path "*:*" $(4)),
+    $(2): $(file)
+    $(file): ;
+  )
+
+  ifneq ($(3),)
+    ifneq ($$(shell find $(1) $(DEP_FINDPARAMS) $(4) 2>/dev/null | md5s),$(if $(3),$(shell cat $(3) 2>/dev/null)))
+      $(2): $(3)
+    endif
+  
+    $(3): FORCE
+         @-find $(1) $(DEP_FINDPARAMS) $(4) 2>/dev/null | md5s > $$@
+  endif
+endef
index 0502d7682a5c9514cd4e10d84fbdccfbef7375f8..b5c2a2203d00673115469a608c0e39c6e34325e2 100644 (file)
@@ -7,13 +7,19 @@
 
 include $(INCLUDE_DIR)/host.mk
 include $(INCLUDE_DIR)/unpack.mk
+include $(INCLUDE_DIR)/depends.mk
 
+STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s)
+STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
+STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
+
+include $(INCLUDE_DIR)/quilt.mk
+
+Build/Patch:=$(Build/Patch/Default)
 ifneq ($(strip $(PKG_UNPACK)),)
   define Build/Prepare/Default
        $(PKG_UNPACK)
-       @if [ -d ./patches ]; then \
-               $(PATCH) $(PKG_BUILD_DIR) ./patches; \
-       fi
+       $(Build/Patch)
   endef
 endif
 
@@ -69,30 +75,44 @@ ifneq ($(strip $(PKG_SOURCE)),)
        mkdir -p $(DL_DIR)
        $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
 
-  $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
+  $(STAMP_PREPARED): $(DL_DIR)/$(PKG_SOURCE)
+endif
+
+ifneq ($(CONFIG_AUTOREBUILD),)
+  define HostBuild/Autoclean
+    $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
+    $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
+    $(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),$(PKG_BUILD_DIR)/.dep_files, -and -not -path "/.*" -and -not -path "*/ipkg*")
+  endef
 endif
 
 define HostBuild
-  $(PKG_BUILD_DIR)/.prepared:
+  ifeq ($(DUMP),)
+    $(call HostBuild/Autoclean)
+  endif
+  
+  $(STAMP_PREPARED):
        @-rm -rf $(PKG_BUILD_DIR)
        @mkdir -p $(PKG_BUILD_DIR)
        $(call Build/Prepare)
        touch $$@
 
-  $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
+  $(STAMP_CONFIGURED): $(STAMP_PREPARED)
        $(call Build/Configure)
        touch $$@
 
-  $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
+  $(STAMP_BUILT): $(STAMP_CONFIGURED)
        $(call Build/Compile)
+       @$(NO_TRACE_MAKE) $(PKG_BUILD_DIR)/.dep_files
        touch $$@
 
-  $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
+  $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(STAMP_BUILT)
        $(call Build/Install)
+       mkdir -p $$(shell dirname $$@)
        touch $$@
        
   ifdef Build/Install
-    install-targets: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
+    install: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
   endif
 
   package-clean: FORCE
@@ -101,18 +121,11 @@ define HostBuild
        rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
 
   download:
-  prepare: $(PKG_BUILD_DIR)/.prepared
-  configure: $(PKG_BUILD_DIR)/.configured
-
-  compile-targets: $(PKG_BUILD_DIR)/.built
-  compile: compile-targets
-
-  install-targets:
-  install: install-targets
-
-  clean-targets:
+  prepare: $(STAMP_PREPARED)
+  configure: $(STAMP_CONFIGURED)
+  compile: $(STAMP_BUILT)
+  install:
   clean: FORCE
-       @$(MAKE) clean-targets
        $(call Build/Clean)
        rm -rf $(PKG_BUILD_DIR)
 
index 4a434711c3c8649c259cb3826aacb53fd9547c8d..833aa83a66fb3c75204c6fe74160e4a59d3fbc15 100644 (file)
@@ -9,6 +9,8 @@ include $(TMP_DIR)/.host.mk
 
 export TAR
 
+ifneq ($(__host_inc),1)
+__host_inc:=1
 $(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
        @mkdir -p $(TMP_DIR)
        @( \
@@ -26,9 +28,13 @@ $(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
                TAR=`which gtar 2>/dev/null`; \
                [ -n "$$TAR" -a -x "$$TAR" ] || TAR=`which tar 2>/dev/null`; \
                echo "TAR:=$$TAR" >> $@; \
-               ZCAT=`which gzcat 2>/dev/null`; \
-               [ -n "$$ZCAT" -a -x "$$ZCAT" ] || ZCAT=`which zcat 2>/dev/null`; \
-               echo "ZCAT:=$$ZCAT" >> $@; \
                echo "BASH:=$(shell which bash)" >> $@; \
        )
 
+endif
+
+ifeq ($(HOST_OS),Linux)
+  XARGS:=xargs -r
+else
+  XARGS:=xargs
+endif
index 4f638f026094b2a4bec81bd716921fbc739a246f..815f01ba029e48d3962b2f30283f4923005ab1bf 100644 (file)
@@ -7,6 +7,7 @@
 
 include $(INCLUDE_DIR)/prereq.mk
 include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/host.mk
 KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
 
 ifneq ($(CONFIG_BIG_ENDIAN),y)
@@ -17,6 +18,19 @@ JFFS2OPTS     :=  --pad --big-endian --squash
 SQUASHFS_OPTS :=  -be
 endif
 
+define add_jffs2_mark
+       echo -ne '\xde\xad\xc0\xde' >> $(1)
+endef
+
+# pad to 64k and add jffs2 end-of-filesystem mark
+# do this twice to make sure that this works with 128k blocksize as well
+define prepare_generic_squashfs
+       dd if=$(1) of=$(KDIR)/tmpfile.1 bs=64k conv=sync
+       $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
+       dd of=$(1) if=$(KDIR)/tmpfile.1 bs=64k conv=sync
+       $(call add_jffs2_mark,$(1))
+endef
+
 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
   ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
     define Image/mkfs/jffs2
@@ -25,9 +39,10 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
                $(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
 
+               
                # add End-of-Filesystem markers
-               echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-64k
-               echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-128k
+               $(call add_jffs2_mark,$(KDIR)/root.jffs2-64k)
+               $(call add_jffs2_mark,$(KDIR)/root.jffs2-128k)
        
                $(call Image/Build,jffs2-64k)
                $(call Image/Build,jffs2-128k)
@@ -47,8 +62,11 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
                tar -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ .
     endef
   endif
-  
-  
+else
+  define Image/BuildKernel
+       cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
+       $(call Image/Build/Initramfs)
+  endef
 endif
 
 
@@ -56,16 +74,16 @@ ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
   E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
   
   define Image/mkfs/ext2
-               $(STAGING_DIR)/bin/genext2fs -U -b $(E2SIZE) -I 1500 -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
+               $(STAGING_DIR)/bin/genext2fs -U -b $(E2SIZE) -I $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
                $(call Image/Build,ext2)
   endef
 endif
 
 
 define Image/mkfs/prepare/default
-       find $(BUILD_DIR)/root -type f -not -perm +0100 -not -name 'ssh_host*' | xargs chmod 0644
-       find $(BUILD_DIR)/root -type f -perm +0100 | xargs chmod 0755
-       find $(BUILD_DIR)/root -type d | xargs chmod 0755
+       find $(BUILD_DIR)/root -type f -not -perm +0100 -not -name 'ssh_host*' | $(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
diff --git a/openwrt/package/sdk/files/include/netfilter.mk b/openwrt/package/sdk/files/include/netfilter.mk
deleted file mode 100644 (file)
index 94699e5..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-# 
-# Copyright (C) 2006 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-# $Id: netfilter.mk 2411 2005-11-11 03:41:43Z nico $
-
-ifeq ($(NF_KMOD),1)
-P_V4:=ipv4/netfilter/
-P_XT:=netfilter/
-endif
-
-IPT_CONNTRACK-m :=
-IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_CONNMARK) += $(P_V4)ipt_connmark
-IPT_CONNTRACK-$(CONFIG_IP_NF_TARGET_CONNMARK) += $(P_V4)ipt_CONNMARK
-IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_CONNTRACK) += $(P_V4)ipt_conntrack
-IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_HELPER) += $(P_V4)ipt_helper
-IPT_CONNTRACK-$(CONFIG_IP_NF_MATCH_STATE) += $(P_V4)ipt_state
-IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_MATCH_CONNMARK) += $(P_XT)xt_connmark
-IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += $(P_XT)xt_CONNMARK
-IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_MATCH_CONNTRACK) += $(P_XT)xt_conntrack
-IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += $(P_XT)xt_helper
-IPT_CONNTRACK-$(CONFIG_NETFILTER_XT_MATCH_STATE) += $(P_XT)xt_state
-
-
-IPT_EXTRA-m :=
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_CONDITION) += $(P_V4)ipt_condition
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_CONNBYTES) += $(P_V4)ipt_connbytes
-IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_CONNBYTES) += $(P_XT)xt_connbytes
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_LIMIT) += $(P_V4)ipt_limit
-IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_LIMIT) += $(P_XT)xt_limit
-IPT_EXTRA-$(CONFIG_IP_NF_TARGET_LOG) += $(P_V4)ipt_LOG
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_MULTIPORT) += $(P_XT)xt_multiport
-IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += $(P_XT)xt_multiport
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_OWNER) += $(P_V4)ipt_owner
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_PHYSDEV) += $(P_V4)ipt_physdev
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_PKTTYPE) += $(P_V4)ipt_pkttype
-IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_PKTTYPE) += $(P_XT)xt_pkttype
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_QUOTA) += $(P_V4)ipt_quota
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_RECENT) += $(P_V4)ipt_recent
-IPT_EXTRA-$(CONFIG_IP_NF_TARGET_REJECT) += $(P_V4)ipt_REJECT
-IPT_EXTRA-$(CONFIG_IP_NF_MATCH_STRING) += $(P_V4)ipt_string
-IPT_EXTRA-$(CONFIG_NETFILTER_XT_MATCH_STRING) += $(P_XT)xt_string
-
-IPT_FILTER-m :=
-IPT_FILTER-$(CONFIG_IP_NF_MATCH_IPP2P) += $(P_V4)ipt_ipp2p
-IPT_FILTER-$(CONFIG_IP_NF_MATCH_LAYER7) += $(P_V4)ipt_layer7
-
-IPT_IMQ-m :=
-IPT_IMQ-$(CONFIG_IP_NF_TARGET_IMQ) += $(P_V4)ipt_IMQ
-
-IPT_IPOPT-m :=
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_DSCP) += $(P_V4)ipt_dscp
-IPT_IPOPT-$(CONFIG_IP_NF_TARGET_DSCP) += $(P_V4)ipt_DSCP
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_ECN) += $(P_V4)ipt_ecn
-IPT_IPOPT-$(CONFIG_IP_NF_TARGET_ECN) += $(P_V4)ipt_ECN
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_LENGTH) += $(P_V4)ipt_length
-IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += $(P_XT)xt_length
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_MAC) += $(P_V4)ipt_mac
-IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_MAC) += $(P_XT)xt_mac
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_MARK) += $(P_V4)ipt_mark
-IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_MARK) += $(P_XT)xt_mark
-IPT_IPOPT-$(CONFIG_IP_NF_TARGET_MARK) += $(P_V4)ipt_MARK
-IPT_IPOPT-$(CONFIG_NETFILTER_XT_TARGET_MARK) += $(P_XT)xt_MARK
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TCPMSS) += $(P_V4)ipt_tcpmss
-IPT_IPOPT-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += $(P_XT)xt_tcpmss
-IPT_IPOPT-$(CONFIG_IP_NF_TARGET_TCPMSS) += $(P_V4)ipt_TCPMSS
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TOS) += $(P_V4)ipt_tos
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TIME) += $(P_V4)ipt_time
-IPT_IPOPT-$(CONFIG_IP_NF_TARGET_TOS) += $(P_V4)ipt_TOS
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_TTL) += $(P_V4)ipt_ttl
-IPT_IPOPT-$(CONFIG_IP_NF_TARGET_TTL) += $(P_V4)ipt_TTL
-IPT_IPOPT-$(CONFIG_IP_NF_MATCH_UNCLEAN) += $(P_V4)ipt_unclean
-
-IPT_IPSEC-m :=
-IPT_IPSEC-$(CONFIG_IP_NF_MATCH_AH_ESP) += $(P_V4)ipt_ah $(P_V4)ipt_esp
-IPT_IPSEC-$(CONFIG_IP_NF_MATCH_AH) += $(P_V4)ipt_ah
-IPT_IPSEC-$(CONFIG_NETFILTER_XT_MATCH_ESP) += $(P_XT)xt_esp
-
-IPT_NAT-m :=
-ifneq ($(NF_KMOD),1)
-  IPT_NAT-$(CONFIG_IP_NF_NAT) += $(P_V4)ipt_SNAT $(P_V4)ipt_DNAT
-endif
-IPT_NAT-$(CONFIG_IP_NF_TARGET_MASQUERADE) += $(P_V4)ipt_MASQUERADE
-IPT_NAT-$(CONFIG_IP_NF_TARGET_MIRROR) += $(P_V4)ipt_MIRROR
-IPT_NAT-$(CONFIG_IP_NF_TARGET_REDIRECT) += $(P_V4)ipt_REDIRECT
-IPT_NAT-$(CONFIG_IP_NF_TARGET_NETMAP) += $(P_V4)ipt_NETMAP
-
-IPT_NAT_DEFAULT-m :=
-IPT_NAT_DEFAULT-$(CONFIG_IP_NF_FTP) += $(P_V4)ip_conntrack_ftp
-IPT_NAT_DEFAULT-$(CONFIG_IP_NF_NAT_FTP) += $(P_V4)ip_nat_ftp
-IPT_NAT_DEFAULT-$(CONFIG_IP_NF_IRC) += $(P_V4)ip_conntrack_irc
-IPT_NAT_DEFAULT-$(CONFIG_IP_NF_NAT_IRC) += $(P_V4)ip_nat_irc
-IPT_NAT_DEFAULT-$(CONFIG_IP_NF_TFTP) += $(P_V4)ip_conntrack_tftp
-
-IPT_NAT_EXTRA-m := 
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_AMANDA) += $(P_V4)ip_conntrack_amanda
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_CT_PROTO_GRE) += $(P_V4)ip_conntrack_proto_gre
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_PROTO_GRE) += $(P_V4)ip_nat_proto_gre
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_H323) += $(P_V4)ip_conntrack_h323
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_H323) += $(P_V4)ip_nat_h323
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_MMS) += $(P_V4)ip_conntrack_mms
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_MMS) += $(P_V4)ip_nat_mms
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_RTSP) += $(P_V4)ip_conntrack_rtsp
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_RTSP) += $(P_V4)ip_nat_rtsp
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_PPTP) += $(P_V4)ip_conntrack_pptp
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_SIP) += $(P_V4)ip_conntrack_sip
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_PPTP) += $(P_V4)ip_nat_pptp
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_SIP) += $(P_V4)ip_nat_sip
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += $(P_V4)ip_nat_snmp_basic
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_SIP) += $(P_V4)ip_conntrack_sip
-IPT_NAT_EXTRA-$(CONFIG_IP_NF_NAT_SIP) += $(P_V4)ip_nat_sip
-
-IPT_QUEUE-m :=
-IPT_QUEUE-$(CONFIG_IP_NF_QUEUE) += $(P_V4)ip_queue
-
-IPT_ULOG-m :=
-IPT_ULOG-$(CONFIG_IP_NF_TARGET_ULOG) += $(P_V4)ipt_ULOG
-
-IPT_BUILTIN := $(P_V4)ipt_standard
-IPT_BUILTIN += $(P_V4)ipt_icmp $(P_V4)ipt_tcp $(P_V4)ipt_udp
-IPT_BUILTIN += $(IPT_CONNTRACK-y)
-IPT_BUILTIN += $(IPT_EXTRA-y)
-IPT_BUILTIN += $(IPT_FILTER-y)
-IPT_BUILTIN += $(IPT_IMQ-y)
-IPT_BUILTIN += $(IPT_IPOPT-y)
-IPT_BUILTIN += $(IPT_IPSEC-y)
-IPT_BUILTIN += $(IPT_NAT-y)
-IPT_BUILTIN += $(IPT_ULOG-y)
diff --git a/openwrt/package/sdk/files/include/package-defaults.mk b/openwrt/package/sdk/files/include/package-defaults.mk
new file mode 100644 (file)
index 0000000..16d9ae0
--- /dev/null
@@ -0,0 +1,108 @@
+# 
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Package/Default
+  CONFIGFILE:=
+  SECTION:=opt
+  CATEGORY:=Extra packages
+  DEPENDS:=
+  PROVIDES:=
+  EXTRA_DEPENDS:=
+  MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
+  SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
+  ifneq ($(PKG_VERSION),)
+    ifneq ($(PKG_RELEASE),)
+      VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
+    else
+      VERSION:=$(PKG_VERSION)
+    endif
+  else
+    VERSION:=$(PKG_RELEASE)
+  endif
+  PKGARCH:=$(ARCH)
+  PRIORITY:=optional
+  DEFAULT:=
+  MENU:=
+  SUBMENU:=
+  SUBMENUDEP:=
+  TITLE:=
+  DESCRIPTION:=
+endef
+
+Build/Patch:=$(Build/Patch/Default)
+ifneq ($(strip $(PKG_UNPACK)),)
+  define Build/Prepare/Default
+       $(PKG_UNPACK)
+       $(Build/Patch)
+  endef
+endif
+
+TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
+TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
+
+CONFIGURE_ARGS = \
+               --target=$(GNU_TARGET_NAME) \
+               --host=$(GNU_TARGET_NAME) \
+               --build=$(GNU_HOST_NAME) \
+               --program-prefix="" \
+               --program-suffix="" \
+               --prefix=/usr \
+               --exec-prefix=/usr \
+               --bindir=/usr/bin \
+               --sbindir=/usr/sbin \
+               --libexecdir=/usr/lib \
+               --sysconfdir=/etc \
+               --datadir=/usr/share \
+               --localstatedir=/var \
+               --mandir=/usr/man \
+               --infodir=/usr/info \
+               $(DISABLE_NLS)
+
+CONFIGURE_VARS = \
+               $(TARGET_CONFIGURE_OPTS) \
+               CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
+               CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
+               CPPFLAGS="$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
+               LDFLAGS="$(TARGET_LDFLAGS)" \
+               PKG_CONFIG_PATH="$(STAGING_DIR)/usr/lib/pkgconfig" \
+               PKG_CONFIG_LIBDIR="$(STAGING_DIR)/usr/lib/pkgconfig"
+
+CONFIGURE_PATH = .
+CONFIGURE_CMD = ./configure
+
+define Build/Configure/Default
+       (cd $(PKG_BUILD_DIR)/$(CONFIGURE_PATH)/$(strip $(3)); \
+       if [ -x $(CONFIGURE_CMD) ]; then \
+               $(CONFIGURE_VARS) \
+               $(2) \
+               $(CONFIGURE_CMD) \
+               $(CONFIGURE_ARGS) \
+               $(1); \
+       fi; \
+       )
+endef
+
+MAKE_VARS = \
+       CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
+       CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
+       LDFLAGS="$(EXTRA_LDFLAGS) "
+
+MAKE_FLAGS = \
+       $(TARGET_CONFIGURE_OPTS) \
+       CROSS="$(TARGET_CROSS)" \
+       ARCH="$(ARCH)"
+
+MAKE_PATH = .
+
+define Build/Compile/Default
+       $(MAKE_VARS) \
+       $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+               $(MAKE_FLAGS) \
+               $(1);
+endef
+
+
diff --git a/openwrt/package/sdk/files/include/package-dumpinfo.mk b/openwrt/package/sdk/files/include/package-dumpinfo.mk
new file mode 100644 (file)
index 0000000..effb863
--- /dev/null
@@ -0,0 +1,38 @@
+# 
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifneq ($(DUMP),)
+  define Config
+    preconfig_$$(1) += echo "Preconfig: $(1)"; echo "Preconfig-Type: $(2)"; echo "Preconfig-Default: $(3)"; echo "Preconfig-Label: $(4)";
+  endef
+
+  define Dumpinfo
+    dumpinfo: dumpinfo-$(1)
+    .SILENT: dumpinfo-$(1)
+    dumpinfo-$(1): FORCE
+         @echo "Package: $(1)" ; \
+               $(if $(MENU),echo "Menu: $(MENU)";) \
+               $(if $(SUBMENU),echo "Submenu: $(SUBMENU)";) \
+               $(if $(SUBMENUDEP),echo "Submenu-Depends: $(SUBMENUDEP)";) \
+               $(if $(DEFAULT),echo "Default: $(DEFAULT)";)  \
+               if [ "$$$$PREREQ_CHECK" = 1 ]; then echo "Prereq-Check: 1"; fi; \
+               echo "Version: $(VERSION)"; \
+               echo "Depends: $(DEPENDS)"; \
+               echo "Provides: $(PROVIDES)"; \
+               echo "Build-Depends: $(PKG_BUILD_DEPENDS)"; \
+               echo "Section: $(SECTION)"; \
+               echo "Category: $(CATEGORY)"; \
+               echo "Title: $(TITLE)"; \
+               echo "Maintainer: $(MAINTAINER)"; \
+               echo -n "Description: "; \
+               getvar $(call shvar,Package/$(1)/description); \
+               $(if $(URL),echo;echo "$(URL)";) \
+               echo "@@" ; \
+               $$(if $$(Package/$(1)/config),echo "Config: "; getvar $(call shvar,Package/$(1)/config); echo "@@"; ) \
+               $$(if $$(preconfig_$(1)),$$(preconfig_$(1)) echo "")
+  endef
+endif
diff --git a/openwrt/package/sdk/files/include/package-ipkg.mk b/openwrt/package/sdk/files/include/package-ipkg.mk
new file mode 100644 (file)
index 0000000..597f5f8
--- /dev/null
@@ -0,0 +1,88 @@
+# 
+# Copyright (C) 2006,2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define BuildIPKGVariable
+  $(call shexport,Package/$(1)/$(2))
+  $(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2);
+endef
+
+ifeq ($(DUMP),)
+  define BuildIPKG
+    IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
+    IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
+    INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
+
+    ifdef Package/$(1)/install
+      ifneq ($(CONFIG_PACKAGE_$(1))$(SDK)$(DEVELOPER),)
+        compile: $$(IPKG_$(1))
+
+        ifeq ($(CONFIG_PACKAGE_$(1)),y)
+          install: $$(INFO_$(1))
+        endif
+      else
+        compile: $(1)-disabled
+        $(1)-disabled:
+               @echo "WARNING: skipping $(1) -- package not selected"
+      endif
+    endif
+
+    IDEPEND_$(1):=$$(strip $$(DEPENDS))
+  
+    $(eval $(call BuildIPKGVariable,$(1),conffiles))
+    $(eval $(call BuildIPKGVariable,$(1),preinst))
+    $(eval $(call BuildIPKGVariable,$(1),postinst))
+    $(eval $(call BuildIPKGVariable,$(1),prerm))
+    $(eval $(call BuildIPKGVariable,$(1),postrm))
+    $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH)
+       @rm -f $(PACKAGE_DIR)/$(1)_*
+       mkdir -p $$(IDIR_$(1))/CONTROL
+       echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
+       echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
+       ( \
+               DEPENDS='$(EXTRA_DEPENDS)'; \
+               for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \
+                       DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
+               done; \
+               echo "Depends: $$$$DEPENDS"; \
+               echo "Source: $(SOURCE)"; \
+               echo "Section: $(SECTION)"; \
+               echo "Priority: $(PRIORITY)"; \
+               echo "Maintainer: $(MAINTAINER)"; \
+               echo "Architecture: $(PKGARCH)"; \
+               echo -n "Description: "; getvar $(call shvar,Package/$(1)/description) | sed -e 's,^[[:space:]]*, ,g'; \
+       ) >> $$(IDIR_$(1))/CONTROL/control
+       chmod 644 $$(IDIR_$(1))/CONTROL/control
+       (cd $$(IDIR_$(1))/CONTROL; \
+               $($(1)_COMMANDS) \
+       )
+
+    $$(IPKG_$(1)): $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control
+       $(call Package/$(1)/install,$$(IDIR_$(1)))
+       mkdir -p $(PACKAGE_DIR)
+       -find $$(IDIR_$(1)) -name CVS   | $(XARGS) rm -rf
+       -find $$(IDIR_$(1)) -name .svn  | $(XARGS) rm -rf
+       -find $$(IDIR_$(1)) -name '.#*' | $(XARGS) rm -f
+       $(RSTRIP) $$(IDIR_$(1))
+       $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
+       @[ -f $$(IPKG_$(1)) ] || false 
+
+    $$(INFO_$(1)): $$(IPKG_$(1))
+       $(IPKG) install $$(IPKG_$(1))
+
+    $(1)-clean:
+       rm -f $(PACKAGE_DIR)/$(1)_*
+
+    clean: $(1)-clean
+
+    $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(STAMP_PREPARED)
+       -@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null
+       @touch $$@
+
+    $$(eval $$(call Build/DefaultTargets,$(1)))
+
+  endef
+endif
index 7f29e5f9c9f46c2156bc1c3c975b344a59fcdad6..daff3ed0d6f444bdaa82683d4dfe3a3c54b329ed 100644 (file)
 # 
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006,2007 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
 #
-ifneq ($(DUMP),)
-  all: dumpinfo
-else
-  all: compile
-endif
+
+all: $(if $(DUMP),dumpinfo,compile)
+
+PKG_BUILD_DIR ?= $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR ?= $(PKG_BUILD_DIR)/ipkg-install
 
 include $(INCLUDE_DIR)/prereq.mk
 include $(INCLUDE_DIR)/host.mk
 include $(INCLUDE_DIR)/unpack.mk
+include $(INCLUDE_DIR)/depends.mk
+
+STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared$(if $(DUMP),,_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s))
+STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
+STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
+
+include $(INCLUDE_DIR)/quilt.mk
+include $(INCLUDE_DIR)/package-defaults.mk
+include $(INCLUDE_DIR)/package-dumpinfo.mk
+include $(INCLUDE_DIR)/package-ipkg.mk
 
-PKG_CONFIG_PATH:=.
 export CONFIG_SITE:=$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)
 
+ifneq ($(CONFIG_AUTOREBUILD),)
+  define Build/Autoclean
+    $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
+    $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
+    $(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),$(PKG_BUILD_DIR)/.dep_files, -and -not -path "/.*" -and -not -path "*/ipkg*")
+  endef
+endif
+
 define Build/DefaultTargets
-  ifeq ($(DUMP),)
-    ifeq ($(CONFIG_AUTOREBUILD),y)
-      ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) . $(PKG_FILE_DEPEND)),$(PKG_BUILD_DIR))
-        $$(info Forcing package rebuild)
-        $(PKG_BUILD_DIR)/.prepared: package-clean
-      endif
-    endif
+  ifneq ($(strip $(PKG_SOURCE_URL)),)
+    download: $(DL_DIR)/$(PKG_SOURCE)
+
+    $(DL_DIR)/$(PKG_SOURCE):
+       mkdir -p $(DL_DIR)
+       $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
+
+    $(STAMP_PREPARED): $(DL_DIR)/$(PKG_SOURCE)
   endif
 
-  $(PKG_BUILD_DIR)/.prepared:
+  $(call Build/Autoclean)
+
+  $(STAMP_PREPARED):
        @-rm -rf $(PKG_BUILD_DIR)
        @mkdir -p $(PKG_BUILD_DIR)
-       $(call Build/Prepare)
+       $(Build/Prepare)
        touch $$@
 
-  $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
-       $(call Build/Configure)
+  $(STAMP_CONFIGURED): $(STAMP_PREPARED)
+       $(Build/Configure)
        touch $$@
 
-  $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
-       $(call Build/Compile)
+  $(STAMP_BUILT): $(STAMP_CONFIGURED)
+       $(Build/Compile)
+       @$(NO_TRACE_MAKE) $(PKG_BUILD_DIR)/.dep_files
        touch $$@
 
   ifdef Build/InstallDev
-    ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed $(PKG_BUILD_DIR)),$(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed)
-      $(PKG_BUILD_DIR)/.built: package-rebuild
-    endif
-
-    $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
+    compile: $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
+    $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed: $(STAMP_BUILT)
        mkdir -p $(STAGING_DIR)/stampfiles
-       $(call Build/InstallDev)
+       $(Build/InstallDev)
        touch $$@
-       
-    compile-targets: $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
   endif
 
-  package-clean: FORCE
-       $(call Build/Clean)
-       $(call Build/UninstallDev)
-       -rm -f $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
-
-  package-rebuild: FORCE
-       @-rm -f $(PKG_BUILD_DIR)/.built
-
   define Build/DefaultTargets
   endef
 endef
 
-define Package/Default
-  CONFIGFILE:=
-  SECTION:=opt
-  CATEGORY:=Extra packages
-  DEPENDS:=
-  PROVIDES:=
-  EXTRA_DEPENDS:=
-  MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
-  SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
-  ifneq ($(PKG_VERSION),)
-    ifneq ($(PKG_RELEASE),)
-      VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
-    else
-      VERSION:=$(PKG_VERSION)
-    endif
-  else
-    VERSION:=$(PKG_RELEASE)
-  endif
-  PKGARCH:=$(ARCH)
-  PRIORITY:=optional
-  DEFAULT:=
-  MENU:=
-  SUBMENU:=
-  SUBMENUDEP:=
-  TITLE:=
-  DESCRIPTION:=
-endef
-
-define BuildDescription
-  ifneq ($(DESCRIPTION),)
-    DESCRIPTION:=$(TITLE)\\ $(DESCRIPTION)
-  else
-    DESCRIPTION:=$(TITLE)
-  endif
-endef
-
-define BuildIPKGVariable
-  $(call shexport,Package/$(1)/$(2))
-  $(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2);
-endef
-
 define BuildPackage
-  $(eval $(call Package/Default))
-  $(eval $(call Package/$(1)))
-  $(eval $(call BuildDescription))
+  $(eval $(Package/Default))
+  $(eval $(Package/$(1)))
+
+# <HACK> Support obsolete DESCRIPTION field
+ifndef Package/$(1)/description
+define Package/$(1)/description
+$(TITLE)$(subst \,
+,\ $(DESCRIPTION))
+endef
+endif
+# </HACK>
 
   $(foreach FIELD, TITLE CATEGORY PRIORITY SECTION VERSION,
     ifeq ($($(FIELD)),)
@@ -118,254 +93,36 @@ define BuildPackage
     endif
   )
 
-  IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
-  IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
-  INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
-
-  ifdef Package/$(1)/install
-    ifeq ($(CONFIG_PACKAGE_$(1)),y)
-      install-targets: $$(INFO_$(1))
-    endif
-
-    ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),)
-      compile-targets: $$(IPKG_$(1))
-    else
-      compile-targets: $(1)-disabled
-      $(1)-disabled:
-       @echo "WARNING: skipping $(1) -- package not selected"
-    endif
-  endif
-
-  ifeq ($(FORCEREBUILD),y)
-    $$(IPKG_$(1)): FORCE
-  endif
-
-  IDEPEND_$(1):=$$(strip $$(DEPENDS))
-
-  ifneq ($(DUMP),)
-    dumpinfo: dumpinfo-$(1)
-    dumpinfo-$(1): FORCE
-               @$$(DUMPINFO_$(call shvar,$(1)))
-               
-    DUMPINFO_$(call shvar,$(1)) += \
-       echo "Package: $(1)"; 
-
-    ifneq ($(MENU),)
-      DUMPINFO_$(call shvar,$(1)) += \
-       echo "Menu: $(MENU)";
-    endif
-
-    ifneq ($(SUBMENU),)
-      DUMPINFO_$(call shvar,$(1)) += \
-       echo "Submenu: $(SUBMENU)";
-      ifneq ($(SUBMENUDEP),)
-        DUMPINFO_$(call shvar,$(1)) += \
-         echo "Submenu-Depends: $(SUBMENUDEP)";
-      endif
-    endif
-
-    ifneq ($(DEFAULT),)
-      DUMPINFO_$(call shvar,$(1)) += \
-       echo "Default: $(DEFAULT)";
-    endif
-
-       $(call shexport,Package/$(1)/description)
-
-    DUMPINFO_$(call shvar,$(1)) += \
-       if [ "$$$$PREREQ_CHECK" = 1 ]; then echo "Prereq-Check: 1"; fi; \
-       echo "Version: $(VERSION)"; \
-       echo "Depends: $$(IDEPEND_$(1))"; \
-       echo "Provides: $(PROVIDES)"; \
-       echo "Build-Depends: $(PKG_BUILD_DEPENDS)"; \
-       echo "Section: $(SECTION)"; \
-       echo "Category: $(CATEGORY)"; \
-       echo "Title: $(TITLE)"; \
-       echo "Maintainer: $(MAINTAINER)"; \
-       if isset $(call shvar,Package/$(1)/description); then \
-               echo -n "Description: "; \
-               getvar $(call shvar,Package/$(1)/description); \
-       else \
-               echo "Description: $(patsubst \\,\\\\,$(DESCRIPTION))" | perl -ne 's/\\/\n/g, print'; \
-       fi;
-       
-    ifneq ($(URL),)
-      DUMPINFO_$(call shvar,$(1)) += \
-               echo; \
-               echo "$(URL)";
-    endif
-       
-       DUMPINFO_$(call shvar,$(1)) += \
-               echo "@@";
+  $(call shexport,Package/$(1)/description)
+  $(call shexport,Package/$(1)/config)
 
-       $(call shexport,Package/$(1)/config)
-       DUMPINFO_$(call shvar,$(1)) += \
-               if isset $(call shvar,Package/$(1)/config); then \
-                       echo "Config: "; \
-                       getvar $(call shvar,Package/$(1)/config); \
-                       echo "@@"; \
-               fi;
-  
-  endif
-
-  $(eval $(call BuildIPKGVariable,$(1),conffiles))
-  $(eval $(call BuildIPKGVariable,$(1),preinst))
-  $(eval $(call BuildIPKGVariable,$(1),postinst))
-  $(eval $(call BuildIPKGVariable,$(1),prerm))
-  $(eval $(call BuildIPKGVariable,$(1),postrm))
-  $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH)
-       mkdir -p $$(IDIR_$(1))/CONTROL
-       echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
-       echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
-       ( \
-               DEPENDS='$(EXTRA_DEPENDS)'; \
-               for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \
-                       DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
-               done; \
-               echo "Depends: $$$$DEPENDS" >> $$(IDIR_$(1))/CONTROL/control; \
-       )
-       echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
-       echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
-       echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
-       echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
-       echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
-       echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g' | sed -e 's,^[[:space:]]*$$$$, .,g' >> $$(IDIR_$(1))/CONTROL/control
-       chmod 644 $$(IDIR_$(1))/CONTROL/control
-       (cd $$(IDIR_$(1))/CONTROL; \
-               $($(1)_COMMANDS) \
-       )
-
-  $$(IPKG_$(1)): $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control
-       $(call Package/$(1)/install,$$(IDIR_$(1)))
-       mkdir -p $(PACKAGE_DIR)
-       -find $$(IDIR_$(1)) -name CVS | xargs rm -rf
-       -find $$(IDIR_$(1)) -name .svn | xargs rm -rf
-       -find $$(IDIR_$(1)) -name '.#*' | xargs rm -f
-       $(RSTRIP) $$(IDIR_$(1))
-       $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
-       @[ -f $$(IPKG_$(1)) ] || false 
-
-  $$(INFO_$(1)): $$(IPKG_$(1))
-       $(IPKG) install $$(IPKG_$(1))
-
-  $(1)-clean:
-       rm -f $(PACKAGE_DIR)/$(1)_*
-
-  clean: $(1)-clean
-
-  $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(PKG_BUILD_DIR)/.prepared
-       -@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null
-       @touch $$@
-
-  $$(eval $$(call Build/DefaultTargets,$(1)))
-
-  ifdef Package/$(1)/install
-    ifneq ($$(CONFIG_PACKAGE_$(1))$(DEVELOPER)$(SDK),)
-      ifneq ($(MAKECMDGOALS),prereq)
-        ifneq ($(DUMP),1)
-          ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg -x ipkg-install '$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_$(1)))
-            $(PKG_BUILD_DIR)/.built: package-rebuild
-            $$(info Rebuilding $(subst $(TOPDIR)/,,$$(IPKG_$(1))))
-          endif
-        endif
-      endif
-    endif
-  endif
+  $(Dumpinfo)
+  $(BuildIPKG)
 endef
 
-ifneq ($(strip $(PKG_UNPACK)),)
-  define Build/Prepare/Default
-       $(PKG_UNPACK)
-       @if [ -d ./patches -a "$$$$(ls ./patches | wc -l)" -gt 0 ]; then \
-               $(PATCH) $(PKG_BUILD_DIR) ./patches; \
-       fi
-  endef
-endif
-
 define Build/Prepare
   $(call Build/Prepare/Default,)
 endef
 
-define Build/Configure/Default
-       (cd $(PKG_BUILD_DIR)/$(strip $(3)); \
-       if [ -x configure ]; then \
-               $(TARGET_CONFIGURE_OPTS) \
-               CFLAGS="$(TARGET_CFLAGS)" \
-               CXXFLAGS="$(TARGET_CFLAGS)" \
-               CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
-               LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
-               PKG_CONFIG_PATH="$(STAGING_DIR)/usr/lib/pkgconfig" \
-               PKG_CONFIG_LIBDIR="$(STAGING_DIR)/usr/lib/pkgconfig" \
-               $(2) \
-               $(PKG_CONFIG_PATH)/configure \
-               --target=$(GNU_TARGET_NAME) \
-               --host=$(GNU_TARGET_NAME) \
-               --build=$(GNU_HOST_NAME) \
-               --program-prefix="" \
-               --program-suffix="" \
-               --prefix=/usr \
-               --exec-prefix=/usr \
-               --bindir=/usr/bin \
-               --sbindir=/usr/sbin \
-               --libexecdir=/usr/lib \
-               --sysconfdir=/etc \
-               --datadir=/usr/share \
-               --localstatedir=/var \
-               --mandir=/usr/man \
-               --infodir=/usr/info \
-               $(DISABLE_NLS) \
-               $(1); \
-       fi; \
-       )
-endef
-
 define Build/Configure
   $(call Build/Configure/Default,)
 endef
 
-define Build/Compile/Default
-       CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
-       LDFLAGS="$(EXTRA_LDFLAGS) " \
-       $(MAKE) -C $(PKG_BUILD_DIR) \
-               $(TARGET_CONFIGURE_OPTS) \
-               CROSS="$(TARGET_CROSS)" \
-               CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
-               ARCH="$(ARCH)" \
-               $(1);
-endef
-
 define Build/Compile
   $(call Build/Compile/Default,)
 endef
 
-ifneq ($(DUMP),)
-  dumpinfo:
-else
-  $(PACKAGE_DIR):
+$(PACKAGE_DIR):
        mkdir -p $@
                
-  ifneq ($(strip $(PKG_SOURCE_URL)),)
-    download: $(DL_DIR)/$(PKG_SOURCE)
-
-    $(DL_DIR)/$(PKG_SOURCE):
-               mkdir -p $(DL_DIR)
-               $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
-
-    $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
-  endif
-
-  download:
-  prepare: $(PKG_BUILD_DIR)/.prepared
-  configure: $(PKG_BUILD_DIR)/.configured
-
-  compile-targets:
-  compile: compile-targets
-
-  install-targets:
-  install: install-targets
-
-  clean-targets:
-  clean: FORCE
-       @$(MAKE) clean-targets
-       $(call Build/Clean)
-       rm -rf $(PKG_BUILD_DIR)
-endif
+dumpinfo:
+download:
+prepare: $(STAMP_PREPARED)
+configure: $(STAMP_CONFIGURED)
+compile:
+install:
+clean: FORCE
+       $(Build/UninstallDev)
+       $(Build/Clean)
+       @rm -f $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
+       @rm -rf $(PKG_BUILD_DIR)
index 41596dcb8b3359d453690ca1720c013621ca31a1..8a08be8e68c9f4d34b0b8085c99ab01602bd21f5 100644 (file)
@@ -27,7 +27,7 @@ define Require
                        echo 'ok.'; \
                else \
                        echo 'failed.'; \
-                       echo -e "$(strip $(2))" | perl -ne 's/\\\s*/\n/g,print' >> $(TMP_DIR)/.prereq-error; \
+                       echo -e "$(PKG_NAME): $(strip $(2))" | perl -ne 's/\\\s*/\n/g,print' >> $(TMP_DIR)/.prereq-error; \
                fi
 
     check-$(1): FORCE
diff --git a/openwrt/package/sdk/files/include/quilt.mk b/openwrt/package/sdk/files/include/quilt.mk
new file mode 100644 (file)
index 0000000..395f64e
--- /dev/null
@@ -0,0 +1,109 @@
+# 
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifeq ($(KERNEL_BUILD),1)
+  PKG_BUILD_DIR:=$(LINUX_DIR)
+endif
+
+define Quilt/Patch
+       @for patch in $$$$( (cd $(1) && ls) 2>/dev/null ); do ( \
+               cp "$(1)/$$$$patch" $(PKG_BUILD_DIR); \
+               cd $(PKG_BUILD_DIR); \
+               quilt import -P$(2)$$$$patch -p 1 "$$$$patch"; \
+               quilt push -f >/dev/null 2>/dev/null; \
+               rm -f "$$$$patch"; \
+       ); done
+endef
+
+QUILT?=$(strip $(shell test -f $(PKG_BUILD_DIR)/.quilt_used && echo y))
+ifneq ($(QUILT),)
+  STAMP_PREPARED:=$(strip $(STAMP_PREPARED))_q
+  STAMP_PATCHED:=$(PKG_BUILD_DIR)/.quilt_patched
+  CONFIG_AUTOREBUILD=
+  PATCHES:=$(shell )
+  define Build/Patch/Default
+       rm -rf $(PKG_BUILD_DIR)/patches
+       mkdir -p $(PKG_BUILD_DIR)/patches
+       $(call Quilt/Patch,./patches,)
+       @echo
+       touch $(PKG_BUILD_DIR)/.quilt_used
+  endef
+  $(STAMP_CONFIGURED): $(STAMP_PATCHED) FORCE
+  prepare: $(STAMP_PATCHED)
+  quilt-check: $(STAMP_PATCHED)
+else
+  define Build/Patch/Default
+       @if [ -d ./patches -a "$$$$(ls ./patches | wc -l)" -gt 0 ]; then \
+               $(PATCH) $(PKG_BUILD_DIR) ./patches; \
+       fi
+  endef
+endif
+
+define Kernel/Patch/Default
+       if [ -d $(GENERIC_PLATFORM_DIR)/files ]; then $(CP) $(GENERIC_PLATFORM_DIR)/files/* $(LINUX_DIR)/; fi
+       if [ -d ./files ]; then $(CP) ./files/* $(LINUX_DIR)/; fi
+       $(if $(strip $(QUILT)),$(call Quilt/Patch,$(GENERIC_PLATFORM_DIR)/patches,generic/), \
+               if [ -d $(GENERIC_PLATFORM_DIR)/patches ]; then $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches; fi \
+       )
+       $(if $(strip $(QUILT)),$(call Quilt/Patch,./patches,platform/), \
+               if [ -d ./patches ]; then $(PATCH) $(LINUX_DIR) ./patches; fi \
+       )
+       $(if $(strip $(QUILT)),touch $(PKG_BUILD_DIR)/.quilt_used)
+endef
+
+$(STAMP_PATCHED): $(STAMP_PREPARED)
+       @cd $(PKG_BUILD_DIR); quilt pop -a -f >/dev/null 2>/dev/null || true
+       [ -f "$(PKG_BUILD_DIR)/patches/series" ] && cd $(PKG_BUILD_DIR); quilt push -a
+       touch $@
+
+define Quilt/RefreshDir
+       mkdir -p $(1)
+       -rm -f $(1)/* 2>/dev/null >/dev/null
+       @( \
+               for patch in $$($(if $(2),grep "^$(2)",cat) $(PKG_BUILD_DIR)/patches/series | awk '{print $$1}'); do \
+                       $(CP) -v "$(PKG_BUILD_DIR)/patches/$$patch" $(1); \
+               done; \
+       )
+endef
+
+define Quilt/Refresh/Package
+       $(call Quilt/RefreshDir,./patches)
+endef
+
+define Quilt/Refresh/Kernel
+       @[ -z "$$(grep -v '^generic/' $(PKG_BUILD_DIR)/patches/series | grep -v '^platform/')" ] || { \
+               echo "All kernel patches must start with either generic/ or platform/"; \
+               false; \
+       }
+       $(call Quilt/RefreshDir,$(GENERIC_PLATFORM_DIR)/patches,generic/)
+       $(call Quilt/RefreshDir,./patches,platform/)
+endef
+
+quilt-check: $(STAMP_PREPARED) FORCE
+       @[ -f "$(PKG_BUILD_DIR)/.quilt_used" ] || { \
+               echo "The source directory was not unpacked using quilt. Please rebuild with QUILT=1"; \
+               false; \
+       }
+       @[ -f "$(PKG_BUILD_DIR)/patches/series" ] || { \
+               echo "The source directory contains no quilt patches."; \
+               false; \
+       }
+       @[ "$$(cat $(PKG_BUILD_DIR)/patches/series | md5sum)" = "$$(sort $(PKG_BUILD_DIR)/patches/series | md5sum)" ] || { \
+               echo "The patches are not sorted in the right order. Please fix."; \
+               false; \
+       }
+
+refresh: quilt-check
+       @cd $(PKG_BUILD_DIR); quilt pop -a -f >/dev/null 2>/dev/null
+       @cd $(PKG_BUILD_DIR); while quilt next 2>/dev/null >/dev/null && quilt push; do \
+               quilt refresh; \
+       done; ! quilt next 2>/dev/null >/dev/null
+       $(if $(KERNEL_BUILD),$(Quilt/Refresh/Kernel),$(Quilt/Refresh/Package))
+       
+update: quilt-check
+       $(if $(KERNEL_BUILD),$(Quilt/Refresh/Kernel),$(Quilt/Refresh/Package))
+
diff --git a/openwrt/package/sdk/files/include/scan.mk b/openwrt/package/sdk/files/include/scan.mk
new file mode 100644 (file)
index 0000000..b149e32
--- /dev/null
@@ -0,0 +1,55 @@
+include $(TOPDIR)/include/verbose.mk
+
+SCAN_TARGET ?= packageinfo
+SCAN_NAME ?= package
+SCAN_DIR ?= package
+SCAN_DEPS ?= include/package.mk
+
+ifeq ($(IS_TTY),1)
+  define progress
+       printf "\033[M\r$(1)" >&2;
+  endef
+else
+  define progress
+       :
+  endef
+endif
+
+SCAN = $(patsubst $(SCAN_DIR)/%/Makefile,%,$(wildcard $(SCAN_DIR)/*/Makefile))
+tmp/.$(SCAN_TARGET):
+       @($(call progress,Collecting $(SCAN_NAME) info: merging...))
+       for file in $(SCAN); do \
+               cat tmp/info/.$(SCAN_TARGET)-$$file; \
+       done > $@
+       @($(call progress,Collecting $(SCAN_NAME) info: done))
+       @echo
+
+ifneq ($(SCAN_EXTRA),)
+SCAN_STAMP=tmp/info/.scan-$(SCAN_TARGET)-$(shell ls $(SCAN_EXTRA) 2>/dev/null | (md5sum || md5) 2>/dev/null | cut -d' ' -f1)
+$(SCAN_STAMP):
+       rm -f tmp/info/.scan-$(SCAN_TARGET)-*
+       touch $@
+endif
+
+# FIXME: generate this dynamically?
+ifeq ($(SCAN_TARGET),packageinfo)
+tmp/info/.packageinfo-kernel: $(wildcard package/kernel/modules/*.mk)
+endif
+
+define scanfiles
+$(foreach FILE,$(SCAN),
+  tmp/.$(SCAN_TARGET): tmp/info/.$(SCAN_TARGET)-$(FILE) $(SCAN_TARGET_DEPS) $(SCAN_DEPS)
+  tmp/info/.$(SCAN_TARGET)-$(FILE): $(SCAN_DIR)/$(FILE)/Makefile $(SCAN_STAMP) $(SCAN_TARGET_DEPS)
+       grep -E 'include (\$$$$\(INCLUDE_DIR\)|\$$$$\(TOPDIR\)/include)/' $(SCAN_DIR)/$(FILE)/Makefile >/dev/null && { \
+               $$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(FILE)); \
+               echo Source-Makefile: $(SCAN_DIR)/$(FILE)/Makefile; \
+               $(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $(SCAN_DIR)/$(FILE) 3>/dev/null || echo "ERROR: please fix $(SCAN_DIR)/$(FILE)/Makefile" >&2; \
+               echo; \
+       } | tee $$@ || true
+)
+
+endef
+$(eval $(call scanfiles))
+
+FORCE:
+.PHONY: FORCE
index 1e60692b97fffcc1864146345da6b761cbe6c3f7..f6be6c526f26fb489cc660d7201bce3c3a1117b7 100644 (file)
@@ -28,3 +28,7 @@ trapret() {(
                }
        }
 )}
+
+md5s() {
+       which md5sum 2>&1 >/dev/null && md5sum "$@" | awk '{print $1}' || md5 "$@"
+}
index e533476b5276c1b8dd91ba5aae08e1426426ab43..500aada4620901b03dde1b09397addca3aee4b55 100644 (file)
@@ -1,20 +1,59 @@
+ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))
+
+# unpacking files with +s may break on some platforms. this typically emits error code 2
+ifneq ($(HOST_OS),Linux)
+  HOST_TAR:=trapret 2 $(TAR)
+else
+  HOST_TAR:=$(TAR)
+endif
+TAR_CMD:=$(HOST_TAR) -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS)
+UNZIP_CMD:=unzip -d $(PKG_BUILD_DIR)/.. $(DL_DIR)/$(PKG_SOURCE)
+
+ifeq ($(PKG_SOURCE),)
+  PKG_UNPACK ?= true
+endif
 ifeq ($(strip $(PKG_UNPACK)),)
-  ifneq ($(HOST_OS),Linux)
-       HOST_TAR:=trapret 2 $(TAR)
-  else
-    HOST_TAR:=$(TAR)
+  ifeq ($(strip $(PKG_CAT)),)
+    # try to autodetect file type
+    EXT:=$(call ext,$(PKG_SOURCE))
+    EXT1:=$(EXT)
+
+    ifeq ($(filter gz tgz,$(EXT)),$(EXT))
+      EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
+      UNPACK:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) |
+    endif      
+    ifeq ($(filter bzip2 bz2 bz tbz2 tbz,$(EXT)),$(EXT))
+      EXT:=$(call ext,$(PKG_SOURCE:.$(EXT)=))
+      UNPACK:=bzcat $(DL_DIR)/$(PKG_SOURCE) |
+    endif
+    ifeq ($(filter tgz tbz tbz2,$(EXT1)),$(EXT1))
+      EXT:=tar
+    endif
+    UNPACK ?= cat $(DL_DIR)/$(PKG_SOURCE) |
+    ifeq ($(EXT),tar)
+      PKG_UNPACK:=$(UNPACK) $(TAR_CMD)
+    endif
+    ifeq ($(EXT),cpio)
+      PKG_UNPACK:=$(UNPACK) (cd $(PKG_BUILD_DIR)/..; cpio -i -d)
+    endif
+    ifeq ($(EXT),zip)
+      PKG_UNPACK:=$(UNZIP_CMD)
+    endif
   endif
-  ifneq ($(strip $(PKG_CAT)),)
+  # compatibility code for packages that set PKG_CAT
+  ifeq ($(strip $(PKG_UNPACK)),)
     # use existing PKG_CAT
-    PKG_UNPACK:=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | $(HOST_TAR) -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS)
+    PKG_UNPACK:=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
     ifeq ($(PKG_CAT),unzip)
-      PKG_UNPACK:=unzip -d $(PKG_BUILD_DIR)/.. $(DL_DIR)/$(PKG_SOURCE)
+      PKG_UNPACK:=$(UNZIP_CMD)
     endif
-    # replace zcat with $(ZCAT), because some system have it as gzcat
+    # replace zcat with $(ZCAT), because some system don't support it properly
     ifeq ($(PKG_CAT),zcat)
-      PKG_UNPACK:=$(ZCAT) $(DL_DIR)/$(PKG_SOURCE) | $(HOST_TAR) -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS)
+      PKG_UNPACK:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR_CMD)
     endif
-  else
-    # try to autodetect file type
+  endif
+  ifneq ($(strip $(CRLF_WORKAROUND)),)
+    PKG_UNPACK += && find $(PKG_BUILD_DIR) -type f -print0 | xargs -0 perl -pi -e 's!\r$$$$!!g'
   endif
 endif
index b4242f212acc512c4d66533932bf86838f374eab..6b2d6d044ba2722e1d83eefdeb89105f818ca425 100644 (file)
@@ -19,17 +19,21 @@ ifeq ("$(origin V)", "command line")
 endif
 
 ifeq ($(IS_TTY),1)
-  _Y:="\\33[33m"# yellow
-  _N:="\\33[m"#        normal
+  _Y:="\\033[33m" # yellow
+  _N:="\\033[m" #normal
 endif
 
+define MESSAGE
+       echo -e "$(_Y)$(1)$(_N)" >&3
+endef
+
 ifneq ($(KBUILD_VERBOSE),99)
   ifeq ($(QUIET),1)
     $(MAKECMDGOALS): trace
     trace: FORCE
        @[ -f "$(MAKECMDGOALS)" ] || { \
                [ -z "$${PWD##$$TOPDIR}" ] || DIR=" -C $${PWD##$$TOPDIR/}"; \
-               echo -e "$(_Y)make[$$(($(MAKELEVEL)+1))]$$DIR $(MAKECMDGOALS)$(_N)" >&3; \
+               $(call MESSAGE, "make[$$(($(MAKELEVEL)+1))]$$DIR $(MAKECMDGOALS)"); \
        }
   else
     export QUIET:=1
index 9dc972abfa0bebb1b70af8098fc5f9cef0b1f01f..3141fae85bbbeb02967d676e7b22426113d72717 100644 (file)
@@ -8,7 +8,7 @@
 
 include $(TOPDIR)/rules.mk
 include $(TOPDIR)/.config
-include $(TOPDIR)/.pkgdeps
+include $(TMP_DIR)/.packagedeps
 include $(INCLUDE_DIR)/host.mk
 
 PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(prereq-y) $(prereq-m))
@@ -41,8 +41,8 @@ ifeq ($(SDK),1)
 GENDEP_OPTS := -s
 endif
 
-$(TOPDIR)/.pkgdeps: $(TOPDIR)/.pkginfo
-       @$(TOPDIR)/scripts/gen_deps.pl $(GENDEP_OPTS) < $< > $@ || rm -f $@
+$(TMP_DIR)/.packagedeps: $(TMP_DIR)/.packageinfo
+       @$(TOPDIR)/scripts/metadata.pl package_mk < $< > $@ || rm -f $@
 
 all: compile
 clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/openwrt/package/sdk/files/scripts/config.pl b/openwrt/package/sdk/files/scripts/config.pl
new file mode 100755 (executable)
index 0000000..2f4a968
--- /dev/null
@@ -0,0 +1,142 @@
+#!/usr/bin/env perl
+# 
+# Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+use warnings;
+use strict;
+
+my @arg = @ARGV;
+
+sub load_config($) {
+       my $file = shift;
+       my %config;
+
+       open FILE, "$file" or die "can't open file";
+       while (<FILE>) {
+               chomp;
+               /^CONFIG_(.+?)=(.+)/ and do {
+                       $config{$1} = $2;
+                       next;
+               };
+               /^# CONFIG_(.+?) is not set/ and do {
+                       $config{$1} = "#undef";
+                       next;
+               };
+               /^#/ and next;
+               /^(.+)$/ and print "WARNING: can't parse line: $1\n";
+       }
+       return \%config;
+}
+
+
+sub config_and($$) {
+       my $cfg1 = shift;
+       my $cfg2 = shift;
+       my %config;
+
+       foreach my $config (keys %$cfg1) {
+               my $val1 = $cfg1->{$config};
+               my $val2 = $cfg2->{$config};
+               $val2 and ($val1 eq $val2) and do {
+                       $config{$config} = $val1;
+               };
+       }
+       return \%config;
+}
+
+
+sub config_add($$) {
+       my $cfg1 = shift;
+       my $cfg2 = shift;
+       my %config;
+       
+       for ($cfg1, $cfg2) {
+               my %cfg = %$_;
+               
+               foreach my $config (keys %cfg) {
+                       $config{$config} = $cfg{$config};
+               }
+       }
+       return \%config;
+}
+
+sub config_diff($$) {
+       my $cfg1 = shift;
+       my $cfg2 = shift;
+       my %config;
+       
+       foreach my $config (keys %$cfg2) {
+               if (!$cfg1->{$config} or $cfg1->{$config} ne $cfg2->{$config}) {
+                       $config{$config} = $cfg2->{$config};
+               }
+       }
+       return \%config
+}
+
+sub config_sub($$) {
+       my $cfg1 = shift;
+       my $cfg2 = shift;
+       my %config = %{$cfg1};
+       
+       foreach my $config (keys %$cfg2) {
+               delete $config{$config};
+       }
+       return \%config;
+}
+
+sub print_cfgline($$) {
+       my $name = shift;
+       my $val = shift;
+       if ($val eq '#undef') {
+               print "# CONFIG_$name is not set\n";
+       } else {
+               print "CONFIG_$name=$val\n";
+       }
+}
+
+
+sub dump_config($) {
+       my $cfg = shift;
+       die "argument error in dump_config" unless ($cfg);
+       my %config = %$cfg;
+       foreach my $config (sort keys %config) {
+               print_cfgline($config, $config{$config});
+       }
+}
+
+sub parse_expr($);
+
+sub parse_expr($) {
+       my $pos = shift;
+       my $arg = $arg[$$pos++];
+       
+       die "Parse error" if (!$arg);
+       
+       if ($arg eq '&') {
+               my $arg1 = parse_expr($pos);
+               my $arg2 = parse_expr($pos);
+               return config_and($arg1, $arg2);
+       } elsif ($arg =~ /^\+/) {
+               my $arg1 = parse_expr($pos);
+               my $arg2 = parse_expr($pos);
+               return config_add($arg1, $arg2);
+       } elsif ($arg eq '>') {
+               my $arg1 = parse_expr($pos);
+               my $arg2 = parse_expr($pos);
+               return config_diff($arg1, $arg2);
+       } elsif ($arg eq '-') {
+               my $arg1 = parse_expr($pos);
+               my $arg2 = parse_expr($pos);
+               return config_sub($arg1, $arg2);
+       } else {
+               return load_config($arg);
+       }
+}
+
+my $pos = 0;
+dump_config(parse_expr(\$pos));
+die "Parse error" if ($arg[$pos]);
index 8f5d1d6b464c2a98a896fe329139b9f901fbdc7c..543dcc1879e5288e838b811a007044a4baae12c8 100755 (executable)
@@ -8,16 +8,41 @@
 
 use strict;
 use warnings;
+use File::Basename;
 
 my $target = shift @ARGV;
 my $filename = shift @ARGV;
 my $md5sum = shift @ARGV;
+my $scriptdir = dirname($0);
 my @mirrors;
 
 my $ok;
 
 @ARGV > 0 or die "Syntax: $0 <target dir> <filename> <md5sum> <mirror> [<mirror> ...]\n";
 
+sub localmirrors {
+    my @mlist;
+    open LM, "$scriptdir/localmirrors" and do {
+           while (<LM>) {
+                       chomp $_;
+                       push @mlist, $_;
+               }
+               close LM;
+       };
+       open CONFIG, "<".$ENV{'TOPDIR'}."/.config" and do {
+               while (<CONFIG>) {
+                       /^CONFIG_LOCALMIRROR="(.+)"/ and do {
+                               chomp;
+                               push @mlist, $1;
+                       };
+               }
+               close CONFIG;
+       };
+       
+
+    return @mlist;
+}
+
 sub which($) {
        my $prog = shift;
        my $res = `which $prog`;
@@ -37,7 +62,8 @@ sub download
        my $mirror = shift;
        my $options = $ENV{WGET_OPTIONS};
        $options or $options = "";
-
+       
+       $mirror =~ s/\/$//;
        open WGET, "wget -t1 --timeout=20 $options -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n";
        open MD5SUM, "| $md5cmd > \"$target/$filename.md5sum\"" or die "Cannot launch md5sum.\n";
        open OUTPUT, "> $target/$filename.dl" or die "Cannot create file $target/$filename.dl: $!\n";
@@ -77,21 +103,14 @@ sub cleanup
        unlink "$target/$filename.md5sum";
 }
 
+@mirrors = localmirrors();
+
 foreach my $mirror (@ARGV) {
        if ($mirror =~ /^\@SF\/(.+)$/) {
-               my $sfpath = $1;
-               open SF, "wget -t1 -q -O- 'http://prdownloads.sourceforge.net/$sfpath/$filename' |";
-               while (<SF>) {
-                       /RADIO NAME=use_default VALUE=(\w+) OnClick="form\.submit\(\)">/ or
-                       /type="radio" name="use_default" value="(\w+)" onclick="form\.submit\(\)"\/>/ and do {
-                               push @mirrors, "http://$1.dl.sourceforge.net/sourceforge/$sfpath";
-                       };
-                       /<a href="\/.+\?use_mirror=(\w+)"><b>Download/ and do {
-                               push @mirrors, "http://$1.dl.sourceforge.net/sourceforge/$sfpath";
-                       };
+               # give sourceforge a few more tries, because it redirects to different mirrors
+               for (1 .. 5) {
+                       push @mirrors, "http://downloads.sourceforge.net/$1";
                }
-               push @mirrors, "http://dl.sourceforge.net/sourceforge/$sfpath";
-               close SF;
        } elsif ($mirror =~ /^\@GNU\/(.+)$/) {
                my $gnupath = $1;
                push @mirrors, "ftp://ftp.gnu.org/gnu/$gnupath";
@@ -107,9 +126,9 @@ foreach my $mirror (@ARGV) {
        }
 }
 
-#push @mirrors, 'http://mirror1.openwrt.org/';
+#push @mirrors, 'http://mirror1.openwrt.org';
 push @mirrors, 'http://mirror2.openwrt.org/sources';
-push @mirrors, 'http://downloads.openwrt.org/sources/';
+push @mirrors, 'http://downloads.openwrt.org/sources';
 
 while (!$ok) {
        my $mirror = shift @mirrors;
diff --git a/openwrt/package/sdk/files/scripts/flash.sh b/openwrt/package/sdk/files/scripts/flash.sh
deleted file mode 100644 (file)
index 8841c35..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/bash
-#
-# tftp flash script for wireless routers 
-#
-# Copyright (C) 2004 by Oleg I. Vdovikin <oleg@cs.msu.su>
-# Copyright (C) 2005 by Waldemar Brodkorb <wbx@openwrt.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-if [ -z "$1" ] || [ ! -f $1 ] || [ -z $2 ]; then
-    echo Usage: $0 firmware vendor
-cat << EOF
-IMPORTANT:
-Notes for Linksys / Asus WL500gx router: 
-   be sure you have set boot_wait to yes. Power on your router
-   after executing this script.
-Notes for Asus WL500g router:
-   be sure POWER led is flashing (If this is not the case
-   poweroff the device, push the reset button & power on
-   it again, then release button)
-
-1) connect your pc to the LAN port
-2) be sure your link is up and has an address in the
-   192.168.1.0/24 address range (and not the 192.168.1.1)
-
-Notes for Toshiba router:
-   boot_wait is enabled by default on these units.
-
-1) connect your pc to any of the four LAN ports
-2) be sure your link is up and has an address in the
-   192.168.10.1/24 address range (and not the 192.168.10.1)
-3) run this script (unit will only accept .trx images)
-4) Turn unit power on.
-
-EOF
-    exit 0
-fi
-if [ "$2" == "asus" ]; then
-echo Confirming IP address setting...
-echo -en "get ASUSSPACELINK\x01\x01\xa8\xc0 /dev/null\nquit\n" | tftp 192.168.1.1
-echo Flashing 192.168.1.1 using $1...
-echo -en "binary\nput $1 ASUSSPACELINK\nquit\n" | tftp 192.168.1.1
-echo Please wait until leds stops flashing. 
-elif [ "$2" == "linksys" ]; then
-echo Flashing 192.168.1.1 using $1...
-echo -en "rexmt 1\ntrace\nbinary\nput $1\nquit\n" | tftp 192.168.1.1
-echo Please wait until power led stops flashing. Do not poweroff! Then you can login via telnet 192.168.1.1.
-elif [ "$2" == "toshiba" ]; then
-echo Flashing 192.168.10.1 using $1...
-echo -en "rexmt 1\ntrace\nbinary\nput $1\nquit\n" | tftp 192.168.10.1
-echo Unit will automatically reboot within 5 minutes.  Do not power off.  Then you can login via telnet 192.168.10.1.
-fi
diff --git a/openwrt/package/sdk/files/scripts/gen_deps.pl b/openwrt/package/sdk/files/scripts/gen_deps.pl
deleted file mode 100755 (executable)
index 0fc80aa..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/perl
-# 
-# Copyright (C) 2006 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-use strict;
-
-my $name;
-my $src;
-my $makefile;
-my %conf;
-my %pkg;
-my %prereq;
-my %dep;
-my %options;
-my $opt;
-
-while ($opt = shift @ARGV) {
-       $opt =~ /^-s/ and $options{SDK} = 1;
-}
-
-my $line;
-while ($line = <>) {
-       chomp $line;
-       $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
-               $makefile = $1;
-               $src = $2;
-               defined $pkg{$src} or $pkg{$src} = {};
-               $pkg{$src}->{src} = $src;
-       };
-       $line =~ /^Package: \s*(.+)\s*$/ and do {
-               $name = $1;
-               defined $pkg{$name} or $pkg{$name} = {};
-               $pkg{$name}->{src} = $src;
-       };
-       $line =~ /^Provides: \s*(.+)\s*$/ and do {
-               foreach my $vpkg (split /\s+/, $1) {
-                       defined $pkg{$vpkg} or $pkg{$vpkg} = {};
-                       $pkg{$vpkg}->{virtual} = 1;
-               }
-       };
-       $line =~ /^Prereq-Check:/ and !defined $prereq{$src} and do {
-               $pkg{$name}->{prereq} = 1;
-       };
-       $line =~ /^(Build-)?Depends: \s*(.+)\s*$/ and do {
-               $pkg{$name}->{depends} ||= [];
-               foreach my $v (split /\s+/, $2) {
-                       next if $v =~ /^[\+]?@/;
-                       $v =~ s/^\+//;
-                       push @{$pkg{$name}->{depends}}, $v;
-               }
-       };
-}
-
-$line="";
-
-foreach $name (sort {uc($a) cmp uc($b)} keys %pkg) {
-       my $config;
-       
-       next if defined $pkg{$name}->{virtual};
-       if ($options{SDK}) {
-               $conf{$pkg{$name}->{src}} or do {
-                       $config = 'm';
-                       $conf{$pkg{$name}->{src}} = 1;
-               };
-       } else {
-               $config = "\$(CONFIG_PACKAGE_$name)"
-       }
-       if ($config) {
-               print "package-$config += $pkg{$name}->{src}\n";
-               $pkg{$name}->{prereq} and print "prereq-$config += $pkg{$name}->{src}\n";
-       }
-
-       my $hasdeps = 0;
-       my $depline = "";
-       foreach my $dep (@{$pkg{$name}->{depends}}) {
-               my $idx;
-               next if defined $pkg{$dep}->{virtual};
-               if (defined $pkg{$dep}->{src}) {
-                       ($pkg{$name}->{src} ne $pkg{$dep}->{src}) and $idx = $pkg{$dep}->{src};
-               } elsif (defined($pkg{$dep}) && !$options{SDK}) {
-                       $idx = $dep;
-               }
-               undef $idx if $idx =~ /^(kernel)|(base-files)$/;
-               if ($idx) {
-                       next if $dep{$pkg{$name}->{src}."->".$idx};
-                       $depline .= " $idx\-compile";
-                       $dep{$pkg{$name}->{src}."->".$idx} = 1;
-               }
-       }
-       if ($depline ne "") {
-               $line .= "$pkg{$name}->{src}-compile: $depline\n";
-       }
-}
-
-if ($line ne "") {
-       print "\n$line";
-}
index 97a315142574a6951331289bc1a09d2710ed5e63..311f3abdb5ffdc911b05adffb5aa1187cbdb0b34 100755 (executable)
@@ -234,7 +234,6 @@ ipkg_download() {
                proxyoption="--proxy=on"
        fi
 
-       echo "Downloading $src ..."
        rm -f $IPKG_TMP/$src_file
        case "$src" in
        http://* | ftp://*)
@@ -252,7 +251,6 @@ ipkg_download() {
                ;;
        esac
 
-       echo "Done."
        return 0
 }
 
@@ -665,7 +663,7 @@ Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg
                        curcheck="`expr $curcheck + 1`"
                        local is_installed="`ipkg_get_installed $pkg`"
                        if [ "$is_installed" = "installed" ]; then
-                               echo "$pkg is installed" > /dev/console
+                               echo "$pkg is installed"
                                continue
                        fi
 
@@ -693,7 +691,6 @@ Status: install ok not-installed" | ipkg_status_update_sd $sd $pkg
                                return 1;
                        fi
 
-                       echo ""
                        local tmp_pkg_file="$IPKG_TMP/"`ipkg_file_part $filename`
                        if ! ipkg_download `ipkg_src_byname $src`/$filename $tmp_pkg_file; then
                                echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"
@@ -907,7 +904,6 @@ ipkg_install_file() {
 }
 
 ipkg_install() {
-
        while [ $# -gt 0 ]; do
                local pkg="$1"
                shift
diff --git a/openwrt/package/sdk/files/scripts/metadata.pl b/openwrt/package/sdk/files/scripts/metadata.pl
new file mode 100755 (executable)
index 0000000..e196003
--- /dev/null
@@ -0,0 +1,569 @@
+#!/usr/bin/perl
+use strict;
+my %preconfig;
+my %package;
+my %srcpackage;
+my %category;
+
+sub get_multiline {
+       my $prefix = shift;
+       my $str;
+       while (<>) {
+               last if /^@@/;
+               s/^\s*//g;
+               $str .= (($_ and $prefix) ? $prefix . $_ : $_);
+       }
+
+       return $str;
+}
+
+sub parse_target_metadata() {
+       my ($target, @target, $profile);        
+       while (<>) {
+               chomp;
+               /^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
+                       my $conf = uc $3.'_'.$2;
+                       $conf =~ tr/\.-/__/;
+                       $target = {
+                               id => $1,
+                               conf => $conf,
+                               board => $2,
+                               kernel => $3,
+                               profiles => []
+                       };
+                       push @target, $target;
+               };
+               /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
+               /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
+               /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
+               /^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ];
+               /^Target-Description:/ and $target->{desc} = get_multiline();
+               /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
+               /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
+               /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
+               /^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ];
+               /^Target-Profile:\s*(.+)\s*$/ and do {
+                       $profile = {
+                               id => $1,
+                               name => $1,
+                               packages => []
+                       };
+                       push @{$target->{profiles}}, $profile;
+               };
+               /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
+               /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
+               /^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline();
+               /^Target-Profile-Config:/ and $profile->{config} = get_multiline("\t");
+               /^Target-Profile-Kconfig:/ and $profile->{kconfig} = 1;
+       }
+       foreach my $target (@target) {
+               @{$target->{profiles}} > 0 or $target->{profiles} = [
+                       {
+                               id => 'Default',
+                               name => 'Default',
+                               packages => []
+                       }
+               ];
+       }
+       return @target;
+}
+
+sub parse_package_metadata() {
+       my $pkg;
+       my $makefile;
+       my $preconfig;
+       my $src;
+       while (<>) {
+               chomp;
+               /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
+                       $makefile = $1;
+                       $src = $2;
+                       $srcpackage{$src} = [];
+                       undef $pkg;
+               };
+               /^Package:\s*(.+?)\s*$/ and do {
+                       $pkg = {};
+                       $pkg->{src} = $src;
+                       $pkg->{makefile} = $makefile;
+                       $pkg->{name} = $1;
+                       $pkg->{default} = "m if ALL";
+                       $pkg->{depends} = [];
+                       $pkg->{builddepends} = [];
+                       $package{$1} = $pkg;
+                       push @{$srcpackage{$src}}, $pkg;
+               };
+               /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
+               /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
+               /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
+               /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
+               /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
+               /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
+               /^Provides: \s*(.+)\s*$/ and do {
+                       my @vpkg = split /\s+/, $1;
+                       foreach my $vpkg (@vpkg) {
+                               $package{$vpkg} or $package{$vpkg} = { vdepends => [] };
+                               push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
+                       }
+               };
+               /^Depends: \s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
+               /^Build-Depends: \s*(.+)\s*$/ and $pkg->{builddepends} = [ split /\s+/, $1 ];
+               /^Category: \s*(.+)\s*$/ and do {
+                       $pkg->{category} = $1;
+                       defined $category{$1} or $category{$1} = {};
+                       defined $category{$1}->{$src} or $category{$1}->{$src} = [];
+                       push @{$category{$1}->{$src}}, $pkg;
+               };
+               /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline("\t\t ");
+               /^Config: \s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline();
+               /^Prereq-Check:/ and $pkg->{prereq} = 1;
+               /^Preconfig:\s*(.+)\s*$/ and do {
+                       my $pkgname = $pkg->{name};
+                       $preconfig{$pkgname} or $preconfig{$pkgname} = [];
+                       $preconfig = {
+                               id => $1
+                       };
+                       push @{$preconfig{$pkgname}}, $preconfig;
+               };
+               /^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1;
+               /^Preconfig-Label:\s*(.*?)\s*$/ and $preconfig->{label} = $1;
+               /^Preconfig-Default:\s*(.*?)\s*$/ and $preconfig->{default} = $1;
+       }
+       return %category;
+}
+
+
+sub gen_target_mk() {
+       my @target = parse_target_metadata();
+       
+       @target = sort {
+               $a->{id} cmp $b->{id}
+       } @target;
+       
+       foreach my $target (@target) {
+               my ($profiles_def, $profiles_eval);
+               my $conf = uc $target->{kernel}.'_'.$target->{board};
+               $conf =~ tr/\.-/__/;
+               
+               foreach my $profile (@{$target->{profiles}}) {
+                       $profiles_def .= "
+  define Profile/$conf\_$profile->{id}
+    ID:=$profile->{id}
+    NAME:=$profile->{name}
+    PACKAGES:=".join(" ", @{$profile->{packages}})."\n";
+                       $profile->{kconfig} and $profiles_def .= "    KCONFIG:=1\n";
+                       $profiles_def .= "  endef";
+                       $profiles_eval .= "
+\$(eval \$(call AddProfile,$conf\_$profile->{id}))"
+               }
+               print "
+ifeq (\$(CONFIG_LINUX_$conf),y)
+  define Target
+    KERNEL:=$target->{kernel}
+    BOARD:=$target->{board}
+    BOARDNAME:=$target->{name}
+    LINUX_VERSION:=$target->{version}
+    LINUX_RELEASE:=$target->{release}
+    LINUX_KARCH:=$target->{karch}
+    DEFAULT_PACKAGES:=".join(" ", @{$target->{packages}})."
+  endef$profiles_def
+endif$profiles_eval
+
+"
+       }
+       print "\$(eval \$(call Target))\n";
+}
+
+sub target_config_features(@) {
+       my $ret;
+
+       while ($_ = shift @_) {
+               /broken/ and $ret .= "\tdepends BROKEN\n";
+               /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
+               /usb/ and $ret .= "\tselect USB_SUPPORT\n";
+               /atm/ and $ret .= "\tselect ATM_SUPPORT\n";
+               /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
+               /video/ and $ret .= "\tselect VIDEO_SUPPORT\n";
+               /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
+               /jffs2/ and $ret .= "\tselect USES_JFFS2\n";
+               /ext2/ and $ret .= "\tselect USES_EXT2\n";
+       }
+       return $ret;
+}
+
+
+sub gen_target_config() {
+       my @target = parse_target_metadata();
+
+       @target = sort {
+               $a->{name} cmp $b->{name}
+       } @target;
+       
+       
+       print <<EOF;
+choice
+       prompt "Target System"
+       default LINUX_2_4_BRCM
+       reset if !DEVEL
+       
+EOF
+
+       foreach my $target (@target) {
+               my $features = target_config_features(@{$target->{features}});
+               my $help = $target->{desc};
+               my $kernel = $target->{kernel};
+               $kernel =~ tr/./_/;
+
+               chomp $features;
+               $features .= "\n";
+               if ($help =~ /\w+/) {
+                       $help =~ s/^\s*/\t  /mg;
+                       $help = "\thelp\n$help";
+               } else {
+                       undef $help;
+               }
+       
+               print <<EOF
+config LINUX_$target->{conf}
+       bool "$target->{name}"
+       select $target->{arch}
+       select LINUX_$kernel
+$features$help
+
+EOF
+       }
+
+       print <<EOF;
+if DEVEL
+
+config LINUX_2_6_ARM
+       bool "UNSUPPORTED little-endian arm platform"
+       depends BROKEN
+       select LINUX_2_6
+       select arm
+
+config LINUX_2_6_CRIS
+       bool "UNSUPPORTED cris platform"
+       depends BROKEN
+       select LINUX_2_6
+       select cris
+
+config LINUX_2_6_M68K
+       bool "UNSUPPORTED m68k platform"
+       depends BROKEN
+       select LINUX_2_6
+       select m68k
+
+config LINUX_2_6_SH3
+       bool "UNSUPPORTED little-endian sh3 platform"
+       depends BROKEN
+       select LINUX_2_6
+       select sh3
+
+config LINUX_2_6_SH3EB
+       bool "UNSUPPORTED big-endian sh3 platform"
+       depends BROKEN
+       select LINUX_2_6
+       select sh3eb
+
+config LINUX_2_6_SH4
+       bool "UNSUPPORTED little-endian sh4 platform"
+       depends BROKEN
+       select LINUX_2_6
+       select sh4
+
+config LINUX_2_6_SH4EB
+       bool "UNSUPPORTED big-endian sh4 platform"
+       depends BROKEN
+       select LINUX_2_6
+       select sh4eb
+
+config LINUX_2_6_SPARC
+       bool "UNSUPPORTED sparc platform"
+       depends BROKEN
+       select LINUX_2_6
+       select sparc
+
+endif
+
+endchoice
+
+choice
+       prompt "Target Profile"
+
+EOF
+       
+       foreach my $target (@target) {
+               my $profiles = $target->{profiles};
+               
+               foreach my $profile (@$profiles) {
+                       print <<EOF;
+config LINUX_$target->{conf}_$profile->{id}
+       bool "$profile->{name}"
+       depends LINUX_$target->{conf}
+$profile->{config}
+EOF
+                       $profile->{kconfig} and print "\tselect PROFILE_KCONFIG\n";
+                       my %pkgs;
+                       foreach my $pkg (@{$target->{packages}}, @{$profile->{packages}}) {
+                               $pkgs{$pkg} = 1;
+                       }
+                       foreach my $pkg (keys %pkgs) {
+                               print "\tselect DEFAULT_$pkg\n" unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
+                       }
+                       print "\n";
+               }
+       }
+
+       print "endchoice\n";
+}
+
+sub find_package_dep($$) {
+       my $pkg = shift;
+       my $name = shift;
+       my $deps = ($pkg->{vdepends} or $pkg->{depends});
+
+       return 0 unless defined $deps;
+       foreach my $dep (@{$deps}) {
+               return 1 if $dep eq $name;
+               return 1 if ($package{$dep} and (find_package_dep($package{$dep},$name) == 1));
+       }
+       return 0;
+}
+
+sub package_depends($$) {
+       my $a = shift;
+       my $b = shift;
+       my $ret;
+
+       return 0 if ($a->{submenu} ne $b->{submenu});
+       if (find_package_dep($a, $b->{name}) == 1) {
+               $ret = 1;
+       } elsif (find_package_dep($b, $a->{name}) == 1) {
+               $ret = -1;
+       } else {
+               return 0;
+       }
+       return $ret;
+}
+
+sub mconf_depends($$) {
+       my $depends = shift;
+       my $only_dep = shift;
+       my $res;
+
+       $depends or return;
+       my @depends = @$depends;
+       foreach my $depend (@depends) {
+               my $m = "depends";
+               $depend =~ s/^([@\+]+)//;
+               my $flags = $1;
+               my $vdep;
+       
+               if ($vdep = $package{$depend}->{vdepends}) {
+                       $depend = join("||", map { "PACKAGE_".$_ } @$vdep);
+               } else {
+                       $flags =~ /\+/ and do {
+                               next if $only_dep;
+                               $m = "select";
+
+                               # Menuconfig will not treat 'select FOO' as a real dependency
+                               # thus if FOO depends on other config options, these dependencies
+                               # will not be checked. To fix this, we simply emit all of FOO's
+                               # depends here as well.
+                               $package{$depend} and $res .= mconf_depends($package{$depend}->{depends}, 1);
+                       };
+                       $flags =~ /@/ or $depend = "PACKAGE_$depend";
+               }
+               $res .= "\t\t$m $depend\n";
+       }
+       return $res;
+}
+
+sub print_package_config_category($) {
+       my $cat = shift;
+       my %menus;
+       my %menu_dep;
+       
+       return unless $category{$cat};
+       
+       print "menu \"$cat\"\n\n";
+       my %spkg = %{$category{$cat}};
+       
+       foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
+               foreach my $pkg (@{$spkg{$spkg}}) {
+                       my $menu = $pkg->{submenu};
+                       if ($menu) {
+                               $menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep};
+                       } else {
+                               $menu = 'undef';
+                       }
+                       $menus{$menu} or $menus{$menu} = [];
+                       push @{$menus{$menu}}, $pkg;
+                       print "\tconfig DEFAULT_".$pkg->{name}."\n";
+                       print "\t\tbool\n\n";
+               }
+       }
+       my @menus = sort {
+               ($a eq 'undef' ?  1 : 0) or
+               ($b eq 'undef' ? -1 : 0) or
+               ($a cmp $b)
+       } keys %menus;
+
+       foreach my $menu (@menus) {
+               my @pkgs = sort {
+                       package_depends($a, $b) or
+                       ($a->{name} cmp $b->{name})
+               } @{$menus{$menu}};
+               if ($menu ne 'undef') {
+                       $menu_dep{$menu} and print "if $menu_dep{$menu}\n";
+                       print "menu \"$menu\"\n";
+               }
+               foreach my $pkg (@pkgs) {
+                       my $title = $pkg->{name};
+                       my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
+                       if ($c > 0) {
+                               $title .= ("." x $c). " ". $pkg->{title};
+                       }
+                       print "\t";
+                       $pkg->{menu} and print "menu";
+                       print "config PACKAGE_".$pkg->{name}."\n";
+                       print "\t\ttristate \"$title\"\n";
+                       print "\t\tdefault y if DEFAULT_".$pkg->{name}."\n";
+                       foreach my $default (split /\s*,\s*/, $pkg->{default}) {
+                               print "\t\tdefault $default\n";
+                       }
+                       print mconf_depends($pkg->{depends}, 0);
+                       print "\t\thelp\n";
+                       print $pkg->{description};
+                       print "\n";
+
+                       $pkg->{config} and print $pkg->{config}."\n";
+               }
+               if ($menu ne 'undef') {
+                       print "endmenu\n";
+                       $menu_dep{$menu} and print "endif\n";
+               }
+       }
+       print "endmenu\n\n";
+       
+       undef $category{$cat};
+}
+
+sub gen_package_config() {
+       parse_package_metadata();
+       print "menuconfig UCI_PRECONFIG\n\tbool \"Image configuration\"\n";
+       foreach my $preconfig (keys %preconfig) {
+               foreach my $cfg (@{$preconfig{$preconfig}}) {
+                       my $conf = $cfg->{id};
+                       $conf =~ tr/\.-/__/;
+                       print <<EOF
+       config UCI_PRECONFIG_$conf
+               string "$cfg->{label}" if UCI_PRECONFIG
+               depends PACKAGE_$preconfig
+               default "$cfg->{default}"
+
+EOF
+               }
+       }
+       print_package_config_category 'Base system';
+       foreach my $cat (keys %category) {
+               print_package_config_category $cat;
+       }
+}
+
+sub gen_package_mk() {
+       my %conf;
+       my %dep;
+       my $line;
+
+       parse_package_metadata();
+       foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
+               my $config;
+               my $pkg = $package{$name};
+               
+               next if defined $pkg->{vdepends};
+               if ($ENV{SDK}) {
+                       $conf{$pkg->{src}} or do {
+                               $config = 'm';
+                               $conf{$pkg->{src}} = 1;
+                       };
+               } else {
+                       $config = "\$(CONFIG_PACKAGE_$name)"
+               }
+               if ($config) {
+                       print "package-$config += $pkg->{src}\n";
+                       $pkg->{prereq} and print "prereq-$config += $pkg->{src}\n";
+               }
+       
+               my $hasdeps = 0;
+               my $depline = "";
+               foreach my $dep (@{$pkg->{depends}}, @{$pkg->{builddepends}}) {
+                       next if $dep =~ /@/;
+                       $dep =~ s/\+//;
+                       my $idx;
+                       my $pkg_dep = $package{$dep};
+                       $pkg_dep or $pkg_dep = $srcpackage{$dep}->[0];
+                       next unless defined $pkg_dep;
+                       next if defined $pkg_dep->{vdepends};
+
+                       if (defined $pkg_dep->{src}) {
+                               ($pkg->{src} ne $pkg_dep->{src}) and $idx = $pkg_dep->{src};
+                       } elsif (defined($pkg_dep) && !defined($ENV{SDK})) {
+                               $idx = $dep;
+                       }
+                       undef $idx if $idx =~ /^(kernel)|(base-files)$/;
+                       if ($idx) {
+                               next if $dep{$pkg->{src}."->".$idx};
+                               $depline .= " $idx\-compile";
+                               $dep{$pkg->{src}."->".$idx} = 1;
+                       }
+               }
+               if ($depline) {
+                       $line .= "$pkg->{src}-compile: $depline\n";
+               }
+       }
+       
+       if ($line ne "") {
+               print "\n$line";
+       }
+       foreach my $preconfig (keys %preconfig) {
+               my $cmds;
+               foreach my $cfg (@{$preconfig{$preconfig}}) {
+                       my $conf = $cfg->{id};
+                       $conf =~ tr/\.-/__/;
+                       $cmds .= "\techo \"uci set '$cfg->{id}=\$(subst \",,\$(CONFIG_UCI_PRECONFIG_$conf))'\"; \\\n";
+               }
+               next unless $cmds;
+               print <<EOF
+
+\$(TARGET_DIR)/etc/uci-defaults/$preconfig: FORCE
+       ( \\
+$cmds \\
+       ) > \$@
+       
+ifneq (\$(UCI_PRECONFIG)\$(CONFIG_UCI_PRECONFIG),)
+  preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig
+endif
+EOF
+       }
+}
+
+
+sub parse_command() {
+       my $cmd = shift @ARGV;
+       for ($cmd) {
+               /^target_mk$/ and return gen_target_mk();
+               /^target_config$/ and return gen_target_config();
+               /^package_mk$/ and return gen_package_mk();
+               /^package_config$/ and return gen_package_config();
+       }
+       print <<EOF
+Available Commands:
+       $0 target_mk [file]             Target metadata in makefile format
+       $0 target_config [file]         Target metadata in Kconfig format
+       $0 package_mk [file]            Package metadata in makefile format
+       $0 package_config [file]        Package metadata in Kconfig format
+EOF
+}
+
+parse_command();
index 09a2f9f5515d735f0af283d26d6abdd4efe90c01..6dd44f2ed272c65e84fbedc8d90a42d7dc627864 100755 (executable)
@@ -6,6 +6,23 @@
 # See /LICENSE for more information.
 #
 
+find_modparams() {
+       FILE="$1"
+       $NM "$FILE" | awk '
+BEGIN {
+       FS=" "
+}
+($3 ~ /^__module_parm_/) && ($3 !~ /^__module_parm_desc/) {
+       gsub(/__module_parm_/, "", $3)
+       printf "-K " $3 " "
+}
+($2 ~ /r/) && ($3 ~ /__param_/) {
+       gsub(/__param_/, "", $3)
+       printf "-K " $3 " "
+}
+'
+}
+
 
 SELF=${0##*/}
 
@@ -28,8 +45,11 @@ find $TARGETS -type f -a -exec file {} \; | \
   IFS=":"
   while read F S; do
     echo "$SELF: $F:$S"
-       [ "${F##*\.}" = "o" -o "${F##*\.}" = "ko" ] && \
-               eval "$STRIP_KMOD $F" || \
+       [ "${F##*\.}" = "o" -o "${F##*\.}" = "ko" ] && {
+               eval "$STRIP_KMOD -w -K '__param*' -K '__mod*' $(find_modparams "$F")$F"
+       } || {
                eval "$STRIP $F"
+       }
   done
+  true
 )
index a3aa50cb0dffe23fbdcbf9f26da58d0328bcbe28..a4c5cae0150822434544dd8412d6db9b5db9ee0a 100755 (executable)
@@ -17,9 +17,8 @@ sub get_ts($$) {
        while (<FIND>) {
                chomp;
                my $file = $_;
-               open FILE, "<$file";
-               my @stat = stat FILE;
-               close FILE;
+               next if -l $file;
+               my @stat = stat $file;
                if ($stat[9] > $ts) {
                        $ts = $stat[9];
                        $fn = $file;