Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Jul 3, 2024
1 parent b0eb4ec commit f25c824
Show file tree
Hide file tree
Showing 437 changed files with 3,541 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true

[*.json]
indent_size = 2

[*.jsonc]
indent_size = 2

[*.vsconfig]
indent_size = 2

[*.yaml]
indent_size = 2

[*.yml]
indent_size = 2
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text
*.verified.* text eol=lf
*.ico binary
*.pdf binary
*.png binary
*.zig eol=lf
*.zon eol=lf
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @vezel-dev/graf-maintainers
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# yaml-language-server: $schema=https://json.schemastore.org/dependabot-2.0.json
version: 2
updates:
- package-ecosystem: nuget
directories:
- /
schedule:
interval: daily
timezone: Europe/Copenhagen
time: "12:00"
open-pull-requests-limit: 25
labels: []
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/out
24 changes: 24 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[submodule "pkg/binutils-gdb"]
path = pkg/binutils-gdb
url = https://sourceware.org/git/binutils-gdb.git
shallow = true
[submodule "pkg/gcc"]
path = pkg/gcc
url = https://gcc.gnu.org/git/gcc.git
shallow = true
[submodule "pkg/glibc"]
path = pkg/glibc
url = https://sourceware.org/git/glibc.git
shallow = true
[submodule "pkg/linux"]
path = pkg/linux
url = https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
shallow = true
[submodule "pkg/musl"]
path = pkg/musl
url = git://git.musl-libc.org/musl
shallow = true
[submodule "pkg/newlib-cygwin"]
path = pkg/newlib-cygwin
url = https://sourceware.org/git/newlib-cygwin.git
shallow = true
95 changes: 95 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json",
"default": true,
"MD001": true,
"MD003": {
"style": "atx"
},
"MD004": {
"style": "asterisk"
},
"MD005": true,
"MD007": {
"start_indented": false,
"start_indent": 4,
"indent": 4
},
"MD009": {
"br_spaces": 0,
"strict": true
},
"MD010": {
"spaces_per_tab": 4
},
"MD011": true,
"MD012": true,
"MD013": {
"code_blocks": false,
"headings": false,
"tables": false
},
"MD014": true,
"MD018": true,
"MD019": true,
"MD020": true,
"MD021": true,
"MD022": true,
"MD023": true,
"MD024": true,
"MD025": true,
"MD026": {
"punctuation": "!,.:;?"
},
"MD027": true,
"MD028": true,
"MD029": {
"style": "ordered"
},
"MD030": true,
"MD031": true,
"MD032": true,
"MD033": {
"allowed_elements": [
"div",
"img",
"p",
"strong"
]
},
"MD034": true,
"MD035": {
"style": "--------------------------------------------------------------------------------"
},
"MD036": {
"punctuation": "!,.:;?"
},
"MD037": true,
"MD038": true,
"MD039": true,
"MD040": {
"language_only": true
},
"MD041": true,
"MD042": true,
"MD043": false,
"MD044": true,
"MD045": true,
"MD046": {
"style": "fenced"
},
"MD047": true,
"MD048": {
"style": "backtick"
},
"MD049": {
"style": "asterisk"
},
"MD050": {
"style": "asterisk"
},
"MD051": true,
"MD052": true,
"MD053": {
"ignored_definitions": []
}
}
20 changes: 20 additions & 0 deletions .netconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[file ".editorconfig"]
url = https://github.com/vezel-dev/.github/blob/master/syn/.editorconfig
sha = 25cfbb6a508a9fcf8444ef283ddfe7b2e5121bca
etag = df90691e6bc4d301e82e508fca55eed234028a335c3615cf916db00cb4a053f1
weak
[file ".gitattributes"]
url = https://github.com/vezel-dev/.github/blob/master/syn/.gitattributes
sha = 0ff05334db6d820dd16428e1aad477ed83ca10ef
etag = 0a6a1f6373760bc1c03e09e1efeeb77109705f11b159afd759e11550b45ee950
weak
[file ".markdownlint.json"]
url = https://github.com/vezel-dev/.github/blob/master/syn/.markdownlint.json
sha = 7d581ae5eedad5892855cebc673edafad664856b
etag = cf98ac95cf318b52e206b9003e342de9db2ecb7be062eab6edf1681b1f374b3a
weak
[file "LICENSE-0BSD"]
url = https://github.com/vezel-dev/.github/blob/master/syn/LICENSE-0BSD
sha = 7d581ae5eedad5892855cebc673edafad664856b
etag = 4fe195e9c11a20688615d92035ac752eeac4ab3f3d82b20df798ea6dc1b49aab
weak
12 changes: 12 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"recommendations": [
"chdsbd.github-code-owners",
"codezombiech.gitignore",
"davidanson.vscode-markdownlint",
"editorconfig.editorconfig",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"redhat.vscode-yaml",
"yy0931.gitconfig-lsp"
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.exclude": {
"out": true
}
}
40 changes: 40 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SPDX-License-Identifier: 0BSD

include bld/common.mk

