7 define Build
/DefaultTargets
8 $(PKG_BUILD_DIR
)/.prepared
:
9 rm -rf
$(PKG_BUILD_DIR
)
10 mkdir
-p
$(PKG_BUILD_DIR
)
14 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
15 $(call Build
/Configure
)
18 ifeq ($(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(PKG_BUILD_DIR
) .
),.
)
19 $(PKG_BUILD_DIR
)/.prepared
: clean
22 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
28 rm -f
$(PKG_BUILD_DIR
)/.built
31 rm -f
$(PKG_BUILD_DIR
)/.built
33 .PHONY
: package-clean package-recompile
35 define Build
/DefaultTargets
39 define Package
/Default
42 CATEGORY
:=Extra packages
44 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
45 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
46 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
54 $(eval
$(call Package
/Default
))
55 $(eval
$(call Package
/$(1)))
58 $$(error Package
$(1) has no TITLE
)
61 $$(error Package
$(1) has no CATEGORY
)
64 $$(error Package
$(1) has no PRIORITY
)
67 $$(error Package
$(1) has no VERSION
)
73 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
74 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
75 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
77 ifneq ($(PACKAGE_
$(1)),)
83 ifeq ($(PACKAGE_
$(1)),y
)
84 install-targets
: $$(INFO_
$(1))
87 ifneq ($$(COMPILE_
$(1)),)
88 ifeq ($$(shell $(SCRIPT_DIR
)/timestamp.pl
-p
-x ipkg
$$(IPKG_
$(1)) $(PKG_BUILD_DIR
)),$(PKG_BUILD_DIR
))
89 $(PKG_BUILD_DIR
)/.built
: package-recompile
92 compile-targets
: $$(IPKG_
$(1))
96 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
99 echo
"Package: $(1)"; \
100 echo
"Version: $(VERSION)"; \
101 echo
"Depends: $(IDEPEND_$(1))"; \
102 echo
"Title: $(TITLE)"; \
103 echo
"$(DESCRIPTION)" | sed
-e
's,\\,\n,g'; \
109 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
110 mkdir
-p
$$(IDIR_
$(1))/CONTROL
111 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
112 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
113 echo
"Depends: $(IDEPEND_$(1))" >> $$(IDIR_
$(1))/CONTROL
/control
114 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
115 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
116 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
117 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
118 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
119 echo
"Description: $(TITLE)" >> $$(IDIR_
$(1))/CONTROL
/control
120 echo
" $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
121 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
122 for file in conffiles preinst postinst prerm postrm
; do \
123 [ -f .
/ipkg
/$(1).
$$$$file ] && cp .
/ipkg
/$(1).
$$$$file $$(IDIR_
$(1))/CONTROL
/$$$$file || true
; \
126 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
127 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
128 mkdir
-p
$(PACKAGE_DIR
)
129 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
131 $$(INFO_
$(1)): $$(IPKG_
$(1))
132 $(IPKG
) install $$(IPKG_
$(1))
135 rm -f
$(PACKAGE_DIR
)/$(1)_
*
138 ifneq ($(__DEFAULT_TARGETS
),1)
139 $(eval
$(call Build
/DefaultTargets
))
144 ifneq ($(strip $(PKG_SOURCE
)),)
145 $(DL_DIR
)/$(PKG_SOURCE
):
146 @
$(CMD_TRACE
) "downloading... "
147 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
) $(MAKE_TRACE
)
149 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
152 ifneq ($(strip $(PKG_CAT
)),)
153 define Build
/Prepare
/Default
154 if
[ "$(PKG_CAT)" = "unzip" ]; then \
155 unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
) ; \
157 $(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) - ; \
159 if
[ -d .
/patches
]; then \
160 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
166 $(call Build
/Prepare
/Default
)
169 define Build
/Configure
/Default
170 # TODO: add configurable default command
173 define Build
/Configure
174 $(call Build
/Configure
/Default
)
177 define Build
/Compile
/Default
178 # TODO: add configurable default command
182 $(call Build
/Compile
/Default
)
194 source
: $(DL_DIR
)/$(PKG_SOURCE
)
196 @
[ -f
$(PKG_BUILD_DIR
)/.prepared
] ||
{ \
197 $(CMD_TRACE
) "preparing... "; \
198 $(MAKE
) $(PKG_BUILD_DIR
)/.prepared
$(MAKE_TRACE
); \
202 @
[ -f
$(PKG_BUILD_DIR
)/.configured
] ||
{ \
203 $(CMD_TRACE
) "configuring... "; \
204 $(MAKE
) $(PKG_BUILD_DIR
)/.configured
$(MAKE_TRACE
); \
209 @
$(CMD_TRACE
) "compiling... "
210 @
$(MAKE
) compile-targets
$(MAKE_TRACE
)
214 @
$(CMD_TRACE
) "installing... "
215 @
$(MAKE
) install-targets
$(MAKE_TRACE
)
218 $(CMD_TRACE
) "rebuilding... "
219 $(MAKE
) package-clean compile
$(MAKE_TRACE
)
226 @
$(CMD_TRACE
) "cleaning... "
227 @
$(MAKE
) clean-targets
$(MAKE_TRACE
)
228 rm -rf
$(PKG_BUILD_DIR
)
231 .PHONY
: all source prepare compile
install clean rebuild dumpinfo compile-targets install-targets clean-targets