1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2007 OpenWrt.org
9 export TOPDIR LC_ALL LANG TZ
12 space
:= $(empty
) $(empty
)
13 $(if
$(findstring $(space
),$(TOPDIR
)),$(error ERROR
: The path to the OpenWrt directory must not
include any spaces
))
17 DISTRO_PKG_CONFIG
:=$(shell which
-a pkg-config | grep
-E
'\/usr' | head
-n
1)
18 export PATH
:=$(TOPDIR
)/staging_dir
/host
/bin
:$(PATH
)
20 ifneq ($(OPENWRT_BUILD
),1)
21 _SINGLE
=export MAKEFLAGS
=$(space
);
23 override OPENWRT_BUILD
=1
29 include $(TOPDIR
)/include/debug.mk
30 include $(TOPDIR
)/include/depends.mk
31 include $(TOPDIR
)/include/toplevel.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
41 $(toolchain
/stamp-compile
): $(tools
/stamp-compile
)
42 $(target
/stamp-compile
): $(toolchain
/stamp-compile
) $(tools
/stamp-compile
) $(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 check: $(tools
/stamp-check
) $(toolchain
/stamp-check
) $(package
/stamp-check
)
51 prepare
: $(target
/stamp-compile
)
54 rm -rf
$(BUILD_DIR
) $(STAGING_DIR
) $(BIN_DIR
) $(OUTPUT_DIR
)/packages
/$(ARCH_PACKAGES
) $(BUILD_LOG_DIR
) $(TOPDIR
)/staging_dir
/packages
57 rm -rf
$(STAGING_DIR_HOST
) $(STAGING_DIR_HOSTPKG
) $(TOOLCHAIN_DIR
) $(BUILD_DIR_BASE
)/host
$(BUILD_DIR_BASE
)/hostpkg
$(BUILD_DIR_TOOLCHAIN
)
59 $(MAKE
) -C
$(TOPDIR
)/scripts
/config
clean
62 ifneq ($(CONFIG_CCACHE
),)
63 $(STAGING_DIR_HOST
)/bin
/ccache
-C
67 $(BUILD_DIR
)/.prepared
: Makefile
68 @mkdir
-p
$$(dirname
$@
)
71 tmp
/.prereq_packages
: .config
73 for package in
$(sort $(prereq-y
) $(prereq-m
)); do \
74 $(_SINGLE
)$(NO_TRACE_MAKE
) -s
-r
-C package
/$$package prereq || ERROR
=1; \
76 if
[ -n
"$$ERROR" ]; then \
77 echo
"Package prerequisite check failed."; \
83 # check prerequisites before starting to build
84 prereq
: $(target
/stamp-prereq
) tmp
/.prereq_packages
85 @if
[ ! -f
"$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
86 echo
'ERROR: Missing site config for architecture "$(ARCH)" !'; \
87 echo
' The missing file will cause configure scripts to fail during compilation.'; \
88 echo
' Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
92 $(BIN_DIR
)/profiles.json
: FORCE
93 $(if
$(CONFIG_JSON_OVERVIEW_IMAGE_INFO
), \
94 WORK_DIR
=$(BUILD_DIR
)/json_info_files \
95 $(SCRIPT_DIR
)/json_overview_image_info.py
$@ \
98 json_overview_image_info
: $(BIN_DIR
)/profiles.json
101 $(call sha256sums
,$(BIN_DIR
),$(CONFIG_BUILDBOT
))
104 $(SCRIPT_DIR
)/getver.sh
> $(BIN_DIR
)/version.buildinfo
107 $(SCRIPT_DIR
)/feeds list
-fs
> $(BIN_DIR
)/feeds.buildinfo
111 $(SCRIPT_DIR
)/diffconfig.sh
> $(BIN_DIR
)/config.buildinfo
114 $(_SINGLE
)$(SUBMAKE
) -r diffconfig buildversion feedsversion
116 prepare
: .config
$(tools
/stamp-compile
) $(toolchain
/stamp-compile
)
117 $(_SINGLE
)$(SUBMAKE
) -r buildinfo
119 world
: prepare
$(target
/stamp-compile
) $(package
/stamp-compile
) $(package
/stamp-install
) $(target
/stamp-install
) FORCE
120 $(_SINGLE
)$(SUBMAKE
) -r package
/index
121 $(_SINGLE
)$(SUBMAKE
) -r json_overview_image_info
122 $(_SINGLE
)$(SUBMAKE
) -r checksum
123 ifneq ($(CONFIG_CCACHE
),)
124 $(STAGING_DIR_HOST
)/bin
/ccache
-s
127 .PHONY
: clean dirclean prereq prepare world package
/symlinks package
/symlinks-install package
/symlinks-clean