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 ifeq ($(DESCRIPTION),)
80 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
81 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
82 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
84 ifneq ($(CONFIG_PACKAGE_$(1)),)
90 ifeq ($(CONFIG_PACKAGE_$(1)),y)
91 install-targets: $$(INFO_$(1))
94 ifneq ($$(COMPILE_$(1)),)
95 ifeq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg $$(IPKG_$(1)) $(PKG_BUILD_DIR)),$(PKG_BUILD_DIR))
96 $(PKG_BUILD_DIR)/.built: package-recompile
99 compile-targets: $$(IPKG_$(1))
103 IDEPEND_$(1):=$$(strip $$(DEPENDS))
106 echo "Package: $(1)";
109 echo "Menu: $(MENU)";
113 echo "Default: $(DEFAULT)";
116 echo "Version: $(VERSION)"; \
117 echo "Depends: $$(IDEPEND_$(1))"; \
118 echo "Category: $(CATEGORY)"; \
119 echo "Title: $(TITLE)"; \
120 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g';
130 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
131 mkdir -p $$(IDIR_$(1))/CONTROL
132 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
133 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
134 echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control
135 echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
136 echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
137 echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
138 echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
139 echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
140 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control
141 chmod 644 $$(IDIR_$(1))/CONTROL/control
142 for file in conffiles preinst postinst prerm postrm; do \
143 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
146 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built
147 $(call Package/$(1)/install,$$(IDIR_$(1)))
148 mkdir -p $(PACKAGE_DIR)
149 $(RSTRIP) $$(IDIR_$(1))
150 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
152 $$(INFO_$(1)): $$(IPKG_$(1))
153 $(IPKG) install $$(IPKG_$(1))
156 rm -f $(PACKAGE_DIR)/$(1)_*
159 ifneq ($(__DEFAULT_TARGETS),1)
160 $(eval $(call Build/DefaultTargets))
165 ifneq ($(strip $(PKG_SOURCE)),)
166 $(DL_DIR)/$(PKG_SOURCE):
167 @$(CMD_TRACE) "downloading... "
168 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL) $(MAKE_TRACE)
170 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
173 ifneq ($(strip $(PKG_CAT)),)
174 define Build/Prepare/Default
175 if [ "$(PKG_CAT)" = "unzip" ]; then \
176 unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
178 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
180 if [ -d ./patches ]; then \
181 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
187 $(call Build/Prepare/Default)
190 define Build/Configure/Default
191 (cd $(PKG_BUILD_DIR); \
192 [ -x configure ] && \
193 $(TARGET_CONFIGURE_OPTS) \
194 CFLAGS="$(TARGET_CFLAGS)" \
196 --target=$(GNU_TARGET_NAME) \
197 --host=$(GNU_TARGET_NAME) \
198 --build=$(GNU_HOST_NAME) \
202 --sbindir=/usr/sbin \
203 --libexecdir=/usr/lib \
205 --datadir=/usr/share \
206 --localstatedir=/var \
208 --infodir=/usr/info \
214 define Build/Configure
215 $(call Build/Configure/Default,)
218 define Build/Compile/Default
219 $(MAKE) -C $(PKG_BUILD_DIR) \
221 CROSS="$(TARGET_CROSS)" \
222 PREFIX="$$(IDIR_$(1))" \
223 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
225 DESTDIR="$$(IDIR_$(1))"
229 $(call Build/Compile/Default)
241 source: $(DL_DIR)/$(PKG_SOURCE)
243 @[ -f $(PKG_BUILD_DIR)/.prepared ] || { \
244 $(CMD_TRACE) "preparing... "; \
245 $(MAKE) $(PKG_BUILD_DIR)/.prepared $(MAKE_TRACE); \
249 @[ -f $(PKG_BUILD_DIR)/.configured ] || { \
250 $(CMD_TRACE) "configuring... "; \
251 $(MAKE) $(PKG_BUILD_DIR)/.configured $(MAKE_TRACE); \
256 @$(CMD_TRACE) "compiling... "
257 @$(MAKE) compile-targets $(MAKE_TRACE)
261 @$(CMD_TRACE) "installing... "
262 @$(MAKE) install-targets $(MAKE_TRACE)
265 $(CMD_TRACE) "rebuilding... "
266 $(MAKE) package-clean compile $(MAKE_TRACE)
273 @$(CMD_TRACE) "cleaning... "
274 @$(MAKE) clean-targets $(MAKE_TRACE)
275 rm -rf $(PKG_BUILD_DIR)
278 .PHONY: all source prepare compile install clean rebuild dumpinfo compile-targets install-targets clean-targets