7 define Build
/DefaultTargets
9 ifeq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) . | tee
/tmp
/xy1
),.
)
10 $(PKG_BUILD_DIR
)/.prepared
: package-clean
13 ifneq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
$(IPKG_
$(1)) $(PKG_BUILD_DIR
) | tee
/tmp
/xy2
),$(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
)
38 $(call Build
/UninstallDev
)
40 package-rebuild
: FORCE
41 @
-rm $(PKG_BUILD_DIR
)/.built
43 define Build
/DefaultTargets
47 define Package
/Default
50 CATEGORY
:=Extra packages
53 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
54 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
55 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
65 $(eval
$(call Package
/Default
))
66 $(eval
$(call Package
/$(1)))
68 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
70 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
78 ifeq ($(DESCRIPTION
),)
79 $(eval DESCRIPTION
:=$(TITLE
))
82 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
83 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
84 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
86 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
87 install-targets
: $$(INFO_
$(1))
90 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
91 compile-targets
: $$(IPKG_
$(1))
94 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
95 INEED_
$(1):=$$(strip $$(NEEDS
))
102 echo
"Menu: $(MENU)";
107 echo
"Default: $(DEFAULT)";
111 echo
"Version: $(VERSION)"; \
112 echo
"Depends: $$(IDEPEND_$(1))"; \
113 echo
"Needs: $$(INEED_$(1))"; \
114 echo
"Category: $(CATEGORY)"; \
115 echo
"Title: $(TITLE)"; \
116 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
129 echo
"Config: $(CONFIG)" | sed
-e
's,\\,\n,g'; \
133 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
134 mkdir
-p
$$(IDIR_
$(1))/CONTROL
135 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
136 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
137 #FIXME: there should be a better way to do it
138 D
="$$(IDEPEND_$(1))"; D
="$$$${D}$$$${D:+, }$$(INEED_$(1))"; echo
"Depends: $$$${D}" >> $$(IDIR_
$(1))/CONTROL
/control
139 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
140 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
141 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
142 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
143 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
144 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
145 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
146 for file in conffiles preinst postinst prerm postrm
; do \
147 [ -f .
/ipkg
/$(1).
$$$$file ] && cp .
/ipkg
/$(1).
$$$$file $$(IDIR_
$(1))/CONTROL
/$$$$file || true
; \
150 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
151 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
152 mkdir
-p
$(PACKAGE_DIR
)
153 $(RSTRIP
) $$(IDIR_
$(1))
154 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
156 $$(INFO_
$(1)): $$(IPKG_
$(1))
157 $(IPKG
) install $$(IPKG_
$(1))
159 compile-targets
: $(PKG_BUILD_DIR
)/.dev-installed
162 rm -f
$(PACKAGE_DIR
)/$(1)_
*
166 $$(eval
$$(call Build
/DefaultTargets
,$(1)))
170 ifneq ($(strip $(PKG_SOURCE
)),)
171 $(DL_DIR
)/$(PKG_SOURCE
):
172 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
175 ifneq ($(strip $(PKG_CAT
)),)
176 define Build
/Prepare
/Default
177 @if
[ "$(PKG_CAT)" = "unzip" ]; then \
178 unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
) ; \
180 $(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) - ; \
182 @if
[ -d .
/patches
]; then \
183 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
189 $(call Build
/Prepare
/Default
)
192 define Build
/Configure
/Default
193 @
(cd
$(PKG_BUILD_DIR
); \
194 [ -x configure
] && \
195 $(TARGET_CONFIGURE_OPTS
) \
196 CFLAGS
="$(TARGET_CFLAGS)" \
197 CPPFLAGS
="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
198 LDFLAGS
="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
200 --target
=$(GNU_TARGET_NAME
) \
201 --host
=$(GNU_TARGET_NAME
) \
202 --build
=$(GNU_HOST_NAME
) \
203 --program-prefix
="" \
204 --program-suffix
="" \
208 --sbindir
=/usr
/sbin \
209 --libexecdir
=/usr
/lib \
211 --datadir=/usr
/share \
212 --localstatedir
=/var \
214 --infodir=/usr
/info \
221 define Build
/Configure
222 $(call Build
/Configure
/Default
,)
225 define Build
/Compile
/Default
226 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
228 CROSS
="$(TARGET_CROSS)" \
229 PREFIX
="$$(IDIR_$(1))" \
230 EXTRA_CFLAGS
="$(TARGET_CFLAGS)" \
232 DESTDIR
="$$(IDIR_$(1))" \
237 $(call Build
/Compile
/Default
,)
240 define Build
/InstallDev
247 define Build
/UninstallDev
258 source
: $(DL_DIR
)/$(PKG_SOURCE
)
259 prepare
: $(PKG_BUILD_DIR
)/.prepared
260 configure
: $(PKG_BUILD_DIR
)/.configured
263 compile
: compile-targets
266 install: install-targets
270 @
$(MAKE
) clean-targets
271 rm -rf
$(PKG_BUILD_DIR
)