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
)
81 $(eval
$(call Package
/Default
))
82 $(eval
$(call Package
/$(1)))
84 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
86 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
94 ifeq ($(DESCRIPTION
),)
95 $(eval DESCRIPTION
:=$(TITLE
))
98 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
99 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
100 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
102 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
103 install-targets
: $$(INFO_
$(1))
106 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
107 compile-targets
: $$(IPKG_
$(1))
110 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
113 echo
"Package: $(1)";
117 echo
"Menu: $(MENU)";
122 echo
"Default: $(DEFAULT)";
126 echo
"Version: $(VERSION)"; \
127 echo
"Depends: $$(IDEPEND_$(1))"; \
128 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
129 echo
"Category: $(CATEGORY)"; \
130 echo
"Title: $(TITLE)"; \
131 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
144 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
148 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
149 mkdir
-p
$$(IDIR_
$(1))/CONTROL
150 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
151 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
154 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
155 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
157 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
159 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
160 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
161 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
162 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
163 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
164 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
165 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
166 for file in conffiles preinst postinst prerm postrm
; do \
167 [ -f .
/ipkg
/$(1).
$$$$file ] && cp .
/ipkg
/$(1).
$$$$file $$(IDIR_
$(1))/CONTROL
/$$$$file || true
; \
170 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
171 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
172 mkdir
-p
$(PACKAGE_DIR
)
173 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
174 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
175 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
176 $(RSTRIP
) $$(IDIR_
$(1))
177 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
179 $$(INFO_
$(1)): $$(IPKG_
$(1))
180 $(IPKG
) install $$(IPKG_
$(1))
183 rm -f
$(PACKAGE_DIR
)/$(1)_
*
187 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
191 ifneq ($(strip $(PKG_SOURCE
)),)
192 $(DL_DIR
)/$(PKG_SOURCE
):
193 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
196 ifneq ($(strip $(PKG_CAT
)),)
197 define Build
/Prepare
/Default
198 @if
[ "$(PKG_CAT)" = "unzip" ]; then \
199 unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
) ; \
201 $(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) - ; \
203 @if
[ -d .
/patches
]; then \
204 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
210 $(call Build
/Prepare
/Default
)
213 define Build
/Configure
/Default
214 @
(cd
$(PKG_BUILD_DIR
)/$(3); \
215 [ -x configure
] && \
217 $(TARGET_CONFIGURE_OPTS
) \
218 CFLAGS
="$(TARGET_CFLAGS)" \
219 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
220 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
222 --target
=$(GNU_TARGET_NAME
) \
223 --host
=$(GNU_TARGET_NAME
) \
224 --build
=$(GNU_HOST_NAME
) \
225 --program-prefix
="" \
226 --program-suffix
="" \
230 --sbindir
=/usr
/sbin \
231 --libexecdir
=/usr
/lib \
233 --datadir=/usr
/share \
234 --localstatedir
=/var \
236 --infodir=/usr
/info \
243 define Build
/Configure
244 $(call Build
/Configure
/Default
,)
247 define Build
/Compile
/Default
248 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
249 $(TARGET_CONFIGURE_OPTS
) \
251 CROSS
="$(TARGET_CROSS)" \
252 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
258 $(call Build
/Compile
/Default
,)
269 source
: $(DL_DIR
)/$(PKG_SOURCE
)
270 prepare
: $(PKG_BUILD_DIR
)/.prepared
271 configure
: $(PKG_BUILD_DIR
)/.configured
274 compile
: compile-targets
277 install: install-targets
281 @
$(MAKE
) clean-targets
283 rm -rf
$(PKG_BUILD_DIR
)