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
69 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
70 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
71 ifneq ($(PKG_VERSION
),)
72 ifneq ($(PKG_RELEASE
),)
73 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
75 VERSION
:=$(PKG_VERSION
)
78 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)";
148 echo
"Default: $(DEFAULT)";
152 echo
"Version: $(VERSION)"; \
153 echo
"Depends: $$(IDEPEND_$(1))"; \
154 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
155 echo
"Category: $(CATEGORY)"; \
156 echo
"Title: $(TITLE)"; \
157 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
170 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
174 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
175 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
176 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
177 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
178 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
179 $$(IDIR_
$(1))/CONTROL
/control
: Makefile
$(PKG_BUILD_DIR
)/.prepared
180 mkdir
-p
$$(IDIR_
$(1))/CONTROL
181 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
182 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
185 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
186 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
188 echo
"Depends: $(EXTRA_DEPENDS) $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
190 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
191 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
192 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
193 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
194 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
195 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
196 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
197 (cd
$$(IDIR_
$(1))/CONTROL
; \
201 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
202 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
203 mkdir
-p
$(PACKAGE_DIR
)
204 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
205 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
206 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
207 $(RSTRIP
) $$(IDIR_
$(1))
208 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
210 $$(INFO_
$(1)): $$(IPKG_
$(1))
211 $(IPKG
) install $$(IPKG_
$(1))
214 rm -f
$(PACKAGE_DIR
)/$(1)_
*
218 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
222 ifneq ($(strip $(PKG_CAT
)),)
223 ifeq ($(PKG_CAT
),unzip
)
224 UNPACK
=unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
)
226 UNPACK
=$(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) -
228 define Build
/Prepare
/Default
230 @if
[ -d .
/patches
]; then \
231 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
237 $(call Build
/Prepare
/Default
)
240 define Build
/Configure
/Default
241 @
(cd
$(PKG_BUILD_DIR
)/$(3); \
242 [ -x configure
] && \
244 $(TARGET_CONFIGURE_OPTS
) \
245 CFLAGS
="$(TARGET_CFLAGS)" \
246 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
247 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
249 --target
=$(GNU_TARGET_NAME
) \
250 --host
=$(GNU_TARGET_NAME
) \
251 --build
=$(GNU_HOST_NAME
) \
252 --program-prefix
="" \
253 --program-suffix
="" \
257 --sbindir
=/usr
/sbin \
258 --libexecdir
=/usr
/lib \
260 --datadir=/usr
/share \
261 --localstatedir
=/var \
263 --infodir=/usr
/info \
270 define Build
/Configure
271 $(call Build
/Configure
/Default
,)
274 define Build
/Compile
/Default
275 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
276 $(TARGET_CONFIGURE_OPTS
) \
278 CROSS
="$(TARGET_CROSS)" \
279 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
285 $(call Build
/Compile
/Default
,)
295 ifneq ($(strip $(PKG_SOURCE
)),)
296 source
: $(DL_DIR
)/$(PKG_SOURCE
)
298 $(DL_DIR
)/$(PKG_SOURCE
):
300 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
302 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
306 prepare
: $(PKG_BUILD_DIR
)/.prepared
307 configure
: $(PKG_BUILD_DIR
)/.configured
310 compile
: compile-targets
313 install: install-targets
317 @
$(MAKE
) clean-targets
319 rm -rf
$(PKG_BUILD_DIR
)