ramips: introduce serial0 aliases
[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_BUILD_PREFIX:=$(if $(IS_PACKAGE_BUILD),$(STAGING_DIR)/host,$(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         $(Host/Patch)
47   endef
48 endif
49
50 define Host/Prepare
51   $(call Host/Prepare/Default)
52 endef
53
54 ifeq ($(HOST_OS),Darwin)
55   HOST_CFLAGS += -I/usr/local/opt/openssl/include
56   HOST_LDFLAGS += -L/usr/local/opt/openssl/lib
57 endif
58
59 HOST_CONFIGURE_VARS = \
60         CC="$(HOSTCC)" \
61         CFLAGS="$(HOST_CFLAGS)" \
62         CPPFLAGS="$(HOST_CPPFLAGS)" \
63         LDFLAGS="$(HOST_LDFLAGS)" \
64         SHELL="$(SHELL)"
65
66 HOST_CONFIGURE_ARGS = \
67         --target=$(GNU_HOST_NAME) \
68         --host=$(GNU_HOST_NAME) \
69         --build=$(GNU_HOST_NAME) \
70         --program-prefix="" \
71         --program-suffix="" \
72         --prefix=$(HOST_BUILD_PREFIX) \
73         --exec-prefix=$(HOST_BUILD_PREFIX) \
74         --sysconfdir=$(HOST_BUILD_PREFIX)/etc \
75         --localstatedir=$(HOST_BUILD_PREFIX)/var \
76         --sbindir=$(HOST_BUILD_PREFIX)/bin
77
78 HOST_MAKE_FLAGS =
79
80 HOST_CONFIGURE_CMD = $(BASH) ./configure
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-* $(if $(IS_PACKAGE_BUILD),$$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*)),-I $$(p))
137   $(1) : export STAGING_PREFIX=$$(HOST_BUILD_PREFIX)
138   $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig:$$(HOST_BUILD_PREFIX)/lib/pkgconfig
139   $(1) : export PKG_CONFIG_LIBDIR=$$(HOST_BUILD_PREFIX)/lib/pkgconfig
140   $(1) : export CCACHE_DIR:=$(STAGING_DIR_HOST)/ccache
141   $(if $(IS_PACKAGE_BUILD),$(1) : export PATH=$$(TARGET_PATH_PKG))
142 endef
143 Host/Exports=$(Host/Exports/Default)
144
145 .NOTPARALLEL:
146
147 ifndef DUMP
148   define HostBuild
149   $(if $(HOST_QUILT),$(Host/Quilt))
150   $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
151   $(if $(DUMP),,$(call HostHost/Autoclean))
152
153   $(HOST_STAMP_PREPARED):
154         @-rm -rf $(HOST_BUILD_DIR)
155         @mkdir -p $(HOST_BUILD_DIR)
156         $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
157         $(call Host/Prepare)
158         $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
159         touch $$@
160
161   $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
162   $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
163         $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
164         $(call Host/Configure)
165         $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
166         touch $$@
167
168   $(call Host/Exports,$(HOST_STAMP_BUILT))
169   $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
170                 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
171                 $(call Host/Compile)
172                 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
173                 touch $$@
174
175   $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
176                 $(call Host/Install)
177                 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
178                 mkdir -p $$(shell dirname $$@)
179                 touch $(HOST_STAMP_BUILT)
180                 touch $$@
181
182   ifndef STAMP_BUILT
183     prepare: host-prepare
184     compile: host-compile
185     install: host-install
186     clean: host-clean
187     update: host-update
188     refresh: host-refresh
189   endif
190
191   host-prepare: $(HOST_STAMP_PREPARED)
192   host-configure: $(HOST_STAMP_CONFIGURED)
193   host-compile: $(HOST_STAMP_BUILT) $(if $(STAMP_BUILT),$(HOST_STAMP_INSTALLED))
194   host-install: $(HOST_STAMP_INSTALLED)
195   host-clean: FORCE
196         $(call Host/Clean)
197         $(call Host/Uninstall)
198         rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
199
200   endef
201
202   download:
203   prepare:
204   compile:
205   install:
206   clean:
207
208 endif