add BOARD and KERNEL to tgz image file name
[openwrt/openwrt.git] / openwrt / include / host-build.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 ($(strip $(PKG_CAT)),)
8 ifeq ($(PKG_CAT),unzip)
9 UNPACK=unzip -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
10 else
11 UNPACK=$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
12 endif
13 define Build/Prepare/Default
14 $(UNPACK)
15 @if [ -d ./patches ]; then \
16 $(PATCH) $(PKG_BUILD_DIR) ./patches; \
17 fi
18 endef
19 endif
20
21 define Build/Prepare
22 $(call Build/Prepare/Default)
23 endef
24
25 define Build/Configure/Default
26 @(cd $(PKG_BUILD_DIR)/$(3); \
27 [ -x configure ] && \
28 $(2) \
29 CPPFLAGS="-I$(STAGING_DIR)/host/include" \
30 LDFLAGS="-L$(STAGING_DIR)/host/lib" \
31 ./configure \
32 --target=$(GNU_TARGET_NAME) \
33 --host=$(GNU_TARGET_NAME) \
34 --build=$(GNU_HOST_NAME) \
35 --program-prefix="" \
36 --program-suffix="" \
37 --prefix=/usr \
38 --exec-prefix=/usr \
39 --bindir=/usr/bin \
40 --sbindir=/usr/sbin \
41 --libexecdir=/usr/lib \
42 --sysconfdir=/etc \
43 --datadir=/usr/share \
44 --localstatedir=/var \
45 --mandir=/usr/man \
46 --infodir=/usr/info \
47 $(DISABLE_NLS) \
48 $(1); \
49 true; \
50 )
51 endef
52
53 define Build/Configure
54 $(call Build/Configure/Default)
55 endef
56
57 define Build/Compile/Default
58 $(MAKE) -C $(PKG_BUILD_DIR) $(1)
59 endef
60
61 define Build/Compile
62 $(call Build/Compile/Default)
63 endef
64
65
66 ifneq ($(strip $(PKG_SOURCE)),)
67 download: $(DL_DIR)/$(PKG_SOURCE)
68
69 $(DL_DIR)/$(PKG_SOURCE):
70 mkdir -p $(DL_DIR)
71 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
72
73 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
74 endif
75
76 define HostBuild
77 $(PKG_BUILD_DIR)/.prepared:
78 @-rm -rf $(PKG_BUILD_DIR)
79 @mkdir -p $(PKG_BUILD_DIR)
80 $(call Build/Prepare)
81 touch $$@
82
83 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
84 $(call Build/Configure)
85 touch $$@
86
87 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
88 $(call Build/Compile)
89 touch $$@
90
91 $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed: $(PKG_BUILD_DIR)/.built
92 $(call Build/Install)
93 touch $$@
94
95 ifdef Build/Install
96 install-targets: $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
97 endif
98
99 package-clean: FORCE
100 $(call Build/Clean)
101 $(call Build/Uninstall)
102 rm -f $(STAGING_DIR)/stampfiles/.host_$(PKG_NAME)-installed
103
104 download:
105 prepare: $(PKG_BUILD_DIR)/.prepared
106 configure: $(PKG_BUILD_DIR)/.configured
107
108 compile-targets: $(PKG_BUILD_DIR)/.built
109 compile: compile-targets
110
111 install-targets:
112 install: install-targets
113
114 clean-targets:
115 clean: FORCE
116 @$(MAKE) clean-targets
117 $(call Build/Clean)
118 rm -rf $(PKG_BUILD_DIR)
119
120 endef