e2fsprogs: Update to 1.43.7
[openwrt/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 include $(INCLUDE_DIR)/download.mk
9
10 HOST_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
11 HOST_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install
12 HOST_BUILD_PARALLEL ?=
13
14 HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
15
16 ifeq ($(strip $(HOST_BUILD_PARALLEL)),0)
17 HOST_JOBS?=-j1
18 else
19 HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL),$(HOST_MAKE_J),-j1)
20 endif
21
22 include $(INCLUDE_DIR)/unpack.mk
23 include $(INCLUDE_DIR)/depends.mk
24 include $(INCLUDE_DIR)/quilt.mk
25
26 BUILD_TYPES += host
27 HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),))_$(call confvar,CONFIG_AUTOREMOVE $(HOST_PREPARED_DEPENDS)))
28 HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
29 HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
30 HOST_BUILD_PREFIX?=$(if $(IS_PACKAGE_BUILD),$(STAGING_DIR_HOSTPKG),$(STAGING_DIR_HOST))
31 HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.$(PKG_NAME)_installed
32
33 override MAKEFLAGS=
34
35 include $(INCLUDE_DIR)/autotools.mk
36
37 _host_target:=$(if $(HOST_QUILT),,.)
38
39 Host/Patch:=$(Host/Patch/Default)
40 ifneq ($(strip $(HOST_UNPACK)),)
41 define Host/Prepare/Default
42 $(HOST_UNPACK)
43 [ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR)
44 $(Host/Patch)
45 endef
46 endif
47
48 define Host/Prepare
49 $(call Host/Prepare/Default)
50 endef
51
52 HOST_CONFIGURE_VARS = \
53 CC="$(HOSTCC)" \
54 CFLAGS="$(HOST_CFLAGS)" \
55 CPPFLAGS="$(HOST_CPPFLAGS)" \
56 LDFLAGS="$(HOST_LDFLAGS)" \
57 CONFIG_SHELL="$(SHELL)"
58
59 HOST_CONFIGURE_ARGS = \
60 --target=$(GNU_HOST_NAME) \
61 --host=$(GNU_HOST_NAME) \
62 --build=$(GNU_HOST_NAME) \
63 --program-prefix="" \
64 --program-suffix="" \
65 --prefix=$(HOST_BUILD_PREFIX) \
66 --exec-prefix=$(HOST_BUILD_PREFIX) \
67 --sysconfdir=$(HOST_BUILD_PREFIX)/etc \
68 --localstatedir=$(HOST_BUILD_PREFIX)/var \
69 --sbindir=$(HOST_BUILD_PREFIX)/bin
70
71 HOST_MAKE_VARS = \
72 CFLAGS="$(HOST_CFLAGS)" \
73 CPPFLAGS="$(HOST_CPPFLAGS)" \
74 CXXFLAGS="$(HOST_CXXFLAGS)" \
75 LDFLAGS="$(HOST_LDFLAGS)"
76
77 HOST_MAKE_FLAGS =
78
79 HOST_CONFIGURE_CMD = $(BASH) ./configure
80
81 ifeq ($(HOST_OS),Darwin)
82 HOST_CONFIG_SITE:=$(INCLUDE_DIR)/site/darwin
83 endif
84
85 define Host/Configure/Default
86 $(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \
87 if [ -x configure ]; then \
88 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
89 $(HOST_CONFIGURE_VARS) \
90 $(2) \
91 $(HOST_CONFIGURE_CMD) \
92 $(HOST_CONFIGURE_ARGS) \
93 $(1); \
94 fi \
95 )
96 endef
97
98 define Host/Configure
99 $(call Host/Configure/Default)
100 endef
101
102 define Host/Compile/Default
103 +$(HOST_MAKE_VARS) \
104 $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
105 $(HOST_MAKE_FLAGS) \
106 $(1)
107 endef
108
109 define Host/Compile
110 $(call Host/Compile/Default)
111 endef
112
113 define Host/Install/Default
114 $(call Host/Compile/Default,install)
115 endef
116
117 define Host/Install
118 $(call Host/Install/Default,$(HOST_BUILD_PREFIX))
119 endef
120
121
122 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
123 define HostHost/Autoclean
124 $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
125 $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
126 endef
127 endif
128
129 define Host/Exports/Default
130 $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-* $(if $(IS_PACKAGE_BUILD),$$(STAGING_DIR)/host/share/aclocal $$(STAGING_DIR_HOSTPKG)/share/aclocal $$(STAGING_DIR)/host/share/aclocal-*)),-I $$(p))
131 $(1) : export STAGING_PREFIX=$$(HOST_BUILD_PREFIX)
132 $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig
133 $(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig
134 $(1) : export CCACHE_DIR:=$(STAGING_DIR_HOST)/ccache
135 $(if $(HOST_CONFIG_SITE),$(1) : export CONFIG_SITE:=$(HOST_CONFIG_SITE))
136 $(if $(IS_PACKAGE_BUILD),$(1) : export PATH=$$(TARGET_PATH_PKG))
137 endef
138 Host/Exports=$(Host/Exports/Default)
139
140 .NOTPARALLEL:
141
142 ifndef DUMP
143 define HostBuild/Core
144 $(if $(HOST_QUILT),$(Host/Quilt))
145 $(if $(DUMP),,$(call HostHost/Autoclean))
146
147 $(HOST_STAMP_PREPARED):
148 @-rm -rf $(HOST_BUILD_DIR)
149 @mkdir -p $(HOST_BUILD_DIR)
150 $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
151 $(call Host/Prepare)
152 $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
153 touch $$@
154
155 $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
156 $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
157 $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
158 $(call Host/Configure)
159 $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
160 touch $$@
161
162 $(call Host/Exports,$(HOST_STAMP_BUILT))
163 $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
164 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
165 $(call Host/Compile)
166 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
167 touch $$@
168
169 $(call Host/Exports,$(HOST_STAMP_INSTALLED))
170 $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
171 $(call Host/Install,$(HOST_BUILD_PREFIX))
172 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
173 mkdir -p $$(shell dirname $$@)
174 touch $(HOST_STAMP_BUILT)
175 touch $$@
176
177 $(call DefaultTargets,$(patsubst %,host-%,$(DEFAULT_SUBDIR_TARGETS)))
178 ifndef STAMP_BUILT
179 $(foreach t,$(DEFAULT_SUBDIR_TARGETS),
180 $(t): host-$(t)
181 .$(t): .host-$(t)
182 )
183 clean-build: host-clean-build
184 endif
185
186 $(_host_target)host-prepare: $(HOST_STAMP_PREPARED)
187 $(_host_target)host-configure: $(HOST_STAMP_CONFIGURED)
188 $(_host_target)host-compile: $(HOST_STAMP_BUILT) $(HOST_STAMP_INSTALLED)
189 host-install: host-compile
190
191 host-clean-build: FORCE
192 rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_BUILT)
193
194 host-clean: host-clean-build
195 $(call Host/Clean)
196 $(call Host/Uninstall)
197 rm -rf $(HOST_STAMP_INSTALLED)
198
199 ifneq ($(CONFIG_AUTOREMOVE),)
200 host-compile:
201 $(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' | \
202 $(XARGS) rm -rf
203 endif
204 endef
205 endif
206
207 define HostBuild
208 $(HostBuild/Core)
209 $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
210 endef