move pkg config stuff to per-target exports to prevent interference with host builds
[openwrt-10.03/.git] / include / host-build.mk
1 #
2 # Copyright (C) 2006-2009 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
11 include $(INCLUDE_DIR)/host.mk
12 include $(INCLUDE_DIR)/unpack.mk
13 include $(INCLUDE_DIR)/depends.mk
14
15 BUILD_TYPES += host
16 HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),)))
17 HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
18 HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
19 HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
20
21 override MAKEFLAGS=
22
23 include $(INCLUDE_DIR)/download.mk
24 include $(INCLUDE_DIR)/quilt.mk
25
26 Host/Patch:=$(Host/Patch/Default)
27 ifneq ($(strip $(HOST_UNPACK)),)
28   define Host/Prepare/Default
29         $(HOST_UNPACK)
30         $(Host/Patch)
31   endef
32 endif
33
34 define Host/Prepare
35   $(call Host/Prepare/Default)
36 endef
37
38 HOST_CONFIGURE_VARS = \
39         CPPFLAGS="$(HOST_CFLAGS)" \
40         LDFLAGS="$(HOST_LDFLAGS)" \
41         SHELL="$(BASH)"
42
43 HOST_CONFIGURE_ARGS = \
44         --target=$(GNU_HOST_NAME) \
45         --host=$(GNU_HOST_NAME) \
46         --build=$(GNU_HOST_NAME) \
47         --program-prefix="" \
48         --program-suffix="" \
49         --prefix=$(STAGING_DIR_HOST) \
50         --exec-prefix=$(STAGING_DIR_HOST) \
51         --sysconfdir=$(STAGING_DIR_HOST)/etc \
52         --localstatedir=$(STAGING_DIR_HOST)/var
53
54 HOST_CONFIGURE_CMD = ./configure
55
56 define Host/Configure/Default
57         @(cd $(HOST_BUILD_DIR)/$(3); \
58                 if [ -x configure ]; then \
59                         $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
60                         $(2) \
61                         $(HOST_CONFIGURE_CMD) \
62                         $(HOST_CONFIGURE_VARS) \
63                         $(HOST_CONFIGURE_ARGS) \
64                         $(1); \
65                 fi \
66         )
67 endef
68
69 define Host/Configure
70   $(call Host/Configure/Default)
71 endef
72
73 define Host/Compile/Default
74         $(MAKE) -C $(HOST_BUILD_DIR) $(1)
75 endef
76
77 define Host/Compile
78   $(call Host/Compile/Default)
79 endef
80
81 define Host/Install/Default
82         $(MAKE) -C $(HOST_BUILD_DIR) install
83 endef
84
85 define Host/Install
86   $(call Host/Install/Default)
87 endef
88
89
90 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
91   define HostHost/Autoclean
92     $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(HOST_STAMP_PREPARED))
93     $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
94   endef
95 endif
96
97 define Download/default
98   FILE:=$(PKG_SOURCE)
99   URL:=$(PKG_SOURCE_URL)
100   PROTO:=$(PKG_SOURCE_PROTO)
101   SUBDIR:=$(PKG_SOURCE_SUBDIR)
102   VERSION:=$(PKG_SOURCE_VERSION)
103   MD5SUM:=$(PKG_MD5SUM)
104 endef
105
106 ifndef DUMP
107   define HostBuild
108   $(if $(HOST_QUILT),$(Host/Quilt))
109   $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
110   $(if $(DUMP),,$(call HostHost/Autoclean))
111
112   $(HOST_STAMP_PREPARED):
113         @-rm -rf $(HOST_BUILD_DIR)
114         @mkdir -p $(HOST_BUILD_DIR)
115         $(call Host/Prepare)
116         touch $$@
117
118   $(HOST_STAMP_CONFIGURED) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig
119   $(HOST_STAMP_CONFIGURED) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig
120   $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
121         $(call Host/Configure)
122         touch $$@
123
124   $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
125         $(call Host/Compile)
126         touch $$@
127
128   $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT)
129         $(call Host/Install)
130         mkdir -p $$(shell dirname $$@)
131         touch $$@
132
133   ifdef Host/Install
134     host-install: $(HOST_STAMP_INSTALLED)
135   endif
136
137   ifndef STAMP_BUILT
138     prepare: host-prepare
139     compile: host-compile
140     install: host-install
141     clean: host-clean
142     update: host-update
143   else
144     host-compile: $(HOST_STAMP_INSTALLED)
145   endif
146   host-prepare: $(HOST_STAMP_PREPARED)
147   host-configure: $(HOST_STAMP_CONFIGURED)
148   host-compile: $(HOST_STAMP_BUILT)
149   host-install:
150   host-clean: FORCE
151         $(call Host/Clean)
152         $(call Host/Uninstall)
153         rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
154
155   endef
156
157   download:
158   prepare:
159   compile:
160   install:
161   clean:
162
163 endif
164