2 # Copyright (C) 2006-2010 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
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 ?=
12 ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),)
13 HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) -j)
15 HOST_MAKE_J:=-j$(CONFIG_PKG_BUILD_JOBS)
18 ifeq ($(strip $(HOST_BUILD_PARALLEL)),0)
21 HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL)$(CONFIG_PKG_DEFAULT_PARALLEL),\
22 $(if $(CONFIG_PKG_BUILD_PARALLEL),$(HOST_MAKE_J),-j1),-j1)
25 include $(INCLUDE_DIR)/host.mk
26 include $(INCLUDE_DIR)/unpack.mk
27 include $(INCLUDE_DIR)/depends.mk
30 HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),)))
31 HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
32 HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
33 HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
37 include $(INCLUDE_DIR)/download.mk
38 include $(INCLUDE_DIR)/quilt.mk
39 include $(INCLUDE_DIR)/autotools.mk
41 Host/Patch:=$(Host/Patch/Default)
42 ifneq ($(strip $(HOST_UNPACK)),)
43 define Host/Prepare/Default
50 $(call Host/Prepare/Default)
53 ifeq ($(HOST_OS),Darwin)
54 HOST_CFLAGS += -I/usr/local/opt/openssl/include
55 HOST_LDFLAGS += -L/usr/local/opt/openssl/lib
58 HOST_CONFIGURE_VARS = \
60 CFLAGS="$(HOST_CFLAGS)" \
61 CPPFLAGS="$(HOST_CPPFLAGS)" \
62 LDFLAGS="$(HOST_LDFLAGS)" \
65 HOST_CONFIGURE_ARGS = \
66 --target=$(GNU_HOST_NAME) \
67 --host=$(GNU_HOST_NAME) \
68 --build=$(GNU_HOST_NAME) \
71 --prefix=$(STAGING_DIR_HOST) \
72 --exec-prefix=$(STAGING_DIR_HOST) \
73 --sysconfdir=$(STAGING_DIR_HOST)/etc \
74 --localstatedir=$(STAGING_DIR_HOST)/var \
75 --sbindir=$(STAGING_DIR_HOST)/bin
79 HOST_CONFIGURE_CMD = $(BASH) ./configure
81 define Host/Configure/Default
82 $(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \
83 if [ -x configure ]; then \
84 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
86 $(HOST_CONFIGURE_CMD) \
87 $(HOST_CONFIGURE_VARS) \
88 $(HOST_CONFIGURE_ARGS) \
95 $(call Host/Configure/Default)
98 define Host/Compile/Default
99 +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
105 $(call Host/Compile/Default)
108 define Host/Install/Default
109 $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install
113 $(call Host/Install/Default)
117 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
118 define HostHost/Autoclean
119 $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
120 $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
124 define Download/default
126 URL:=$(PKG_SOURCE_URL)
127 PROTO:=$(PKG_SOURCE_PROTO)
128 SUBDIR:=$(PKG_SOURCE_SUBDIR)
129 VERSION:=$(PKG_SOURCE_VERSION)
130 MD5SUM:=$(PKG_MD5SUM)
131 MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM)
134 define Host/Exports/Default
135 $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*),-I $$(p))
136 $(1) : export STAGING_PREFIX=$$(STAGING_DIR_HOST)
137 $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig
138 $(1) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig
139 $(1) : export CCACHE_DIR:=$(STAGING_DIR_HOST)/ccache
141 Host/Exports=$(Host/Exports/Default)
147 $(if $(HOST_QUILT),$(Host/Quilt))
148 $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
149 $(if $(DUMP),,$(call HostHost/Autoclean))
151 $(HOST_STAMP_PREPARED):
152 @-rm -rf $(HOST_BUILD_DIR)
153 @mkdir -p $(HOST_BUILD_DIR)
154 $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
156 $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
159 $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
160 $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
161 $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
162 $(call Host/Configure)
163 $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
166 $(call Host/Exports,$(HOST_STAMP_BUILT))
167 $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
168 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
170 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
173 $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
175 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
176 mkdir -p $$(shell dirname $$@)
177 touch $(HOST_STAMP_BUILT)
181 prepare: host-prepare
182 compile: host-compile
183 install: host-install
186 refresh: host-refresh
189 host-prepare: $(HOST_STAMP_PREPARED)
190 host-configure: $(HOST_STAMP_CONFIGURED)
191 host-compile: $(HOST_STAMP_BUILT) $(if $(STAMP_BUILT),$(HOST_STAMP_INSTALLED))
192 host-install: $(HOST_STAMP_INSTALLED)
195 $(call Host/Uninstall)
196 rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)