hostapd: prevent spurious 20/40 mhz channel bandwidth switches if noscan is enabled
[openwrt.git] / include / host-build.mk
1 #
2 # Copyright (C) 2006-2010 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 HOST_BUILD_PARALLEL ?=
11
12 ifneq ($(CONFIG_PKG_BUILD_USE_JOBSERVER),)
13   HOST_MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) -j)
14 else
15   HOST_MAKE_J:=-j$(CONFIG_PKG_BUILD_JOBS)
16 endif
17
18 ifeq ($(strip $(HOST_BUILD_PARALLEL)),0)
19 HOST_JOBS?=-j1
20 else
21 HOST_JOBS?=$(if $(HOST_BUILD_PARALLEL)$(CONFIG_PKG_DEFAULT_PARALLEL),\
22         $(if $(CONFIG_PKG_BUILD_PARALLEL),$(HOST_MAKE_J),-j1),-j1)
23 endif
24
25 include $(INCLUDE_DIR)/host.mk
26 include $(INCLUDE_DIR)/unpack.mk
27 include $(INCLUDE_DIR)/depends.mk
28
29 BUILD_TYPES += host
30 HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared$(if $(HOST_QUILT)$(DUMP),,$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPENDS),)))
31 HOST_STAMP_CONFIGURED:=$(HOST_BUILD_DIR)/.configured
32 HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
33 HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
34
35 override MAKEFLAGS=
36
37 include $(INCLUDE_DIR)/download.mk
38 include $(INCLUDE_DIR)/quilt.mk
39 include $(INCLUDE_DIR)/autotools.mk
40
41 Host/Patch:=$(Host/Patch/Default)
42 ifneq ($(strip $(HOST_UNPACK)),)
43   define Host/Prepare/Default
44         $(HOST_UNPACK)
45         $(Host/Patch)
46   endef
47 endif
48
49 define Host/Prepare
50   $(call Host/Prepare/Default)
51 endef
52
53 HOST_CONFIGURE_VARS = \
54         CC="$(HOSTCC)" \
55         CFLAGS="$(HOST_CFLAGS)" \
56         CPPFLAGS="$(HOST_CPPFLAGS)" \
57         LDFLAGS="$(HOST_LDFLAGS)" \
58         SHELL="$(BASH)"
59
60 HOST_CONFIGURE_ARGS = \
61         --target=$(GNU_HOST_NAME) \
62         --host=$(GNU_HOST_NAME) \
63         --build=$(GNU_HOST_NAME) \
64         --program-prefix="" \
65         --program-suffix="" \
66         --prefix=$(STAGING_DIR_HOST) \
67         --exec-prefix=$(STAGING_DIR_HOST) \
68         --sysconfdir=$(STAGING_DIR_HOST)/etc \
69         --localstatedir=$(STAGING_DIR_HOST)/var \
70         --sbindir=$(STAGING_DIR_HOST)/bin
71
72 HOST_MAKE_FLAGS =
73
74 HOST_CONFIGURE_CMD = $(BASH) ./configure
75
76 ifneq ($(HOST_OS),Darwin)
77   ifeq ($(CONFIG_BUILD_STATIC_TOOLS),y)
78     HOST_STATIC_LINKING = -static
79   endif
80 endif
81
82 define Host/Configure/Default
83         $(if $(HOST_CONFIGURE_PARALLEL),+)(cd $(HOST_BUILD_DIR)/$(3); \
84                 if [ -x configure ]; then \
85                         $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/$(3)/ && \
86                         $(2) \
87                         $(HOST_CONFIGURE_CMD) \
88                         $(HOST_CONFIGURE_VARS) \
89                         $(HOST_CONFIGURE_ARGS) \
90                         $(1); \
91                 fi \
92         )
93 endef
94
95 define Host/Configure
96   $(call Host/Configure/Default)
97 endef
98
99 define Host/Compile/Default
100         +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
101                 $(HOST_MAKE_FLAGS) \
102                 $(1)
103 endef
104
105 define Host/Compile
106   $(call Host/Compile/Default)
107 endef
108
109 define Host/Install/Default
110         $(_SINGLE)$(MAKE) -C $(HOST_BUILD_DIR) install
111 endef
112
113 define Host/Install
114   $(call Host/Install/Default)
115 endef
116
117
118 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
119   define HostHost/Autoclean
120     $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
121     $(if $(if $(Host/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(HOST_BUILD_DIR),$(HOST_STAMP_BUILT)))
122   endef
123 endif
124
125 define Download/default
126   FILE:=$(PKG_SOURCE)
127   URL:=$(PKG_SOURCE_URL)
128   PROTO:=$(PKG_SOURCE_PROTO)
129   SUBDIR:=$(PKG_SOURCE_SUBDIR)
130   VERSION:=$(PKG_SOURCE_VERSION)
131   MD5SUM:=$(PKG_MD5SUM)
132   MIRROR_MD5SUM:=$(PKG_MIRROR_MD5SUM)
133 endef
134
135 define Host/Exports/Default
136   $(1) : export ACLOCAL_INCLUDE=$$(foreach p,$$(wildcard $$(STAGING_DIR_HOST)/share/aclocal $$(STAGING_DIR_HOST)/share/aclocal-*),-I $$(p))
137   $(1) : export STAGING_PREFIX=$$(STAGING_DIR_HOST)
138   $(1) : export PKG_CONFIG_PATH=$$(STAGING_DIR_HOST)/lib/pkgconfig
139   $(1) : export PKG_CONFIG_LIBDIR=$$(STAGING_DIR_HOST)/lib/pkgconfig
140 endef
141 Host/Exports=$(Host/Exports/Default)
142
143 .NOTPARALLEL:
144
145 ifndef DUMP
146   define HostBuild
147   $(if $(HOST_QUILT),$(Host/Quilt))
148   $(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
149   $(if $(DUMP),,$(call HostHost/Autoclean))
150
151   $(HOST_STAMP_PREPARED):
152         @-rm -rf $(HOST_BUILD_DIR)
153         @mkdir -p $(HOST_BUILD_DIR)
154         $(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
155         $(call Host/Prepare)
156         $(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
157         touch $$@
158
159   $(call Host/Exports,$(HOST_STAMP_CONFIGURED))
160   $(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
161         $(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
162         $(call Host/Configure)
163         $(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
164         touch $$@
165
166   $(call Host/Exports,$(HOST_STAMP_BUILT))
167   $(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
168                 $(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
169                 $(call Host/Compile)
170                 $(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
171                 touch $$@
172
173   $(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
174                 $(call Host/Install)
175                 $(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
176                 mkdir -p $$(shell dirname $$@)
177                 touch $$@
178
179   ifndef STAMP_BUILT
180     prepare: host-prepare
181     compile: host-compile
182     install: host-install
183     clean: host-clean
184     update: host-update
185     refresh: host-refresh
186   endif
187
188   host-prepare: $(HOST_STAMP_PREPARED)
189   host-configure: $(HOST_STAMP_CONFIGURED)
190   host-compile: $(HOST_STAMP_BUILT) $(if $(STAMP_BUILT),$(HOST_STAMP_INSTALLED))
191   host-install: $(HOST_STAMP_INSTALLED)
192   host-clean: FORCE
193         $(call Host/Clean)
194         $(call Host/Uninstall)
195         rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_INSTALLED) $(HOST_STAMP_BUILT)
196
197   endef
198
199   download:
200   prepare:
201   compile:
202   install:
203   clean:
204
205 endif