2 # Copyright (C) 2006-2010 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
10 HOST_BUILD_PARALLEL ?
=
12 ifeq ($(strip $(HOST_BUILD_PARALLEL
)),0)
15 HOST_JOBS?
=$(if
$(HOST_BUILD_PARALLEL
)$(CONFIG_PKG_DEFAULT_PARALLEL
),\
16 $(if
$(CONFIG_PKG_BUILD_PARALLEL
),-j
$(CONFIG_PKG_BUILD_JOBS
),-j1
),-j1
)
19 include $(INCLUDE_DIR
)/host.mk
20 include $(INCLUDE_DIR
)/unpack.mk
21 include $(INCLUDE_DIR
)/depends.mk
24 HOST_STAMP_PREPARED
=$(HOST_BUILD_DIR
)/.prepared
$(if
$(HOST_QUILT
)$(DUMP
),,$(shell $(call find_md5
,${CURDIR} $(PKG_FILE_DEPENDS
),)))
25 HOST_STAMP_CONFIGURED
:=$(HOST_BUILD_DIR
)/.configured
26 HOST_STAMP_BUILT
:=$(HOST_BUILD_DIR
)/.built
27 HOST_STAMP_INSTALLED
:=$(STAGING_DIR_HOST
)/stamp
/.
$(PKG_NAME
)_installed
31 include $(INCLUDE_DIR
)/download.mk
32 include $(INCLUDE_DIR
)/quilt.mk
33 include $(INCLUDE_DIR
)/autotools.mk
35 Host
/Patch
:=$(Host
/Patch
/Default
)
36 ifneq ($(strip $(HOST_UNPACK
)),)
37 define Host
/Prepare
/Default
44 $(call Host
/Prepare
/Default
)
47 HOST_CONFIGURE_VARS
= \
49 CFLAGS
="$(HOST_CFLAGS)" \
50 CPPFLAGS
="$(HOST_CFLAGS)" \
51 LDFLAGS
="$(HOST_LDFLAGS)" \
54 HOST_CONFIGURE_ARGS
= \
55 --target
=$(GNU_HOST_NAME
) \
56 --host
=$(GNU_HOST_NAME
) \
57 --build
=$(GNU_HOST_NAME
) \
60 --prefix=$(STAGING_DIR_HOST
) \
61 --exec-prefix
=$(STAGING_DIR_HOST
) \
62 --sysconfdir
=$(STAGING_DIR_HOST
)/etc \
63 --localstatedir
=$(STAGING_DIR_HOST
)/var \
64 --sbindir
=$(STAGING_DIR_HOST
)/bin
66 HOST_CONFIGURE_CMD
= .
/configure
68 define Host
/Configure
/Default
69 (cd
$(HOST_BUILD_DIR
)/$(3); \
70 if
[ -x configure
]; then \
71 $(CP
) $(SCRIPT_DIR
)/config.
{guess
,sub
} $(HOST_BUILD_DIR
)/$(3)/ && \
73 $(HOST_CONFIGURE_CMD
) \
74 $(HOST_CONFIGURE_VARS
) \
75 $(HOST_CONFIGURE_ARGS
) \
82 $(call Host
/Configure
/Default
)
85 define Host
/Compile
/Default
86 $(MAKE
) $(HOST_JOBS
) -C
$(HOST_BUILD_DIR
) $(1)
90 $(call Host
/Compile
/Default
)
93 define Host
/Install
/Default
94 $(_SINGLE
)$(MAKE
) -C
$(HOST_BUILD_DIR
) install
98 $(call Host
/Install
/Default
)
102 ifneq ($(if
$(HOST_QUILT
),,$(CONFIG_AUTOREBUILD
)),)
103 define HostHost
/Autoclean
104 $(call rdep
,${CURDIR} $(PKG_FILE_DEPENDS
),$(HOST_STAMP_PREPARED
))
105 $(if
$(if
$(Host
/Compile
),$(filter prepare
,$(MAKECMDGOALS
)),1),,$(call rdep
,$(HOST_BUILD_DIR
),$(HOST_STAMP_BUILT
)))
109 define Download
/default
111 URL
:=$(PKG_SOURCE_URL
)
112 PROTO
:=$(PKG_SOURCE_PROTO
)
113 SUBDIR
:=$(PKG_SOURCE_SUBDIR
)
114 VERSION
:=$(PKG_SOURCE_VERSION
)
115 MD5SUM
:=$(PKG_MD5SUM
)
118 define Host
/Exports
/Default
119 $(1) : export ACLOCAL_INCLUDE
=$$(foreach p
,$$(wildcard $$(STAGING_DIR_HOST
)/share
/aclocal
$$(STAGING_DIR_HOST
)/share
/aclocal-
*),-I
$$(p
))
120 $(1) : export STAGING_PREFIX
=$$(STAGING_DIR_HOST
)
121 $(1) : export PKG_CONFIG_PATH
=$$(STAGING_DIR_HOST
)/lib
/pkgconfig
122 $(1) : export PKG_CONFIG_LIBDIR
=$$(STAGING_DIR_HOST
)/lib
/pkgconfig
124 Host
/Exports
=$(Host
/Exports
/Default
)
128 $(if
$(HOST_QUILT
),$(Host
/Quilt
))
129 $(if
$(if
$(PKG_HOST_ONLY
),,$(STAMP_PREPARED
)),,$(if
$(strip $(PKG_SOURCE_URL
)),$(call Download
,default
)))
130 $(if
$(DUMP
),,$(call HostHost
/Autoclean
))
132 $(HOST_STAMP_PREPARED
):
133 @
-rm -rf
$(HOST_BUILD_DIR
)
134 @mkdir
-p
$(HOST_BUILD_DIR
)
135 $(foreach hook
,$(Hooks
/HostPrepare
/Pre
),$(call
$(hook
))$(sep
))
137 $(foreach hook
,$(Hooks
/HostPrepare
/Post
),$(call
$(hook
))$(sep
))
140 $(call Host
/Exports
,$(HOST_STAMP_CONFIGURED
))
141 $(HOST_STAMP_CONFIGURED
): $(HOST_STAMP_PREPARED
)
142 $(foreach hook
,$(Hooks
/HostConfigure
/Pre
),$(call
$(hook
))$(sep
))
143 $(call Host
/Configure
)
144 $(foreach hook
,$(Hooks
/HostConfigure
/Post
),$(call
$(hook
))$(sep
))
147 $(call Host
/Exports
,$(HOST_STAMP_BUILT
))
149 host-install
: $(if
$(STAMP_BUILT
),$(HOST_STAMP_BUILT
),$(HOST_STAMP_INSTALLED
))
153 prepare
: host-prepare
154 compile
: host-compile
155 install: host-install
158 refresh
: host-refresh
160 $(HOST_STAMP_BUILT
): $(HOST_STAMP_CONFIGURED
)
161 $(foreach hook
,$(Hooks
/HostCompile
/Pre
),$(call
$(hook
))$(sep
))
163 $(foreach hook
,$(Hooks
/HostCompile
/Post
),$(call
$(hook
))$(sep
))
166 $(HOST_STAMP_INSTALLED
): $(HOST_STAMP_BUILT
) $(if
$(FORCE_HOST_INSTALL
),FORCE
)
168 $(foreach hook
,$(Hooks
/HostInstall
/Post
),$(call
$(hook
))$(sep
))
169 mkdir
-p
$$(shell dirname
$$@
)
172 $(HOST_STAMP_BUILT
): $(HOST_STAMP_CONFIGURED
) $(if
$(FORCE_HOST_INSTALL
),FORCE
)
173 $(foreach hook
,$(Hooks
/HostCompile
/Pre
),$(call
$(hook
))$(sep
))
175 $(foreach hook
,$(Hooks
/HostCompile
/Post
),$(call
$(hook
))$(sep
))
177 $(foreach hook
,$(Hooks
/HostInstall
/Post
),$(call
$(hook
))$(sep
))
180 host-prepare
: $(HOST_STAMP_PREPARED
)
181 host-configure
: $(HOST_STAMP_CONFIGURED
)
182 host-compile
: $(HOST_STAMP_BUILT
)
186 $(call Host
/Uninstall
)
187 rm -rf
$(HOST_BUILD_DIR
) $(HOST_STAMP_INSTALLED
) $(HOST_STAMP_BUILT
)