fix the host vs native stampfile dependencies to improve quilt support
[openwrt/staging/florian.git] / include / host-build.mk
1 #
2 # Copyright (C) 2006-2008 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 HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),)))
16 HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
17 HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
18 HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
19
20 override MAKEFLAGS=
21
22 include $(INCLUDE_DIR)/download.mk
23 include $(INCLUDE_DIR)/quilt.mk
24
25 Host/Patch:=$(Host/Patch/Default)
26 ifneq ($(strip $(HOST_UNPACK)),)
27 define Host/Prepare/Default
28 $(HOST_UNPACK)
29 $(Host/Patch)
30 endef
31 endif
32
33 define Host/Prepare
34 $(call Host/Prepare/Default)
35 endef
36
37 define Host/Configure/Default
38 @(cd $(HOST_BUILD_DIR)/$(3); \
39 [ -x configure ] && \
40 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
41 $(2) \
42 CPPFLAGS="$(HOST_CFLAGS)" \
43 LDFLAGS="$(HOST_LDFLAGS)" \
44 SHELL="$(BASH)" \
45 ./configure \
46 --target=$(GNU_HOST_NAME) \
47 --host=$(GNU_HOST_NAME) \
48 --build=$(GNU_HOST_NAME) \
49 --program-prefix="" \
50 --program-suffix="" \
51 --prefix=$(STAGING_DIR_HOST) \
52 --exec-prefix=$(STAGING_DIR_HOST) \
53 --sysconfdir=$(STAGING_DIR_HOST)/etc \
54 --localstatedir=$(STAGING_DIR_HOST)/var \
55 $(DISABLE_NLS) \
56 $(1); \
57 true; \
58 )
59 endef
60
61 define Host/Configure
62 $(call Host/Configure/Default)
63 endef
64
65 define Host/Compile/Default
66 $(MAKE) -C $(HOST_BUILD_DIR) $(1)
67 endef
68
69 define Host/Compile
70 $(call Host/Compile/Default)
71 endef
72
73 ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
74 define HostHost/Autoclean
75 $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(HOST_STAMP_PREPARED))
76 $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
77 endef
78 endif
79
80 define Download/default
81 FILE:=$(PKG_SOURCE)
82 URL:=$(PKG_SOURCE_URL)
83 PROTO:=$(PKG_SOURCE_PROTO)
84 SUBDIR:=$(PKG_SOURCE_SUBDIR)
85 VERSION:=$(PKG_SOURCE_VERSION)
86 MD5SUM:=$(PKG_MD5SUM)
87 endef
88
89 ifndef DUMP
90 define HostBuild
91 $(if $(QUILT),$(Host/Quilt))
92 $(if $(STAMP_PREPARED),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
93 $(if $(DUMP),,$(call HostHost/Autoclean))
94
95 $(HOST_STAMP_PREPARED):
96 @-rm -rf $(HOST_BUILD_DIR)
97 @mkdir -p $(HOST_BUILD_DIR)
98 $(call Host/Prepare)
99 touch $$@
100
101 $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
102 $(call Host/Configure)
103 touch $$@
104
105 $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
106 $(call Host/Compile)
107 touch $$@
108
109 $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT)
110 $(call Host/Install)
111 mkdir -p $$(shell dirname $$@)
112 touch $$@
113
114 ifdef Host/Install
115 host-install: $(HOST_STAMP_INSTALLED)
116 endif
117
118 download:
119 host-prepare: $(HOST_STAMP_PREPARED)
120 host-configure: $(HOST_STAMP_CONFIGURED)
121 host-compile: $(HOST_STAMP_BUILT)
122 host-install:
123 host-clean: FORCE
124 $(call Host/Clean)
125 $(call Host/Uninstall)
126 rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
127
128 endef
129
130 prepare: host-prepare
131 compile: host-compile
132 install: host-install
133 clean: host-clean
134
135 endif
136