[backfire] target: standardize config file & patches dir names (2.6)
[openwrt/svn-archive/archive.git] / include / host-build.mk
1 #
2 # Copyright (C) 2006-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 HOST_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
9 HOST_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install
10
11 include $(INCLUDE_DIR)/host.mk
12 include $(INCLUDE_DIR)/unpack.mk
13 include $(INCLUDE_DIR)/depends.mk
14
15 BUILD_TYPES += host
16 HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),)))
17 HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
18 HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
19 HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
20
21 override MAKEFLAGS=
22
23 include $(INCLUDE_DIR)/download.mk
24 include $(INCLUDE_DIR)/quilt.mk
25 include $(INCLUDE_DIR)/autotools.mk
26
27 Host/Patch:=$(Host/Patch/Default)
28 ifneq ($(strip $(HOST_UNPACK)),)
29 define Host/Prepare/Default
30 $(HOST_UNPACK)
31 $(Host/Patch)
32 endef
33 endif
34
35 define Host/Prepare
36 $(call Host/Prepare/Default)
37 endef
38
39 HOST_CONFIGURE_VARS = \
40 CFLAGS="$(HOST_CFLAGS)" \
41 CPPFLAGS="$(HOST_CFLAGS)" \
42 LDFLAGS="$(HOST_LDFLAGS)" \
43 SHELL="$(BASH)"
44
45 HOST_CONFIGURE_ARGS = \
46 --target=$(GNU_HOST_NAME) \
47 --host=$(GNU_HOST_NAME) \
48 --build=$(GNU_HOST_NAME) \
49 --program-prefix="" \
50 --program-suffix="" \
51 --prefix=$(STAGING_DIR_HOST) \
52 --exec-prefix=$(STAGING_DIR_HOST) \
53 --sysconfdir=$(STAGING_DIR_HOST)/etc \
54 --localstatedir=$(STAGING_DIR_HOST)/var
55
56 HOST_CONFIGURE_CMD = ./configure
57
58 define Host/Configure/Default
59 (cd $(HOST_BUILD_DIR)/$(3); \
60 if [ -x configure ]; then \
61 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
62 $(2) \
63 $(HOST_CONFIGURE_CMD) \
64 $(HOST_CONFIGURE_VARS) \
65 $(HOST_CONFIGURE_ARGS) \
66 $(1); \
67 fi \
68 )
69 endef
70
71 define Host/Configure
72 $(call Host/Configure/Default)
73 endef
74
75 define Host/Compile/Default
76 $(MAKE) -C $(HOST_BUILD_DIR) $(1)
77 endef
78
79 define Host/Compile
80 $(call Host/Compile/Default)
81 endef
82
83 define Host/Install/Default
84 $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install
85 endef
86
87 define Host/Install
88 $(call Host/Install/Default)
89 endef
90
91
92 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
93 define HostHost/Autoclean
94 $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
95 $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
96 endef
97 endif
98
99 define Download/default
100 FILE:=$(PKG_SOURCE)
101 URL:=$(PKG_SOURCE_URL)
102 PROTO:=$(PKG_SOURCE_PROTO)
103 SUBDIR:=$(PKG_SOURCE_SUBDIR)
104 VERSION:=$(PKG_SOURCE_VERSION)
105 MD5SUM:=$(PKG_MD5SUM)
106 endef
107
108 define Host/Exports/Default
109 $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*),-I $$(p))
110 $(1) : export STAGING_PREFIX=$$(STAGING_DIR_HOST)
111 $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig
112 $(1) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig
113 endef
114 Host/Exports=$(Host/Exports/Default)
115
116 ifndef DUMP
117 define HostBuild
118 $(if $(HOST_QUILT),$(Host/Quilt))
119 $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
120 $(if $(DUMP),,$(call HostHost/Autoclean))
121
122 $(HOST_STAMP_PREPARED):
123 @-rm -rf $(HOST_BUILD_DIR)
124 @mkdir -p $(HOST_BUILD_DIR)
125 $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
126 $(call Host/Prepare)
127 $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
128 touch $$@
129
130 $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
131 $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
132 $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
133 $(call Host/Configure)
134 $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
135 touch $$@
136
137 $(call Host/Exports,$(HOST_STAMP_BUILT))
138 ifdef Host/Install
139 host-install: $(if $(STAMP_BUILT),$(HOST_STAMP_BUILT),$(HOST_STAMP_INSTALLED))
140 endif
141
142 ifndef STAMP_BUILT
143 prepare: host-prepare
144 compile: host-compile
145 install: host-install
146 clean: host-clean
147 update: host-update
148
149 $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
150 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
151 $(call Host/Compile)
152 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
153 touch $$@
154
155 $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT)
156 $(call Host/Install)
157 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
158 mkdir -p $$(shell dirname $$@)
159 touch $$@
160 else
161 $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
162 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
163 $(call Host/Compile)
164 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
165 $(call Host/Install)
166 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
167 touch $$@
168 endif
169 host-prepare: $(HOST_STAMP_PREPARED)
170 host-configure: $(HOST_STAMP_CONFIGURED)
171 host-compile: $(HOST_STAMP_BUILT)
172 host-install:
173 host-clean: FORCE
174 $(call Host/Clean)
175 $(call Host/Uninstall)
176 rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
177
178 endef
179
180 download:
181 prepare:
182 compile:
183 install:
184 clean:
185
186 endif
187