8 define Build/DefaultTargets
9 $(PKG_BUILD_DIR)/.prepared:
10 rm -rf $(PKG_BUILD_DIR)
11 mkdir -p $(PKG_BUILD_DIR)
15 $(PKG_BUILD_DIR)/.configured:
16 $(call Build/Configure)
19 $(PKG_BUILD_DIR)/.built:
23 define Build/DefaultTargets
28 define Package/Default
31 CATEGORY:=Extra packages
33 MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
34 SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
35 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
43 $$(eval $$(call Package/Default))
44 $$(eval $$(call Package/$(1)))
47 $$(error Package $(1) has no TITLE)
50 $$(error Package $(1) has no CATEGORY)
53 $$(error Package $(1) has no PRIORITY)
56 $$(error Package $(1) has no VERSION)
62 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
63 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
64 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
66 ifneq ($(PACKAGE_$(1)),)
67 compile-targets: $$(IPKG_$(1))
70 compile-targets: $$(IPKG_$(1))
72 ifeq ($(PACKAGE_$(1)),y)
73 install-targets: $$(INFO_$(1))
76 IDEPEND_$(1):=$$(strip $$(DEPENDS))
78 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control; \
79 echo "Version: $$(VERSION)" >> $$(IDIR_$(1))/CONTROL/control; \
80 echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control; \
81 echo "Source: $$(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control; \
82 echo "Section: $$(SECTION)" >> $$(IDIR_$(1))/CONTROL/control; \
83 echo "Priority: $$(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control; \
84 echo "Maintainer: $$(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control; \
85 echo "Architecture: $$(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control; \
86 echo "Description: $$(TITLE)" >> $$(IDIR_$(1))/CONTROL/control; \
87 echo "$$(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control;
89 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
90 mkdir -p $$(IDIR_$(1))/CONTROL
92 chmod 644 $$(IDIR_$(1))/CONTROL/control
93 for file in conffiles preinst postinst prerm postrm; do \
94 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
97 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built $(PACKAGE_DIR)
98 $(call Package/$(1)/install,$$(IDIR_$(1)))
99 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
101 $$(INFO_$(1)): $$(IPKG_$(1))
102 $(IPKG) install $$(IPKG_$(1))
109 echo "Package: $(1)"; \
110 echo "Version: $$(VERSION)"; \
111 echo "Depends: $$(IDEPEND_$(1))"; \
112 echo "Title: $$(TITLE)"; \
113 echo "$$(DESCRIPTION)" | sed -e 's,\\,\n,g'; \
120 ifneq ($(__DEFAULT_TARGETS),1)
121 $(eval $(call Build/DefaultTargets))
126 ifneq ($(strip $(PKG_SOURCE)),)
127 $(DL_DIR)/$(PKG_SOURCE):
128 @$(CMD_TRACE) "downloading... "
129 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL) $(MAKE_TRACE)
131 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
134 ifneq ($(strip $(PKG_CAT)),)
135 define Build/Prepare/Default
136 if [ "$(PKG_CAT)" = "unzip" ]; then \
137 unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
139 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
141 if [ -d ./patches ]; then \
142 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
148 $(call Build/Prepare/Default)
151 define Build/Configure/Default
152 # TODO: add configurable default command
155 define Build/Configure
156 $(call Build/Configure/Default)
159 define Build/Compile/Default
160 # TODO: add configurable default command
164 $(call Build/Compile/Default)
172 source: $(DL_DIR)/$(PKG_SOURCE)
174 @[ -f $(PKG_BUILD_DIR)/.prepared ] || { \
175 $(CMD_TRACE) "preparing... "; \
176 $(MAKE) $(PKG_BUILD_DIR)/.prepared $(MAKE_TRACE); \
180 @[ -f $(PKG_BUILD_DIR)/.configured ] || { \
181 $(CMD_TRACE) "configuring... "; \
182 $(MAKE) $(PKG_BUILD_DIR)/.configured $(MAKE_TRACE); \
187 @$(CMD_TRACE) "compiling... "
188 @$(MAKE) compile-targets $(MAKE_TRACE)
192 @$(CMD_TRACE) "installing... "
193 @$(MAKE) install-targets $(MAKE_TRACE)
197 $(CMD_TRACE) "rebuilding... "
198 @-$(MAKE) mostlyclean 2>&1 >/dev/null
199 if [ -f $(PKG_BUILD_DIR)/.built ]; then \
200 $(MAKE) clean $(MAKE_TRACE); \
202 $(MAKE) compile $(MAKE_TRACE)
209 @$(CMD_TRACE) "cleaning... "
210 @$(MAKE) clean-targets $(MAKE_TRACE)
211 rm -rf $(PKG_BUILD_DIR)
214 .PHONY: all source prepare compile install clean dumpinfo