packages = $(sort $(foreach package,$(wildcard pkg/*),$(notdir $(package))))
targets = $(sort $(foreach target,$(wildcard tgt/*.mk),$(basename $(notdir $(target)))))

.PHONY: list
list:
> $(Q)echo "Supported targets:"
> $(Q)echo
> $(Q)for target in $(targets); do echo " $$target"; done
> $(Q)echo
> $(Q)echo "Run 'make <target> PREFIX=...' to build and install a toolchain."

# $(1) = target
define build_toolchain
.PHONY: $(1)
$(1):
> $(Q)$(MAKE) clean
> $(Q)$(MAKE) -C tgt -f $(1).mk -I ../bld
endef

$(foreach target,$(targets),$(eval $(call build_toolchain,$(target))))

.PHONY: all
all: $(targets)

# $(1) = package
define clean_package
.PHONY: clean-$(1)
clean-$(1):
> $(Q)echo "Cleaning $(1)..."
> $(Q)cd pkg/$(1) && $(RM) -f -r build
endef

$(foreach package,$(packages),$(eval $(call clean_package,$(package))))

.PHONY: clean
clean: $(foreach package,$(packages),clean-$(package))
12 changes: 12 additions & 0 deletions LICENSE-0BSD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
BSD Zero Clause License (0BSD)

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Kruco

This is a makefile that simplifies the creation of [GCC](https://gcc.gnu.org)
cross-toolchains for a wide variety of target platforms.

The toolchains produced by this makefile are *probably* not appropriate for
building production software. The point of this makefile is just to be able to
type a single command and have a toolchain that is useful for development and
testing purposes in less than 15 minutes.

## Caveats

* This makefile is only tested regularly on modern Linux machines. It *might*
work in other Unix-like environments, but we make no promises.
* The versions for Linux kernel headers, [glibc](https://sourceware.org/glibc),
and [musl](https://musl.libc.org) are generally pinned to whatever the latest
release of [Zig](https://ziglang.org) supports.
* You need to install various build prerequisites yourself, including some
libraries. The build is done in this way to reduce the size of the generated
toolchains.

## Usage

In a nutshell, usage is as follows:

1. Clone this repository.
2. Run `make list` to get a list of supported targets.
3. Run `make <target> PREFIX=...` to build and install a toolchain.
4. Run `make clean` to remove leftover build artifacts.

For example, `make arm-linux-gnueabi PREFIX=$HOME/cross` will install a
toolchain targeting Linux and glibc under `$HOME/cross/arm-linux-gnueabi` with a
sysroot under `$HOME/cross/arm-linux-gnueabi/sysroot`.

If you need to use your computer as an expensive space heater and/or you have a
burning hatred for your CPU and disk drive, you can run `make all` to build a
toolchain for every single supported target. That is 400+ toolchains, just to be
clear. You probably should not do that. But you *can*.

## Configuration

The following variables affect the makefile:

* `PREFIX`: The location to install the built toolchain in. Note that the
toolchain will actually be installed under `$PREFIX/<target>`. Defaults to the
`out` directory in the root of the repository.
* `BUILD`: The platform that you are building the toolchain on. This defaults to
`x86_64-cross-linux-gnu`. The `cross` vendor component is crucial here, as it
forces Autotools to run in cross-compilation mode. You only need to set this
if you are building on a different platform, e.g. `aarch64-cross-linux-gnu`.
* `JOBS`: The maximum number of concurrent jobs that will be used while building
each software package. Defaults to the output of `nproc`, i.e. as many jobs as
you have CPU cores.
* `V`: Can be set to any value to get verbose output from the makefile.

## License

The build system is licensed under the terms found in
[`LICENSE-0BSD`](LICENSE-0BSD). Each software package that is built has its own
license terms.
32 changes: 32 additions & 0 deletions bld/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-License-Identifier: 0BSD

# Disable some slow and/or unhelpful features.
MAKEFLAGS += -R -r --warn-undefined-variables

# Avoid shell portability issues.
SHELL = bash
.SHELLFLAGS = -e -o pipefail -u -c

# Avoid the need for tabs.
.RECIPEPREFIX = >

# We parallelize package builds, but our makefiles should be serial.
.NOTPARALLEL:

# Tools used throughout our makefiles.
FIND ?= find
MKDIR ?= mkdir
NPROC ?= nproc
RM ?= rm
SED ?= sed
XARGS ?= xargs

# How many jobs should we use in package builds?
JOBS ?= $(shell $(NPROC))

# Only echo commands if requested by the user with the V variable.
ifdef V
Q =
else
Q = @
endif
4 changes: 4 additions & 0 deletions bld/kernel/freestanding.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: 0BSD

# Nothing to do.
build-kernel:
8 changes: 8 additions & 0 deletions bld/kernel/linux.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: 0BSD

build-kernel:
> $(Q)$(call cd_pkg,linux) && $(RM) -f -r build
> $(Q)$(call cd_pkg,linux) && $(make_j) headers_install \
O=build \
ARCH=$(arch) \
INSTALL_HDR_PATH=$(sysroot)/usr
Loading

0 comments on commit f25c824

Please sign in to comment.