7 define Build
/DefaultTargets
9 ifeq ($(shell $(SCRIPT_DIR
)/timestamp.pl
-p
$(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
17 $(PKG_BUILD_DIR
)/.prepared
: $(DL_DIR
)/$(PKG_SOURCE
)
18 @
-rm -rf
$(PKG_BUILD_DIR
)
19 @mkdir
-p
$(PKG_BUILD_DIR
)
23 $(PKG_BUILD_DIR
)/.configured
: $(PKG_BUILD_DIR
)/.prepared
24 $(call Build
/Configure
)
27 $(PKG_BUILD_DIR
)/.built
: $(PKG_BUILD_DIR
)/.configured
34 package-rebuild
: FORCE
35 @
-rm $(PKG_BUILD_DIR
)/.built
37 define Build
/DefaultTargets
41 define Package
/Default
44 CATEGORY
:=Extra packages
46 MAINTAINER
:=OpenWrt Developers Team
<openwrt-devel@openwrt.org
>
47 SOURCE
:=$(patsubst $(TOPDIR
)/%,%,${shell pwd
})
48 VERSION
:=$(PKG_VERSION
)-$(PKG_RELEASE
)
58 $(eval
$(call Package
/Default
))
59 $(eval
$(call Package
/$(1)))
61 $(foreach FIELD
, TITLE CATEGORY PRIORITY VERSION
,
63 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
71 ifeq ($(DESCRIPTION
),)
72 $(eval DESCRIPTION
:=$(TITLE
))
75 IPKG_
$(1):=$(PACKAGE_DIR
)/$(1)_
$(VERSION
)_
$(PKGARCH
).ipk
76 IDIR_
$(1):=$(PKG_BUILD_DIR
)/ipkg
/$(1)
77 INFO_
$(1):=$(IPKG_STATE_DIR
)/info/$(1).list
79 ifeq ($(CONFIG_PACKAGE_
$(1)),y
)
80 install-targets
: $$(INFO_
$(1))
83 ifneq ($(CONFIG_PACKAGE_
$(1))$(DEVELOPER
),)
84 compile-targets
: $$(IPKG_
$(1))
87 IDEPEND_
$(1):=$$(strip $$(DEPENDS
))
99 echo
"Default: $(DEFAULT)";
103 echo
"Version: $(VERSION)"; \
104 echo
"Depends: $$(IDEPEND_$(1))"; \
105 echo
"Category: $(CATEGORY)"; \
106 echo
"Title: $(TITLE)"; \
107 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n,g';
118 $$(IDIR_
$(1))/CONTROL
/control
: $(PKG_BUILD_DIR
)/.prepared
119 mkdir
-p
$$(IDIR_
$(1))/CONTROL
120 echo
"Package: $(1)" > $$(IDIR_
$(1))/CONTROL
/control
121 echo
"Version: $(VERSION)" >> $$(IDIR_
$(1))/CONTROL
/control
122 echo
"Depends: $$(IDEPEND_$(1))" >> $$(IDIR_
$(1))/CONTROL
/control
123 echo
"Source: $(SOURCE)" >> $$(IDIR_
$(1))/CONTROL
/control
124 echo
"Section: $(SECTION)" >> $$(IDIR_
$(1))/CONTROL
/control
125 echo
"Priority: $(PRIORITY)" >> $$(IDIR_
$(1))/CONTROL
/control
126 echo
"Maintainer: $(MAINTAINER)" >> $$(IDIR_
$(1))/CONTROL
/control
127 echo
"Architecture: $(PKGARCH)" >> $$(IDIR_
$(1))/CONTROL
/control
128 echo
"Description: $(DESCRIPTION)" | sed
-e
's,\\,\n ,g' >> $$(IDIR_
$(1))/CONTROL
/control
129 chmod
644 $$(IDIR_
$(1))/CONTROL
/control
130 for file in conffiles preinst postinst prerm postrm
; do \
131 [ -f .
/ipkg
/$(1).
$$$$file ] && cp .
/ipkg
/$(1).
$$$$file $$(IDIR_
$(1))/CONTROL
/$$$$file || true
; \
134 $$(IPKG_
$(1)): $$(IDIR_
$(1))/CONTROL
/control
$(PKG_BUILD_DIR
)/.built
135 $(call Package
/$(1)/install,$$(IDIR_
$(1)))
136 mkdir
-p
$(PACKAGE_DIR
)
137 $(RSTRIP
) $$(IDIR_
$(1))
138 $(IPKG_BUILD
) $$(IDIR_
$(1)) $(PACKAGE_DIR
)
140 $$(INFO_
$(1)): $$(IPKG_
$(1))
141 $(IPKG
) install $$(IPKG_
$(1))
144 rm -f
$(PACKAGE_DIR
)/$(1)_
*
148 ifneq ($(__DEFAULT_TARGETS
),1)
149 $(eval
$(call Build
/DefaultTargets
,$(1)))
154 ifneq ($(strip $(PKG_SOURCE
)),)
155 $(DL_DIR
)/$(PKG_SOURCE
):
156 $(SCRIPT_DIR
)/download.pl
"$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL
)
159 ifneq ($(strip $(PKG_CAT
)),)
160 define Build
/Prepare
/Default
161 @if
[ "$(PKG_CAT)" = "unzip" ]; then \
162 unzip
-d
$(PKG_BUILD_DIR
) $(DL_DIR
)/$(PKG_SOURCE
) ; \
164 $(PKG_CAT
) $(DL_DIR
)/$(PKG_SOURCE
) |
tar -C
$(PKG_BUILD_DIR
)/..
$(TAR_OPTIONS
) - ; \
166 @if
[ -d .
/patches
]; then \
167 $(PATCH
) $(PKG_BUILD_DIR
) .
/patches
; \
173 $(call Build
/Prepare
/Default
)
176 define Build
/Configure
/Default
177 @
(cd
$(PKG_BUILD_DIR
); \
178 [ -x configure
] && \
179 $(TARGET_CONFIGURE_OPTS
) \
180 CFLAGS
="$(TARGET_CFLAGS)" \
182 --target
=$(GNU_TARGET_NAME
) \
183 --host
=$(GNU_TARGET_NAME
) \
184 --build
=$(GNU_HOST_NAME
) \
188 --sbindir
=/usr
/sbin \
189 --libexecdir
=/usr
/lib \
191 --datadir=/usr
/share \
192 --localstatedir
=/var \
194 --infodir=/usr
/info \
200 define Build
/Configure
201 $(call Build
/Configure
/Default
,)
204 define Build
/Compile
/Default
205 $(MAKE
) -C
$(PKG_BUILD_DIR
) \
207 CROSS
="$(TARGET_CROSS)" \
208 PREFIX
="$$(IDIR_$(1))" \
209 EXTRA_CFLAGS
="$(TARGET_CFLAGS)" \
211 DESTDIR
="$$(IDIR_$(1))"
215 $(call Build
/Compile
/Default
)
230 source
: $(DL_DIR
)/$(PKG_SOURCE
)
231 prepare
: $(PKG_BUILD_DIR
)/.prepared
232 configure
: $(PKG_BUILD_DIR
)/.configured
235 compile
: compile-targets
238 install: install-targets
242 @
$(MAKE
) clean-targets
243 rm -rf
$(PKG_BUILD_DIR
)