2 # Copyright (C) 2006-2009 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
11 include $(INCLUDE_DIR)/host.mk
12 include $(INCLUDE_DIR)/unpack.mk
13 include $(INCLUDE_DIR)/depends.mk
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
23 include $(INCLUDE_DIR)/download.mk
24 include $(INCLUDE_DIR)/quilt.mk
26 Host/Patch:=$(Host/Patch/Default)
27 ifneq ($(strip $(HOST_UNPACK)),)
28 define Host/Prepare/Default
35 $(call Host/Prepare/Default)
38 HOST_CONFIGURE_VARS = \
39 CPPFLAGS="$(HOST_CFLAGS)" \
40 LDFLAGS="$(HOST_LDFLAGS)" \
43 HOST_CONFIGURE_ARGS = \
44 --target=$(GNU_HOST_NAME) \
45 --host=$(GNU_HOST_NAME) \
46 --build=$(GNU_HOST_NAME) \
49 --prefix=$(STAGING_DIR_HOST) \
50 --exec-prefix=$(STAGING_DIR_HOST) \
51 --sysconfdir=$(STAGING_DIR_HOST)/etc \
52 --localstatedir=$(STAGING_DIR_HOST)/var
54 HOST_CONFIGURE_CMD = ./configure
56 define Host/Configure/Default
57 @(cd $(HOST_BUILD_DIR)/$(3); \
58 if [ -x configure ]; then \
59 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
61 $(HOST_CONFIGURE_CMD) \
62 $(HOST_CONFIGURE_VARS) \
63 $(HOST_CONFIGURE_ARGS) \
70 $(call Host/Configure/Default)
73 define Host/Compile/Default
74 $(MAKE) -C $(HOST_BUILD_DIR) $(1)
78 $(call Host/Compile/Default)
81 define Host/Install/Default
82 $(MAKE) -C $(HOST_BUILD_DIR) install
86 $(call Host/Install/Default)
90 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
91 define HostHost/Autoclean
92 $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
93 $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
97 define Download/default
99 URL:=$(PKG_SOURCE_URL)
100 PROTO:=$(PKG_SOURCE_PROTO)
101 SUBDIR:=$(PKG_SOURCE_SUBDIR)
102 VERSION:=$(PKG_SOURCE_VERSION)
103 MD5SUM:=$(PKG_MD5SUM)
106 define Host/Exports/Default
107 $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*),-I $$(p))
108 $(1) : export STAGING_PREFIX=$$(STAGING_DIR_HOST)
109 $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig
110 $(1) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig
112 Host/Exports=$(Host/Exports/Default)
116 $(if $(HOST_QUILT),$(Host/Quilt))
117 $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
118 $(if $(DUMP),,$(call HostHost/Autoclean))
120 $(HOST_STAMP_PREPARED):
121 @-rm -rf $(HOST_BUILD_DIR)
122 @mkdir -p $(HOST_BUILD_DIR)
126 $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
127 $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
128 $(call Host/Configure)
131 $(call Host/Exports,$(HOST_STAMP_BUILT))
132 $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
136 $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT)
138 mkdir -p $$(shell dirname $$@)
142 host-install: $(HOST_STAMP_INSTALLED)
146 prepare: host-prepare
147 compile: host-compile
148 install: host-install
152 host-compile: $(HOST_STAMP_INSTALLED)
154 host-prepare: $(HOST_STAMP_PREPARED)
155 host-configure: $(HOST_STAMP_CONFIGURED)
156 host-compile: $(HOST_STAMP_BUILT)
160 $(call Host/Uninstall)
161 rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)