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
16 V_
$(subst .
,_
,$(subst -,_
,$(subst /,_
,$(1))))
20 $(call shvar
,$(1))=$$(call
$(1))
21 export $(call shvar
,$(1))
24 define Build
/DefaultTargets
26 ifeq ($(CONFIG_AUTOREBUILD
),y
)
28 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
),$(PKG_BUILD_DIR
))
29 _INFO
+=$(subst $(TOPDIR
)/,,$(PKG_BUILD_DIR
))
30 $(PKG_BUILD_DIR
)/.prepared
: package-clean
35 $(PKG_BUILD_DIR
)/.prepared
:
36 @
-rm -rf
$(PKG_BUILD_DIR
)
37 @mkdir
-p
$(PKG_BUILD_DIR
)
41 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
42 $(call Build
/Configure
)
45 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
49 ifdef Build
/InstallDev
50 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
)
51 $(PKG_BUILD_DIR
)/.built
: package-rebuild
54 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
55 mkdir
-p
$(STAGING_DIR
)/stampfiles
56 $(call Build
/InstallDev
)
59 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
64 $(call Build
/UninstallDev
)
65 -rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
67 package-rebuild
: FORCE
68 @
-rm -f
$(PKG_BUILD_DIR
)/.built
70 define Build
/DefaultTargets
74 define Package
/Default
77 CATEGORY
:=Extra packages
80 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
81 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
82 ifneq ($(PKG_VERSION
),)
83 ifneq ($(PKG_RELEASE
),)
84 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
86 VERSION
:=$(PKG_VERSION
)
89 VERSION
:=$(PKG_RELEASE
)
101 define BuildDescription
102 ifneq ($(DESCRIPTION
),)
103 DESCRIPTION
:=$(TITLE
)\\ $(DESCRIPTION
)
105 DESCRIPTION
:=$(TITLE
)
109 define BuildIPKGVariable
110 $(call shexport
,Package
/$(1)/$(2))
111 $(1)_COMMANDS
+= var2file
"$(call shvar,Package/$(1)/$(2))" $(2);
115 $(eval
$(call Package
/Default
))
116 $(eval
$(call Package
/$(1)))
117 $(eval
$(call BuildDescription
))
119 $(foreach FIELD
, TITLE CATEGORY PRIORITY SECTION VERSION
,
121 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
125 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
126 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
127 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
129 ifdef Package
/$(1)/install
130 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
131 install-targets
: $$(INFO_
$(1))
134 ifneq ($(CONFIG_PACKAGE_
$(1)),)
135 compile-targets
: $$(IPKG_
$(1))
137 compile-targets
: $(1)-disabled
139 @echo
"WARNING: skipping $(1) -- package not selected"
143 ifeq ($(FORCEREBUILD
),y
)
147 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
151 echo
"Package: $(1)";
155 echo
"Menu: $(MENU)";
160 echo
"Submenu: $(SUBMENU)";
161 ifneq ($(SUBMENUDEP
),)
163 echo
"Submenu-Depends: $(SUBMENUDEP)";
169 echo
"Default: $(DEFAULT)";
172 $(call shexport
,Package
/$(1)/description
)
175 if
[ "$$$$PREREQ_CHECK" = 1 ]; then echo
"Prereq-Check: 1"; fi
; \
176 echo
"Version: $(VERSION)"; \
177 echo
"Depends: $$(IDEPEND_$(1))"; \
178 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
179 echo
"Category: $(CATEGORY)"; \
180 echo
"Title: $(TITLE)"; \
181 if isset
$(call shvar
,Package
/$(1)/description
); then \
182 echo
-n
"Description: "; \
183 getvar
$(call shvar
,Package
/$(1)/description
); \
185 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g'; \
197 $(call shexport
,Package
/$(1)/config
)
199 if isset
$(call shvar
,Package
/$(1)/config
); then echo
"Config: "; getvar
$(call shvar
,Package
/$(1)/config
); fi
; \
204 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
205 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
206 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
207 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
208 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
209 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
)
210 mkdir
-p
$$(IDIR_
$(1))/CONTROL
211 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
212 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
215 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
216 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
218 echo
"Depends: $(EXTRA_DEPENDS) $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
220 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
221 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
222 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
223 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
224 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
225 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g' | sed
-e
's,^[[:space:]]*$$$$, .,g' >> $$(IDIR_
$(1))/CONTROL
/control
226 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
227 (cd
$$(IDIR_
$(1))/CONTROL
; \
231 $$(IPKG_
$(1)): $(PKG_BUILD_DIR
)/.built
$$(IDIR_
$(1))/CONTROL
/control
232 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
233 mkdir
-p
$(PACKAGE_DIR
)
234 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
235 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
236 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
237 $(RSTRIP
) $$(IDIR_
$(1))
238 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
239 @
[ -f
$$(IPKG_
$(1)) ] || false
241 $$(INFO_
$(1)): $$(IPKG_
$(1))
242 $(IPKG
) install $$(IPKG_
$(1))
245 rm -f
$(PACKAGE_DIR
)/$(1)_
*
249 $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
): $(PKG_BUILD_DIR
)/.prepared
250 -@
rm $(PKG_BUILD_DIR
)/.version-
$(1)_
* 2>/dev
/null
253 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
255 ifneq ($$(CONFIG_PACKAGE_
$(1)),)
256 ifneq ($(MAKECMDGOALS
),prereq
)
258 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
-x ipkg-install
'$$(IPKG_$(1))' '$(PKG_BUILD_DIR)'),$$(IPKG_
$(1)))
259 _INFO
+=$(subst $(TOPDIR
)/,,$$(IPKG_
$(1)))
260 $(PKG_BUILD_DIR
)/.built
: package-rebuild
264 $$(info Rebuilding
$$(_INFO
))
271 ifneq ($(strip $(PKG_CAT
)),)
272 ifeq ($(PKG_CAT
),unzip
)
273 UNPACK
=unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
)
275 UNPACK
=$(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) -
277 define Build
/Prepare
/Default
279 @if
[ -d .
/patches
]; then \
280 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
286 $(call Build
/Prepare
/Default
,)
289 define Build
/Configure
/Default
290 (cd
$(PKG_BUILD_DIR
)/$(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" \
300 --target
=$(GNU_TARGET_NAME
) \
301 --host
=$(GNU_TARGET_NAME
) \
302 --build
=$(GNU_HOST_NAME
) \
303 --program-prefix
="" \
304 --program-suffix
="" \
308 --sbindir
=/usr
/sbin \
309 --libexecdir
=/usr
/lib \
311 --datadir=/usr
/share \
312 --localstatedir
=/var \
314 --infodir=/usr
/info \
321 define Build
/Configure
322 $(call Build
/Configure
/Default
,)
325 define Build
/Compile
/Default
326 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
327 $(TARGET_CONFIGURE_OPTS
) \
328 CROSS
="$(TARGET_CROSS)" \
329 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include " \
330 EXTRA_LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib " \
336 $(call Build
/Compile
/Default
,)
346 ifneq ($(strip $(PKG_SOURCE
)),)
347 download
: $(DL_DIR
)/$(PKG_SOURCE
)
349 $(DL_DIR
)/$(PKG_SOURCE
):
351 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
353 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
357 prepare
: $(PKG_BUILD_DIR
)/.prepared
358 configure
: $(PKG_BUILD_DIR
)/.configured
361 compile
: compile-targets
364 install: install-targets
368 @
$(MAKE
) clean-targets
370 rm -rf
$(PKG_BUILD_DIR
)