lldpd: fix reload bug: advertisements shall default to on
[openwrt/openwrt.git] / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2007 OpenWrt.org
4
5 TOPDIR:=${CURDIR}
6 LC_ALL:=C
7 LANG:=C
8 TZ:=UTC
9 export TOPDIR LC_ALL LANG TZ
10
11 empty:=
12 space:= $(empty) $(empty)
13 $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt directory must not include any spaces))
14
15 world:
16
17 DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep -e '/usr' -e '/nix/store' -m 1)
18
19 export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
20 export PATH:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host/bin),$(TOPDIR)/staging_dir/host/bin):$(PATH)
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 CDPATH=
30 export CDPATH
31 include $(TOPDIR)/include/debug.mk
32 include $(TOPDIR)/include/depends.mk
33 include $(TOPDIR)/include/toplevel.mk
34 else
35 include rules.mk
36 include $(INCLUDE_DIR)/depends.mk
37 include $(INCLUDE_DIR)/subdir.mk
38 include target/Makefile
39 include package/Makefile
40 include tools/Makefile
41 include toolchain/Makefile
42
43 $(toolchain/stamp-compile): $(tools/stamp-compile) $(if $(CONFIG_BUILDBOT),toolchain_rebuild_check)
44 $(target/stamp-compile): $(toolchain/stamp-compile) $(tools/stamp-compile) $(BUILD_DIR)/.prepared
45 $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
46 $(package/stamp-install): $(package/stamp-compile)
47 $(target/stamp-install): $(package/stamp-compile) $(package/stamp-install)
48 check: $(tools/stamp-check) $(toolchain/stamp-check) $(package/stamp-check)
49
50 printdb:
51 @true
52
53 prepare: $(target/stamp-compile)
54
55 _clean: FORCE
56 rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(TOPDIR)/staging_dir/packages
57
58 clean: _clean
59 rm -rf $(BUILD_LOG_DIR)
60
61 targetclean: _clean
62 rm -rf $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN)
63
64 dirclean: targetclean clean
65 rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(BUILD_DIR_BASE)/host
66 rm -rf $(TMP_DIR)
67 $(MAKE) -C $(TOPDIR)/scripts/config clean
68
69 toolchain_rebuild_check:
70 $(SCRIPT_DIR)/check-toolchain-clean.sh
71
72 cacheclean:
73 ifneq ($(CONFIG_CCACHE),)
74 $(STAGING_DIR_HOST)/bin/ccache -C
75 endif
76
77 ifndef DUMP_TARGET_DB
78 $(BUILD_DIR)/.prepared: Makefile
79 @mkdir -p $$(dirname $@)
80 @touch $@
81
82 tmp/.prereq_packages: .config
83 unset ERROR; \
84 for package in $(sort $(prereq-y) $(prereq-m)); do \
85 $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
86 done; \
87 if [ -n "$$ERROR" ]; then \
88 echo "Package prerequisite check failed."; \
89 false; \
90 fi
91 touch $@
92 endif
93
94 # check prerequisites before starting to build
95 prereq: $(target/stamp-prereq) tmp/.prereq_packages
96 @if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
97 echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \
98 echo ' The missing file will cause configure scripts to fail during compilation.'; \
99 echo ' Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
100 exit 1; \
101 fi
102
103 $(BIN_DIR)/profiles.json: FORCE
104 $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \
105 WORK_DIR=$(BUILD_DIR)/json_info_files \
106 $(SCRIPT_DIR)/json_overview_image_info.py $@ \
107 )
108
109 json_overview_image_info: $(BIN_DIR)/profiles.json
110
111 checksum: FORCE
112 $(call sha256sums,$(BIN_DIR),$(CONFIG_BUILDBOT))
113
114 buildversion: FORCE
115 $(SCRIPT_DIR)/getver.sh > $(BIN_DIR)/version.buildinfo
116
117 feedsversion: FORCE
118 $(SCRIPT_DIR)/feeds list -fs > $(BIN_DIR)/feeds.buildinfo
119
120 diffconfig: FORCE
121 mkdir -p $(BIN_DIR)
122 $(SCRIPT_DIR)/diffconfig.sh > $(BIN_DIR)/config.buildinfo
123
124 buildinfo: FORCE
125 $(_SINGLE)$(SUBMAKE) -r diffconfig buildversion feedsversion
126
127 prepare: .config $(tools/stamp-compile) $(toolchain/stamp-compile)
128 $(_SINGLE)$(SUBMAKE) -r buildinfo
129
130 world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
131 $(_SINGLE)$(SUBMAKE) -r package/index
132 $(_SINGLE)$(SUBMAKE) -r json_overview_image_info
133 $(_SINGLE)$(SUBMAKE) -r checksum
134 ifneq ($(CONFIG_CCACHE),)
135 $(STAGING_DIR_HOST)/bin/ccache -s
136 endif
137
138 .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
139
140 endif