source: trunk/include/host-build.mk @ 14610

Last change on this file since 14610 was 14610, checked in by nbd, 8 years ago

build system refactoring in preparation for allowing packages to do host-build steps

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
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
8HOST_BUILD_DIR ?= $(BUILD_DIR_HOST)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
9PKG_INSTALL_DIR ?= $(HOST_BUILD_DIR)/host-install
10
11include $(INCLUDE_DIR)/host.mk
12include $(INCLUDE_DIR)/unpack.mk
13include $(INCLUDE_DIR)/depends.mk
14
15HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),)))
16HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
17HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
18HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
19
20override MAKEFLAGS=
21
22include $(INCLUDE_DIR)/download.mk
23include $(INCLUDE_DIR)/quilt.mk
24
25Host/Patch:=$(Host/Patch/Default)
26ifneq ($(strip $(HOST_UNPACK)),)
27  define Host/Prepare/Default
28        $(HOST_UNPACK)
29        $(Host/Patch)
30        $(if $(QUILT),touch $(HOST_BUILD_DIR)/.quilt_used)
31  endef
32endif
33
34define Host/Prepare
35  $(call Host/Prepare/Default)
36endef
37
38define Host/Configure/Default
39        @(cd $(HOST_BUILD_DIR)/$(3); \
40        [ -x configure ] && \
41                $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
42                $(2) \
43                CPPFLAGS="$(HOST_CFLAGS)" \
44                LDFLAGS="$(HOST_LDFLAGS)" \
45                SHELL="$(BASH)" \
46                ./configure \
47                --target=$(GNU_HOST_NAME) \
48                --host=$(GNU_HOST_NAME) \
49                --build=$(GNU_HOST_NAME) \
50                --program-prefix="" \
51                --program-suffix="" \
52                --prefix=$(STAGING_DIR_HOST) \
53                --exec-prefix=$(STAGING_DIR_HOST) \
54                --sysconfdir=$(STAGING_DIR_HOST)/etc \
55                --localstatedir=$(STAGING_DIR_HOST)/var \
56                $(DISABLE_NLS) \
57                $(1); \
58                true; \
59        )
60endef
61
62define Host/Configure
63  $(call Host/Configure/Default)
64endef
65
66define Host/Compile/Default
67        $(MAKE) -C $(HOST_BUILD_DIR) $(1)
68endef
69
70define Host/Compile
71  $(call Host/Compile/Default)
72endef
73
74ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
75  define HostHost/Autoclean
76    $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(HOST_STAMP_PREPARED))
77    $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
78  endef
79endif
80
81define Download/default
82  FILE:=$(PKG_SOURCE)
83  URL:=$(PKG_SOURCE_URL)
84  PROTO:=$(PKG_SOURCE_PROTO)
85  SUBDIR:=$(PKG_SOURCE_SUBDIR)
86  VERSION:=$(PKG_SOURCE_VERSION)
87  MD5SUM:=$(PKG_MD5SUM)
88endef
89
90define HostBuild
91  $(if $(QUILT),$(Host/Quilt))
92  $(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    install: $(HOST_STAMP_INSTALLED)
116  endif
117
118  package-clean: FORCE
119        $(call Host/Clean)
120        $(call Host/Uninstall)
121        rm -f $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
122
123  download:
124  prepare: $(HOST_STAMP_PREPARED)
125  configure: $(HOST_STAMP_CONFIGURED)
126  compile: $(HOST_STAMP_BUILT)
127  install:
128  clean: FORCE
129        $(call Host/Clean)
130        rm -rf $(HOST_BUILD_DIR)
131
132endef
Note: See TracBrowser for help on using the repository browser.