CC: ar71xx: fix syntax error in /etc/uci-defaults/01_leds
[15.05/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 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 ifeq ($(HOST_OS),Darwin)
54   HOST_CFLAGS += -I/usr/local/opt/openssl/include
55   HOST_LDFLAGS += -L/usr/local/opt/openssl/lib
56 endif
57
58 HOST_CONFIGURE_VARS = \
59         CC="$(HOSTCC)" \
60         CFLAGS="$(HOST_CFLAGS)" \
61         CPPFLAGS="$(HOST_CPPFLAGS)" \
62         LDFLAGS="$(HOST_LDFLAGS)" \
63         SHELL="$(SHELL)"
64
65 HOST_CONFIGURE_ARGS = \
66         --target=$(GNU_HOST_NAME) \
67         --host=$(GNU_HOST_NAME) \
68         --build=$(GNU_HOST_NAME) \
69         --program-prefix="" \
70         --program-suffix="" \
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
76
77 HOST_MAKE_FLAGS =
78
79 HOST_CONFIGURE_CMD = $(BASH) ./configure
80
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)/ && \
85                         $(2) \
86                         $(HOST_CONFIGURE_CMD) \
87                         $(HOST_CONFIGURE_VARS) \
88                         $(HOST_CONFIGURE_ARGS) \
89                         $(1); \
90                 fi \
91         )
92 endef
93
94 define Host/Configure
95   $(call Host/Configure/Default)
96 endef
97
98 define Host/Compile/Default
99         +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
100                 $(HOST_MAKE_FLAGS) \
101                 $(1)
102 endef
103
104 define Host/Compile
105   $(call Host/Compile/Default)
106 endef
107
108 define Host/Install/Default
109         $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install
110 endef
111
112 define Host/Install
113   $(call Host/Install/Default)
114 endef
115
116
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)))
121   endef
122 endif
123
124 define Download/default
125   FILE:=$(PKG_SOURCE)
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)
132 endef
133
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
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   $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
168                 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
169                 $(call Host/Compile)
170                 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
171                 touch $$@
172
173   $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
174                 $(call Host/Install)
175                 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
176                 mkdir -p $$(shell dirname $$@)
177                 touch $(HOST_STAMP_BUILT)
178                 touch $$@
179
180   ifndef STAMP_BUILT
181     prepare: host-prepare
182     compile: host-compile
183     install: host-install
184     clean: host-clean
185     update: host-update
186     refresh: host-refresh
187   endif
188
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)
193   host-clean: FORCE
194         $(call Host/Clean)
195         $(call Host/Uninstall)
196         rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
197
198   endef
199
200   download:
201   prepare:
202   compile:
203   install:
204   clean:
205
206 endif