Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
29dcc16
Fixed some issues with readability and parallel builds
dulstack May 29, 2026
3d87a56
Added variables for package configuration
dulstack May 29, 2026
052e95a
Added a sample package
dulstack May 29, 2026
933d607
modified: build/.package_sample.mk
dulstack May 29, 2026
f59b853
Enabled curses for bash
dulstack May 29, 2026
091c0fd
Added ncurses
dulstack May 29, 2026
4bfd0c3
Fixed issues with missing symlink
dulstack May 29, 2026
601f043
Modified configuration flags
dulstack May 29, 2026
17f8112
Added script to build the host toolchain
dulstack May 30, 2026
c7c49f2
Added configuration flags for tools
dulstack May 30, 2026
0d994cb
Fixed the target naming issues
dulstack May 30, 2026
366f7a3
Fixed problems with parallelism
dulstack May 30, 2026
f1a7966
Made sample package simpler to use
dulstack May 30, 2026
15d0215
Added gcc
dulstack Jun 1, 2026
74a557c
Added common configuration flags for all packages
dulstack Jun 1, 2026
9cae152
Modified configuration flags
dulstack Jun 1, 2026
f26c0d7
Added missing target and forced serial build sequence for target
dulstack Jun 2, 2026
0f908b8
Modified configuration option and installation process
dulstack Jun 3, 2026
2fe2eaa
Disabled wide character suppport(so libtinfo.so.6 can be found)
dulstack Jun 3, 2026
eb1ee6e
Improved the sample package
dulstack Jun 3, 2026
0511139
modified: Makefile
dulstack Jun 3, 2026
ecc30f2
Fixed some mistakes
dulstack Jun 3, 2026
830b668
Added the required package libelf-dev
dulstack Jun 4, 2026
6b1c659
Add LDFLAGS
dulstack Jun 4, 2026
f7874d4
Modified configuration flags
dulstack Jun 5, 2026
8a5cb1c
Modified configuration flags
dulstack Jun 5, 2026
e2edf2a
Added xz
dulstack Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 38 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
# Quick and dirty Makefile for building Linux kernel
CPUS := $(shell nproc)
OUT ?= out

.PHONY: all download-all

all: $(OUT)/mnt download-all linux systemd symlink coreutils disk

download-all: download-linux download-systemd download-coreutils

include build/linux.mk
include build/systemd.mk
include build/coreutils.mk
include build/bash.mk

