+$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
+ $(call Build/Configure)
+ touch $$@
+
+ifeq ($(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) .),.)
+$(PKG_BUILD_DIR)/.prepared: clean
+endif
+
+$(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
+ $(call Build/Compile)
+ touch $$@
+
+package-clean:
+ $(call Build/Clean)
+ rm -f $(PKG_BUILD_DIR)/.built
+
+package-recompile:
+ rm -f $(PKG_BUILD_DIR)/.built
+
+.PHONY: package-clean package-recompile
+
+define Build/DefaultTargets
+endef
+endef
+
+define Package/Default
+CONFIGFILE:=
+SECTION:=opt
+CATEGORY:=Extra packages
+DEPENDS:=
+MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
+SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
+VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
+PKGARCH:=$(ARCH)
+PRIORITY:=optional
+DEFAULT:=
+MENU:=
+TITLE:=
+DESCRIPTION:=
+endef
+
+define BuildPackage
+$(eval $(call Package/Default))
+$(eval $(call Package/$(1)))
+
+ifeq ($(TITLE),)
+$$(error Package $(1) has no TITLE)
+endif
+ifeq ($(CATEGORY),)
+$$(error Package $(1) has no CATEGORY)
+endif
+ifeq ($(PRIORITY),)
+$$(error Package $(1) has no PRIORITY)
+endif
+ifeq ($(VERSION),)
+$$(error Package $(1) has no VERSION)
+endif
+ifeq ($(PKGARCH),)
+PKGARCH:=$(ARCH)
+endif
+$(eval
+ifeq ($(DESCRIPTION),)
+DESCRIPTION:=$(TITLE)
+endif
+)
+
+IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
+IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
+INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
+
+ifneq ($(CONFIG_PACKAGE_$(1)),)
+COMPILE_$(1):=1