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