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 include $(INCLUDE_DIR
)/prereq.mk
15 define Build
/DefaultTargets
17 ifeq ($(CONFIG_AUTOREBUILD
),y
)
19 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
),$(PKG_BUILD_DIR
))
20 _INFO
+=$(subst $(TOPDIR
)/,,$(PKG_BUILD_DIR
))
21 $(PKG_BUILD_DIR
)/.prepared
: package-clean
27 $(PKG_BUILD_DIR
)/.prepared
:
28 @
-rm -rf
$(PKG_BUILD_DIR
)
29 @mkdir
-p
$(PKG_BUILD_DIR
)
33 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
34 $(call Build
/Configure
)
37 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
41 ifdef Build
/InstallDev
42 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
-x ipkg-install
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
$(PKG_BUILD_DIR
)),$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
)
43 $(PKG_BUILD_DIR
)/.built
: package-rebuild
46 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
47 mkdir
-p
$(STAGING_DIR
)/stampfiles
48 $(call Build
/InstallDev
)
51 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
56 $(call Build
/UninstallDev
)
57 -rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
59 package-rebuild
: FORCE
60 @
-rm -f
$(PKG_BUILD_DIR
)/.built
62 define Build
/DefaultTargets
66 define Package
/Default
69 CATEGORY
:=Extra packages
72 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
73 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
74 ifneq ($(PKG_VERSION
),)
75 ifneq ($(PKG_RELEASE
),)
76 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
78 VERSION
:=$(PKG_VERSION
)
81 VERSION
:=$(PKG_RELEASE
)
93 define BuildIPKGVariable
94 pkg_
$(subst .
,_
,$(subst -,_
,$(1)))_
$(2) = $$(Package
/$(1)/$(2))
95 export pkg_
$(subst .
,_
,$(subst -,_
,$(1))_
$(2))
96 $(1)_COMMANDS
+= if
[ -n
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" ]; then echo
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" > $(2); fi
;
100 $(eval
$(call Package
/Default
))
101 $(eval
$(call Package
/$(1)))
103 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
105 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
113 ifeq ($(DESCRIPTION
),)
114 $(eval DESCRIPTION
:=$(TITLE
))
117 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
118 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
119 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
121 ifdef Package
/$(1)/install
122 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
123 install-targets
: $$(INFO_
$(1))
126 ifneq ($(CONFIG_PACKAGE_
$(1)),)
127 compile-targets
: $$(IPKG_
$(1))
129 compile-targets
: $(1)-disabled
131 @echo
"WARNING: skipping $(1) -- package not selected"
135 ifeq ($(FORCEREBUILD
),y
)
139 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
143 echo
"Package: $(1)";
147 echo
"Menu: $(MENU)";
152 echo
"Submenu: $(SUBMENU)";
153 ifneq ($(SUBMENUDEP
),)
155 echo
"Submenu-Depends: $(SUBMENUDEP)";
161 echo
"Default: $(DEFAULT)";
165 echo
"Version: $(VERSION)"; \
166 echo
"Depends: $$(IDEPEND_$(1))"; \
167 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
168 echo
"Category: $(CATEGORY)"; \
169 echo
"Title: $(TITLE)"; \
170 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
183 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
188 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
189 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
190 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
191 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
192 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
193 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
)
194 mkdir
-p
$$(IDIR_
$(1))/CONTROL
195 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
196 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
199 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
200 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
202 echo
"Depends: $(EXTRA_DEPENDS) $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
204 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
205 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
206 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
207 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
208 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
209 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
210 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
211 (cd
$$(IDIR_
$(1))/CONTROL
; \
215 $$(IPKG_
$(1)): $(PKG_BUILD_DIR
)/.built
$$(IDIR_
$(1))/CONTROL
/control
216 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
217 mkdir
-p
$(PACKAGE_DIR
)
218 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
219 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
220 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
221 $(RSTRIP
) $$(IDIR_
$(1))
222 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
223 @
[ -f
$$(IPKG_
$(1)) ] || false
225 $$(INFO_
$(1)): $$(IPKG_
$(1))
226 $(IPKG
) install $$(IPKG_
$(1))
229 rm -f
$(PACKAGE_DIR
)/$(1)_
*
233 $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
): $(PKG_BUILD_DIR
)/.prepared
234 -@
rm $(PKG_BUILD_DIR
)/.version-
$(1)_
* 2>/dev
/null
237 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
239 ifneq ($$(CONFIG_PACKAGE_
$(1)),)
240 ifneq ($(MAKECMDGOALS
),prereq
)
242 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
-x ipkg-install
'$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_
$(1)))
243 _INFO
+=$(subst $(TOPDIR
)/,,$$(IPKG_
$(1)))
244 $(PKG_BUILD_DIR
)/.built
: package-rebuild
248 $$(info Rebuilding
$$(_INFO
))
255 ifneq ($(strip $(PKG_CAT
)),)
256 ifeq ($(PKG_CAT
),unzip
)
257 UNPACK
=unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
)
259 UNPACK
=$(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) -
261 define Build
/Prepare
/Default
263 @if
[ -d .
/patches
]; then \
264 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
270 $(call Build
/Prepare
/Default
,)
273 define Build
/Configure
/Default
274 @
(cd
$(PKG_BUILD_DIR
)/$(3); \
275 if
[ -x configure
]; then \
276 $(TARGET_CONFIGURE_OPTS
) \
277 CFLAGS
="$(TARGET_CFLAGS)" \
278 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
279 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
282 --target
=$(GNU_TARGET_NAME
) \
283 --host
=$(GNU_TARGET_NAME
) \
284 --build
=$(GNU_HOST_NAME
) \
285 --program-prefix
="" \
286 --program-suffix
="" \
290 --sbindir
=/usr
/sbin \
291 --libexecdir
=/usr
/lib \
293 --datadir=/usr
/share \
294 --localstatedir
=/var \
296 --infodir=/usr
/info \
303 define Build
/Configure
304 $(call Build
/Configure
/Default
,)
307 define Build
/Compile
/Default
308 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
309 $(TARGET_CONFIGURE_OPTS
) \
310 CROSS
="$(TARGET_CROSS)" \
311 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
317 $(call Build
/Compile
/Default
,)
327 ifneq ($(strip $(PKG_SOURCE
)),)
328 download
: $(DL_DIR
)/$(PKG_SOURCE
)
330 $(DL_DIR
)/$(PKG_SOURCE
):
332 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
334 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
338 prepare
: $(PKG_BUILD_DIR
)/.prepared
339 configure
: $(PKG_BUILD_DIR
)/.configured
342 compile
: compile-targets
345 install: install-targets
349 @
$(MAKE
) clean-targets
351 rm -rf
$(PKG_BUILD_DIR
)