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 ?
=
11 HOST_JOBS ?
= $(if
$(HOST_BUILD_PARALLEL
)$(CONFIG_PKG_DEFAULT_PARALLEL
),$(if
$(CONFIG_PKG_BUILD_PARALLEL
),-j
$(CONFIG_PKG_BUILD_JOBS
)))
13 include $(INCLUDE_DIR
)/host.mk
14 include $(INCLUDE_DIR
)/unpack.mk
15 include $(INCLUDE_DIR
)/depends.mk
18 HOST_STAMP_PREPARED
=$(HOST_BUILD_DIR
)/.prepared
$(if
$(HOST_QUILT
)$(DUMP
),,$(shell $(call find_md5
,${CURDIR} $(PKG_FILE_DEPENDS
),)))
19 HOST_STAMP_CONFIGURED
:=$(HOST_BUILD_DIR
)/.configured
20 HOST_STAMP_BUILT
:=$(HOST_BUILD_DIR
)/.built
21 HOST_STAMP_INSTALLED
:=$(STAGING_DIR_HOST
)/stamp
/.
$(PKG_NAME
)_installed
25 include $(INCLUDE_DIR
)/download.mk
26 include $(INCLUDE_DIR
)/quilt.mk
28 Host
/Patch
:=$(Host
/Patch
/Default
)
29 ifneq ($(strip $(HOST_UNPACK
)),)
30 define Host
/Prepare
/Default
37 $(call Host
/Prepare
/Default
)
40 HOST_CONFIGURE_VARS
= \
41 CFLAGS
="$(HOST_CFLAGS)" \
42 CPPFLAGS
="$(HOST_CFLAGS)" \
43 LDFLAGS
="$(HOST_LDFLAGS)" \
46 HOST_CONFIGURE_ARGS
= \
47 --target
=$(GNU_HOST_NAME
) \
48 --host
=$(GNU_HOST_NAME
) \
49 --build
=$(GNU_HOST_NAME
) \
52 --prefix=$(STAGING_DIR_HOST
) \
53 --exec-prefix
=$(STAGING_DIR_HOST
) \
54 --sysconfdir
=$(STAGING_DIR_HOST
)/etc \
55 --localstatedir
=$(STAGING_DIR_HOST
)/var
57 HOST_CONFIGURE_CMD
= .
/configure
59 define Host
/Configure
/Default
60 (cd
$(HOST_BUILD_DIR
)/$(3); \
61 if
[ -x configure
]; then \
62 $(CP
) $(SCRIPT_DIR
)/config.
{guess
,sub
} $(HOST_BUILD_DIR
)/$(3)/ && \
64 $(HOST_CONFIGURE_CMD
) \
65 $(HOST_CONFIGURE_VARS
) \
66 $(HOST_CONFIGURE_ARGS
) \
73 $(call Host
/Configure
/Default
)
76 define Host
/Compile
/Default
77 $(MAKE
) $(HOST_JOBS
) -C
$(HOST_BUILD_DIR
) $(1)
81 $(call Host
/Compile
/Default
)
84 define Host
/Install
/Default
85 $(_SINGLE
)$(MAKE
) -C
$(HOST_BUILD_DIR
) install
89 $(call Host
/Install
/Default
)
93 ifneq ($(if
$(HOST_QUILT
),,$(CONFIG_AUTOREBUILD
)),)
94 define HostHost
/Autoclean
95 $(call rdep
,${CURDIR} $(PKG_FILE_DEPENDS
),$(HOST_STAMP_PREPARED
))
96 $(if
$(if
$(Host
/Compile
),$(filter prepare
,$(MAKECMDGOALS
)),1),,$(call rdep
,$(HOST_BUILD_DIR
),$(HOST_STAMP_BUILT
)))
100 define Download
/default
102 URL
:=$(PKG_SOURCE_URL
)
103 PROTO
:=$(PKG_SOURCE_PROTO
)
104 SUBDIR
:=$(PKG_SOURCE_SUBDIR
)
105 VERSION
:=$(PKG_SOURCE_VERSION
)
106 MD5SUM
:=$(PKG_MD5SUM
)
109 define Host
/Exports
/Default
110 $(1) : export ACLOCAL_INCLUDE
=$$(foreach p
,$$(wildcard $$(STAGING_DIR_HOST
)/share
/aclocal
$$(STAGING_DIR_HOST
)/share
/aclocal-
*),-I
$$(p
))
111 $(1) : export STAGING_PREFIX
=$$(STAGING_DIR_HOST
)
112 $(1) : export PKG_CONFIG_PATH
=$$(STAGING_DIR_HOST
)/lib
/pkgconfig
113 $(1) : export PKG_CONFIG_LIBDIR
=$$(STAGING_DIR_HOST
)/lib
/pkgconfig
115 Host
/Exports
=$(Host
/Exports
/Default
)
119 $(if
$(HOST_QUILT
),$(Host
/Quilt
))
120 $(if
$(if
$(PKG_HOST_ONLY
),,$(STAMP_PREPARED
)),,$(if
$(strip $(PKG_SOURCE_URL
)),$(call Download
,default
)))
121 $(if
$(DUMP
),,$(call HostHost
/Autoclean
))
123 $(HOST_STAMP_PREPARED
):
124 @
-rm -rf
$(HOST_BUILD_DIR
)
125 @mkdir
-p
$(HOST_BUILD_DIR
)
129 $(call Host
/Exports
,$(HOST_STAMP_CONFIGURED
))
130 $(HOST_STAMP_CONFIGURED
): $(HOST_STAMP_PREPARED
)
131 $(call Host
/Configure
)
134 $(call Host
/Exports
,$(HOST_STAMP_BUILT
))
136 host-install
: $(if
$(STAMP_BUILT
),$(HOST_STAMP_BUILT
),$(HOST_STAMP_INSTALLED
))
140 prepare
: host-prepare
141 compile
: host-compile
142 install: host-install
146 $(HOST_STAMP_BUILT
): $(HOST_STAMP_CONFIGURED
)
150 $(HOST_STAMP_INSTALLED
): $(HOST_STAMP_BUILT
)
152 mkdir
-p
$$(shell dirname
$$@
)
155 $(HOST_STAMP_BUILT
): $(HOST_STAMP_CONFIGURED
)
160 host-prepare
: $(HOST_STAMP_PREPARED
)
161 host-configure
: $(HOST_STAMP_CONFIGURED
)
162 host-compile
: $(HOST_STAMP_BUILT
)
166 $(call Host
/Uninstall
)
167 rm -rf
$(HOST_BUILD_DIR
) $(HOST_STAMP_INSTALLED
) $(HOST_STAMP_BUILT
)