2 # Copyright (C) 2006 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
13 define Build/DefaultTargets
15 ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) .),$(PKG_BUILD_DIR))
16 ifeq ($(CONFIG_AUTOREBUILD),y)
17 $(PKG_BUILD_DIR)/.prepared: package-clean
21 ifneq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg $(IPKG_$(1)) $(PKG_BUILD_DIR)),$(IPKG_$(1)))
22 ifeq ($(CONFIG_AUTOREBUILD),y)
23 $(PKG_BUILD_DIR)/.built: package-rebuild
29 $(PKG_BUILD_DIR)/.prepared:
30 @-rm -rf $(PKG_BUILD_DIR)
31 @mkdir -p $(PKG_BUILD_DIR)
35 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
36 $(call Build/Configure)
39 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
43 $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
44 mkdir -p $(STAGING_DIR)/stampfiles
45 $(call Build/InstallDev)
48 ifdef Build/InstallDev
49 compile-targets: $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
54 $(call Build/UninstallDev)
55 rm -f $(STAGING_DIR)/stampfiles/.$(PKG_NAME)-installed
57 package-rebuild: FORCE
58 @-rm -f $(PKG_BUILD_DIR)/.built
60 define Build/DefaultTargets
64 define Package/Default
67 CATEGORY:=Extra packages
70 MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
71 SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
72 ifneq ($(PKG_VERSION),)
73 ifneq ($(PKG_RELEASE),)
74 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
76 VERSION:=$(PKG_VERSION)
79 VERSION:=$(PKG_RELEASE)
91 define BuildIPKGVariable
92 pkg_$(subst .,_,$(subst -,_,$(1)))_$(2) = $$(Package/$(1)/$(2))
93 export pkg_$(subst .,_,$(subst -,_,$(1))_$(2))
94 $(1)_COMMANDS += if [ -n "$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" ]; then echo "$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" > $(2); fi;
98 $(eval $(call Package/Default))
99 $(eval $(call Package/$(1)))
101 $(foreach FIELD, TITLE CATEGORY PRIORITY VERSION,
103 $$(error Package/$(1) is missing the $(FIELD) field)
111 ifeq ($(DESCRIPTION),)
112 $(eval DESCRIPTION:=$(TITLE))
115 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
116 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
117 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
119 ifdef Package/$(1)/install
120 ifeq ($(CONFIG_PACKAGE_$(1)),y)
121 install-targets: $$(INFO_$(1))
124 ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),)
125 compile-targets: $$(IPKG_$(1))
129 ifeq ($(FORCEREBUILD),y)
133 IDEPEND_$(1):=$$(strip $$(DEPENDS))
136 echo "Package: $(1)";
140 echo "Menu: $(MENU)";
145 echo "Submenu: $(SUBMENU)";
146 ifneq ($(SUBMENUDEP),)
148 echo "Submenu-Depends: $(SUBMENUDEP)";
154 echo "Default: $(DEFAULT)";
158 echo "Version: $(VERSION)"; \
159 echo "Depends: $$(IDEPEND_$(1))"; \
160 echo "Build-Depends: $(PKG_BUILDDEP)"; \
161 echo "Category: $(CATEGORY)"; \
162 echo "Title: $(TITLE)"; \
163 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g';
176 echo "Config: $(CONFIG)" | sed -e 's,\\,\n,g'; \
180 $(eval $(call BuildIPKGVariable,$(1),conffiles))
181 $(eval $(call BuildIPKGVariable,$(1),preinst))
182 $(eval $(call BuildIPKGVariable,$(1),postinst))
183 $(eval $(call BuildIPKGVariable,$(1),prerm))
184 $(eval $(call BuildIPKGVariable,$(1),postrm))
185 $$(IDIR_$(1))/CONTROL/control: Makefile $(PKG_BUILD_DIR)/.prepared
186 mkdir -p $$(IDIR_$(1))/CONTROL
187 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
188 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
191 for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \
192 DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
194 echo "Depends: $(EXTRA_DEPENDS) $$$$DEPENDS" >> $$(IDIR_$(1))/CONTROL/control; \
196 echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
197 echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
198 echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
199 echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
200 echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
201 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control
202 chmod 644 $$(IDIR_$(1))/CONTROL/control
203 (cd $$(IDIR_$(1))/CONTROL; \
207 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built
208 $(call Package/$(1)/install,$$(IDIR_$(1)))
209 mkdir -p $(PACKAGE_DIR)
210 -find $$(IDIR_$(1)) -name CVS | xargs rm -rf
211 -find $$(IDIR_$(1)) -name .svn | xargs rm -rf
212 -find $$(IDIR_$(1)) -name '.#*' | xargs rm -f
213 $(RSTRIP) $$(IDIR_$(1))
214 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
216 $$(INFO_$(1)): $$(IPKG_$(1))
217 $(IPKG) install $$(IPKG_$(1))
220 rm -f $(PACKAGE_DIR)/$(1)_*
224 $$(eval $$(call Build/DefaultTargets,$(1)))
228 ifneq ($(strip $(PKG_CAT)),)
229 ifeq ($(PKG_CAT),unzip)
230 UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
232 UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
234 define Build/Prepare/Default
236 @if [ -d ./patches ]; then \
237 $(PATCH) $(PKG_BUILD_DIR) ./patches; \
243 $(call Build/Prepare/Default)
246 define Build/Configure/Default
247 @(cd $(PKG_BUILD_DIR)/$(3); \
248 [ -x configure ] && \
250 $(TARGET_CONFIGURE_OPTS) \
251 CFLAGS="$(TARGET_CFLAGS)" \
252 CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
253 LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
255 --target=$(GNU_TARGET_NAME) \
256 --host=$(GNU_TARGET_NAME) \
257 --build=$(GNU_HOST_NAME) \
258 --program-prefix="" \
259 --program-suffix="" \
263 --sbindir=/usr/sbin \
264 --libexecdir=/usr/lib \
266 --datadir=/usr/share \
267 --localstatedir=/var \
269 --infodir=/usr/info \
276 define Build/Configure
277 $(call Build/Configure/Default,)
280 define Build/Compile/Default
281 $(MAKE) -C $(PKG_BUILD_DIR) \
282 $(TARGET_CONFIGURE_OPTS) \
284 CROSS="$(TARGET_CROSS)" \
285 EXTRA_CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
291 $(call Build/Compile/Default,)
301 ifneq ($(strip $(PKG_SOURCE)),)
302 download: $(DL_DIR)/$(PKG_SOURCE)
304 $(DL_DIR)/$(PKG_SOURCE):
306 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
308 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
312 prepare: $(PKG_BUILD_DIR)/.prepared
313 configure: $(PKG_BUILD_DIR)/.configured
316 compile: compile-targets
319 install: install-targets
323 @$(MAKE) clean-targets
325 rm -rf $(PKG_BUILD_DIR)