ramips: add support for PCI based OHCI/EHCI support for F5D8235 V1
[lede.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 ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),)
13   HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-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_BUILD_PREFIX:=$(if $(IS_PACKAGE_BUILD),$(STAGING_DIR_HOSTPKG),$(STAGING_DIR_HOST))
34 HOST_STAMP_INSTALLED:=$(HOST_BUILD_PREFIX)/stamp/.$(PKG_NAME)_installed
35
36 override MAKEFLAGS=
37
38 include $(INCLUDE_DIR)/download.mk
39 include $(INCLUDE_DIR)/quilt.mk
40 include $(INCLUDE_DIR)/autotools.mk
41
42 Host/Patch:=$(Host/Patch/Default)
43 ifneq ($(strip $(HOST_UNPACK)),)
44   define Host/Prepare/Default
45         $(HOST_UNPACK)
46         [ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR)
47         $(Host/Patch)
48   endef
49 endif
50
51 define Host/Prepare
52   $(call Host/Prepare/Default)
53 endef
54
55 ifeq ($(HOST_OS),Darwin)
56   HOST_CFLAGS += -I/usr/local/opt/openssl/include
57   HOST_LDFLAGS += -L/usr/local/opt/openssl/lib
58 endif
59
60 HOST_CONFIGURE_VARS = \
61         CC="$(HOSTCC)" \
62         CFLAGS="$(HOST_CFLAGS)" \
63         CPPFLAGS="$(HOST_CPPFLAGS)" \
64         LDFLAGS="$(HOST_LDFLAGS)" \
65         SHELL="$(SHELL)"
66
67 HOST_CONFIGURE_ARGS = \
68         --target=$(GNU_HOST_NAME) \
69         --host=$(GNU_HOST_NAME) \
70         --build=$(GNU_HOST_NAME) \
71         --program-prefix="" \
72         --program-suffix="" \
73         --prefix=$(HOST_BUILD_PREFIX) \
74         --exec-prefix=$(HOST_BUILD_PREFIX) \
75         --sysconfdir=$(HOST_BUILD_PREFIX)/etc \
76         --localstatedir=$(HOST_BUILD_PREFIX)/var \
77         --sbindir=$(HOST_BUILD_PREFIX)/bin
78
79 HOST_MAKE_FLAGS =
80
81 HOST_CONFIGURE_CMD = $(BASH) ./configure
82
83 define Host/Configure/Default
84         $(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \
85                 if [ -x configure ]; then \
86                         $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
87                         $(2) \
88                         $(HOST_CONFIGURE_CMD) \
89                         $(HOST_CONFIGURE_VARS) \
90                         $(HOST_CONFIGURE_ARGS) \
91                         $(1); \
92                 fi \
93         )
94 endef
95
96 define Host/Configure
97   $(call Host/Configure/Default)
98 endef
99
100 define Host/Compile/Default
101         +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
102                 $(HOST_MAKE_FLAGS) \
103                 $(1)
104 endef
105
106 define Host/Compile
107   $(call Host/Compile/Default)
108 endef
109
110 define Host/Install/Default
111         $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install
112 endef
113
114 define Host/Install
115   $(call Host/Install/Default,$(HOST_BUILD_PREFIX))
116 endef
117
118
119 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
120   define HostHost/Autoclean
121     $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
122     $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
123   endef
124 endif
125
126 define Download/default
127   FILE:=$(PKG_SOURCE)
128   URL:=$(PKG_SOURCE_URL)
129   PROTO:=$(PKG_SOURCE_PROTO)
130   SUBDIR:=$(PKG_SOURCE_SUBDIR)
131   VERSION:=$(PKG_SOURCE_VERSION)
132   MD5SUM:=$(PKG_MD5SUM)
133   MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM)
134 endef
135
136 define Host/Exports/Default
137   $(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)/host/share/aclocal-*)),-I $$(p))
138   $(1) : export STAGING_PREFIX=$$(HOST_BUILD_PREFIX)
139   $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig
140   $(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig
141   $(1) : export CCACHE_DIR:=$(STAGING_DIR_HOST)/ccache
142   $(if $(IS_PACKAGE_BUILD),$(1) : export PATH=$$(TARGET_PATH_PKG))
143 endef
144 Host/Exports=$(Host/Exports/Default)
145
146 .NOTPARALLEL:
147
148 ifndef DUMP
149   define HostBuild
150   $(if $(HOST_QUILT),$(Host/Quilt))
151   $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
152   $(if $(DUMP),,$(call HostHost/Autoclean))
153
154   $(HOST_STAMP_PREPARED):
155         @-rm -rf $(HOST_BUILD_DIR)
156         @mkdir -p $(HOST_BUILD_DIR)
157         $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
158         $(call Host/Prepare)
159         $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
160         touch $$@
161
162   $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
163   $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
164         $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
165         $(call Host/Configure)
166         $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
167         touch $$@
168
169   $(call Host/Exports,$(HOST_STAMP_BUILT))
170   $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
171                 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
172                 $(call Host/Compile)
173                 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
174                 touch $$@
175
176   $(call Host/Exports,$(HOST_STAMP_INSTALLED))
177   $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
178                 $(call Host/Install,$(HOST_BUILD_PREFIX))
179                 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
180                 mkdir -p $$(shell dirname $$@)
181                 touch $(HOST_STAMP_BUILT)
182                 touch $$@
183
184   ifndef STAMP_BUILT
185     prepare: host-prepare
186     compile: host-compile
187     install: host-install
188     clean: host-clean
189     update: host-update
190     refresh: host-refresh
191   endif
192
193   host-prepare: $(HOST_STAMP_PREPARED)
194   host-configure: $(HOST_STAMP_CONFIGURED)
195   host-compile: $(HOST_STAMP_BUILT) $(if $(STAMP_BUILT),$(HOST_STAMP_INSTALLED))
196   host-install: $(HOST_STAMP_INSTALLED)
197   host-clean: FORCE
198         $(call Host/Clean)
199         $(call Host/Uninstall)
200         rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
201
202   endef
203
204   download:
205   prepare:
206   compile:
207   install:
208   clean:
209
210 endif