| 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 | ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),) |
| 13 | HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) -j) |
| 14 | else |
| 15 | HOST_MAKE_J:=-j$(CONFIG_PKG_BUILD_JOBS) |
| 16 | endif |
| 17 | |
| 18 | ifeq ($(strip $(HOST_BUILD_PARALLEL)),0) |
| 19 | HOST_JOBS?=-j1 |
| 20 | else |
| 21 | HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL)$(CONFIG_PKG_DEFAULT_PARALLEL),\ |
| 22 | $(if $(CONFIG_PKG_BUILD_PARALLEL),$(HOST_MAKE_J),-j1),-j1) |
| 23 | endif |
| 24 | |
| 25 | include $(INCLUDE_DIR)/host.mk |
| 26 | include $(INCLUDE_DIR)/unpack.mk |
| 27 | include $(INCLUDE_DIR)/depends.mk |
| 28 | |
| 29 | BUILD_TYPES += host |
| 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 |
| 34 | |
| 35 | override MAKEFLAGS= |
| 36 | |
| 37 | include $(INCLUDE_DIR)/download.mk |
| 38 | include $(INCLUDE_DIR)/quilt.mk |
| 39 | include $(INCLUDE_DIR)/autotools.mk |
| 40 | |
| 41 | Host/Patch:=$(Host/Patch/Default) |
| 42 | ifneq ($(strip $(HOST_UNPACK)),) |
| 43 | define Host/Prepare/Default |
| 44 | $(HOST_UNPACK) |
| 45 | $(Host/Patch) |
| 46 | endef |
| 47 | endif |
| 48 | |
| 49 | define Host/Prepare |
| 50 | $(call Host/Prepare/Default) |
| 51 | endef |
| 52 | |
| 53 | HOST_CONFIGURE_VARS = \ |
| 54 | CC="$(HOSTCC)" \ |
| 55 | CFLAGS="$(HOST_CFLAGS)" \ |
| 56 | CPPFLAGS="$(HOST_CPPFLAGS)" \ |
| 57 | LDFLAGS="$(HOST_LDFLAGS)" \ |
| 58 | SHELL="$(BASH)" |
| 59 | |
| 60 | HOST_CONFIGURE_ARGS = \ |
| 61 | --target=$(GNU_HOST_NAME) \ |
| 62 | --host=$(GNU_HOST_NAME) \ |
| 63 | --build=$(GNU_HOST_NAME) \ |
| 64 | --program-prefix="" \ |
| 65 | --program-suffix="" \ |
| 66 | --prefix=$(STAGING_DIR_HOST) \ |
| 67 | --exec-prefix=$(STAGING_DIR_HOST) \ |
| 68 | --sysconfdir=$(STAGING_DIR_HOST)/etc \ |
| 69 | --localstatedir=$(STAGING_DIR_HOST)/var \ |
| 70 | --sbindir=$(STAGING_DIR_HOST)/bin |
| 71 | |
| 72 | HOST_MAKE_FLAGS = |
| 73 | |
| 74 | HOST_CONFIGURE_CMD = ./configure |
| 75 | |
| 76 | ifneq ($(HOST_OS),Darwin) |
| 77 | ifeq ($(CONFIG_BUILD_STATIC_TOOLS),y) |
| 78 | HOST_STATIC_LINKING = -static |
| 79 | endif |
| 80 | endif |
| 81 | |
| 82 | define Host/Configure/Default |
| 83 | $(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \ |
| 84 | if [ -x configure ]; then \ |
| 85 | $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \ |
| 86 | $(2) \ |
| 87 | $(HOST_CONFIGURE_CMD) \ |
| 88 | $(HOST_CONFIGURE_VARS) \ |
| 89 | $(HOST_CONFIGURE_ARGS) \ |
| 90 | $(1); \ |
| 91 | fi \ |
| 92 | ) |
| 93 | endef |
| 94 | |
| 95 | define Host/Configure |
| 96 | $(call Host/Configure/Default) |
| 97 | endef |
| 98 | |
| 99 | define Host/Compile/Default |
| 100 | +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \ |
| 101 | $(HOST_MAKE_FLAGS) \ |
| 102 | $(1) |
| 103 | endef |
| 104 | |
| 105 | define Host/Compile |
| 106 | $(call Host/Compile/Default) |
| 107 | endef |
| 108 | |
| 109 | define Host/Install/Default |
| 110 | $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install |
| 111 | endef |
| 112 | |
| 113 | define Host/Install |
| 114 | $(call Host/Install/Default) |
| 115 | endef |
| 116 | |
| 117 | |
| 118 | ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),) |
| 119 | define HostHost/Autoclean |
| 120 | $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED)) |
| 121 | $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT))) |
| 122 | endef |
| 123 | endif |
| 124 | |
| 125 | define Download/default |
| 126 | FILE:=$(PKG_SOURCE) |
| 127 | URL:=$(PKG_SOURCE_URL) |
| 128 | PROTO:=$(PKG_SOURCE_PROTO) |
| 129 | SUBDIR:=$(PKG_SOURCE_SUBDIR) |
| 130 | VERSION:=$(PKG_SOURCE_VERSION) |
| 131 | MD5SUM:=$(PKG_MD5SUM) |
| 132 | MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM) |
| 133 | endef |
| 134 | |
| 135 | define Host/Exports/Default |
| 136 | $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*),-I $$(p)) |
| 137 | $(1) : export STAGING_PREFIX=$$(STAGING_DIR_HOST) |
| 138 | $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig |
| 139 | $(1) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig |
| 140 | endef |
| 141 | Host/Exports=$(Host/Exports/Default) |
| 142 | |
| 143 | .NOTPARALLEL: |
| 144 | |
| 145 | ifndef DUMP |
| 146 | define HostBuild |
| 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)) |
| 150 | |
| 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)) |
| 155 | $(call Host/Prepare) |
| 156 | $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep)) |
| 157 | touch $$@ |
| 158 | |
| 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)) |
| 164 | touch $$@ |
| 165 | |
| 166 | $(call Host/Exports,$(HOST_STAMP_BUILT)) |
| 167 | ifdef Host/Install |
| 168 | host-install: $(if $(STAMP_BUILT),$(HOST_STAMP_BUILT),$(HOST_STAMP_INSTALLED)) |
| 169 | endif |
| 170 | |
| 171 | ifndef STAMP_BUILT |
| 172 | prepare: host-prepare |
| 173 | compile: host-compile |
| 174 | install: host-install |
| 175 | clean: host-clean |
| 176 | update: host-update |
| 177 | refresh: host-refresh |
| 178 | |
| 179 | $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED) |
| 180 | $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep)) |
| 181 | $(call Host/Compile) |
| 182 | $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep)) |
| 183 | touch $$@ |
| 184 | |
| 185 | $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE) |
| 186 | $(call Host/Install) |
| 187 | $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep)) |
| 188 | mkdir -p $$(shell dirname $$@) |
| 189 | touch $$@ |
| 190 | else |
| 191 | $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED) $(if $(FORCE_HOST_INSTALL),FORCE) |
| 192 | $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep)) |
| 193 | $(call Host/Compile) |
| 194 | $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep)) |
| 195 | $(call Host/Install) |
| 196 | $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep)) |
| 197 | touch $$@ |
| 198 | endif |
| 199 | host-prepare: $(HOST_STAMP_PREPARED) |
| 200 | host-configure: $(HOST_STAMP_CONFIGURED) |
| 201 | host-compile: $(HOST_STAMP_BUILT) |
| 202 | host-install: |
| 203 | host-clean: FORCE |
| 204 | $(call Host/Clean) |
| 205 | $(call Host/Uninstall) |
| 206 | rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT) |
| 207 | |
| 208 | endef |
| 209 | |
| 210 | download: |
| 211 | prepare: |
| 212 | compile: |
| 213 | install: |
| 214 | clean: |
| 215 | |
| 216 | endif |
| 217 | |