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