7 define Build/DefaultTargets
8 $(PKG_BUILD_DIR)/.prepared:
9 rm -rf $(PKG_BUILD_DIR)
10 mkdir -p $(PKG_BUILD_DIR)
14 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
15 $(call Build/Configure)
18 ifeq ($(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) .),.)
19 $(PKG_BUILD_DIR)/.prepared: clean
22 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
28 rm -f $(PKG_BUILD_DIR)/.built
31 rm -f $(PKG_BUILD_DIR)/.built
33 .PHONY: package-clean package-recompile
35 define Build/DefaultTargets
39 define Package/Default
42 CATEGORY:=Extra packages
44 MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
45 SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
46 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
56 $(eval $(call Package/Default))
57 $(eval $(call Package/$(1)))
60 $$(error Package $(1) has no TITLE)
63 $$(error Package $(1) has no CATEGORY)
66 $$(error Package $(1) has no PRIORITY)
69 $$(error Package $(1) has no VERSION)
75 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
76 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
77 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
79 ifneq ($(PACKAGE_$(1)),)
85 ifeq ($(PACKAGE_$(1)),y)
86 install-targets: $$(INFO_$(1))
89 ifneq ($$(COMPILE_$(1)),)
90 ifeq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg $$(IPKG_$(1)) $(PKG_BUILD_DIR)),$(PKG_BUILD_DIR))
91 $(PKG_BUILD_DIR)/.built: package-recompile
94 compile-targets: $$(IPKG_$(1))
98 IDEPEND_$(1):=$$(strip $$(DEPENDS))
101 echo "Package: $(1)";
104 echo "Menu: $(MENU)";
108 echo "Default: $(DEFAULT)";
111 echo "Version: $(VERSION)"; \
112 echo "Depends: $$(IDEPEND_$(1))"; \
113 echo "Category: $(CATEGORY)"; \
114 echo "Title: $(TITLE)"; \
115 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g'; \
121 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
122 mkdir -p $$(IDIR_$(1))/CONTROL
123 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
124 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
125 echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control
126 echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
127 echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
128 echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
129 echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
130 echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
131 echo "Description: $(TITLE)" >> $$(IDIR_$(1))/CONTROL/control
132 echo " $(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control
133 chmod 644 $$(IDIR_$(1))/CONTROL/control
134 for file in conffiles preinst postinst prerm postrm; do \
135 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
138 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built
139 $(call Package/$(1)/install,$$(IDIR_$(1)))
140 mkdir -p $(PACKAGE_DIR)
141 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
143 $$(INFO_$(1)): $$(IPKG_$(1))
144 $(IPKG) install $$(IPKG_$(1))
147 rm -f $(PACKAGE_DIR)/$(1)_*
150 ifneq ($(__DEFAULT_TARGETS),1)
151 $(eval $(call Build/DefaultTargets))
156 ifneq ($(strip $(PKG_SOURCE)),)
157 $(DL_DIR)/$(PKG_SOURCE):
158 @$(CMD_TRACE) "downloading... "
159 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL) $(MAKE_TRACE)
161 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
164 ifneq ($(strip $(PKG_CAT)),)
165 define Build/Prepare/Default
166 if [ "$(PKG_CAT)" = "unzip" ]; then \
167 unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
169 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
171 if [ -d ./patches ]; then \
172 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
178 $(call Build/Prepare/Default)
181 define Build/Configure/Default
182 # TODO: add configurable default command
185 define Build/Configure
186 $(call Build/Configure/Default)
189 define Build/Compile/Default
190 # TODO: add configurable default command
194 $(call Build/Compile/Default)
206 source: $(DL_DIR)/$(PKG_SOURCE)
208 @[ -f $(PKG_BUILD_DIR)/.prepared ] || { \
209 $(CMD_TRACE) "preparing... "; \
210 $(MAKE) $(PKG_BUILD_DIR)/.prepared $(MAKE_TRACE); \
214 @[ -f $(PKG_BUILD_DIR)/.configured ] || { \
215 $(CMD_TRACE) "configuring... "; \
216 $(MAKE) $(PKG_BUILD_DIR)/.configured $(MAKE_TRACE); \
221 @$(CMD_TRACE) "compiling... "
222 @$(MAKE) compile-targets $(MAKE_TRACE)
226 @$(CMD_TRACE) "installing... "
227 @$(MAKE) install-targets $(MAKE_TRACE)
230 $(CMD_TRACE) "rebuilding... "
231 $(MAKE) package-clean compile $(MAKE_TRACE)
238 @$(CMD_TRACE) "cleaning... "
239 @$(MAKE) clean-targets $(MAKE_TRACE)
240 rm -rf $(PKG_BUILD_DIR)
243 .PHONY: all source prepare compile install clean rebuild dumpinfo compile-targets install-targets clean-targets