Makefile: add a check to bail out early when the path to the openwrt directory contai...
[openwrt/svn-archive/archive.git] / Makefile
1 # Makefile for OpenWrt
2 #
3 # Copyright (C) 2007 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 TOPDIR:=${CURDIR}
10 LC_ALL:=C
11 LANG:=C
12 export TOPDIR LC_ALL LANG
13
14 empty:=
15 space:= $(empty) $(empty)
16 $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt directory must not include any spaces))
17
18 world:
19
20 include $(TOPDIR)/include/host.mk
21
22 ifneq ($(OPENWRT_BUILD),1)
23 # XXX: these three lines are normally defined by rules.mk
24 # but we can't include that file in this context
25 empty:=
26 space:= $(empty) $(empty)
27 _SINGLE=export MAKEFLAGS=$(space);
28
29 override OPENWRT_BUILD=1
30 export OPENWRT_BUILD
31 GREP_OPTIONS=
32 export GREP_OPTIONS
33 include $(TOPDIR)/include/debug.mk
34 include $(TOPDIR)/include/depends.mk
35 include $(TOPDIR)/include/toplevel.mk
36 else
37 include rules.mk
38 include $(INCLUDE_DIR)/depends.mk
39 include $(INCLUDE_DIR)/subdir.mk
40 include target/Makefile
41 include package/Makefile
42 include tools/Makefile
43 include toolchain/Makefile
44
45 $(toolchain/stamp-install): $(tools/stamp-install)
46 $(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared
47 $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
48 $(package/stamp-install): $(package/stamp-compile)
49 $(target/stamp-install): $(package/stamp-compile) $(package/stamp-install)
50
51 printdb:
52 @true
53
54 prepare: $(target/stamp-compile)
55
56 clean: FORCE
57 $(_SINGLE)$(SUBMAKE) target/linux/clean
58 rm -rf $(BUILD_DIR) $(BIN_DIR) $(BUILD_LOG_DIR)
59
60 dirclean: clean
61 rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
62 rm -rf $(TMP_DIR)
63
64 ifndef DUMP_TARGET_DB
65 $(BUILD_DIR)/.prepared: Makefile
66 @mkdir -p $$(dirname $@)
67 @touch $@
68
69 tmp/.prereq_packages: .config
70 unset ERROR; \
71 for package in $(sort $(prereq-y) $(prereq-m)); do \
72 $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
73 done; \
74 if [ -n "$$ERROR" ]; then \
75 echo "Package prerequisite check failed."; \
76 false; \
77 fi
78 touch $@
79 endif
80
81 # check prerequisites before starting to build
82 prereq: $(target/stamp-prereq) tmp/.prereq_packages
83 @if [ ! -f "$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)" ]; then \
84 echo 'ERROR: Missing site config for target "$(REAL_GNU_TARGET_NAME)" !'; \
85 echo ' The missing file will cause configure scripts to fail during compilation.'; \
86 echo ' Please provide a "$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)" file and restart the build.'; \
87 exit 1; \
88 fi
89
90 prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
91 world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
92 $(_SINGLE)$(SUBMAKE) -r package/index
93
94 # update all feeds, re-create index files, install symlinks
95 package/symlinks:
96 $(SCRIPT_DIR)/feeds update -a
97 $(SCRIPT_DIR)/feeds install -a
98
99 # re-create index files, install symlinks
100 package/symlinks-install:
101 $(SCRIPT_DIR)/feeds update -i
102 $(SCRIPT_DIR)/feeds install -a
103
104 # remove all symlinks, don't touch ./feeds
105 package/symlinks-clean:
106 $(SCRIPT_DIR)/feeds uninstall -a
107
108 .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
109
110 endif