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