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
17 export CONFIG_SITE
:=$(INCLUDE_DIR
)/site
/$(REAL_GNU_TARGET_NAME
)
19 define Build
/DefaultTargets
21 ifeq ($(CONFIG_AUTOREBUILD
),y
)
22 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
$(PKG_FILE_DEPEND
)),$(PKG_BUILD_DIR
))
23 $$(info Forcing package rebuild
)
24 $(PKG_BUILD_DIR
)/.prepared
: package-clean
29 $(PKG_BUILD_DIR
)/.prepared
:
30 @
-rm -rf
$(PKG_BUILD_DIR
)
31 @mkdir
-p
$(PKG_BUILD_DIR
)
35 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
36 $(call Build
/Configure
)
39 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
43 ifdef Build
/InstallDev
44 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
)
45 $(PKG_BUILD_DIR
)/.built
: package-rebuild
48 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
49 mkdir
-p
$(STAGING_DIR
)/stampfiles
50 $(call Build
/InstallDev
)
53 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
58 $(call Build
/UninstallDev
)
59 -rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
61 package-rebuild
: FORCE
62 @
-rm -f
$(PKG_BUILD_DIR
)/.built
64 define Build
/DefaultTargets
68 define Package
/Default
71 CATEGORY
:=Extra packages
75 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
76 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
77 ifneq ($(PKG_VERSION
),)
78 ifneq ($(PKG_RELEASE
),)
79 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
81 VERSION
:=$(PKG_VERSION
)
84 VERSION
:=$(PKG_RELEASE
)
96 define BuildDescription
97 ifneq ($(DESCRIPTION
),)
98 DESCRIPTION
:=$(TITLE
)\\ $(DESCRIPTION
)
100 DESCRIPTION
:=$(TITLE
)
104 define BuildIPKGVariable
105 $(call shexport
,Package
/$(1)/$(2))
106 $(1)_COMMANDS
+= var2file
"$(call shvar,Package/$(1)/$(2))" $(2);
110 $(eval
$(call Package
/Default
))
111 $(eval
$(call Package
/$(1)))
112 $(eval
$(call BuildDescription
))
114 $(foreach FIELD
, TITLE CATEGORY PRIORITY SECTION VERSION
,
116 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
120 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
121 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
122 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
124 ifdef Package
/$(1)/install
125 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
126 install-targets
: $$(INFO_
$(1))
129 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
)$(SDK
),)
130 compile-targets
: $$(IPKG_
$(1))
132 compile-targets
: $(1)-disabled
134 @echo
"WARNING: skipping $(1) -- package not selected"
138 ifeq ($(FORCEREBUILD
),y
)
142 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
145 dumpinfo
: dumpinfo-
$(1)
147 @
$$(DUMPINFO_
$(call shvar
,$(1)))
149 DUMPINFO_
$(call shvar
,$(1)) += \
150 echo
"Package: $(1)";
153 DUMPINFO_
$(call shvar
,$(1)) += \
154 echo
"Menu: $(MENU)";
158 DUMPINFO_
$(call shvar
,$(1)) += \
159 echo
"Submenu: $(SUBMENU)";
160 ifneq ($(SUBMENUDEP
),)
161 DUMPINFO_
$(call shvar
,$(1)) += \
162 echo
"Submenu-Depends: $(SUBMENUDEP)";
167 DUMPINFO_
$(call shvar
,$(1)) += \
168 echo
"Default: $(DEFAULT)";
171 $(call shexport
,Package
/$(1)/description
)
173 DUMPINFO_
$(call shvar
,$(1)) += \
174 if
[ "$$$$PREREQ_CHECK" = 1 ]; then echo
"Prereq-Check: 1"; fi
; \
175 echo
"Version: $(VERSION)"; \
176 echo
"Depends: $$(IDEPEND_$(1))"; \
177 echo
"Provides: $(PROVIDES)"; \
178 echo
"Build-Depends: $(PKG_BUILD_DEPENDS)"; \
179 echo
"Section: $(SECTION)"; \
180 echo
"Category: $(CATEGORY)"; \
181 echo
"Title: $(TITLE)"; \
182 echo
"Maintainer: $(MAINTAINER)"; \
183 if isset
$(call shvar
,Package
/$(1)/description
); then \
184 echo
-n
"Description: "; \
185 getvar
$(call shvar
,Package
/$(1)/description
); \
187 echo
"Description: $(patsubst \\,\\\\,$(DESCRIPTION))" | perl
-ne
's/\\/\n/g, print'; \
191 DUMPINFO_
$(call shvar
,$(1)) += \
196 DUMPINFO_
$(call shvar
,$(1)) += \
199 $(call shexport
,Package
/$(1)/config
)
200 DUMPINFO_
$(call shvar
,$(1)) += \
201 if isset
$(call shvar
,Package
/$(1)/config
); then \
203 getvar
$(call shvar
,Package
/$(1)/config
); \
209 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
210 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
211 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
212 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
213 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
214 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
)
215 @
rm -f
$(PACKAGE_DIR
)/$(1)_
*
216 mkdir
-p
$$(IDIR_
$(1))/CONTROL
217 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
218 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
220 DEPENDS
='$(EXTRA_DEPENDS)'; \
221 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
222 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
224 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
226 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
227 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
228 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
229 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
230 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
231 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g' | sed
-e
's,^[[:space:]]*$$$$, .,g' >> $$(IDIR_
$(1))/CONTROL
/control
232 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
233 (cd
$$(IDIR_
$(1))/CONTROL
; \
237 $$(IPKG_
$(1)): $(PKG_BUILD_DIR
)/.built
$$(IDIR_
$(1))/CONTROL
/control
238 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
239 mkdir
-p
$(PACKAGE_DIR
)
240 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
241 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
242 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
243 $(RSTRIP
) $$(IDIR_
$(1))
244 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
245 @
[ -f
$$(IPKG_
$(1)) ] || false
247 $$(INFO_
$(1)): $$(IPKG_
$(1))
248 $(IPKG
) install $$(IPKG_
$(1))
251 rm -f
$(PACKAGE_DIR
)/$(1)_
*
255 $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
): $(PKG_BUILD_DIR
)/.prepared
256 -@
rm -f
$(PKG_BUILD_DIR
)/.version-
$(1)_
* 2>/dev
/null
259 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
261 ifdef Package
/$(1)/install
262 ifneq ($$(CONFIG_PACKAGE_
$(1))$(DEVELOPER
)$(SDK
),)
263 ifneq ($(MAKECMDGOALS
),prereq
)
265 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
-x ipkg-install
'$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_
$(1)))
266 $(PKG_BUILD_DIR
)/.built
: package-rebuild
267 $$(info Rebuilding
$(subst $(TOPDIR
)/,,$$(IPKG_
$(1))))
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
,)
289 --target
=$(GNU_TARGET_NAME
) \
290 --host
=$(GNU_TARGET_NAME
) \
291 --build
=$(GNU_HOST_NAME
) \
292 --program-prefix
="" \
293 --program-suffix
="" \
297 --sbindir
=/usr
/sbin \
298 --libexecdir
=/usr
/lib \
300 --datadir=/usr
/share \
301 --localstatedir
=/var \
303 --infodir=/usr
/info \
307 $(TARGET_CONFIGURE_OPTS
) \
308 CFLAGS
="$(TARGET_CFLAGS)" \
309 CXXFLAGS
="$(TARGET_CFLAGS)" \
310 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
311 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
312 PKG_CONFIG_PATH
="$(STAGING_DIR)/usr/lib/pkgconfig" \
313 PKG_CONFIG_LIBDIR
="$(STAGING_DIR)/usr/lib/pkgconfig"
317 define Build
/Configure
/Default
318 (cd
$(PKG_BUILD_DIR
)/$(strip $(3)); \
319 if
[ -x configure
]; then \
322 $(CONFIGURE_PATH
)/configure \
329 define Build
/Configure
330 $(call Build
/Configure
/Default
,)
334 CFLAGS
="$(TARGET_CFLAGS)" \
335 CXXFLAGS
="$(TARGET_CFLAGS) " \
336 LDFLAGS
="$(EXTRA_LDFLAGS) "
339 $(TARGET_CONFIGURE_OPTS
) \
340 CROSS
="$(TARGET_CROSS)" \
343 define Build
/Compile
/Default
345 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
351 $(call Build
/Compile
/Default
,)
360 ifneq ($(strip $(PKG_SOURCE_URL
)),)
361 download
: $(DL_DIR
)/$(PKG_SOURCE
)
363 $(DL_DIR
)/$(PKG_SOURCE
):
365 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
367 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
371 prepare
: $(PKG_BUILD_DIR
)/.prepared
372 configure
: $(PKG_BUILD_DIR
)/.configured
375 compile
: compile-targets
378 install: install-targets
382 @
$(MAKE
) clean-targets
384 rm -rf
$(PKG_BUILD_DIR
)