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
14 include $(INCLUDE_DIR
)/host.mk
15 include $(INCLUDE_DIR
)/unpack.mk
18 V_
$(subst .
,_
,$(subst -,_
,$(subst /,_
,$(1))))
22 $(call shvar
,$(1))=$$(call
$(1))
23 export $(call shvar
,$(1))
26 define Build
/DefaultTargets
28 ifeq ($(CONFIG_AUTOREBUILD
),y
)
30 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
),$(PKG_BUILD_DIR
))
31 _INFO
+=$(subst $(TOPDIR
)/,,$(PKG_BUILD_DIR
))
32 $(PKG_BUILD_DIR
)/.prepared
: package-clean
37 $(PKG_BUILD_DIR
)/.prepared
:
38 @
-rm -rf
$(PKG_BUILD_DIR
)
39 @mkdir
-p
$(PKG_BUILD_DIR
)
43 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
44 $(call Build
/Configure
)
47 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
51 ifdef Build
/InstallDev
52 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
)
53 $(PKG_BUILD_DIR
)/.built
: package-rebuild
56 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
57 mkdir
-p
$(STAGING_DIR
)/stampfiles
58 $(call Build
/InstallDev
)
61 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
66 $(call Build
/UninstallDev
)
67 -rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
69 package-rebuild
: FORCE
70 @
-rm -f
$(PKG_BUILD_DIR
)/.built
72 define Build
/DefaultTargets
76 define Package
/Default
79 CATEGORY
:=Extra packages
83 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
84 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
85 ifneq ($(PKG_VERSION
),)
86 ifneq ($(PKG_RELEASE
),)
87 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
89 VERSION
:=$(PKG_VERSION
)
92 VERSION
:=$(PKG_RELEASE
)
104 define BuildDescription
105 ifneq ($(DESCRIPTION
),)
106 DESCRIPTION
:=$(TITLE
)\\ $(DESCRIPTION
)
108 DESCRIPTION
:=$(TITLE
)
112 define BuildIPKGVariable
113 $(call shexport
,Package
/$(1)/$(2))
114 $(1)_COMMANDS
+= var2file
"$(call shvar,Package/$(1)/$(2))" $(2);
118 $(eval
$(call Package
/Default
))
119 $(eval
$(call Package
/$(1)))
120 $(eval
$(call BuildDescription
))
122 $(foreach FIELD
, TITLE CATEGORY PRIORITY SECTION VERSION
,
124 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
128 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
129 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
130 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
132 ifdef Package
/$(1)/install
133 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
134 install-targets
: $$(INFO_
$(1))
137 ifneq ($(CONFIG_PACKAGE_
$(1)),)
138 compile-targets
: $$(IPKG_
$(1))
140 compile-targets
: $(1)-disabled
142 @echo
"WARNING: skipping $(1) -- package not selected"
146 ifeq ($(FORCEREBUILD
),y
)
150 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
154 echo
"Package: $(1)";
158 echo
"Menu: $(MENU)";
163 echo
"Submenu: $(SUBMENU)";
164 ifneq ($(SUBMENUDEP
),)
166 echo
"Submenu-Depends: $(SUBMENUDEP)";
172 echo
"Default: $(DEFAULT)";
175 $(call shexport
,Package
/$(1)/description
)
178 if
[ "$$$$PREREQ_CHECK" = 1 ]; then echo
"Prereq-Check: 1"; fi
; \
179 echo
"Version: $(VERSION)"; \
180 echo
"Depends: $$(IDEPEND_$(1))"; \
181 echo
"Provides: $(PROVIDES)"; \
182 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
183 echo
"Category: $(CATEGORY)"; \
184 echo
"Title: $(TITLE)"; \
185 if isset
$(call shvar
,Package
/$(1)/description
); then \
186 echo
-n
"Description: "; \
187 getvar
$(call shvar
,Package
/$(1)/description
); \
189 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g'; \
201 $(call shexport
,Package
/$(1)/config
)
203 if isset
$(call shvar
,Package
/$(1)/config
); then echo
"Config: "; getvar
$(call shvar
,Package
/$(1)/config
); fi
; \
208 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
209 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
210 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
211 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
212 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
213 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
)
214 mkdir
-p
$$(IDIR_
$(1))/CONTROL
215 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
216 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
219 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
220 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
222 echo
"Depends: $(EXTRA_DEPENDS) $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
224 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
225 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
226 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
227 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
228 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
229 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g' | sed
-e
's,^[[:space:]]*$$$$, .,g' >> $$(IDIR_
$(1))/CONTROL
/control
230 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
231 (cd
$$(IDIR_
$(1))/CONTROL
; \
235 $$(IPKG_
$(1)): $(PKG_BUILD_DIR
)/.built
$$(IDIR_
$(1))/CONTROL
/control
236 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
237 mkdir
-p
$(PACKAGE_DIR
)
238 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
239 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
240 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
241 $(RSTRIP
) $$(IDIR_
$(1))
242 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
243 @
[ -f
$$(IPKG_
$(1)) ] || false
245 $$(INFO_
$(1)): $$(IPKG_
$(1))
246 $(IPKG
) install $$(IPKG_
$(1))
249 rm -f
$(PACKAGE_DIR
)/$(1)_
*
253 $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
): $(PKG_BUILD_DIR
)/.prepared
254 -@
rm -f
$(PKG_BUILD_DIR
)/.version-
$(1)_
* 2>/dev
/null
257 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
259 ifneq ($$(CONFIG_PACKAGE_
$(1)),)
260 ifneq ($(MAKECMDGOALS
),prereq
)
262 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
-x ipkg-install
'$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_
$(1)))
263 _INFO
+=$(subst $(TOPDIR
)/,,$$(IPKG_
$(1)))
264 $(PKG_BUILD_DIR
)/.built
: package-rebuild
268 $$(info Rebuilding
$$(_INFO
))
275 ifneq ($(strip $(PKG_UNPACK
)),)
276 define Build
/Prepare
/Default
278 @if
[ -d .
/patches
-a
"$$$$(ls ./patches | wc -l)" -gt
0 ]; then \
279 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
285 $(call Build
/Prepare
/Default
,)
288 define Build
/Configure
/Default
289 (cd
$(PKG_BUILD_DIR
)/$(3); \
290 if
[ -x configure
]; then \
291 $(TARGET_CONFIGURE_OPTS
) \
292 CFLAGS
="$(TARGET_CFLAGS)" \
293 CXXFLAGS
="$(TARGET_CFLAGS)" \
294 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
295 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
296 PKG_CONFIG_PATH
="$(STAGING_DIR)/usr/lib/pkgconfig" \
299 --target
=$(GNU_TARGET_NAME
) \
300 --host
=$(GNU_TARGET_NAME
) \
301 --build
=$(GNU_HOST_NAME
) \
302 --program-prefix
="" \
303 --program-suffix
="" \
307 --sbindir
=/usr
/sbin \
308 --libexecdir
=/usr
/lib \
310 --datadir=/usr
/share \
311 --localstatedir
=/var \
313 --infodir=/usr
/info \
320 define Build
/Configure
321 $(call Build
/Configure
/Default
,)
324 define Build
/Compile
/Default
325 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
326 $(TARGET_CONFIGURE_OPTS
) \
327 CROSS
="$(TARGET_CROSS)" \
328 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include " \
329 EXTRA_LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib " \
335 $(call Build
/Compile
/Default
,)
345 ifneq ($(strip $(PKG_SOURCE
)),)
346 download
: $(DL_DIR
)/$(PKG_SOURCE
)
348 $(DL_DIR
)/$(PKG_SOURCE
):
350 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
352 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
356 prepare
: $(PKG_BUILD_DIR
)/.prepared
357 configure
: $(PKG_BUILD_DIR
)/.configured
360 compile
: compile-targets
363 install: install-targets
367 @
$(MAKE
) clean-targets
369 rm -rf
$(PKG_BUILD_DIR
)