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