7 define Build/DefaultTargets
8 ifeq ($(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) .),.)
9 $(PKG_BUILD_DIR)/.prepared: package-clean
12 ifneq ($(shell $(SCRIPT_DIR)/timestamp.pl -p -x ipkg $(IPKG_$(1)) $(PKG_BUILD_DIR)),$(IPKG_$(1)))
13 $(PKG_BUILD_DIR)/.built: package-rebuild
16 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
17 @-rm -rf $(PKG_BUILD_DIR)
18 @mkdir -p $(PKG_BUILD_DIR)
22 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
23 $(call Build/Configure)
26 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
33 package-rebuild: FORCE
34 @-rm $(PKG_BUILD_DIR)/.built
36 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)
57 $(eval $(call Package/Default))
58 $(eval $(call Package/$(1)))
60 $(foreach FIELD, TITLE CATEGORY PRIORITY VERSION,
62 $$(error Package/$(1) is missing the $(FIELD) field)
70 ifeq ($(DESCRIPTION),)
71 $(eval DESCRIPTION:=$(TITLE))
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 ifeq ($(CONFIG_PACKAGE_$(1)),y)
79 install-targets: $$(INFO_$(1))
82 ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),)
83 compile-targets: $$(IPKG_$(1))
86 IDEPEND_$(1):=$$(strip $$(DEPENDS))
98 echo "Default: $(DEFAULT)";
102 echo "Version: $(VERSION)"; \
103 echo "Depends: $$(IDEPEND_$(1))"; \
104 echo "Category: $(CATEGORY)"; \
105 echo "Title: $(TITLE)"; \
106 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g';
117 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
118 mkdir -p $$(IDIR_$(1))/CONTROL
119 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
120 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
121 echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control
122 echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
123 echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
124 echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
125 echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
126 echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
127 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control
128 chmod 644 $$(IDIR_$(1))/CONTROL/control
129 for file in conffiles preinst postinst prerm postrm; do \
130 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
133 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built
134 $(call Package/$(1)/install,$$(IDIR_$(1)))
135 mkdir -p $(PACKAGE_DIR)
136 $(RSTRIP) $$(IDIR_$(1))
137 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
139 $$(INFO_$(1)): $$(IPKG_$(1))
140 $(IPKG) install $$(IPKG_$(1))
143 rm -f $(PACKAGE_DIR)/$(1)_*
147 $$(eval $$(call Build/DefaultTargets,$(1)))
151 ifneq ($(strip $(PKG_SOURCE)),)
152 $(DL_DIR)/$(PKG_SOURCE):
153 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
156 ifneq ($(strip $(PKG_CAT)),)
157 define Build/Prepare/Default
158 @if [ "$(PKG_CAT)" = "unzip" ]; then \
159 unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
161 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
163 @if [ -d ./patches ]; then \
164 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
170 $(call Build/Prepare/Default)
173 define Build/Configure/Default
174 @(cd $(PKG_BUILD_DIR); \
175 [ -x configure ] && \
176 $(TARGET_CONFIGURE_OPTS) \
177 CFLAGS="$(TARGET_CFLAGS)" \
179 --target=$(GNU_TARGET_NAME) \
180 --host=$(GNU_TARGET_NAME) \
181 --build=$(GNU_HOST_NAME) \
185 --sbindir=/usr/sbin \
186 --libexecdir=/usr/lib \
188 --datadir=/usr/share \
189 --localstatedir=/var \
191 --infodir=/usr/info \
197 define Build/Configure
198 $(call Build/Configure/Default,)
201 define Build/Compile/Default
202 $(MAKE) -C $(PKG_BUILD_DIR) \
204 CROSS="$(TARGET_CROSS)" \
205 PREFIX="$$(IDIR_$(1))" \
206 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
208 DESTDIR="$$(IDIR_$(1))"
212 $(call Build/Compile/Default)
227 source: $(DL_DIR)/$(PKG_SOURCE)
228 prepare: $(PKG_BUILD_DIR)/.prepared
229 configure: $(PKG_BUILD_DIR)/.configured
232 compile: compile-targets
235 install: install-targets
239 @$(MAKE) clean-targets
240 rm -rf $(PKG_BUILD_DIR)