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 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
68 $(eval
$(call Package
/Default
))
69 $(eval
$(call Package
/$(1)))
71 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
73 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
81 ifeq ($(DESCRIPTION
),)
82 $(eval DESCRIPTION
:=$(TITLE
))
85 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
86 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
87 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
89 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
90 install-targets
: $$(INFO_
$(1))
93 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
94 compile-targets
: $$(IPKG_
$(1))
97 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
100 echo
"Package: $(1)";
104 echo
"Menu: $(MENU)";
109 echo
"Default: $(DEFAULT)";
113 echo
"Version: $(VERSION)"; \
114 echo
"Depends: $$(IDEPEND_$(1))"; \
115 echo
"Build-Depends: $(PKG_BUILDDEP)"; \
116 echo
"Category: $(CATEGORY)"; \
117 echo
"Title: $(TITLE)"; \
118 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
131 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
135 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
136 mkdir
-p
$$(IDIR_
$(1))/CONTROL
137 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
138 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
141 for depend in
$$(filter-out @
%,$$(IDEPEND_
$(1))); do \
142 DEPENDS
=$$$${DEPENDS
:+$$$$DEPENDS, }$$$${depend
##+}; \
144 echo
"Depends: $$$$DEPENDS" >> $$(IDIR_
$(1))/CONTROL
/control
; \
146 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
147 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
148 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
149 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
150 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
151 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
152 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
153 for file in conffiles preinst postinst prerm postrm
; do \
154 [ -f .
/ipkg
/$(1).
$$$$file ] && cp .
/ipkg
/$(1).
$$$$file $$(IDIR_
$(1))/CONTROL
/$$$$file || true
; \
157 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
158 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
159 mkdir
-p
$(PACKAGE_DIR
)
160 -find
$$(IDIR_
$(1)) -name CVS | xargs
rm -rf
161 -find
$$(IDIR_
$(1)) -name .svn | xargs
rm -rf
162 -find
$$(IDIR_
$(1)) -name
'.#*' | xargs
rm -f
163 $(RSTRIP
) $$(IDIR_
$(1))
164 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
166 $$(INFO_
$(1)): $$(IPKG_
$(1))
167 $(IPKG
) install $$(IPKG_
$(1))
170 rm -f
$(PACKAGE_DIR
)/$(1)_
*
174 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
178 ifneq ($(strip $(PKG_SOURCE
)),)
179 $(DL_DIR
)/$(PKG_SOURCE
):
180 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
183 ifneq ($(strip $(PKG_CAT
)),)
184 define Build
/Prepare
/Default
185 @if
[ "$(PKG_CAT)" = "unzip" ]; then \
186 unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
) ; \
188 $(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) - ; \
190 @if
[ -d .
/patches
]; then \
191 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
197 $(call Build
/Prepare
/Default
)
200 define Build
/Configure
/Default
201 @
(cd
$(PKG_BUILD_DIR
); \
202 [ -x configure
] && \
203 $(TARGET_CONFIGURE_OPTS
) \
204 CFLAGS
="$(TARGET_CFLAGS)" \
205 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
206 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
208 --target
=$(GNU_TARGET_NAME
) \
209 --host
=$(GNU_TARGET_NAME
) \
210 --build
=$(GNU_HOST_NAME
) \
211 --program-prefix
="" \
212 --program-suffix
="" \
216 --sbindir
=/usr
/sbin \
217 --libexecdir
=/usr
/lib \
219 --datadir=/usr
/share \
220 --localstatedir
=/var \
222 --infodir=/usr
/info \
229 define Build
/Configure
230 $(call Build
/Configure
/Default
,)
233 define Build
/Compile
/Default
234 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
235 $(TARGET_CONFIGURE_OPTS
) \
237 CROSS
="$(TARGET_CROSS)" \
238 EXTRA_CFLAGS
="$(TARGET_CFLAGS) -I$(STAGING_DIR)/include -I$(STAGING_DIR)/usr/include" \
244 $(call Build
/Compile
/Default
,)
259 source
: $(DL_DIR
)/$(PKG_SOURCE
)
260 prepare
: $(PKG_BUILD_DIR
)/.prepared
261 configure
: $(PKG_BUILD_DIR
)/.configured
264 compile
: compile-targets
267 install: install-targets
271 @
$(MAKE
) clean-targets
272 rm -rf
$(PKG_BUILD_DIR
)