4 define Build/DefaultTargets
5 $(PKG_BUILD_DIR)/.prepared:
6 rm -rf $(PKG_BUILD_DIR)
7 mkdir -p $(PKG_BUILD_DIR)
11 $(PKG_BUILD_DIR)/.configured:
12 $(call Build/Configure)
15 $(PKG_BUILD_DIR)/.built:
26 CATEGORY:=Extra packages
28 MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
29 SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
30 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
36 $$(eval $$(call Package/$(1)))
39 $$(error Package $(1) has no TITLE)
42 $$(error Package $(1) has no CATEGORY)
45 $$(error Package $(1) has no PRIORITY)
48 $$(error Package $(1) has no VERSION)
54 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
55 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
56 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
58 ifneq ($(BR2_PACKAGE_$(1)),)
59 compile-targets: $$(IPKG_$(1))
62 compile-targets: $$(IPKG_$(1))
64 ifeq ($(BR2_PACKAGE_$(1)),y)
65 install-targets: $$(INFO_$(1))
68 IDEPEND_$(1):=$$(strip $$(DEPENDS))
70 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
71 mkdir -p $$(IDIR_$(1))/CONTROL
72 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
73 echo "Version: $$(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
74 echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control
75 echo "Source: $$(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
76 echo "Section: $$(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
77 echo "Priority: $$(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
78 echo "Maintainer: $$(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
79 echo "Architecture: $$(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
80 echo "Description: $$(DESCRIPTION)" >> $$(IDIR_$(1))/CONTROL/control
81 chmod 644 $$(IDIR_$(1))/CONTROL/control
82 for file in conffiles preinst postinst prerm postrm; do \
83 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
86 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built $(PACKAGE_DIR)
87 $(call Package/$(1)/install,$$(IDIR_$(1)))
88 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
90 $$(INFO_$(1)): $$(IPKG_$(1))
91 $(IPKG) install $$(IPKG_$(1))
97 ifneq ($(__DEFAULT_TARGETS),1)
98 $(eval $(call Build/DefaultTargets))
103 ifneq ($(strip $(PKG_SOURCE)),)
104 $(DL_DIR)/$(PKG_SOURCE):
105 @$(CMD_TRACE) "downloading... "
106 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL) $(MAKE_TRACE)
108 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
111 ifneq ($(strip $(PKG_CAT)),)
112 define Build/Prepare/Default
113 if [ "$(PKG_CAT)" = "unzip" ]; then \
114 unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
116 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
118 if [ -d ./patches ]; then \
119 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
125 $(call Build/Prepare/Default)
128 define Build/Configure/Default
129 # TODO: add configurable default command
132 define Build/Configure
133 $(call Build/Configure/Default)
136 define Build/Compile/Default
137 # TODO: add configurable default command
141 $(call Build/Compile/Default)
144 source: $(DL_DIR)/$(PKG_SOURCE)
146 @[ -f $(PKG_BUILD_DIR)/.prepared ] || { \
147 $(CMD_TRACE) "preparing... "; \
148 $(MAKE) $(PKG_BUILD_DIR)/.prepared $(MAKE_TRACE); \
152 @[ -f $(PKG_BUILD_DIR)/.configured ] || { \
153 $(CMD_TRACE) "configuring... "; \
154 $(MAKE) $(PKG_BUILD_DIR)/.configured $(MAKE_TRACE); \
159 @$(CMD_TRACE) "compiling... "
160 @$(MAKE) compile-targets $(MAKE_TRACE)
164 @$(CMD_TRACE) "installing... "
165 @$(MAKE) install-targets $(MAKE_TRACE)
169 $(CMD_TRACE) "rebuilding... "
170 @-$(MAKE) mostlyclean 2>&1 >/dev/null
171 if [ -f $(PKG_BUILD_DIR)/.built ]; then \
172 $(MAKE) clean $(MAKE_TRACE); \
174 $(MAKE) compile $(MAKE_TRACE)
181 @$(CMD_TRACE) "cleaning... "
182 @$(MAKE) clean-targets $(MAKE_TRACE)
183 rm -rf $(PKG_BUILD_DIR)
185 .PHONY: all source prepare compile install clean