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 define Build
/DefaultTargets
15 ifeq ($(CONFIG_AUTOREBUILD
),y
)
16 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
),$(PKG_BUILD_DIR
))
17 $(PKG_BUILD_DIR
)/.prepared
: package-clean
20 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
$(IPKG_
$(1)) $(PKG_BUILD_DIR
)),$(IPKG_
$(1)))
21 $(PKG_BUILD_DIR
)/.built
: package-rebuild
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 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
42 mkdir
-p
$(STAGING_DIR
)/stampfiles
43 $(call Build
/InstallDev
)
46 ifdef Build
/InstallDev
47 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
52 $(call Build
/UninstallDev
)
53 rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
55 package-rebuild
: FORCE
56 @
-rm -f
$(PKG_BUILD_DIR
)/.built
58 define Build
/DefaultTargets
62 define Package
/Default
65 CATEGORY
:=Extra packages
68 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
69 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
70 ifneq ($(PKG_VERSION
),)
71 ifneq ($(PKG_RELEASE
),)
72 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
74 VERSION
:=$(PKG_VERSION
)
77 VERSION
:=$(PKG_RELEASE
)
89 define BuildIPKGVariable
90 pkg_
$(subst .
,_
,$(subst -,_
,$(1)))_
$(2) = $$(Package
/$(1)/$(2))
91 export pkg_
$(subst .
,_
,$(subst -,_
,$(1))_
$(2))
92 $(1)_COMMANDS
+= if
[ -n
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" ]; then echo
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" > $(2); fi
;
96 $(eval
$(call Package
/Default
))
97 $(eval
$(call Package
/$(1)))
99 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
101 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
109 ifeq ($(DESCRIPTION
),)
110 $(eval DESCRIPTION
:=$(TITLE
))
113 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
114 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
115 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
117 ifdef Package
/$(1)/install
118 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
119 install-targets
: $$(INFO_
$(1))
122 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
123 compile-targets
: $$(IPKG_
$(1))
127 ifeq ($(FORCEREBUILD
),y
)
131 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
134 echo
"Package: $(1)";
138 echo
"Menu: $(MENU)";
143 echo
"Submenu: $(SUBMENU)";
144 ifneq ($(SUBMENUDEP
),)
146 echo
"Submenu-Depends: $(SUBMENUDEP)";
152 echo
"Default: $(DEFAULT)";
156 echo
"Version: $(VERSION)"; \
157 echo
"Depends: $$(IDEPEND_$(1))"; \
158 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
159 echo
"Category: $(CATEGORY)"; \
160 echo
"Title: $(TITLE)"; \
161 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
174 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
178 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
179 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
180 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
181 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
182 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
183 $$(IDIR_
$(1))/CONTROL
/control
: Makefile
$(PKG_BUILD_DIR
)/.prepared
$(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
)
184 mkdir
-p
$$(IDIR_
$(1))/CONTROL
185 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
186 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
189 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
190 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
192 echo
"Depends: $(EXTRA_DEPENDS) $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
194 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
195 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
196 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
197 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
198 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
199 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
200 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
201 (cd
$$(IDIR_
$(1))/CONTROL
; \
205 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
206 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
207 mkdir
-p
$(PACKAGE_DIR
)
208 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
209 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
210 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
211 $(RSTRIP
) $$(IDIR_
$(1))
212 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
213 @
[ -f
$$(IPKG_
$(1)) ] || false
215 $$(INFO_
$(1)): $$(IPKG_
$(1))
216 $(IPKG
) install $$(IPKG_
$(1))
219 rm -f
$(PACKAGE_DIR
)/$(1)_
*
223 $(PKG_BUILD_DIR
)/.version-
$(1)_
$(VERSION
)_
$(PKGARCH
):
224 -rm $(PKG_BUILD_DIR
)/.version-
$(1)_
*
227 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
231 ifneq ($(strip $(PKG_CAT
)),)
232 ifeq ($(PKG_CAT
),unzip
)
233 UNPACK
=unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
)
235 UNPACK
=$(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) -
237 define Build
/Prepare
/Default
239 @if
[ -d .
/patches
]; then \
240 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
246 $(call Build
/Prepare
/Default
)
249 define Build
/Configure
/Default
250 @
(cd
$(PKG_BUILD_DIR
)/$(3); \
251 [ -x configure
] && \
253 $(TARGET_CONFIGURE_OPTS
) \
254 CFLAGS
="$(TARGET_CFLAGS)" \
255 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
256 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
258 --target
=$(GNU_TARGET_NAME
) \
259 --host
=$(GNU_TARGET_NAME
) \
260 --build
=$(GNU_HOST_NAME
) \
261 --program-prefix
="" \
262 --program-suffix
="" \
266 --sbindir
=/usr
/sbin \
267 --libexecdir
=/usr
/lib \
269 --datadir=/usr
/share \
270 --localstatedir
=/var \
272 --infodir=/usr
/info \
279 define Build
/Configure
280 $(call Build
/Configure
/Default
,)
283 define Build
/Compile
/Default
284 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
285 $(TARGET_CONFIGURE_OPTS
) \
287 CROSS
="$(TARGET_CROSS)" \
288 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
294 $(call Build
/Compile
/Default
,)
304 ifneq ($(strip $(PKG_SOURCE
)),)
305 download
: $(DL_DIR
)/$(PKG_SOURCE
)
307 $(DL_DIR
)/$(PKG_SOURCE
):
309 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
311 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
315 prepare
: $(PKG_BUILD_DIR
)/.prepared
316 configure
: $(PKG_BUILD_DIR
)/.configured
319 compile
: compile-targets
322 install: install-targets
326 @
$(MAKE
) clean-targets
328 rm -rf
$(PKG_BUILD_DIR
)