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
40 define Package/Default
43 CATEGORY:=Extra packages
45 MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
46 SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
47 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
55 $(eval $(call Package/Default))
56 $(eval $(call Package/$(1)))
59 $$(error Package $(1) has no TITLE)
62 $$(error Package $(1) has no CATEGORY)
65 $$(error Package $(1) has no PRIORITY)
68 $$(error Package $(1) has no VERSION)
74 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
75 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
76 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
78 ifneq ($(PACKAGE_$(1)),)
84 ifeq ($(PACKAGE_$(1)),y)
85 install-targets: $$(INFO_$(1))
88 ifneq ($$(COMPILE_$(1)),)
89 ifeq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg $$(IPKG_$(1)) $(PKG_BUILD_DIR)),$(PKG_BUILD_DIR))
90 $(PKG_BUILD_DIR)/.built: package-recompile
93 compile-targets: $$(IPKG_$(1))
97 IDEPEND_$(1):=$$(strip $$(DEPENDS))
100 echo "Package: $(1)"; \
101 echo "Version: $(VERSION)"; \
102 echo "Depends: $(IDEPEND_$(1))"; \
103 echo "Title: $(TITLE)"; \
104 echo "$(DESCRIPTION)" | sed -e 's,\\,\n,g'; \
110 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
111 mkdir -p $$(IDIR_$(1))/CONTROL
112 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
113 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
114 echo "Depends: $(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control
115 echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
116 echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
117 echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
118 echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
119 echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
120 echo "Description: $(TITLE)" >> $$(IDIR_$(1))/CONTROL/control
121 echo " $(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control
122 chmod 644 $$(IDIR_$(1))/CONTROL/control
123 for file in conffiles preinst postinst prerm postrm; do \
124 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
127 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built
128 $(call Package/$(1)/install,$$(IDIR_$(1)))
129 mkdir -p $(PACKAGE_DIR)
130 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
132 $$(INFO_$(1)): $$(IPKG_$(1))
133 $(IPKG) install $$(IPKG_$(1))
136 rm -f $(PACKAGE_DIR)/$(1)_*
139 ifneq ($(__DEFAULT_TARGETS),1)
140 $(eval $(call Build/DefaultTargets))
145 ifneq ($(strip $(PKG_SOURCE)),)
146 $(DL_DIR)/$(PKG_SOURCE):
147 @$(CMD_TRACE) "downloading... "
148 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL) $(MAKE_TRACE)
150 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
153 ifneq ($(strip $(PKG_CAT)),)
154 define Build/Prepare/Default
155 if [ "$(PKG_CAT)" = "unzip" ]; then \
156 unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
158 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
160 if [ -d ./patches ]; then \
161 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
167 $(call Build/Prepare/Default)
170 define Build/Configure/Default
171 # TODO: add configurable default command
174 define Build/Configure
175 $(call Build/Configure/Default)
178 define Build/Compile/Default
179 # TODO: add configurable default command
183 $(call Build/Compile/Default)
195 source: $(DL_DIR)/$(PKG_SOURCE)
197 @[ -f $(PKG_BUILD_DIR)/.prepared ] || { \
198 $(CMD_TRACE) "preparing... "; \
199 $(MAKE) $(PKG_BUILD_DIR)/.prepared $(MAKE_TRACE); \
203 @[ -f $(PKG_BUILD_DIR)/.configured ] || { \
204 $(CMD_TRACE) "configuring... "; \
205 $(MAKE) $(PKG_BUILD_DIR)/.configured $(MAKE_TRACE); \
210 @$(CMD_TRACE) "compiling... "
211 @$(MAKE) compile-targets $(MAKE_TRACE)
215 @$(CMD_TRACE) "installing... "
216 @$(MAKE) install-targets $(MAKE_TRACE)
219 $(CMD_TRACE) "rebuilding... "
220 $(MAKE) package-clean compile $(MAKE_TRACE)
227 @$(CMD_TRACE) "cleaning... "
228 @$(MAKE) clean-targets $(MAKE_TRACE)
229 rm -rf $(PKG_BUILD_DIR)
232 .PHONY: all source prepare compile install clean rebuild dumpinfo compile-targets install-targets clean-targets