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