ramips: add support for TP-Link TL-WR850N v2
[openwrt/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 TZ:=UTC
13 export TOPDIR LC_ALL LANG TZ
14
15 empty:=
16 space:= $(empty) $(empty)
17 $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt directory must not include any spaces))
18
19 world:
20
21 DISTRO_PKG_CONFIG:=$(shell which -a pkg-config | grep -E '\/usr' | head -n 1)
22 export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
23
24 ifneq ($(OPENWRT_BUILD),1)
25 _SINGLE=export MAKEFLAGS=$(space);
26
27 override OPENWRT_BUILD=1
28 export OPENWRT_BUILD
29 GREP_OPTIONS=
30 export GREP_OPTIONS
31 CDPATH=
32 export CDPATH
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-compile): $(tools/stamp-compile)
46 $(target/stamp-compile): $(toolchain/stamp-compile) $(tools/stamp-compile) $(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 check: $(tools/stamp-check) $(toolchain/stamp-check) $(package/stamp-check)
51
52 printdb:
53 @true
54
55 prepare: $(target/stamp-compile)
56
57 clean: FORCE
58 rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(BUILD_LOG_DIR) $(TOPDIR)/staging_dir/packages
59
60 dirclean: clean
61 rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/host $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN)
62 rm -rf $(TMP_DIR)
63 $(MAKE) -C $(TOPDIR)/scripts/config clean
64
65 cacheclean:
66 ifneq ($(CONFIG_CCACHE),)
67 rm -rf $(if $(call qstrip,$(CONFIG_CCACHE_DIR)),$(call qstrip,$(CONFIG_CCACHE_DIR)),$(TOPDIR)/.ccache)
68 endif
69
70 ifndef DUMP_TARGET_DB
71 $(BUILD_DIR)/.prepared: Makefile
72 @mkdir -p $$(dirname $@)
73 @touch $@
74
75 tmp/.prereq_packages: .config
76 unset ERROR; \
77 for package in $(sort $(prereq-y) $(prereq-m)); do \
78 $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
79 done; \
80 if [ -n "$$ERROR" ]; then \
81 echo "Package prerequisite check failed."; \
82 false; \
83 fi
84 touch $@
85 endif
86
87 # check prerequisites before starting to build
88 prereq: $(target/stamp-prereq) tmp/.prereq_packages
89 @if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
90 echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \
91 echo ' The missing file will cause configure scripts to fail during compilation.'; \
92 echo ' Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
93 exit 1; \
94 fi
95
96 $(BIN_DIR)/profiles.json: FORCE
97 $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \
98 WORK_DIR=$(BUILD_DIR)/json_info_files \
99 $(SCRIPT_DIR)/json_overview_image_info.py $@ \
100 )
101
102 json_overview_image_info: $(BIN_DIR)/profiles.json
103
104 checksum: FORCE
105 $(call sha256sums,$(BIN_DIR),$(CONFIG_BUILDBOT))
106
107 buildversion: FORCE
108 $(SCRIPT_DIR)/getver.sh > $(BIN_DIR)/version.buildinfo
109
110 feedsversion: FORCE
111 $(SCRIPT_DIR)/feeds list -fs > $(BIN_DIR)/feeds.buildinfo
112
113 diffconfig: FORCE
114 mkdir -p $(BIN_DIR)
115 $(SCRIPT_DIR)/diffconfig.sh > $(BIN_DIR)/config.buildinfo
116
117 buildinfo: FORCE
118 $(_SINGLE)$(SUBMAKE) -r diffconfig buildversion feedsversion
119
120 prepare: .config $(tools/stamp-compile) $(toolchain/stamp-compile)
121 $(_SINGLE)$(SUBMAKE) -r buildinfo
122
123 world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
124 $(_SINGLE)$(SUBMAKE) -r package/index
125 $(_SINGLE)$(SUBMAKE) -r json_overview_image_info
126 $(_SINGLE)$(SUBMAKE) -r checksum
127 ifneq ($(CONFIG_CCACHE),)
128 $(STAGING_DIR_HOST)/bin/ccache -s
129 endif
130
131 .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
132
133 endif