47ec9b0d3a5845a88ab53f6ad2a539e023594cb6
[openwrt/svn-archive/archive.git] / include / host-build.mk
1 #
2 # Copyright (C) 2006-2007 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 PKG_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
9 PKG_INSTALL_DIR ?= $(PKG_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 STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s)
16 STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
17 STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
18 STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
19
20 override MAKEFLAGS=
21
22 include $(INCLUDE_DIR)/quilt.mk
23
24 Build/Patch:=$(Build/Patch/Default)
25 ifneq ($(strip $(PKG_UNPACK)),)
26 define Build/Prepare/Default
27 $(PKG_UNPACK)
28 $(Build/Patch)
29 endef
30 endif
31
32 define Build/Prepare
33 $(call Build/Prepare/Default)
34 endef
35
36 define Build/Configure/Default
37 @(cd $(PKG_BUILD_DIR)/$(3); \
38 [ -x configure ] && \
39 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(PKG_BUILD_DIR)/$(3)/ && \
40 $(2) \
41 CPPFLAGS="$(HOST_CFLAGS)" \
42 LDFLAGS="$(HOST_LDFLAGS)" \
43 SHELL="$(BASH)" \
44 ./configure \
45 --target=$(GNU_HOST_NAME) \
46 --host=$(GNU_HOST_NAME) \
47 --build=$(GNU_HOST_NAME) \
48 --program-prefix="" \
49 --program-suffix="" \
50 --prefix=$(STAGING_DIR_HOST) \
51 --exec-prefix=$(STAGING_DIR_HOST) \
52 --sysconfdir=$(STAGING_DIR_HOST)/etc \
53 --localstatedir=$(STAGING_DIR_HOST)/var \
54 $(DISABLE_NLS) \
55 $(1); \
56 true; \
57 )
58 endef
59
60 define Build/Configure
61 $(call Build/Configure/Default)
62 endef
63
64 define Build/Compile/Default
65 $(MAKE) -C $(PKG_BUILD_DIR) $(1)
66 endef
67
68 define Build/Compile
69 $(call Build/Compile/Default)
70 endef
71
72
73 ifneq ($(strip $(PKG_SOURCE)),)
74 download: $(DL_DIR)/$(PKG_SOURCE)
75
76 $(DL_DIR)/$(PKG_SOURCE):
77 mkdir -p $(DL_DIR)
78 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
79
80 $(STAMP_PREPARED): $(DL_DIR)/$(PKG_SOURCE)
81 endif
82
83 ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
84 define HostBuild/Autoclean
85 $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
86 $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
87 $(if $(if $(Build/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),$(PKG_BUILD_DIR)/.dep_files, -and -not -path "/.*" -and -not -path "*/ipkg*"))
88 endef
89 endif
90
91 define HostBuild
92 ifeq ($(DUMP),)
93 $(call HostBuild/Autoclean)
94 endif
95
96 $(STAMP_PREPARED):
97 @-rm -rf $(PKG_BUILD_DIR)
98 @mkdir -p $(PKG_BUILD_DIR)
99 $(call Build/Prepare)
100 touch $$@
101
102 $(STAMP_CONFIGURED): $(STAMP_PREPARED)
103 $(call Build/Configure)
104 touch $$@
105
106 $(STAMP_BUILT): $(STAMP_CONFIGURED)
107 $(call Build/Compile)
108 touch $$@
109
110 $(STAMP_INSTALLED): $(STAMP_BUILT)
111 $(call Build/Install)
112 mkdir -p $$(shell dirname $$@)
113 touch $$@
114
115 ifdef Build/Install
116 install: $(STAMP_INSTALLED)
117 endif
118
119 package-clean: FORCE
120 $(call Build/Clean)
121 $(call Build/Uninstall)
122 rm -f $(STAMP_INSTALLED) $(STAMP_BUILT)
123
124 download:
125 prepare: $(STAMP_PREPARED)
126 configure: $(STAMP_CONFIGURED)
127 compile: $(STAMP_BUILT)
128 install:
129 clean: FORCE
130 $(call Build/Clean)
131 rm -rf $(PKG_BUILD_DIR)
132
133 endef