fix missing variable
[openwrt.git] / package / rules.mk
1 ifneq ($(DUMP),)
2 all: dumpinfo
3 else
4 all: compile
5 endif
6
7 define Build/DefaultTargets
8 ifeq ($(DUMP),)
9 ifeq ($$(shell $(SCRIPT_DIR)/timestamp.pl -p $(PKG_BUILD_DIR) . | tee /tmp/xy1),.)
10 $(PKG_BUILD_DIR)/.prepared: package-clean
11 endif
12
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
15 endif
16 endif
17
18 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
19 @-rm -rf $(PKG_BUILD_DIR)
20 @mkdir -p $(PKG_BUILD_DIR)
21 $(call Build/Prepare)
22 touch $$@
23
24 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
25 $(call Build/Configure)
26 touch $$@
27
28 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
29 $(call Build/Compile)
30 touch $$@
31
32 $(PKG_BUILD_DIR)/.dev-installed: $(PKG_BUILD_DIR)/.built
33 $(call Build/InstallDev)
34 touch $$@
35
36 package-clean: FORCE
37 $(call Build/Clean)
38 $(call Build/UninstallDev)
39
40 package-rebuild: FORCE
41 @-rm $(PKG_BUILD_DIR)/.built
42
43 define Build/DefaultTargets
44 endef
45 endef
46
47 define Package/Default
48 CONFIGFILE:=
49 SECTION:=opt
50 CATEGORY:=Extra packages
51 DEPENDS:=
52 MAINTAINER:=OpenWrt Developers Team <openwrt-devel@openwrt.org>
53 SOURCE:=$(patsubst $(TOPDIR)/%,%,${shell pwd})
54 VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
55 PKGARCH:=$(ARCH)
56 PRIORITY:=optional
57 DEFAULT:=
58 MENU:=
59 TITLE:=
60 DESCRIPTION:=
61 endef
62
63 define BuildPackage
64 $(eval $(call Package/Default))
65 $(eval $(call Package/$(1)))
66
67 $(foreach FIELD, TITLE CATEGORY PRIORITY VERSION,
68 ifeq ($($(FIELD)),)
69 $$(error Package/$(1) is missing the $(FIELD) field)
70 endif
71 )
72
73 ifeq ($(PKGARCH),)
74 PKGARCH:=$(ARCH)
75 endif
76
77 ifeq ($(DESCRIPTION),)
78 $(eval DESCRIPTION:=$(TITLE))
79 endif
80
81 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
82 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
83 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
84
85 ifeq ($(CONFIG_PACKAGE_$(1)),y)
86 install-targets: $$(INFO_$(1))
87 endif
88
89 ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),)
90 compile-targets: $$(IPKG_$(1))
91 endif
92
93 IDEPEND_$(1):=$$(strip $$(DEPENDS))
94
95 DUMPINFO += \
96 echo "Package: $(1)";
97
98 ifneq ($(MENU),)
99 DUMPINFO += \
100 echo "Menu: $(MENU)";
101 endif
102
103 ifneq ($(DEFAULT),)
104 DUMPINFO += \
105 echo "Default: $(DEFAULT)";
106 endif
107
108 DUMPINFO += \
109 echo "Version: $(VERSION)"; \
110 echo "Depends: $$(IDEPEND_$(1))"; \
111 echo "Build-Depends: $(PKG_BUILDDEP)"; \
112 echo "Category: $(CATEGORY)"; \
113 echo "Title: $(TITLE)"; \
114 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n,g';
115
116 ifneq ($(URL),)
117 DUMPINFO += \
118 echo; \
119 echo "$(URL)";
120 endif
121
122 DUMPINFO += \
123 echo "@@";
124
125 ifneq ($(CONFIG),)
126 DUMPINFO += \
127 echo "Config: $(CONFIG)" | sed -e 's,\\,\n,g'; \
128 echo "@@";
129 endif
130
131 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
132 mkdir -p $$(IDIR_$(1))/CONTROL
133 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
134 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
135 ( \
136 DEPENDS=; \
137 for depend in $$(IDEPEND_$(1)); do \
138 [ "$$$${depend%%%%%%%%[A-Za-z]*}" = "@" ] && continue; \
139 DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
140 done; \
141 echo "Depends: $$$$DEPENDS" >> $$(IDIR_$(1))/CONTROL/control; \
142 )
143 echo "Source: $(SOURCE)" >> $$(IDIR_$(1))/CONTROL/control
144 echo "Section: $(SECTION)" >> $$(IDIR_$(1))/CONTROL/control
145 echo "Priority: $(PRIORITY)" >> $$(IDIR_$(1))/CONTROL/control
146 echo "Maintainer: $(MAINTAINER)" >> $$(IDIR_$(1))/CONTROL/control
147 echo "Architecture: $(PKGARCH)" >> $$(IDIR_$(1))/CONTROL/control
148 echo "Description: $(DESCRIPTION)" | sed -e 's,\\,\n ,g' >> $$(IDIR_$(1))/CONTROL/control
149 chmod 644 $$(IDIR_$(1))/CONTROL/control
150 for file in conffiles preinst postinst prerm postrm; do \
151 [ -f ./ipkg/$(1).$$$$file ] && cp ./ipkg/$(1).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
152 done
153
154 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built
155 $(call Package/$(1)/install,$$(IDIR_$(1)))
156 mkdir -p $(PACKAGE_DIR)
157 $(RSTRIP) $$(IDIR_$(1))
158 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
159
160 $$(INFO_$(1)): $$(IPKG_$(1))
161 $(IPKG) install $$(IPKG_$(1))
162
163 $(1)-clean:
164 rm -f $(PACKAGE_DIR)/$(1)_*
165
166 clean: $(1)-clean
167
168 $$(eval $$(call Build/DefaultTargets,$(1)))
169
170 endef
171
172 ifneq ($(strip $(PKG_SOURCE)),)
173 $(DL_DIR)/$(PKG_SOURCE):
174 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
175 endif
176
177 ifneq ($(strip $(PKG_CAT)),)
178 define Build/Prepare/Default
179 @if [ "$(PKG_CAT)" = "unzip" ]; then \
180 unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) ; \
181 else \
182 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) - ; \
183 fi
184 @if [ -d ./patches ]; then \
185 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
186 fi
187 endef
188 endif
189
190 define Build/Prepare
191 $(call Build/Prepare/Default)
192 endef
193
194 define Build/Configure/Default
195 @(cd $(PKG_BUILD_DIR); \
196 [ -x configure ] && \
197 $(TARGET_CONFIGURE_OPTS) \
198 CFLAGS="$(TARGET_CFLAGS)" \
199 CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
200 LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
201 ./configure \
202 --target=$(GNU_TARGET_NAME) \
203 --host=$(GNU_TARGET_NAME) \
204 --build=$(GNU_HOST_NAME) \
205 --program-prefix="" \
206 --program-suffix="" \
207 --prefix=/usr \
208 --exec-prefix=/usr \
209 --bindir=/usr/bin \
210 --sbindir=/usr/sbin \
211 --libexecdir=/usr/lib \
212 --sysconfdir=/etc \
213 --datadir=/usr/share \
214 --localstatedir=/var \
215 --mandir=/usr/man \
216 --infodir=/usr/info \
217 $(DISABLE_NLS) \
218 $(1); \
219 true; \
220 )
221 endef
222
223 define Build/Configure
224 $(call Build/Configure/Default,)
225 endef
226
227 define Build/Compile/Default
228 $(MAKE) -C $(PKG_BUILD_DIR) \
229 CC=$(TARGET_CC) \
230 CROSS="$(TARGET_CROSS)" \
231 PREFIX="$$(IDIR_$(1))" \
232 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
233 ARCH="$(ARCH)" \
234 DESTDIR="$$(IDIR_$(1))" \
235 $(1);
236 endef
237
238 define Build/Compile
239 $(call Build/Compile/Default,)
240 endef
241
242 define Build/InstallDev
243 endef
244
245 define Build/Clean
246 $(MAKE) clean
247 endef
248
249 define Build/UninstallDev
250 endef
251
252 ifneq ($(DUMP),)
253 dumpinfo: FORCE
254 @$(DUMPINFO)
255 else
256
257 $(PACKAGE_DIR):
258 mkdir -p $@
259
260 source: $(DL_DIR)/$(PKG_SOURCE)
261 prepare: $(PKG_BUILD_DIR)/.prepared
262 configure: $(PKG_BUILD_DIR)/.configured
263
264 compile-targets: $(PKG_BUILD_DIR)/.dev-installed
265 compile: compile-targets
266
267 install-targets:
268 install: install-targets
269
270 clean-targets:
271 clean: FORCE
272 @$(MAKE) clean-targets
273 rm -rf $(PKG_BUILD_DIR)
274 endif
This page took 0.072206 seconds and 5 git commands to generate.