Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 14:35:53 +02:00
commit c06fb25d1f
9263 changed files with 1750214 additions and 0 deletions

17
target/sdk/Config.in Normal file
View File

@@ -0,0 +1,17 @@
config SDK
bool "Build the OpenWrt SDK"
depends on !EXTERNAL_TOOLCHAIN
default BUILDBOT
help
This is essentially a stripped-down version of the buildroot
with a precompiled toolchain. It can be used to develop and
test packages for OpenWrt before including them in the buildroot
config SDK_LLVM_BPF
bool "Build the LLVM-BPF toolchain tarball"
depends on BPF_TOOLCHAIN_BUILD_LLVM
default BUILDBOT
help
This is a tarball of the precompiled LLVM toolchain suitable
for unpacking into the buildroot/SDK. It is used to build packages
that ship with eBPF kernel modules

200
target/sdk/Makefile Normal file
View File

@@ -0,0 +1,200 @@
#
# Copyright (C) 2006-2014 OpenWrt.org
# Copyright (C) 2016 LEDE Project
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk
include $(INCLUDE_DIR)/download.mk
override MAKEFLAGS=
SDK_NAME:=$(VERSION_DIST_SANITIZED)-sdk-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))$(if $(GCCV),_gcc-$(GCCV))$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH)
SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME)
STAGING_SUBDIR_HOST := staging_dir/host
STAGING_SUBDIR_TARGET := staging_dir/$(TARGET_DIR_NAME)
STAGING_SUBDIR_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)$(if $(CONFIG_arm),_eabi)
BUNDLER_PATH := $(subst $(space),:,$(filter-out $(TOPDIR)/%,$(subst :,$(space),$(PATH))))
BUNDLER_COMMAND := PATH=$(BUNDLER_PATH) $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)
EXCLUDE_DIRS:= \
*/stamp \
*/stampfiles \
*/man \
*/info \
*/root-* \
*.install.clean \
*.install.flags \
*.install \
*/share/locale
SDK_DIRS = \
$(STAGING_SUBDIR_HOST) \
$(STAGING_SUBDIR_TOOLCHAIN)
GIT_URL:=$(shell git config --get remote.origin.url 2>/dev/null)
GIT_URL:=$(if $(CONFIG_BUILDBOT),$(filter git://% http://% https://%,$(GIT_URL)),$(GIT_URL))
GIT_COMMIT:=$(shell git rev-parse HEAD 2>/dev/null)
GIT_BRANCH:=$(filter-out master HEAD,$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null))
GIT_TAGNAME:=$(shell git show-ref --tags --dereference 2>/dev/null | sed -ne '/^$(GIT_COMMIT) / { s|^.*/||; s|\^.*||; p }')
BASE_FEED:=$(if $(GIT_URL),src-git-full base $(GIT_URL)$(if $(GIT_BRANCH),;$(GIT_BRANCH),$(if $(GIT_TAGNAME),;$(GIT_TAGNAME))))
BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C git svn info 2>/dev/null | sed -ne 's/^URL: /src-gitsvn base /p'))
BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C svn info 2>/dev/null | sed -ne 's/^URL: /src-svn base /p'))
BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git-full base $(PROJECT_GIT)/openwrt/openwrt.git$(if $(GIT_BRANCH),;$(GIT_BRANCH),$(if $(GIT_TAGNAME),;$(GIT_TAGNAME))))
KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
KDIR_ARCHES = $(LINUX_KARCH)
# arch/arm64/ includes reference files in arch/arm/, so we'll need both
ifeq ($(LINUX_KARCH),arm64)
KDIR_ARCHES += arm
endif
KERNEL_FILES_ARCH = \
Makefile* \
module.lds \
Kbuild.platforms \
*/Platform \
include \
*/include \
scripts \
kernel/asm-offsets.s \
kernel/module.lds
ifeq ($(LINUX_KARCH),powerpc)
KERNEL_FILES_ARCH += lib/crtsavres.o
endif
KERNEL_FILES_BASE := \
.config \
Makefile \
scripts \
tools/objtool \
include \
Module.symvers \
modules.builtin \
$(foreach arch,$(KDIR_ARCHES),$(addprefix arch/$(arch)/,$(KERNEL_FILES_ARCH)))
KERNEL_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(KERNEL_FILES_BASE))))
# The kernel source hosts various userspace utilities sources.
# These are packaged separately from the kernel and kernel modules.
# The source has to be included here to be buildable by the SDK.
#
USERSPACE_UTILS_FILES := \
tools/build \
tools/leds \
tools/power/cpupower \
tools/scripts \
tools/spi \
tools/thermal/tmon \
tools/usb/usbip
USERSPACE_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(USERSPACE_UTILS_FILES))))
all: compile
$(BIN_DIR)/$(SDK_NAME).tar.zst: clean
mkdir -p \
$(SDK_BUILD_DIR)/dl \
$(SDK_BUILD_DIR)/package \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TARGET)/include \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TARGET)/usr/include
$(CP) -L $(INCLUDE_DIR) $(SCRIPT_DIR) $(SDK_BUILD_DIR)/
$(TAR) -cf - -C $(TOPDIR) \
`cd $(TOPDIR); find $(KDIR_BASE)/ -name \*.ko` \
`cd $(TOPDIR); find $(KDIR_BASE)/firmware/ -newer $(KDIR_BASE)/firmware/Makefile \
-type f -name '*.bin' -or -name '*.cis' -or -name '*.csp' -or -name '*.dsp' -or -name '*.fw'` \
$(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
$(SDK_DIRS) $(KERNEL_FILES) | \
$(TAR) -xf - -C $(SDK_BUILD_DIR)
$(TAR) -cf - -C $(TOPDIR) $(USERSPACE_FILES) | \
$(TAR) -xf - -C $(SDK_BUILD_DIR)
(cd $(SDK_BUILD_DIR); find $(STAGING_SUBDIR_HOST)/bin $(STAGING_SUBDIR_HOST)/usr/bin \
$(STAGING_SUBDIR_HOST)/llvm-bpf/bin $(STAGING_SUBDIR_HOST)/llvm-bpf/libexec \
$(STAGING_SUBDIR_TOOLCHAIN)/bin $(STAGING_SUBDIR_TOOLCHAIN)/*/bin $(STAGING_SUBDIR_TOOLCHAIN)/libexec \
$(KDIR_BASE) \
-type f | $(BUNDLER_COMMAND))
@-( \
find \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/llvm-bpf/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/llvm-bpf/libexec \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \
-type f; \
find \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/llvm-bpf/lib \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
-type f -name \*.so\*; \
) | xargs strip 2>/dev/null >/dev/null
mkdir -p $(SDK_BUILD_DIR)/target/linux
$(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/
rm -rf \
$(SDK_BUILD_DIR)/target/linux/*/files* \
$(SDK_BUILD_DIR)/target/linux/*/patches*
./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
$(CP) -L \
$(TOPDIR)/LICENSES \
$(TOPDIR)/COPYING \
$(TOPDIR)/rules.mk \
./files/Config.in \
./files/Makefile \
./files/include/prepare.mk \
./files/README.md \
$(SDK_BUILD_DIR)/
mkdir -p $(SDK_BUILD_DIR)/package/kernel
$(CP) \
$(TOPDIR)/package/Makefile \
$(TOPDIR)/package/libs/toolchain \
$(SDK_BUILD_DIR)/package/
$(CP) \
$(TOPDIR)/package/kernel/linux \
$(SDK_BUILD_DIR)/package/kernel/
-rm -rf $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/.prereq-build
-rm -rf $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/doc
-rm -rf $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/share/doc
-rm -f $(SDK_BUILD_DIR)/feeds.conf.default
$(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
if [ -f $(TOPDIR)/feeds.conf ]; then \
cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \
else \
cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \
fi
$(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
$(SED) 's,^# SOURCE_DATE_EPOCH:=.*,SOURCE_DATE_EPOCH:=$(SOURCE_DATE_EPOCH),g' $(SDK_BUILD_DIR)/include/version.mk
$(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
-make -C $(SDK_BUILD_DIR)/scripts/config clean
(cd $(BUILD_DIR); \
tar -I '$(STAGING_DIR_HOST)/bin/zstd -T0 --ultra -20' -cf $@ $(SDK_NAME) \
--mtime="$(shell date --date=@$(SOURCE_DATE_EPOCH))"; \
)
download:
prepare:
compile: $(BIN_DIR)/$(SDK_NAME).tar.zst
install: compile
clean:
rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.zst

65
target/sdk/convert-config.pl Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env perl
use strict;
while (<>) {
my $match;
my $var;
my $val;
my $type;
chomp;
next if /^CONFIG_SIGNED_PACKAGES/;
if (/^CONFIG_((BINARY)|(DOWNLOAD))_FOLDER=(.*)$/) {
# We don't want to preserve the build setting of
# BINARY_FOLDER and DOWNLOAD_FOLDER.
$var = "$1_FOLDER";
$val = '""';
$type = "string";
} elsif (/^CONFIG_([^=]+)=(.*)$/) {
$var = $1;
$val = $2;
next if $var eq 'ALL';
if ($val eq 'y') {
$type = "bool";
} elsif ($val eq 'm') {
$type = "tristate";
} elsif ($val =~ /^".*"$/) {
$type = "string";
} elsif ($val =~ /^\d+$/) {
$type = "int";
} else {
warn "WARNING: no type found for symbol CONFIG_$var=$val\n";
next;
}
} elsif (/^# CONFIG_BUSYBOX_(.*) is not set/) {
$var = "BUSYBOX_$1";
$val = 'n';
$type = "bool";
} else {
# We don't want to preserve a record of deselecting
# packages because we may want build them in the SDK.
# non-package configs however may be important to preserve
# the same compilation settings for packages that get
# recompiled in the SDK.
# Also we want avoid preserving image generation settings
# because we set those while in ImageBuilder
next if /^(# )?CONFIG_PACKAGE/;
next if /^(# )?CONFIG_TARGET/;
if (/^# CONFIG_(.*) is not set/) {
$var = $1;
$val = 'n';
$type = "bool";
}
}
if (($var ne '') && ($type ne '') && ($val ne '')) {
print <<EOF;
config $var
$type
default $val
EOF
}
}

154
target/sdk/files/Config.in Normal file
View File

@@ -0,0 +1,154 @@
mainmenu "OpenWrt Configuration"
menu "Global build settings"
config ALL_NONSHARED
bool "Select all target specific packages by default"
default ALL
config ALL_KMODS
bool "Select all kernel module packages by default"
default ALL
config ALL
bool "Select all userspace packages by default"
default y
config SIGNED_PACKAGES
bool "Cryptographically sign package lists"
default y
comment "General build options"
config BUILD_PATENTED
default n
bool "Compile with support for patented functionality"
help
When this option is disabled, software which provides patented functionality
will not be built. In case software provides optional support for patented
functionality, this optional support will get disabled for this package.
config BUILD_NLS
default n
bool "Compile with full language support"
help
When this option is enabled, packages are built with the full versions of
iconv and GNU gettext instead of the default OpenWrt stubs.
comment "Package build options"
config DEBUG
bool
prompt "Compile packages with debugging info"
help
Adds -g3 to the CFLAGS.
comment "Stripping options"
choice
prompt "Binary stripping method"
default USE_STRIP if USE_GLIBC
default USE_SSTRIP
help
Select the binary stripping method you wish to use.
config NO_STRIP
bool "none"
help
This will install unstripped binaries (useful for native
compiling/debugging).
config USE_STRIP
bool "strip"
help
This will install binaries stripped using strip from binutils.
config USE_SSTRIP
bool "sstrip"
depends on !USE_GLIBC
help
This will install binaries stripped using sstrip.
endchoice
config STRIP_ARGS
string
prompt "Strip arguments"
depends on USE_STRIP
default "--strip-unneeded --remove-section=.comment --remove-section=.note" if DEBUG
default "--strip-all"
help
Specifies arguments passed to the strip command when stripping binaries.
endmenu
menu "Advanced configuration options (for developers)"
config BROKEN
bool "Show broken packages"
config DOWNLOAD_FOLDER
string "Download folder"
default ""
help
Store downloaded source bundles in this directory.
If not set then defaults to './dl', which is removed by operations such as
'git clean -xdf' or 'make distclean'.
This option is useful if you have a low bandwidth Internet connection, and by
setting a path outside the OpenWrt tree downloads will be saved.
config LOCALMIRROR
string "Local mirror for source packages"
default ""
config AUTOREBUILD
bool "Automatic rebuild of packages"
default y
help
Automatically rebuild packages when their files change.
config AUTOREMOVE
bool "Automatic removal of build directories"
default y
help
Automatically delete build directories after make target completed.
This allows you to symlink build_dir into a scratch location, e.g. a ramdisk,
which does not have enough space to keep a complete build_dir.
config CCACHE
bool "Use ccache"
help
Compiler cache; see https://ccache.samba.org/
config CCACHE_DIR
string "Set ccache directory" if CCACHE
default ""
help
Store ccache in this directory.
If not set, uses './.ccache'
config BUILD_LOG
bool "Enable log files during build process"
help
If enabled, log files will be written to the ./log directory.
config SRC_TREE_OVERRIDE
bool "Enable package source tree override"
help
If enabled, you can force a package to use a git tree as source
code instead of the normal tarball. Create a symlink 'git-src'
in the package directory, pointing to the .git tree that you want
to pull the source code from.
endmenu
config IN_SDK
default y
bool
config MODULES
bool
default y
modules
source "Config-build.in"
source "tmp/.config-package.in"

62
target/sdk/files/Makefile Normal file
View File

@@ -0,0 +1,62 @@
# Makefile for OpenWrt
#
# Copyright (C) 2007-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
TOPDIR:=${CURDIR}
LC_ALL:=C
LANG:=C
SDK:=1
export TOPDIR LC_ALL LANG SDK
world:
DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1)
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
ifneq ($(OPENWRT_BUILD),1)
override OPENWRT_BUILD=1
export OPENWRT_BUILD
empty:=
space:= $(empty) $(empty)
_SINGLE=export MAKEFLAGS=$(space);
include $(TOPDIR)/include/debug.mk
include $(TOPDIR)/include/depends.mk
include $(TOPDIR)/include/toplevel.mk
else
include rules.mk
include $(INCLUDE_DIR)/depends.mk
include $(INCLUDE_DIR)/subdir.mk
include package/Makefile
$(package/stamp-compile): $(BUILD_DIR)/.prepared
$(BUILD_DIR)/.prepared: Makefile
@mkdir -p $$(dirname $@)
@touch $@
clean: FORCE
git clean -f -d $(STAGING_DIR); true
git clean -f -d $(BUILD_DIR); true
git clean -f -d $(BIN_DIR); true
dirclean: clean
git reset --hard HEAD
git clean -f -d
rm -rf feeds/
# check prerequisites before starting to build
prereq: $(package/stamp-prereq) ;
world: prepare $(package/stamp-compile) FORCE
@$(MAKE) package/index
.PHONY: clean dirclean prereq prepare world
endif

View File

@@ -0,0 +1,11 @@
This is the OpenWrt SDK. It contains a stripped-down version of
the buildroot. You can use it to test/develop packages without
having to compile your own toolchain or any of the libraries
included with OpenWrt.
To use it, just put your buildroot-compatible package directory
(including its dependencies) in the subdir 'package/' and run
'make' from this directory.
To make dependency handling easier, you can use ./scripts/feeds
to install any core package that you need

View File

@@ -0,0 +1,17 @@
#
# Copyright (C) 2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
prepare: .git/config
.git/config:
@( \
printf "Initializing SDK ... "; \
git init -q .; \
find . -mindepth 1 -maxdepth 1 -not -name feeds | xargs git add; \
git commit -q -m "Initial state"; \
echo "ok."; \
)