7 define Build
/DefaultTargets
9 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
$(TOPDIR
)/package
/rules.mk
),$(PKG_BUILD_DIR
))
10 ifeq ($(CONFIG_AUTOREBUILD
),y
)
11 $(PKG_BUILD_DIR
)/.prepared
: package-clean
15 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
$(IPKG_
$(1)) $(PKG_BUILD_DIR
)),$(IPKG_
$(1)))
16 ifeq ($(CONFIG_AUTOREBUILD
),y
)
17 $(PKG_BUILD_DIR
)/.built
: package-rebuild
22 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
23 @
-rm -rf
$(PKG_BUILD_DIR
)
24 @mkdir
-p
$(PKG_BUILD_DIR
)
28 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
29 $(call Build
/Configure
)
32 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
36 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
37 $(call Build
/InstallDev
)
40 ifdef Build
/InstallDev
41 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
46 $(call Build
/UninstallDev
)
47 rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
49 package-rebuild
: FORCE
50 @
-rm -f
$(PKG_BUILD_DIR
)/.built
52 define Build
/DefaultTargets
56 define Package
/Default
59 CATEGORY
:=Extra packages
61 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
62 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
63 ifneq ($(PKG_VERSION
),)
64 ifneq ($(PKG_RELEASE
),)
65 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
67 VERSION
:=$(PKG_VERSION
)
70 VERSION
:=$(PKG_RELEASE
)
80 define BuildIPKGVariable
81 pkg_
$(subst .
,_
,$(subst -,_
,$(1)))_
$(2) = $$(Package
/$(1)/$(2))
82 export pkg_
$(subst .
,_
,$(subst -,_
,$(1))_
$(2))
83 $(1)_COMMANDS
+= if
[ -n
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" ]; then echo
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" > $(2); fi
;
87 $(eval
$(call Package
/Default
))
88 $(eval
$(call Package
/$(1)))
90 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
92 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
100 ifeq ($(DESCRIPTION
),)
101 $(eval DESCRIPTION
:=$(TITLE
))
104 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
105 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
106 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
108 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
109 install-targets
: $$(INFO_
$(1))
112 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
113 compile-targets
: $$(IPKG_
$(1))
116 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
119 echo
"Package: $(1)";
123 echo
"Menu: $(MENU)";
128 echo
"Default: $(DEFAULT)";
132 echo
"Version: $(VERSION)"; \
133 echo
"Depends: $$(IDEPEND_$(1))"; \
134 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
135 echo
"Category: $(CATEGORY)"; \
136 echo
"Title: $(TITLE)"; \
137 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
150 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
154 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
155 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
156 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
157 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
158 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
159 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
160 mkdir
-p
$$(IDIR_
$(1))/CONTROL
161 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
162 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
165 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
166 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
168 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
170 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
171 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
172 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
173 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
174 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
175 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
176 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
177 (cd
$$(IDIR_
$(1))/CONTROL
; \
181 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
182 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
183 mkdir
-p
$(PACKAGE_DIR
)
184 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
185 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
186 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
187 $(RSTRIP
) $$(IDIR_
$(1))
188 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
190 $$(INFO_
$(1)): $$(IPKG_
$(1))
191 $(IPKG
) install $$(IPKG_
$(1))
194 rm -f
$(PACKAGE_DIR
)/$(1)_
*
198 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
202 ifneq ($(strip $(PKG_SOURCE
)),)
203 $(DL_DIR
)/$(PKG_SOURCE
):
204 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
207 ifneq ($(strip $(PKG_CAT
)),)
208 define Build
/Prepare
/Default
209 @if
[ "$(PKG_CAT)" = "unzip" ]; then \
210 unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
) ; \
212 $(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) - ; \
214 @if
[ -d .
/patches
]; then \
215 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
221 $(call Build
/Prepare
/Default
)
224 define Build
/Configure
/Default
225 @
(cd
$(PKG_BUILD_DIR
)/$(3); \
226 [ -x configure
] && \
228 $(TARGET_CONFIGURE_OPTS
) \
229 CFLAGS
="$(TARGET_CFLAGS)" \
230 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
231 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
233 --target
=$(GNU_TARGET_NAME
) \
234 --host
=$(GNU_TARGET_NAME
) \
235 --build
=$(GNU_HOST_NAME
) \
236 --program-prefix
="" \
237 --program-suffix
="" \
241 --sbindir
=/usr
/sbin \
242 --libexecdir
=/usr
/lib \
244 --datadir=/usr
/share \
245 --localstatedir
=/var \
247 --infodir=/usr
/info \
254 define Build
/Configure
255 $(call Build
/Configure
/Default
,)
258 define Build
/Compile
/Default
259 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
260 $(TARGET_CONFIGURE_OPTS
) \
262 CROSS
="$(TARGET_CROSS)" \
263 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
269 $(call Build
/Compile
/Default
,)
280 source
: $(DL_DIR
)/$(PKG_SOURCE
)
281 prepare
: $(PKG_BUILD_DIR
)/.prepared
282 configure
: $(PKG_BUILD_DIR
)/.configured
285 compile
: compile-targets
288 install: install-targets
292 @
$(MAKE
) clean-targets
294 rm -rf
$(PKG_BUILD_DIR
)