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 export CONFIG_SITE
:=$(INCLUDE_DIR
)/site
/$(REAL_GNU_TARGET_NAME
)
20 define Build
/DefaultTargets
22 ifeq ($(CONFIG_AUTOREBUILD
),y
)
23 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
$(PKG_FILE_DEPEND
)),$(PKG_BUILD_DIR
))
24 $$(info Forcing package rebuild
)
25 $(PKG_BUILD_DIR
)/.prepared
: package-clean
30 $(PKG_BUILD_DIR
)/.prepared
:
31 @
-rm -rf
$(PKG_BUILD_DIR
)
32 @mkdir
-p
$(PKG_BUILD_DIR
)
36 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
37 $(call Build
/Configure
)
40 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
44 ifdef Build
/InstallDev
45 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
)
46 $(PKG_BUILD_DIR
)/.built
: package-rebuild
49 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
50 mkdir
-p
$(STAGING_DIR
)/stampfiles
51 $(call Build
/InstallDev
)
54 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
59 $(call Build
/UninstallDev
)
60 -rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
62 package-rebuild
: FORCE
63 @
-rm -f
$(PKG_BUILD_DIR
)/.built
65 define Build
/DefaultTargets
69 define Package
/Default
72 CATEGORY
:=Extra packages
76 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
77 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
78 ifneq ($(PKG_VERSION
),)
79 ifneq ($(PKG_RELEASE
),)
80 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
82 VERSION
:=$(PKG_VERSION
)
85 VERSION
:=$(PKG_RELEASE
)
97 define BuildDescription
98 ifneq ($(DESCRIPTION
),)
99 DESCRIPTION
:=$(TITLE
)\\ $(DESCRIPTION
)
101 DESCRIPTION
:=$(TITLE
)
105 define BuildIPKGVariable
106 $(call shexport
,Package
/$(1)/$(2))
107 $(1)_COMMANDS
+= var2file
"$(call shvar,Package/$(1)/$(2))" $(2);
111 $(eval
$(call Package
/Default
))
112 $(eval
$(call Package
/$(1)))
113 $(eval
$(call BuildDescription
))
115 $(foreach FIELD
, TITLE CATEGORY PRIORITY SECTION VERSION
,
117 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
121 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
122 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
123 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
125 ifdef Package
/$(1)/install
126 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
127 install-targets
: $$(INFO_
$(1))
130 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
)$(SDK
),)
131 compile-targets
: $$(IPKG_
$(1))
133 compile-targets
: $(1)-disabled
135 @echo
"WARNING: skipping $(1) -- package not selected"
139 ifeq ($(FORCEREBUILD
),y
)
143 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
146 dumpinfo
: dumpinfo-
$(1)
148 @
$$(DUMPINFO_
$(call shvar
,$(1)))
150 DUMPINFO_
$(call shvar
,$(1)) += \
151 echo
"Package: $(1)";
154 DUMPINFO_
$(call shvar
,$(1)) += \
155 echo
"Menu: $(MENU)";
159 DUMPINFO_
$(call shvar
,$(1)) += \
160 echo
"Submenu: $(SUBMENU)";
161 ifneq ($(SUBMENUDEP
),)
162 DUMPINFO_
$(call shvar
,$(1)) += \
163 echo
"Submenu-Depends: $(SUBMENUDEP)";
168 DUMPINFO_
$(call shvar
,$(1)) += \
169 echo
"Default: $(DEFAULT)";
172 $(call shexport
,Package
/$(1)/description
)
174 DUMPINFO_
$(call shvar
,$(1)) += \
175 if
[ "$$$$PREREQ_CHECK" = 1 ]; then echo
"Prereq-Check: 1"; fi
; \
176 echo
"Version: $(VERSION)"; \
177 echo
"Depends: $$(IDEPEND_$(1))"; \
178 echo
"Provides: $(PROVIDES)"; \
179 echo
"Build-Depends: $(PKG_BUILD_DEPENDS)"; \
180 echo
"Section: $(SECTION)"; \
181 echo
"Category: $(CATEGORY)"; \
182 echo
"Title: $(TITLE)"; \
183 echo
"Maintainer: $(MAINTAINER)"; \
184 if isset
$(call shvar
,Package
/$(1)/description
); then \
185 echo
-n
"Description: "; \
186 getvar
$(call shvar
,Package
/$(1)/description
); \
188 echo
"Description: $(patsubst \\,\\\\,$(DESCRIPTION))" | perl
-ne
's/\\/\n/g, print'; \
192 DUMPINFO_
$(call shvar
,$(1)) += \
197 DUMPINFO_
$(call shvar
,$(1)) += \
200 $(call shexport
,Package
/$(1)/config
)
201 DUMPINFO_
$(call shvar
,$(1)) += \
202 if isset
$(call shvar
,Package
/$(1)/config
); then \
204 getvar
$(call shvar
,Package
/$(1)/config
); \
210 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
211 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
212 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
213 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
214 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
215 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
)
216 @
rm -f
$(PACKAGE_DIR
)/$(1)_
*
217 mkdir
-p
$$(IDIR_
$(1))/CONTROL
218 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
219 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
221 DEPENDS
='$(EXTRA_DEPENDS)'; \
222 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
223 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
225 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
227 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
228 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
229 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
230 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
231 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
232 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g' | sed
-e
's,^[[:space:]]*$$$$, .,g' >> $$(IDIR_
$(1))/CONTROL
/control
233 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
234 (cd
$$(IDIR_
$(1))/CONTROL
; \
238 $$(IPKG_
$(1)): $(PKG_BUILD_DIR
)/.built
$$(IDIR_
$(1))/CONTROL
/control
239 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
240 mkdir
-p
$(PACKAGE_DIR
)
241 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
242 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
243 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
244 $(RSTRIP
) $$(IDIR_
$(1))
245 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
246 @
[ -f
$$(IPKG_
$(1)) ] || false
248 $$(INFO_
$(1)): $$(IPKG_
$(1))
249 $(IPKG
) install $$(IPKG_
$(1))
252 rm -f
$(PACKAGE_DIR
)/$(1)_
*
256 $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
): $(PKG_BUILD_DIR
)/.prepared
257 -@
rm -f
$(PKG_BUILD_DIR
)/.version-
$(1)_
* 2>/dev
/null
260 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
262 ifdef Package
/$(1)/install
263 ifneq ($$(CONFIG_PACKAGE_
$(1))$(DEVELOPER
)$(SDK
),)
264 ifneq ($(MAKECMDGOALS
),prereq
)
266 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
-x ipkg-install
'$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_
$(1)))
267 $(PKG_BUILD_DIR
)/.built
: package-rebuild
268 $$(info Rebuilding
$(subst $(TOPDIR
)/,,$$(IPKG_
$(1))))
276 ifneq ($(strip $(PKG_UNPACK
)),)
277 define Build
/Prepare
/Default
279 @if
[ -d .
/patches
-a
"$$$$(ls ./patches | wc -l)" -gt
0 ]; then \
280 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
286 $(call Build
/Prepare
/Default
,)
289 define Build
/Configure
/Default
290 (cd
$(PKG_BUILD_DIR
)/$(strip $(3)); \
291 if
[ -x configure
]; then \
292 $(TARGET_CONFIGURE_OPTS
) \
293 CFLAGS
="$(TARGET_CFLAGS)" \
294 CXXFLAGS
="$(TARGET_CFLAGS)" \
295 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
296 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
297 PKG_CONFIG_PATH
="$(STAGING_DIR)/usr/lib/pkgconfig" \
298 PKG_CONFIG_LIBDIR
="$(STAGING_DIR)/usr/lib/pkgconfig" \
300 $(PKG_CONFIGURE_PATH
)/configure \
301 --target
=$(GNU_TARGET_NAME
) \
302 --host
=$(GNU_TARGET_NAME
) \
303 --build
=$(GNU_HOST_NAME
) \
304 --program-prefix
="" \
305 --program-suffix
="" \
309 --sbindir
=/usr
/sbin \
310 --libexecdir
=/usr
/lib \
312 --datadir=/usr
/share \
313 --localstatedir
=/var \
315 --infodir=/usr
/info \
322 define Build
/Configure
323 $(call Build
/Configure
/Default
,)
326 define Build
/Compile
/Default
327 CFLAGS
="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
328 LDFLAGS
="$(EXTRA_LDFLAGS) " \
329 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
330 $(TARGET_CONFIGURE_OPTS
) \
331 CROSS
="$(TARGET_CROSS)" \
332 CXXFLAGS
="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
338 $(call Build
/Compile
/Default
,)
347 ifneq ($(strip $(PKG_SOURCE_URL
)),)
348 download
: $(DL_DIR
)/$(PKG_SOURCE
)
350 $(DL_DIR
)/$(PKG_SOURCE
):
352 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
354 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
358 prepare
: $(PKG_BUILD_DIR
)/.prepared
359 configure
: $(PKG_BUILD_DIR
)/.configured
362 compile
: compile-targets
365 install: install-targets
369 @
$(MAKE
) clean-targets
371 rm -rf
$(PKG_BUILD_DIR
)