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 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
),$(PKG_BUILD_DIR
))
16 ifeq ($(CONFIG_AUTOREBUILD
),y
)
17 $(PKG_BUILD_DIR
)/.prepared
: package-clean
21 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
$(IPKG_
$(1)) $(PKG_BUILD_DIR
)),$(IPKG_
$(1)))
22 ifeq ($(CONFIG_AUTOREBUILD
),y
)
23 $(PKG_BUILD_DIR
)/.built
: package-rebuild
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 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
44 $(call Build
/InstallDev
)
47 ifdef Build
/InstallDev
48 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
53 $(call Build
/UninstallDev
)
54 rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
56 package-rebuild
: FORCE
57 @
-rm -f
$(PKG_BUILD_DIR
)/.built
59 define Build
/DefaultTargets
63 define Package
/Default
66 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
)
88 define BuildIPKGVariable
89 pkg_
$(subst .
,_
,$(subst -,_
,$(1)))_
$(2) = $$(Package
/$(1)/$(2))
90 export pkg_
$(subst .
,_
,$(subst -,_
,$(1))_
$(2))
91 $(1)_COMMANDS
+= if
[ -n
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" ]; then echo
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" > $(2); fi
;
95 $(eval
$(call Package
/Default
))
96 $(eval
$(call Package
/$(1)))
98 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
100 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
108 ifeq ($(DESCRIPTION
),)
109 $(eval DESCRIPTION
:=$(TITLE
))
112 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
113 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
114 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
116 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
117 install-targets
: $$(INFO_
$(1))
120 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
121 compile-targets
: $$(IPKG_
$(1))
124 ifeq ($(FORCEREBUILD
),y
)
128 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
131 echo
"Package: $(1)";
135 echo
"Menu: $(MENU)";
140 echo
"Submenu: $(SUBMENU)";
145 echo
"Default: $(DEFAULT)";
149 echo
"Version: $(VERSION)"; \
150 echo
"Depends: $$(IDEPEND_$(1))"; \
151 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
152 echo
"Category: $(CATEGORY)"; \
153 echo
"Title: $(TITLE)"; \
154 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
167 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
171 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
172 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
173 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
174 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
175 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
176 $$(IDIR_
$(1))/CONTROL
/control
: Makefile
$(PKG_BUILD_DIR
)/.prepared
177 mkdir
-p
$$(IDIR_
$(1))/CONTROL
178 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
179 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
182 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
183 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
185 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
187 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
188 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
189 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
190 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
191 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
192 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
193 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
194 (cd
$$(IDIR_
$(1))/CONTROL
; \
198 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
199 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
200 mkdir
-p
$(PACKAGE_DIR
)
201 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
202 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
203 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
204 $(RSTRIP
) $$(IDIR_
$(1))
205 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
207 $$(INFO_
$(1)): $$(IPKG_
$(1))
208 $(IPKG
) install $$(IPKG_
$(1))
211 rm -f
$(PACKAGE_DIR
)/$(1)_
*
215 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
219 ifneq ($(strip $(PKG_CAT
)),)
220 ifeq ($(PKG_CAT
),unzip
)
221 UNPACK
=unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
)
223 UNPACK
=$(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) -
225 define Build
/Prepare
/Default
227 @if
[ -d .
/patches
]; then \
228 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
234 $(call Build
/Prepare
/Default
)
237 define Build
/Configure
/Default
238 @
(cd
$(PKG_BUILD_DIR
)/$(3); \
239 [ -x configure
] && \
241 $(TARGET_CONFIGURE_OPTS
) \
242 CFLAGS
="$(TARGET_CFLAGS)" \
243 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
244 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
246 --target
=$(GNU_TARGET_NAME
) \
247 --host
=$(GNU_TARGET_NAME
) \
248 --build
=$(GNU_HOST_NAME
) \
249 --program-prefix
="" \
250 --program-suffix
="" \
254 --sbindir
=/usr
/sbin \
255 --libexecdir
=/usr
/lib \
257 --datadir=/usr
/share \
258 --localstatedir
=/var \
260 --infodir=/usr
/info \
267 define Build
/Configure
268 $(call Build
/Configure
/Default
,)
271 define Build
/Compile
/Default
272 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
273 $(TARGET_CONFIGURE_OPTS
) \
275 CROSS
="$(TARGET_CROSS)" \
276 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
282 $(call Build
/Compile
/Default
,)
292 ifneq ($(strip $(PKG_SOURCE
)),)
293 source
: $(DL_DIR
)/$(PKG_SOURCE
)
295 $(DL_DIR
)/$(PKG_SOURCE
):
297 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
299 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
303 prepare
: $(PKG_BUILD_DIR
)/.prepared
304 configure
: $(PKG_BUILD_DIR
)/.configured
307 compile
: compile-targets
310 install: install-targets
314 @
$(MAKE
) clean-targets
316 rm -rf
$(PKG_BUILD_DIR
)