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
23 $(PKG_BUILD_DIR
)/.prepared
:
24 @
-rm -rf
$(PKG_BUILD_DIR
)
25 @mkdir
-p
$(PKG_BUILD_DIR
)
29 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
30 $(call Build
/Configure
)
33 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
37 $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
: $(PKG_BUILD_DIR
)/.built
38 $(call Build
/InstallDev
)
41 ifdef Build
/InstallDev
42 compile-targets
: $(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
47 $(call Build
/UninstallDev
)
48 rm -f
$(STAGING_DIR
)/stampfiles
/.
$(PKG_NAME
)-installed
50 package-rebuild
: FORCE
51 @
-rm -f
$(PKG_BUILD_DIR
)/.built
53 define Build
/DefaultTargets
57 define Package
/Default
60 CATEGORY
:=Extra packages
62 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
63 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
64 ifneq ($(PKG_VERSION
),)
65 ifneq ($(PKG_RELEASE
),)
66 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
68 VERSION
:=$(PKG_VERSION
)
71 VERSION
:=$(PKG_RELEASE
)
81 define BuildIPKGVariable
82 pkg_
$(subst .
,_
,$(subst -,_
,$(1)))_
$(2) = $$(Package
/$(1)/$(2))
83 export pkg_
$(subst .
,_
,$(subst -,_
,$(1))_
$(2))
84 $(1)_COMMANDS
+= if
[ -n
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" ]; then echo
"$$$$$$$$pkg_$(subst .,_,$(subst -,_,$(1)))_$(2)" > $(2); fi
;
88 $(eval
$(call Package
/Default
))
89 $(eval
$(call Package
/$(1)))
91 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
93 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
101 ifeq ($(DESCRIPTION
),)
102 $(eval DESCRIPTION
:=$(TITLE
))
105 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
106 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
107 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
109 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
110 install-targets
: $$(INFO_
$(1))
113 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
114 compile-targets
: $$(IPKG_
$(1))
117 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
120 echo
"Package: $(1)";
124 echo
"Menu: $(MENU)";
129 echo
"Default: $(DEFAULT)";
133 echo
"Version: $(VERSION)"; \
134 echo
"Depends: $$(IDEPEND_$(1))"; \
135 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
136 echo
"Category: $(CATEGORY)"; \
137 echo
"Title: $(TITLE)"; \
138 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
151 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
155 $(eval
$(call BuildIPKGVariable
,$(1),conffiles
))
156 $(eval
$(call BuildIPKGVariable
,$(1),preinst
))
157 $(eval
$(call BuildIPKGVariable
,$(1),postinst
))
158 $(eval
$(call BuildIPKGVariable
,$(1),prerm
))
159 $(eval
$(call BuildIPKGVariable
,$(1),postrm
))
160 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
161 mkdir
-p
$$(IDIR_
$(1))/CONTROL
162 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
163 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
166 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
167 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
169 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
171 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
172 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
173 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
174 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
175 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
176 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
177 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
178 (cd
$$(IDIR_
$(1))/CONTROL
; \
182 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
183 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
184 mkdir
-p
$(PACKAGE_DIR
)
185 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
186 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
187 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
188 $(RSTRIP
) $$(IDIR_
$(1))
189 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
191 $$(INFO_
$(1)): $$(IPKG_
$(1))
192 $(IPKG
) install $$(IPKG_
$(1))
195 rm -f
$(PACKAGE_DIR
)/$(1)_
*
199 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
203 ifneq ($(strip $(PKG_CAT
)),)
204 ifeq ($(PKG_CAT
),unzip
)
205 UNPACK
=unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
)
207 UNPACK
=$(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) -
209 define Build
/Prepare
/Default
211 @if
[ -d .
/patches
]; then \
212 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
218 $(call Build
/Prepare
/Default
)
221 define Build
/Configure
/Default
222 @
(cd
$(PKG_BUILD_DIR
)/$(3); \
223 [ -x configure
] && \
225 $(TARGET_CONFIGURE_OPTS
) \
226 CFLAGS
="$(TARGET_CFLAGS)" \
227 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
228 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
230 --target
=$(GNU_TARGET_NAME
) \
231 --host
=$(GNU_TARGET_NAME
) \
232 --build
=$(GNU_HOST_NAME
) \
233 --program-prefix
="" \
234 --program-suffix
="" \
238 --sbindir
=/usr
/sbin \
239 --libexecdir
=/usr
/lib \
241 --datadir=/usr
/share \
242 --localstatedir
=/var \
244 --infodir=/usr
/info \
251 define Build
/Configure
252 $(call Build
/Configure
/Default
,)
255 define Build
/Compile
/Default
256 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
257 $(TARGET_CONFIGURE_OPTS
) \
259 CROSS
="$(TARGET_CROSS)" \
260 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
266 $(call Build
/Compile
/Default
,)
276 ifneq ($(strip $(PKG_SOURCE
)),)
277 source
: $(DL_DIR
)/$(PKG_SOURCE
)
279 $(DL_DIR
)/$(PKG_SOURCE
):
281 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
283 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
287 prepare
: $(PKG_BUILD_DIR
)/.prepared
288 configure
: $(PKG_BUILD_DIR
)/.configured
291 compile
: compile-targets
294 install: install-targets
298 @
$(MAKE
) clean-targets
300 rm -rf
$(PKG_BUILD_DIR
)