symlink:
cd $(OUT)/mnt;\
CPUS := $(shell nproc)
CFLAGS ?= -O2
CPPFLAGS ?= -I $(PWD)/$(ROOTFS)/usr/include
LD_FLAGS ?=
OUT ?= out
ROOTFS ?= $(OUT)/mnt
LDFLAGS += -L/$(PWD)/$(ROOTFS)/usr/lib
LDFLAGS += -L/$(PWD)/$(ROOTFS)/usr/lib/x86_64-linux-gnu
DOWNLOAD_DIR ?= $(OUT)/download
SUBMAKEFILES = $(wildcard build/*.mk)
PACKAGES = $(SUBMAKEFILES:build/%.mk=%)
DOWNLOAD_TARGETS = $(PACKAGES:%=download-%)
LIBRARY_PATH ?= $(PWD)/$(ROOTFS)/usr/lib:$(PWD)/$(ROOTFS)/usr/lib64:$(PWD)/$(ROOTFS)/usr/lib/x86_64-linux-gnu/
COMMON_CONFIG_FLAGS = LIBRARY_PATH="$(LIBRARY_PATH)" CXX=$(PWD)/$(TOOLS_ROOT)/bin/x86_64-linux-gnu-g++ CPP=$(PWD)/$(TOOLS_ROOT)/bin/x86_64-linux-gnu-cpp CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)"

.PHONY: all download-all disk symlink packages
.NOTPARALLEL: all download-all packages disk

all: $(ROOTFS) symlink download-all packages disk

download-all: $(DOWNLOAD_TARGETS) | $(ROOTFS)
packages: $(PACKAGES) | $(DOWNLOAD_TARGETS)

include $(SUBMAKEFILES)

symlink: $(ROOTFS)
cd $(ROOTFS);\
ln -sf usr/bin bin;\
ln -sf usr/sbin sbin;\
ln -sf usr/lib lib;\
ln -sf usr/lib64 lib64

RAMDISK = $(OUT)/initrd.cpio.gz

disk: $(RAMDISK)
disk: $(RAMDISK) | $(PACKAGES)

$(RAMDISK): $(OUT)/mnt
cd $(OUT)/mnt;\
$(RAMDISK): $(ROOTFS)
cd $(ROOTFS);\
fakeroot find . | fakeroot cpio -o -H newc | gzip > $(PWD)/$(RAMDISK)

run:
qemu-system-x86_64 \
-cpu host \
-kernel $(LINUX_BZIMAGE) \
-initrd $(RAMDISK) \
-append "rdinit=/bin/bash console=ttyS0 raid=noautodetect" \
-append "LD_LIBRARY_PATH="/lib:/lib64:/lib/x86_64-linux-gnu" rdinit=/bin/bash console=ttyS0 raid=noautodetect" \
-m 1G \
-serial stdio \
-display none \
--enable-kvm
$(OUT)/mnt:
mkdir -p $(OUT)/mnt/usr/lib64 $(OUT)/mnt/usr/lib/x86_64-linux-gnu\
$(OUT)/download
cd $(OUT)/mnt ;\
cp /lib64/ld-linux-x86-64.so.2 usr/lib64/;\
cp /lib/x86_64-linux-gnu/libc.so.6 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libm.so.6 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libcrypt.so.1 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libcrypto.so.3 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libz.so.1 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libzstd.so.1 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libselinux.so.1 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libcap.so.2 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libpcre2-8.so.0 usr/lib/x86_64-linux-gnu/;\
cp /lib/x86_64-linux-gnu/libtinfo.so.6 usr/lib/x86_64-linux-gnu/

$(ROOTFS):
mkdir -p $(ROOTFS)/usr/lib64 $(ROOTFS)/usr/lib/x86_64-linux-gnu\
$(ROOTFS)/usr/bin $(ROOTFS)/usr/sbin $(ROOTFS)/usr/lib\
$(ROOTFS)/usr/lib64 $(DOWNLOAD_DIR)
# Missing shared objects that should be added later:
# libz.so.1 libzstd.so.1

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Port of Celestial to Automated Linux From Scratch
## Building
------------------------------
These packages are needed to build the project: `meson fakeroot cpio ninja gperf bison flex diffutils wget make gcc` and python package `jinja2`.
These packages are needed to build the project: `meson fakeroot cpio ninja gperf bison flex diffutils libelf-dev wget make gcc gettext autoconf automake libtool autopoint` and python package `jinja2`. The required packages to build the compiler and binutils can be found in [https://wiki.osdev.org/GCC\_Cross-Compiler](https://wiki.osdev.org/GCC_Cross-Compiler)

To build, clone this repository and run `make`.
# Stay in touch with us! **[Join Our Discord](https://discord.gg/C6QVUKnJRq)** or **[Join our Matrix](https://matrix.to/#/#aclevo-general:matrix.org)**
47 changes: 47 additions & 0 deletions build/.package_sample.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Sample package. Can be copied with a different name to add a new package.
# After copying, replace everything here from 'package' to another package name.
# Modify the variables below this line. Targets "package" and
# "download-package" should match the file name of package, so repace every word
# FILENAME with the filename of current script


package_VERSION = 1.0
package_TARBALL = package-$(package_VERSION).tar.gz
package_URL = https://example.com/$(package_TARBALL)
package_DIR = package-$(package_VERSION)
package_CONFIG_FLAGS = $(COMMON_CONFIG_FLAGS) --prefix=/$(PWD)/$(ROOTFS)/usr

#Alias for target
.PHONY: package FILENAME download-FILENAME package-untar package-configure package-build package-install
package: FILENAME

FILENAME: download-FILENAME package-untar package-configure package-build package-install

download-FILENAME: $(OUT)/.downloaded_package_stamp
package-untar: $(OUT)/.unpacked_package_stamp
package-configure: $(OUT)/.configured_package_stamp
package-build: $(OUT)/.built_package_stamp
package-install: $(OUT)/.installed_package_stamp

$(OUT)/.downloaded_package_stamp:
wget -O $(DOWNLOAD_DIR)/$(package_TARBALL) $(package_URL)
touch $@

$(OUT)/.unpacked_package_stamp: $(OUT)/.downloaded_package_stamp
tar -xf $(DOWNLOAD_DIR)/$(package_TARBALL) -C $(OUT)
touch $@

$(OUT)/.configured_package_stamp: $(OUT)/.unpacked_package_stamp
mkdir -p $(OUT)/$(package_DIR)/out
cd $(OUT)/$(package_DIR)/out;\
../configure $(package_CONFIG_FLAGS)
touch $@

$(OUT)/.built_package_stamp: $(OUT)/.configured_package_stamp
cd $(OUT)/$(package_DIR)/out;\
make
touch $@

$(OUT)/.installed_package_stamp: $(OUT)/.built_package_stamp
make -C $(OUT)/$(package_DIR)/out install
touch $@
17 changes: 17 additions & 0 deletions build/1_tools.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.PHONY: 1_tools download-1_tools tools-build

TOOL_SUBMAKEFILES = $(wildcard $(PWD)/build/tools/*.mk)
TOOL_PACKAGES = $(TOOL_SUBMAKEFILES:$(PWD)/build/tools/%.mk=%)
TOOL_DOWNLOAD_TARGETS = $(TOOL_PACKAGES:%=download-%)
TOOLS_ROOT = $(OUT)/tools
TOOLS_CFLAGS = -O2

include $(TOOL_SUBMAKEFILES)

1_tools: download-1_tools tools-build | $(TOOLS_ROOT)

download-1_tools: $(TOOL_DOWNLOAD_TARGETS)
tools-build: $(TOOL_PACKAGES)

$(TOOLS_ROOT):
mkdir -p $@
39 changes: 39 additions & 0 deletions build/2_glibc.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.PHONY: 2_glibc download-2_glibc glibc-untar glibc-configure glibc-build glibc-install

GLIBC_VERSION = 2.43
GLIBC_TARBALL = glibc-$(GLIBC_VERSION).tar.xz
GLIBC_URL = https://ftp.gnu.org/gnu/glibc/$(GLIBC_TARBALL)
GLIBC_DIR = glibc-$(GLIBC_VERSION)
GLIBC_CONFIG_FLAGS = $(COMMON_CONFIG_FLAGS) --prefix=$(PWD)/$(ROOTFS)

2_glibc: download-2_glibc glibc-untar glibc-configure glibc-build glibc-install

download-2_glibc: $(OUT)/.downloaded_glibc_stamp
glibc-untar: $(OUT)/.unpacked_glibc_stamp
glibc-configure: $(OUT)/.configured_glibc_stamp
glibc-build: $(OUT)/.built_glibc_stamp
glibc-install: $(OUT)/.installed_glibc_stamp

$(OUT)/.downloaded_glibc_stamp:
wget -O $(DOWNLOAD_DIR)/$(GLIBC_TARBALL) $(GLIBC_URL)
touch $@

$(OUT)/.unpacked_glibc_stamp: $(OUT)/.downloaded_glibc_stamp
tar -xf $(DOWNLOAD_DIR)/$(GLIBC_TARBALL) -C $(OUT)
touch $@

$(OUT)/.configured_glibc_stamp: $(OUT)/.unpacked_glibc_stamp
mkdir -p $(OUT)/$(GLIBC_DIR)/out
cd $(OUT)/$(GLIBC_DIR)/out;\
../configure $(GLIBC_CONFIG_FLAGS)
touch $@

$(OUT)/.built_glibc_stamp: $(OUT)/.configured_glibc_stamp
cd $(OUT)/$(GLIBC_DIR)/out;\
make
touch $@

$(OUT)/.installed_glibc_stamp: $(OUT)/.built_glibc_stamp
make -C $(OUT)/$(GLIBC_DIR)/out install
cp $(ROOTFS)/lib/ld-linux-x86-64.so.2 $(ROOTFS)/lib64/ld-linux-x86-64.so.2
touch $@
14 changes: 7 additions & 7 deletions build/linux.mk → build/3_linux.mk
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
.PHONY: linux linux-nocompile download-linux untar-linux configure-linux compile-linux
.PHONY: 3_linux linux-nocompile download-3_linux untar-linux configure-linux compile-linux

LINUX_VERSION = 6.18.6
LINUX = linux-$(LINUX_VERSION)
LINUX_TARBALL = $(LINUX).tar.xz
LINUX_LINK = https://cdn.kernel.org/pub/linux/kernel/v6.x/$(LINUX_TARBALL)
LINUX_BZIMAGE = $(OUT)/$(LINUX)/arch/x86_64/boot/bzImage

linux: download-linux untar-linux configure-linux compile-linux
3_linux: download-3_linux untar-linux configure-linux compile-linux


download-linux: $(OUT)/.downloaded_linux_stamp
download-3_linux: $(OUT)/.downloaded_linux_stamp
untar-linux: $(OUT)/.unpacked_linux_stamp
configure-linux: $(OUT)/.configured_linux_stamp
compile-linux: $(OUT)/.compiled_linux_stamp

$(OUT)/.downloaded_linux_stamp:
wget -O $(OUT)/download/$(LINUX_TARBALL) $(LINUX_LINK)
wget -O $(DOWNLOAD_DIR)/$(LINUX_TARBALL) $(LINUX_LINK)
touch $@

$(OUT)/.unpacked_linux_stamp: $(OUT)/.downloaded_linux_stamp
tar -xf $(OUT)/download/$(LINUX_TARBALL) -C $(OUT)
tar -xf $(DOWNLOAD_DIR)/$(LINUX_TARBALL) -C $(OUT)
touch $@

$(OUT)/.configured_linux_stamp: $(OUT)/.unpacked_linux_stamp
make -j$(CPUS) -C $(OUT)/$(LINUX) defconfig
make -C $(OUT)/$(LINUX) defconfig
touch $@

$(OUT)/.compiled_linux_stamp: $(OUT)/.configured_linux_stamp
make -C $(OUT)/$(LINUX) -j$(CPUS) 2>&1 | tee $(OUT)/kernel-build.log
make -C $(OUT)/$(LINUX) 2>&1 | tee $(OUT)/kernel-build.log
touch $@
40 changes: 40 additions & 0 deletions build/4_attr.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
attr_VERSION = 2.5.2
attr_TARBALL = attr-$(attr_VERSION).tar.xz
attr_URL = https://download-mirror.savannah.gnu.org/releases/attr/$(attr_TARBALL)
attr_DIR = attr-$(attr_VERSION)
attr_CONFIG_FLAGS = $(COMMON_CONFIG_FLAGS) --disable-static --prefix=/$(PWD)/$(ROOTFS)/usr --sysconfdir=/$(PWD)/$(ROOTFS)/etc

#Alias for target
.PHONY: attr 4_attr download-4_attr attr-untar attr-configure attr-build attr-install
attr: 4_attr

4_attr: download-4_attr attr-untar attr-configure attr-build attr-install

download-4_attr: $(OUT)/.downloaded_attr_stamp
attr-untar: $(OUT)/.unpacked_attr_stamp
attr-configure: $(OUT)/.configured_attr_stamp
attr-build: $(OUT)/.built_attr_stamp
attr-install: $(OUT)/.installed_attr_stamp

$(OUT)/.downloaded_attr_stamp:
wget -O $(DOWNLOAD_DIR)/$(attr_TARBALL) $(attr_URL)
touch $@

$(OUT)/.unpacked_attr_stamp: $(OUT)/.downloaded_attr_stamp
tar -xf $(DOWNLOAD_DIR)/$(attr_TARBALL) -C $(OUT)
touch $@

$(OUT)/.configured_attr_stamp: $(OUT)/.unpacked_attr_stamp
mkdir -p $(OUT)/$(attr_DIR)/out
cd $(OUT)/$(attr_DIR)/out;\
../configure $(attr_CONFIG_FLAGS)
touch $@

$(OUT)/.built_attr_stamp: $(OUT)/.configured_attr_stamp
cd $(OUT)/$(attr_DIR)/out;\
make
touch $@

$(OUT)/.installed_attr_stamp: $(OUT)/.built_attr_stamp
make -C $(OUT)/$(attr_DIR)/out install
touch $@
26 changes: 13 additions & 13 deletions build/coreutils.mk → build/4_coreutils.mk
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
.PHONY: coreutils coreutils-download coreutils-untar coreutils-configure coreutils-build coreutils-install
.PHONY: 4_coreutils download-4_coreutils coreutils-untar coreutils-configure coreutils-build coreutils-install

COREUTILS_VERSION ?= 9.11
COREUTILS_TARBALL = coreutils-$(COREUTILS_VERSION).tar.xz
COREUTILS_URL = https://ftp.gnu.org/gnu/coreutils/$(COREUTILS_TARBALL)
COREUTILS = coreutils-$(COREUTILS_VERSION)
COREUTILS_FLAGS ?= $(COMMON_CONFIG_FLAGS) --build=$(shell $(OUT)/$(COREUTILS)/build-aux/config.guess) --enable-install-program=hostname --enable-no-install-program=kill,uptime --host=x86_64-linux-gnu --prefix=$(PWD)/$(ROOTFS)

coreutils: download-coreutils coreutils-untar coreutils-configure coreutils-build coreutils-install
4_coreutils: download-4_coreutils coreutils-untar coreutils-configure coreutils-build coreutils-install

download-coreutils: $(OUT)/.downloaded_coreutils_stamp
download-4_coreutils: $(OUT)/.downloaded_coreutils_stamp
coreutils-untar: $(OUT)/.unpacked_coreutils_stamp
coreutils-configure: $(OUT)/.configured_coreutils_stamp
coreutils-build: $(OUT)/.built_coreutils_stamp
coreutils-install: $(OUT)/.installed_coreutils_stamp


$(OUT)/.downloaded_coreutils_stamp: $(OUT)/download/$(COREUTILS_TARBALL)
$(OUT)/.downloaded_coreutils_stamp:
wget -O $(DOWNLOAD_DIR)/$(COREUTILS_TARBALL) $(COREUTILS_URL)
touch $@

$(OUT)/.unpacked_coreutils_stamp: $(OUT)/.downloaded_coreutils_stamp
tar -xf $(OUT)/download/$(COREUTILS_TARBALL) -C $(OUT)
tar -xf $(DOWNLOAD_DIR)/$(COREUTILS_TARBALL) -C $(OUT)
touch $@

$(OUT)/.configured_coreutils_stamp: $(OUT)/.unpacked_coreutils_stamp
mkdir -p $(OUT)/$(COREUTILS)/out
cd $(OUT)/$(COREUTILS)/out;\
../configure --prefix=$(PWD)/$(OUT)/mnt CFLAGS="-O2"
../configure $(COREUTILS_FLAGS)
touch $@

$(OUT)/.built_coreutils_stamp: $(OUT)/.configured_coreutils_stamp
cd $(OUT)/$(COREUTILS)/out;\
make -j$(CPUS)
make
touch $@

$(OUT)/.installed_coreutils_stamp: $(OUT)/.built_coreutils_stamp
make -C $(OUT)/$(COREUTILS)/out install
mv -v $(PWD)/$(ROOTFS)/usr/bin/chroot $(PWD)/$(ROOTFS)/usr/sbin
mkdir -pv $(PWD)/$(ROOTFS)/usr/share/man/man8
touch $@

$(OUT)/download/$(COREUTILS_TARBALL): $(OUT)
if [ ! -f $@ ] && [ ! -d $(OUT)/$(COREUTILS) ]; then\
wget -O $@ $(COREUTILS_URL);\
fi
39 changes: 39 additions & 0 deletions build/4_ncurses.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.PHONY: 4_ncurses download-4_ncurses ncurses-untar ncurses-configure ncurses-build ncurses-install

ncurses_VERSION = 6.6
ncurses_TARBALL = ncurses-$(ncurses_VERSION).tar.gz
ncurses_URL = https://invisible-mirror.net/archives/ncurses/$(ncurses_TARBALL)
ncurses_DIR = ncurses-$(ncurses_VERSION)
ncurses_CONFIG_FLAGS = $(COMMON_CONFIG_FLAGS) --disable-widec --disable-libtool-version --with-termlib --with-manpage-format=normal --with-shared --without-normal --disable-stripping --without-debug --with-cxx-shared --without-ada --prefix=/$(PWD)/$(ROOTFS) --host=x86_64-linux-gnu --build=$(shell /$(PWD)/$(OUT)/$(ncurses_DIR)/config.guess)

4_ncurses: download-4_ncurses ncurses-untar ncurses-configure ncurses-build ncurses-install

download-4_ncurses: $(OUT)/.downloaded_ncurses_stamp
ncurses-untar: $(OUT)/.unpacked_ncurses_stamp
ncurses-configure: $(OUT)/.configured_ncurses_stamp
ncurses-build: $(OUT)/.built_ncurses_stamp
ncurses-install: $(OUT)/.installed_ncurses_stamp

$(OUT)/.downloaded_ncurses_stamp:
wget -O $(DOWNLOAD_DIR)/$(ncurses_TARBALL) $(ncurses_URL)
touch $@

$(OUT)/.unpacked_ncurses_stamp: $(OUT)/.downloaded_ncurses_stamp
tar -xf $(DOWNLOAD_DIR)/$(ncurses_TARBALL) -C $(OUT)
touch $@

$(OUT)/.configured_ncurses_stamp: $(OUT)/.unpacked_ncurses_stamp
mkdir -p $(OUT)/$(ncurses_DIR)/out
cd $(OUT)/$(ncurses_DIR)/out;\
../configure $(ncurses_CONFIG_FLAGS)
touch $@

$(OUT)/.built_ncurses_stamp: $(OUT)/.configured_ncurses_stamp
cd $(OUT)/$(ncurses_DIR)/out;\
make
touch $@

$(OUT)/.installed_ncurses_stamp: $(OUT)/.built_ncurses_stamp
make -C $(OUT)/$(ncurses_DIR)/out install
#ln -sv libncursesw.so $(PWD)/$(ROOTFS)/usr/lib/libncurses.so
touch $@
Loading