maccalc: remove package
[openwrt/openwrt.git] / include / toplevel.mk
1 # Makefile for OpenWrt
2 #
3 # Copyright (C) 2007-2012 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 PREP_MK= OPENWRT_BUILD= QUIET=0
10
11 export IS_TTY=$(shell tty -s && echo 1 || echo 0)
12
13 include $(TOPDIR)/include/verbose.mk
14
15 ifeq ($(SDK),1)
16 include $(TOPDIR)/include/version.mk
17 else
18 REVISION:=$(shell $(TOPDIR)/scripts/getver.sh)
19 SOURCE_DATE_EPOCH:=$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh)
20 endif
21
22 export REVISION
23 export SOURCE_DATE_EPOCH
24 export GIT_CONFIG_PARAMETERS='core.autocrlf=false'
25 export GIT_ASKPASS:=/bin/true
26 export MAKE_JOBSERVER=$(filter --jobserver%,$(MAKEFLAGS))
27 export GNU_HOST_NAME:=$(shell $(TOPDIR)/scripts/config.guess)
28 export HOST_OS:=$(shell uname)
29 export HOST_ARCH:=$(shell uname -m)
30
31 ifeq ($(HOST_OS),Darwin)
32 ifneq ($(filter /Applications/Xcode.app/% /Library/Developer/%,$(MAKE)),)
33 $(error Please use a newer version of GNU make. The version shipped by Apple is not supported)
34 endif
35 endif
36
37 # prevent perforce from messing with the patch utility
38 unexport P4PORT P4USER P4CONFIG P4CLIENT
39
40 # prevent user defaults for quilt from interfering
41 unexport QUILT_PATCHES QUILT_PATCH_OPTS
42
43 unexport C_INCLUDE_PATH CROSS_COMPILE ARCH
44
45 # prevent distro default LPATH from interfering
46 unexport LPATH
47
48 # make sure that a predefined CFLAGS variable does not disturb packages
49 export CFLAGS=
50 export LDFLAGS=
51
52 empty:=
53 space:= $(empty) $(empty)
54 path:=$(subst :,$(space),$(PATH))
55 path:=$(filter-out .%,$(path))
56 path:=$(subst $(space),:,$(path))
57 export PATH:=$(path)
58
59 unexport TAR_OPTIONS
60
61 ifeq ($(FORCE),)
62 .config scripts/config/conf scripts/config/mconf: staging_dir/host/.prereq-build
63 endif
64
65 SCAN_COOKIE?=$(shell echo $$$$)
66 export SCAN_COOKIE
67
68 SUBMAKE:=umask 022; $(SUBMAKE)
69
70 ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024;
71
72 prepare-mk: staging_dir/host/.prereq-build FORCE ;
73
74 ifdef SDK
75 IGNORE_PACKAGES = linux
76 endif
77
78 _ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p))
79
80 prepare-tmpinfo: FORCE
81 @+$(MAKE) -r -s staging_dir/host/.prereq-build $(PREP_MK)
82 mkdir -p tmp/info
83 $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPTH=5 SCAN_EXTRA=""
84 $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
85 for type in package target; do \
86 f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
87 [ "$$t" -nt "$$f" ] || ./scripts/$${type}-metadata.pl $(_ignore) config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
88 done
89 [ tmp/.config-feeds.in -nt tmp/.packageauxvars ] || ./scripts/feeds feed_config > tmp/.config-feeds.in
90 ./scripts/package-metadata.pl mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
91 ./scripts/package-metadata.pl pkgaux tmp/.packageinfo > tmp/.packageauxvars || { rm -f tmp/.packageauxvars; false; }
92 ./scripts/package-metadata.pl usergroup tmp/.packageinfo > tmp/.packageusergroup || { rm -f tmp/.packageusergroup; false; }
93 touch $(TOPDIR)/tmp/.build
94
95 .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
96 @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
97 [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
98 $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
99 fi
100
101 ifeq ($(RECURSIVE_DEP_IS_ERROR),1)
102 KCONF_FLAGS=--fatalrecursive
103 endif
104 ifneq ($(DISTRO_PKG_CONFIG),)
105 scripts/config/%onf: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
106 endif
107 scripts/config/%onf: CFLAGS+= -O2
108 scripts/config/%onf:
109 @$(_SINGLE)$(SUBMAKE) $(if $(findstring s,$(OPENWRT_VERBOSE)),,-s) \
110 -C scripts/config $(notdir $@)
111
112 $(eval $(call rdep,scripts/config,scripts/config/mconf))
113
114 config: scripts/config/conf prepare-tmpinfo FORCE
115 [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
116 $< $(KCONF_FLAGS) Config.in
117
118 config-clean: FORCE
119 $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
120
121 defconfig: scripts/config/conf prepare-tmpinfo FORCE
122 touch .config
123 @if [ ! -s .config -a -e $(HOME)/.openwrt/defconfig ]; then cp $(HOME)/.openwrt/defconfig .config; fi
124 [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
125 $< $(KCONF_FLAGS) --defconfig=.config Config.in
126
127 confdefault-y=allyes
128 confdefault-m=allmod
129 confdefault-n=allno
130 confdefault:=$(confdefault-$(CONFDEFAULT))
131
132 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
133 [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
134 $< $(KCONF_FLAGS) --$(if $(confdefault),$(confdefault),old)config Config.in
135
136 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
137 if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
138 cp $(HOME)/.openwrt/defconfig .config; \
139 fi
140 [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
141 $< Config.in
142
143 nconfig: scripts/config/nconf prepare-tmpinfo FORCE
144 if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
145 cp $(HOME)/.openwrt/defconfig .config; \
146 fi
147 [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \
148 $< Config.in
149
150 xconfig: scripts/config/qconf prepare-tmpinfo FORCE
151 if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
152 cp $(HOME)/.openwrt/defconfig .config; \
153 fi
154 $< Config.in
155
156 prepare_kernel_conf: .config toolchain/install FORCE
157
158 ifeq ($(wildcard staging_dir/host/bin/quilt),)
159 prepare_kernel_conf:
160 @+$(SUBMAKE) -r tools/quilt/compile
161 else
162 prepare_kernel_conf: ;
163 endif
164
165 kernel_oldconfig: prepare_kernel_conf
166 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
167
168 ifneq ($(DISTRO_PKG_CONFIG),)
169 kernel_menuconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
170 kernel_nconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
171 kernel_xconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH)
172 endif
173 kernel_menuconfig: prepare_kernel_conf
174 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
175
176 kernel_nconfig: prepare_kernel_conf
177 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
178
179 kernel_xconfig: prepare_kernel_conf
180 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux xconfig
181
182 staging_dir/host/.prereq-build: include/prereq-build.mk
183 mkdir -p tmp
184 @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
185 echo "Prerequisite check failed. Use FORCE=1 to override."; \
186 false; \
187 }
188 ifneq ($(realpath $(TOPDIR)/include/prepare.mk),)
189 @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk prepare 2>/dev/null || { \
190 echo "Preparation failed."; \
191 false; \
192 }
193 endif
194 touch $@
195
196 printdb: FORCE
197 @$(_SINGLE)$(NO_TRACE_MAKE) -p $@ V=99 DUMP_TARGET_DB=1 2>&1
198
199 ifndef SDK
200 DOWNLOAD_DIRS = tools/download toolchain/download package/download target/download
201 else
202 DOWNLOAD_DIRS = package/download
203 endif
204
205 download: .config FORCE $(if $(wildcard $(TOPDIR)/staging_dir/host/bin/flock),,tools/flock/compile)
206 @+$(foreach dir,$(DOWNLOAD_DIRS),$(SUBMAKE) $(dir);)
207
208 clean dirclean: .config
209 @+$(SUBMAKE) -r $@
210
211 prereq:: prepare-tmpinfo .config
212 @+$(NO_TRACE_MAKE) -r -s $@
213
214 check: .config FORCE
215 @+$(NO_TRACE_MAKE) -r -s $@ QUIET= V=s
216
217 val.%: FORCE
218 @+$(NO_TRACE_MAKE) -r -s $@ QUIET= V=s
219
220 WARN_PARALLEL_ERROR = $(if $(BUILD_LOG),,$(and $(filter -j,$(MAKEFLAGS)),$(findstring s,$(OPENWRT_VERBOSE))))
221
222 ifeq ($(SDK),1)
223
224 %::
225 @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
226 @./scripts/config/conf $(KCONF_FLAGS) --defconfig=.config Config.in
227 @+$(ULIMIT_FIX) $(SUBMAKE) -r $@
228
229 else
230
231 %::
232 @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
233 @( \
234 cp .config tmp/.config; \
235 ./scripts/config/conf $(KCONF_FLAGS) --defconfig=tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
236 if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \
237 printf "$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
238 fi \
239 )
240 @+$(ULIMIT_FIX) $(SUBMAKE) -r $@ $(if $(WARN_PARALLEL_ERROR), || { \
241 printf "$(_R)Build failed - please re-run with -j1 to see the real error message$(_N)\n" >&2; \
242 false; \
243 } )
244
245 endif
246
247 # update all feeds, re-create index files, install symlinks
248 package/symlinks:
249 ./scripts/feeds update -a
250 ./scripts/feeds install -a
251
252 # re-create index files, install symlinks
253 package/symlinks-install:
254 ./scripts/feeds update -i
255 ./scripts/feeds install -a
256
257 # remove all symlinks, don't touch ./feeds
258 package/symlinks-clean:
259 ./scripts/feeds uninstall -a
260
261 help:
262 cat README.md
263
264 distclean:
265 rm -rf bin build_dir .ccache .config* dl feeds key-build* logs package/feeds package/openwrt-packages staging_dir tmp
266 @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
267
268 ifeq ($(findstring v,$(DEBUG)),)
269 .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig staging_dir/host/.prereq-build tmp/.prereq-package prepare-tmpinfo
270 endif
271 .PHONY: help FORCE
272 .NOTPARALLEL:
273