CC: polarssl: update to version 1.3.14
[15.05/openwrt.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   _SINGLE=export MAKEFLAGS=$(space);
24
25   override OPENWRT_BUILD=1
26   export OPENWRT_BUILD
27   GREP_OPTIONS=
28   export GREP_OPTIONS
29   include $(TOPDIR)/include/debug.mk
30   include $(TOPDIR)/include/depends.mk
31   include $(TOPDIR)/include/toplevel.mk
32 else
33   include rules.mk
34   include $(INCLUDE_DIR)/depends.mk
35   include $(INCLUDE_DIR)/subdir.mk
36   include target/Makefile
37   include package/Makefile
38   include tools/Makefile
39   include toolchain/Makefile
40
41 $(toolchain/stamp-install): $(tools/stamp-install)
42 $(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared
43 $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
44 $(package/stamp-install): $(package/stamp-compile)
45 $(target/stamp-install): $(package/stamp-compile) $(package/stamp-install)
46
47 printdb:
48         @true
49
50 prepare: $(target/stamp-compile)
51
52 clean: FORCE
53         rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(BUILD_LOG_DIR)
54
55 dirclean: clean
56         rm -rf $(STAGING_DIR_HOST) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
57         rm -rf $(TMP_DIR)
58
59 ifndef DUMP_TARGET_DB
60 $(BUILD_DIR)/.prepared: Makefile
61         @mkdir -p $$(dirname $@)
62         @touch $@
63
64 tmp/.prereq_packages: .config
65         unset ERROR; \
66         for package in $(sort $(prereq-y) $(prereq-m)); do \
67                 $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
68         done; \
69         if [ -n "$$ERROR" ]; then \
70                 echo "Package prerequisite check failed."; \
71                 false; \
72         fi
73         touch $@
74 endif
75
76 # check prerequisites before starting to build
77 prereq: $(target/stamp-prereq) tmp/.prereq_packages
78         @if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
79                 echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \
80                 echo '       The missing file will cause configure scripts to fail during compilation.'; \
81                 echo '       Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
82                 exit 1; \
83         fi
84
85 prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
86 world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
87         $(_SINGLE)$(SUBMAKE) -r package/index
88
89 .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
90
91 endif