7 define Build/DefaultTargets
8 $(PKG_BUILD_DIR)/.prepared: FORCE $(DL_DIR)/$(PKG_SOURCE)
9 ifeq ($(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) .),.)
10 @-rm -rf $(PKG_BUILD_DIR)
11 @mkdir -p $(PKG_BUILD_DIR)
16 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
17 $(call Build/Configure)
20 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
26 rm -f $(PKG_BUILD_DIR)/.built
29 rm -f $(PKG_BUILD_DIR)/.built
31 .PHONY: package-clean package-recompile
33 # define Build/DefaultTargets
37 define Package/Default
40 CATEGORY:=Extra packages
42 MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
43 SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
44 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
55 $$(error Package/$$(1) is missing the $(1) field)
60 $(eval $(call Package/Default))
61 $(eval $(call Package/$(1)))
63 $(foreach FIELD, TITLE CATEGORY PRIORITY VERSION, $(eval $(call RequiredField,$(FIELD))))
69 ifeq ($(DESCRIPTION),)
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 ($(CONFIG_PACKAGE_$(1)),)
84 ifeq ($(CONFIG_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)";
103 echo "Menu: $(MENU)";
107 echo "Default: $(DEFAULT)";
110 echo "Version: $(VERSION)"; \
111 echo "Depends: $$(IDEPEND_$(1))"; \
112 echo "Category: $(CATEGORY)"; \
113 echo "Title: $(TITLE)"; \
114 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g';
124 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
125 mkdir -p $$(IDIR_$(1))/CONTROL
126 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
127 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
128 echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control
129 echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
130 echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
131 echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
132 echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
133 echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
134 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control
135 chmod 644 $$(IDIR_$(1))/CONTROL/control
136 for file in conffiles preinst postinst prerm postrm; do \
137 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
140 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built
141 $(call Package/$(1)/install,$$(IDIR_$(1)))
142 mkdir -p $(PACKAGE_DIR)
143 $(RSTRIP) $$(IDIR_$(1))
144 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
146 $$(INFO_$(1)): $$(IPKG_$(1))
147 $(IPKG) install $$(IPKG_$(1))
150 rm -f $(PACKAGE_DIR)/$(1)_*
153 ifneq ($(__DEFAULT_TARGETS),1)
154 $(eval $(call Build/DefaultTargets))
159 ifneq ($(strip $(PKG_SOURCE)),)
160 $(DL_DIR)/$(PKG_SOURCE):
161 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
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 @(cd $(PKG_BUILD_DIR); \
183 [ -x configure ] && \
184 $(TARGET_CONFIGURE_OPTS) \
185 CFLAGS="$(TARGET_CFLAGS)" \
187 --target=$(GNU_TARGET_NAME) \
188 --host=$(GNU_TARGET_NAME) \
189 --build=$(GNU_HOST_NAME) \
193 --sbindir=/usr/sbin \
194 --libexecdir=/usr/lib \
196 --datadir=/usr/share \
197 --localstatedir=/var \
199 --infodir=/usr/info \
205 define Build/Configure
206 $(call Build/Configure/Default,)
209 define Build/Compile/Default
210 $(MAKE) -C $(PKG_BUILD_DIR) \
212 CROSS="$(TARGET_CROSS)" \
213 PREFIX="$$(IDIR_$(1))" \
214 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
216 DESTDIR="$$(IDIR_$(1))"
220 $(call Build/Compile/Default)
235 source: FORCE $(DL_DIR)/$(PKG_SOURCE)
236 prepare: FORCE $(PKG_BUILD_DIR)/.prepared
237 configure: FORCE $(PKG_BUILD_DIR)/.configured
239 compile-targets: FORCE
240 compile: FORCE compile-targets
242 install-targets: FORCE
243 install: FORCE install-targets
247 @$(MAKE) clean-targets
248 rm -rf $(PKG_BUILD_DIR)