7 define Build
/DefaultTargets
9 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
$(TOPDIR
)/package
/rules.mk
),$(PKG_BUILD_DIR
))
10 $(PKG_BUILD_DIR
)/.prepared
: package-clean
13 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
$(IPKG_
$(1)) $(PKG_BUILD_DIR
)),$(IPKG_
$(1)))
14 $(PKG_BUILD_DIR
)/.built
: package-rebuild
18 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
19 @
-rm -rf
$(PKG_BUILD_DIR
)
20 @mkdir
-p
$(PKG_BUILD_DIR
)
24 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
25 $(call Build
/Configure
)
28 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
32 $(PKG_BUILD_DIR
)/.dev-installed
: $(PKG_BUILD_DIR
)/.built
33 $(call Build
/InstallDev
)
36 ifdef Build
/InstallDev
37 compile-targets
: $(PKG_BUILD_DIR
)/.dev-installed
42 $(call Build
/UninstallDev
)
44 package-rebuild
: FORCE
45 @
-rm $(PKG_BUILD_DIR
)/.built
47 define Build
/DefaultTargets
51 define Package
/Default
54 CATEGORY
:=Extra packages
56 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
57 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
58 ifneq ($(PKG_VERSION
),)
59 ifneq ($(PKG_RELEASE
),)
60 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
62 VERSION
:=$(PKG_VERSION
)
65 VERSION
:=$(PKG_RELEASE
)
76 $(eval
$(call Package
/Default
))
77 $(eval
$(call Package
/$(1)))
79 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
81 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
89 ifeq ($(DESCRIPTION
),)
90 $(eval DESCRIPTION
:=$(TITLE
))
93 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
94 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
95 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
97 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
98 install-targets
: $$(INFO_
$(1))
101 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
102 compile-targets
: $$(IPKG_
$(1))
105 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
108 echo
"Package: $(1)";
112 echo
"Menu: $(MENU)";
117 echo
"Default: $(DEFAULT)";
121 echo
"Version: $(VERSION)"; \
122 echo
"Depends: $$(IDEPEND_$(1))"; \
123 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
124 echo
"Category: $(CATEGORY)"; \
125 echo
"Title: $(TITLE)"; \
126 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
139 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
143 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
144 mkdir
-p
$$(IDIR_
$(1))/CONTROL
145 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
146 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
149 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
150 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
152 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
154 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
155 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
156 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
157 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
158 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
159 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
160 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
161 for file in conffiles preinst postinst prerm postrm
; do \
162 [ -f .
/ipkg
/$(1).
$$$$file ] && cp .
/ipkg
/$(1).
$$$$file $$(IDIR_
$(1))/CONTROL
/$$$$file || true
; \
165 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
166 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
167 mkdir
-p
$(PACKAGE_DIR
)
168 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
169 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
170 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
171 $(RSTRIP
) $$(IDIR_
$(1))
172 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
174 $$(INFO_
$(1)): $$(IPKG_
$(1))
175 $(IPKG
) install $$(IPKG_
$(1))
178 rm -f
$(PACKAGE_DIR
)/$(1)_
*
182 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
186 ifneq ($(strip $(PKG_SOURCE
)),)
187 $(DL_DIR
)/$(PKG_SOURCE
):
188 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
191 ifneq ($(strip $(PKG_CAT
)),)
192 define Build
/Prepare
/Default
193 @if
[ "$(PKG_CAT)" = "unzip" ]; then \
194 unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
) ; \
196 $(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) - ; \
198 @if
[ -d .
/patches
]; then \
199 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
205 $(call Build
/Prepare
/Default
)
208 define Build
/Configure
/Default
209 @
(cd
$(PKG_BUILD_DIR
); \
210 [ -x configure
] && \
211 $(TARGET_CONFIGURE_OPTS
) \
212 CFLAGS
="$(TARGET_CFLAGS)" \
213 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
214 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
216 --target
=$(GNU_TARGET_NAME
) \
217 --host
=$(GNU_TARGET_NAME
) \
218 --build
=$(GNU_HOST_NAME
) \
219 --program-prefix
="" \
220 --program-suffix
="" \
224 --sbindir
=/usr
/sbin \
225 --libexecdir
=/usr
/lib \
227 --datadir=/usr
/share \
228 --localstatedir
=/var \
230 --infodir=/usr
/info \
237 define Build
/Configure
238 $(call Build
/Configure
/Default
,)
241 define Build
/Compile
/Default
242 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
243 $(TARGET_CONFIGURE_OPTS
) \
245 CROSS
="$(TARGET_CROSS)" \
246 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
252 $(call Build
/Compile
/Default
,)
267 source
: $(DL_DIR
)/$(PKG_SOURCE
)
268 prepare
: $(PKG_BUILD_DIR
)/.prepared
269 configure
: $(PKG_BUILD_DIR
)/.configured
272 compile
: compile-targets
275 install: install-targets
279 @
$(MAKE
) clean-targets
280 rm -rf
$(PKG_BUILD_DIR
)