Ongoing build system maintainance.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-06-28 16:10:20 +02:00
parent 2b2dd347ec
commit 2586685061
29 changed files with 177 additions and 450 deletions

124
Makefile
View File

@ -1,7 +1,7 @@
SOFTWARE_MEANT_FOR_SORTIX=1
MAKEFILE_NOT_MEANT_FOR_SORTIX=1
include compiler.mak
include version.mak
include build-aux/platform.mak
include build-aux/compiler.mak
include build-aux/version.mak
MODULES=\
doc \
@ -22,12 +22,10 @@ kernel
ifndef SYSROOT
SYSROOT:=$(shell pwd)/sysroot
SUBMAKE_OPTIONS:=$(SUBMAKE_OPTIONS) "SYSROOT=$(SYSROOT)"
endif
ifndef SYSROOT_OVERLAY
SYSROOT_OVERLAY:=$(shell pwd)/sysroot-overlay
SUBMAKE_OPTIONS:=$(SUBMAKE_OPTIONS) "SYSROOT_OVERLAY=$(SYSROOT_OVERLAY)"
endif
SORTIX_BUILDS_DIR?=builds
@ -35,18 +33,36 @@ SORTIX_PORTS_DIR?=ports
SORTIX_RELEASE_DIR?=release
SORTIX_REPOSITORY_DIR?=repository
include dirs.mak
include build-aux/dirs.mak
PREFIX:=
EXEC_PREFIX:=$(PREFIX)/$(HOST)
export PREFIX
export EXEC_PREFIX
export SYSROOT
ifeq ($(BUILD_IS_SORTIX),1)
export C_INCLUDE_PATH=$(SYSROOT)/include
export CPLUS_INCLUDE_PATH=$(SYSROOT)/include
export LIBRARY_PATH=$(SYSROOT)/$(HOST)/lib
endif
BUILD_NAME:=sortix_$(VERSION)_$(MACHINE)
DEBNAME:=sortix_$(VERSION)_$(MACHINE)
INITRD:=$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).initrd
SUBMAKE_OPTIONS:=$(SUBMAKE_OPTIONS) VERSION=$(VERSION) PREFIX= EXEC_PREFIX=/$(HOST)
.PHONY: all
all: sysroot
ifeq ($(BUILD_IS_SORTIX),1)
.PHONY: install
install: sysroot
(for ENTRY in $$(ls -A "$(SYSROOT)" | grep -Ev '^src$$'); do \
cp -RTv "$(SYSROOT)/$$ENTRY" "$(DESTDIR)/$$ENTRY" || exit $$?; \
done)
endif
.PHONY: build-tools
build-tools:
$(MAKE) -C carray
@ -81,23 +97,21 @@ sysroot-fsh:
.PHONY: sysroot-base-headers
sysroot-base-headers: sysroot-fsh
(for D in libc libm libpthread kernel; do ($(MAKE) -C $$D install-headers $(SUBMAKE_OPTIONS) DESTDIR="$(SYSROOT)") || exit $$?; done)
(for D in libc libm libpthread kernel; do ($(MAKE) -C $$D install-headers DESTDIR="$(SYSROOT)") || exit $$?; done)
.PHONY: sysroot-system
sysroot-system: sysroot-fsh sysroot-base-headers
(for D in $(MODULES); do ($(MAKE) -C $$D $(SUBMAKE_OPTIONS) && $(MAKE) -C $$D install $(SUBMAKE_OPTIONS) DESTDIR="$(SYSROOT)") || exit $$?; done)
(for D in $(MODULES); do ($(MAKE) -C $$D && $(MAKE) -C $$D install DESTDIR="$(SYSROOT)") || exit $$?; done)
.PHONY: sysroot-source
sysroot-source: sysroot-fsh
cp compiler.mak -t "$(SYSROOT)/src"
cp dirs.mak -t "$(SYSROOT)/src"
cp platform.mak -t "$(SYSROOT)/src"
cp version.mak -t "$(SYSROOT)/src"
cp .gitignore -t "$(SYSROOT)/src"
cp COPYING-GPL -t "$(SYSROOT)/src"
cp COPYING-LGPL -t "$(SYSROOT)/src"
cp Makefile -t "$(SYSROOT)/src"
cp README -t "$(SYSROOT)/src"
cp -RT build-aux "$(SYSROOT)/src/build-aux"
(for D in $(MODULES); do (cp -LR $$D -t "$(SYSROOT)/src" && $(MAKE) -C "$(SYSROOT)/src/$$D" clean) || exit $$?; done)
cp -LR system -t "$(SYSROOT)/src"
.PHONY: sysroot-ports
sysroot-ports: sysroot-fsh sysroot-base-headers sysroot-system sysroot-source
@ -106,13 +120,13 @@ sysroot-ports: sysroot-fsh sysroot-base-headers sysroot-system sysroot-source
SYSROOT="$(SYSROOT)" \
HOST="$(HOST)" \
MAKE="$(MAKE)" \
MAKEFLAGS="$(MAKEFLAGS) $(SUBMAKE_OPTIONS)" \
./build-ports.sh
MAKEFLAGS="$(MAKEFLAGS)" \
build-aux/build-ports.sh
.PHONY: sysroot-overlay
sysroot-overlay: sysroot-fsh sysroot-system sysroot-ports
! [ -d "$(SYSROOT_OVERLAY)" ] || \
cp -R --preserve=mode,timestamp,links "$(SYSROOT_OVERLAY)" -T "$(SYSROOT)"
cp -RT --preserve=mode,timestamp,links "$(SYSROOT_OVERLAY)" "$(SYSROOT)"
.PHONY: sysroot-user-skel
sysroot-user-skel: sysroot-fsh sysroot-system sysroot-ports sysroot-overlay
@ -121,7 +135,7 @@ sysroot-user-skel: sysroot-fsh sysroot-system sysroot-ports sysroot-overlay
.PHONY: sysroot-home-directory
sysroot-home-directory: sysroot-fsh sysroot-system sysroot-ports sysroot-overlay sysroot-user-skel
mkdir -p "$(SYSROOT)/root"
cp -R "$(SYSROOT)/etc/skel" -T "$(SYSROOT)/root"
cp -RT "$(SYSROOT)/etc/skel" "$(SYSROOT)/root"
.PHONY: sysroot
sysroot: sysroot-system sysroot-source sysroot-ports sysroot-overlay sysroot-home-directory
@ -134,15 +148,15 @@ $(SORTIX_REPOSITORY_DIR)/$(HOST): $(SORTIX_REPOSITORY_DIR)
.PHONY: clean-core
clean-core:
(for D in $(MODULES); do $(MAKE) clean $(SUBMAKE_OPTIONS) --directory $$D || exit $$?; done)
(for D in $(MODULES); do $(MAKE) clean -C $$D || exit $$?; done)
.PHONY: clean-ports
clean-ports:
@SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \
HOST="$(HOST)" \
MAKE="$(MAKE)" \
MAKEFLAGS="$(MAKEFLAGS) $(SUBMAKE_OPTIONS)" \
./clean-ports.sh
MAKEFLAGS="$(MAKEFLAGS)" \
build-aux/clean-ports.sh
.PHONY: clean-builds
clean-builds:
@ -174,7 +188,7 @@ mostlyclean: clean-core clean-ports clean-builds clean-release clean-sysroot
distclean: clean-core clean-ports clean-builds clean-release clean-repository clean-sysroot
.PHONY: most-things
most-things: sysroot initrd deb tar iso
most-things: sysroot initrd tar iso
.PHONY: everything
everything: most-things iso.xz
@ -232,6 +246,7 @@ $(INITRD): sysroot
echo "exclude /boot" >> $(INITRD).filter
echo "exclude /dev" >> $(INITRD).filter
echo "exclude /next" >> $(INITRD).filter
echo "exclude /src/sysroot" >> $(INITRD).filter
echo "exclude /tmp" >> $(INITRD).filter
for OTHER_PLATFORM in $(OTHER_PLATFORMS); do \
echo "exclude /$$OTHER_PLATFORM" >> $(INITRD).filter; \
@ -249,22 +264,6 @@ initrd: $(INITRD)
sortix.initrd: $(INITRD)
cp $(INITRD) sortix.initrd
# Local machine
.PHONY: install
install: sysroot initrd
cp "$(SYSROOT)/boot/$(HOST)/sortix.bin" /boot/sortix.initrd
cp $(INITRD) /boot/sortix.initrd
cp debsrc/etc/grub.d/42_sortix /etc/grub.d/42_sortix
chmod +x /etc/grub.d/42_sortix
update-grub
.PHONY: uninstall
uninstall:
rm -f /boot/sortix.bin
rm -f /boot/sortix.initrd
rm -f /etc/grub.d/42_sortix
# Packaging
$(SORTIX_BUILDS_DIR):
@ -276,45 +275,18 @@ $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).tar.xz: sysroot $(INITRD) $(SORTIX_BUILDS_DIR
mkdir -p $(SORTIX_BUILDS_DIR)/tardir/boot
cp "$(SYSROOT)/boot/$(HOST)/sortix.bin" $(SORTIX_BUILDS_DIR)/tardir/boot/sortix.bin
cp $(INITRD) $(SORTIX_BUILDS_DIR)/tardir/boot/sortix.initrd
cp -R debsrc -T $(SORTIX_BUILDS_DIR)/tardir
rm -rf $(SORTIX_BUILDS_DIR)/tardir/DEBIAN
tar --create --xz --file $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).tar.xz -C $(SORTIX_BUILDS_DIR)/tardir `ls $(SORTIX_BUILDS_DIR)/tardir`
rm -rf $(SORTIX_BUILDS_DIR)/tardir
.PHONY: tar
tar: $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).tar.xz
$(SORTIX_BUILDS_DIR)/$(DEBNAME).deb: sysroot $(INITRD) $(SORTIX_BUILDS_DIR)
rm -rf $(SORTIX_BUILDS_DIR)/$(DEBNAME)
mkdir -p $(SORTIX_BUILDS_DIR)/$(DEBNAME)
mkdir -p $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot
cp "$(SYSROOT)/boot/$(HOST)/sortix.bin" $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot/sortix.bin
cp $(INITRD) $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot/sortix.initrd
expr \( `stat --printf="%s" $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot/sortix.bin` \
+ `stat --printf="%s" $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot/sortix.initrd` \
+ 1023 \) / 1024 > $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot/deb.size
cp -R debsrc -T $(SORTIX_BUILDS_DIR)/$(DEBNAME)
SIZE=`cat $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot/deb.size`; \
cat debsrc/DEBIAN/control | \
sed "s/SORTIX_PACKAGE_NAME/sortix/g" | \
sed "s/SORTIX_VERSION/$(VERSION)/g" | \
sed "s/SORTIX_ARCH/all/g" | \
sed "s/SORTIX_SIZE/$$SIZE/g" | \
cat > $(SORTIX_BUILDS_DIR)/$(DEBNAME)/DEBIAN/control
rm $(SORTIX_BUILDS_DIR)/$(DEBNAME)/boot/deb.size
dpkg --build $(SORTIX_BUILDS_DIR)/$(DEBNAME) $(SORTIX_BUILDS_DIR)/$(DEBNAME).deb
rm -rf $(SORTIX_BUILDS_DIR)/$(DEBNAME)/DEBIAN
rm -rf $(SORTIX_BUILDS_DIR)/$(DEBNAME)
.PHONY: deb
deb: $(SORTIX_BUILDS_DIR)/$(DEBNAME).deb
# Bootable images
$(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso: sysroot $(INITRD) $(SORTIX_BUILDS_DIR)
rm -rf $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
mkdir -p $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
cp -R isosrc -T $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
cp -RT isosrc $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
cp "$(SYSROOT)/boot/$(HOST)/sortix.bin" $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/boot/sortix.bin
cp $(INITRD) $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso/boot/sortix.initrd
grub-mkrescue -o $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso $(SORTIX_BUILDS_DIR)/$(BUILD_NAME)-iso
@ -330,10 +302,10 @@ iso: $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso
iso.xz: $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso.xz
sortix.iso: $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso
cp $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso $@
cp $< $@
sortix.iso.xz: $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso.xz
cp $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).iso.xz $@
cp $< $@
# Release
@ -352,12 +324,6 @@ $(SORTIX_RELEASE_DIR)/$(VERSION)/builds/$(BUILD_NAME).iso.xz: $(SORTIX_BUILDS_DI
.PHONY: release-iso.xz
release-iso.xz: $(SORTIX_RELEASE_DIR)/$(VERSION)/builds/$(BUILD_NAME).iso.xz
$(SORTIX_RELEASE_DIR)/$(VERSION)/builds/$(DEBNAME).deb: $(SORTIX_BUILDS_DIR)/$(DEBNAME).deb $(SORTIX_RELEASE_DIR)/$(VERSION)/builds
cp $< $@
.PHONY: release-deb
release-deb: $(SORTIX_RELEASE_DIR)/$(VERSION)/builds/$(DEBNAME).deb
$(SORTIX_RELEASE_DIR)/$(VERSION)/builds/$(BUILD_NAME).tar.xz: $(SORTIX_BUILDS_DIR)/$(BUILD_NAME).tar.xz $(SORTIX_RELEASE_DIR)/$(VERSION)/builds
cp $< $@
@ -365,10 +331,10 @@ $(SORTIX_RELEASE_DIR)/$(VERSION)/builds/$(BUILD_NAME).tar.xz: $(SORTIX_BUILDS_DI
release-tar: $(SORTIX_RELEASE_DIR)/$(VERSION)/builds/$(BUILD_NAME).tar.xz
.PHONY: release-builds
release-builds: release-iso.xz release-deb release-tar
release-builds: release-iso.xz release-tar
$(SORTIX_RELEASE_DIR)/$(VERSION)/doc: $(SORTIX_RELEASE_DIR)/$(VERSION) doc doc/*
cp -R doc -T $(SORTIX_RELEASE_DIR)/$(VERSION)/doc
cp -RT doc $(SORTIX_RELEASE_DIR)/$(VERSION)/doc
rm -f $(SORTIX_RELEASE_DIR)/$(VERSION)/doc/.gitignore
rm -f $(SORTIX_RELEASE_DIR)/$(VERSION)/doc/Makefile
@ -385,7 +351,7 @@ $(SORTIX_RELEASE_DIR)/$(VERSION)/repository:
mkdir -p $@
$(SORTIX_RELEASE_DIR)/$(VERSION)/repository/$(HOST): sysroot $(SORTIX_REPOSITORY_DIR)/$(HOST) $(SORTIX_RELEASE_DIR)/$(VERSION)/repository
cp -R $(SORTIX_REPOSITORY_DIR)/$(HOST) -T $@
cp -RT $(SORTIX_REPOSITORY_DIR)/$(HOST) $@
.PHONY: release-repository
release-repository: $(SORTIX_RELEASE_DIR)/$(VERSION)/repository/$(HOST)

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
@ -25,4 +26,3 @@ install: all
clean:
rm -f $(BINARIES) *.o

View File

@ -1,5 +1,3 @@
#!/bin/sh
set -e
make_dir_path_absolute() {

View File

@ -1,5 +1,3 @@
#!/bin/sh
set -e
make_dir_path_absolute() {

View File

@ -1,6 +1,3 @@
COMPILER_MAK_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
include $(COMPILER_MAK_DIR)/platform.mak
# Warn if default target is used and the software shouldn't be built under Sortix.
ifeq ($(BUILD_IS_SORTIX),1)
ifeq ($(MAKEFILE_NOT_MEANT_FOR_SORTIX), 1)

View File

@ -1,12 +1,8 @@
ifeq ($(HOST_IS_SORTIX),1)
DEFAULT_PREFIX=
else
DEFAULT_PREFIX=/usr/local
endif
ifeq ($(HOST_IS_SORTIX),1)
DEFAULT_EXEC_PREFIX=$(PREFIX)/$(HOST)
else
DEFAULT_PREFIX=/usr/local
DEFAULT_EXEC_PREFIX=$(PREFIX)
endif

View File

@ -4,7 +4,7 @@ UNAME_PLATFORM:=$(shell uname -i)
# Detect the platform that the software is being built on.
ifndef BUILD
# If the software is being built on Sortix-
# If the software is being built on Sortix.
ifeq ($(UNAME_OS),Sortix)
ifeq ($(MAKEFILE_NOT_MEANT_FOR_SORTIX), 1)
makefile_not_meant_for_sortix:
@ -18,7 +18,7 @@ makefile_not_meant_for_sortix:
BUILD:=x86_64-sortix
endif
# If the softwarte is not built on Sortix.
# If the software is not built on Sortix.
else
ifeq ($(MEANT_FOR_SORTIX), 1)
makefile_meant_for_sortix:
@ -36,21 +36,13 @@ makefile_meant_for_sortix:
endif
endif
MFLAGS:=$(MFLAGS) BUILD=$(BUILD)
endif
# Determine the platform the software will run on.
ifndef HOST
HOST:=$(BUILD)
MFLAGS:=$(MFLAGS) HOST=$(HOST)
endif
HOST?=$(BUILD)
# Determine the platform the software will target.
ifndef TARGET
TARGET:=$(HOST)
MFLAGS:=$(MFLAGS) TARGET=$(TARGET)
endif
TARGET?=$(HOST)
BUILD_IS_SORTIX:=$(if $(shell echo $(BUILD) | grep sortix$),1,0)
HOST_IS_SORTIX:=$(if $(shell echo $(HOST) | grep sortix$),1,0)

View File

@ -1,6 +1,7 @@
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)

View File

@ -1,12 +0,0 @@
Package: SORTIX_PACKAGE_NAME
Version: SORTIX_VERSION
Section: kernel
Priority: optional
Architecture: SORTIX_ARCH
Installed-Size: SORTIX_SIZE
Essential: no
Recommends: grub2, xorriso
Provides: sortix
Maintainer: Jonas Termansen [sortie@maxsi.org]
Description: Sortix is a small hobby kernel developed for the heck of it.

View File

@ -1,4 +0,0 @@
#!/bin/sh
set -e
update-grub

View File

@ -1,3 +0,0 @@
#!/bin/sh
set -e
if [ "$1" != "upgrade" ]; then update-grub; fi

View File

@ -1,10 +0,0 @@
#!/bin/sh
for KERNEL in `ls /boot | grep sortix | grep bin`; do
echo "Found Sortix kernel: $KERNEL" >&2
INITRD=`echo "$KERNEL" | sed 's/bin/initrd/g'`
echo "menuentry \"Sortix\" {"
echo "\tmultiboot /boot/$KERNEL"
echo "\tmodule /boot/$INITRD"
echo "}"
done

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)

View File

@ -1,6 +1,7 @@
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
DOCUMENTS:=\
cross-compilation-sins \

View File

@ -67,7 +67,7 @@ More Documentation
------------------
The system documentation (at least what has been documented so far) is installed
in the /share/doc directory. You can view these documents (well, the ones that
in the `/share/doc` directory. You can view these documents (well, the ones that
are plain text, there is no `man` program yet) using the `editor` program, which
you exit by pressing Control-Q ('^Q'). It is probably a good idea to change
the resolution using the `chvideomode` program if drivers are available.
@ -81,20 +81,20 @@ Filesystem Structure
This as an incomplete list of the common top level directories in Sortix.
* /boot - Kernel images, initrd images.
* /dev - Device filesystem.
* /etc - System-wide configuration.
* /home - User directories.
* /include - Header files.
* /root - Directory of the root user.
* /share - Architecture independent files.
* /share/doc - Documentation.
* /src - System source code.
* /tmp - Temporary files.
* /$cputype - Files for $cputype.
* /$cputype/bin - Programs for $cputype.
* /$cputype/lib - Shared libaries for $cputype.
* /$cputype/libexec - Shared libaries for $cputype.
* `/boot` - Kernel images, initrd images.
* `/dev` - Device filesystem.
* `/etc` - System-wide configuration.
* `/home` - User directories.
* `/include` - Header files.
* `/root` - Directory of the root user.
* `/share` - Architecture independent files.
* `/share/doc` - Documentation.
* `/src` - System source code.
* `/tmp` - Temporary files.
* `/$cputype` - Files for $cputype.
* `/$cputype/bin` - Programs for $cputype.
* `/$cputype/lib` - Shared libaries for $cputype.
* `/$cputype/libexec` - Shared libaries for $cputype.
Some of these directories not be present or empty on your installation.
@ -292,9 +292,9 @@ System Source Code
------------------
The entire system source code (except third party components) is installed into
the /src directory. You can use the `editor` program to view and edit the system
source code. If your release contains the GNU compiler collection (gcc), you can
even modify the system and compile custom programs.
the `/src` directory. You can use the `editor` program to view and edit the
system source code. If your release contains the GNU compiler collection (gcc),
you can even modify the system and compile custom programs.
Editing Files
-------------
@ -337,14 +337,14 @@ will have to be done from an external system. You must take care to send the
filesystem server a SIGTERM signal to shut down when you are unfinished,
otherwise the data may not have been synced to disk. This will be done
automatically if the root filesystem was mounted by the initrd. If the device
/dev/ata0p1 contasins an ext2 filesystem, then it can be mounted using:
`/dev/ata0p1` contasins an ext2 filesystem, then it can be mounted using:
mkdir /fs
extfs /dev/ata0 /fs
You can then access the filesystem at /fs. There is no real unmount support and
if the file system server shuts down, the system may hang trying to communicate
with a server that isn't there.
You can then access the filesystem at `/fs`. There is no real unmount support
and if the file system server shuts down, the system may hang trying to
communicate with a server that isn't there.
Graphical User Interface
------------------------
@ -366,33 +366,40 @@ possible to build all the the third party software used to build itself, but you
can use the system to improve it until it is possible to build third party
software under it.
You need a version of Sortix that ships its own source code in /src and contains
a copy of the GNU Compiler Collection (gcc). Additionally, you should be booting
from a harddisk so that the new kernel is used after a reboot, otherwise you
will have to be satisfied with only using a new user-land.
You need a version of Sortix that ships its own source code in `/src` and
contains a copy of the GNU Compiler Collection (gcc). Additionally, you should
be booting from a harddisk so that the new kernel is used after a reboot,
otherwise you will have to be satisfied with only using a new user-land.
You can use the `colormake` program instead of regular `make` if you want
colored output, which eases spotting compile warnings and errors. This program
simply invokes the real `make` and colors its output.
The /src/system directory contains a makefile that eases rebuilding the entire
The `/src` directory contains a makefile that eases rebuilding the entire
system automatically. To rebuild the entire system simply run:
cd /src/system
make system
cd /src
make
make install
This will recompile the entire operating system and install it into the root
directory as it progresses. You will be running a new version of everything upon
completion, except the kernel and programs were previously started will still
be running the old version. If the root filesystem is permanent and the computer
has been configured to boot from it, then you can reboot the system by exiting
the initial shell. You will then be running an entirely new system.
This will recompile the entire operating system and install it into the staging
area `/src/sysroot`. This is a full usable image of the root filesystem for a
Sortix installation and you can successfully execute `chroot /src/sysroot init`.
The install target does a single `cp -RT /src/sysroot /` command that replaces
copies all files in `/src/sysroot` onto their root filesystem counterparts, with
the exception that the precious files in /src are not replaced with their
/src/system/src counterparts (even though they usually would be equal).
In general, the projects that are part of the core system can be easily built
and installed with the provided makefiles. In general, they can be built with
this simple sequence:
You will be running a new version of everything upon completion, except the
kernel and programs were previously started will still be running the old
version. If the root filesystem is permanent and the computer has been
configured to boot from it, then you can reboot the system by exiting the
initial shell. You will then be running an entirely new system.
cd /src/package
The projects that are part of the core system can be easily built and installed
with the provided makefiles. They can be built with this simple sequence:
cd /src/<package>
make
make install
@ -416,7 +423,7 @@ the package will expect that it is installed into `/local` when it is run. This
is useful for package management purposes to capture a copy of all the installed
files before they are installed for real.
### Building the C library ###
### The C library ###
The C library (libc) implements the common functions, data types and constants
required by the C programming language standard, POSIX, other standards, and
@ -427,32 +434,19 @@ freestanding C library designed for inclusion into the Sortix kernel. After
rebuilding the C library, you may wish to rebuild the entire user-land since
those programs have an older libc version statically linked into them.
cd /src/libc
make
make install
### Building the Math Library ###
### The Math Library ###
The Math Library (libm) provides useful mathematical functions for manipulating
floating-point numbers of various sizes. This implements the <math.h> header as
known from standard C. Like the C library, you will likely want to recompile
large parts of user-land if you update this library.
cd /src/libm
make
make install
### Building the Pthread Library ###
### The Pthread Library ###
The Pthread Library (libpthread) provides a threading implementation through the
standard header <pthread.h> as known from POSIX. Like the C library, you will
likely want to recompile large parts of user-land if you update this library.
cd /src/libpthread
make
make install
### Building the Display Daemon ###
### The Display Daemon ###
The dispd library allows processes to communicate with the dispd server that
handles window management and graphical output. Currently, there is no such
@ -460,89 +454,49 @@ server and the library calls the kernel interface itself. This library allows
games such as asteroids to detect the current resolution and request whatever
resolution they need to function.
cd /src/dispd
make
make install
### Building the Utility Collection ###
### Utility Collection ###
The utility collection contains common programs such as `ls`, `cp`, `mkdir` and
more. These programs allow the basic operation from the command line.
cd /src/utils
make
make install
### Building the Benchmarks ###
### Benchmarks ###
The system comes with some small and outdated benchmark programs. They don't
currently give any meaningful values, so you should not use them for anything.
cd /src/bench
make
make install
### Building the Games ###
### Games ###
The games directory contains the source code for the above mentioned games.
These depend on libdispd.
cd /src/games
make
make install
### Building mbrfs ###
### mbrfs ###
The `mbrfs` program creates block devices for every partition in the master boot
record in a block device.
cd /src/mbr
make
make install
### Building extfs ###
### extfs ###
The `extfs` program translates a block device formatted with the second extended
filesystem and mounts it at an empty directory.
cd /src/ext
make
make install
### Building mkinitrd ###
### mkinitrd ###
This program produces a Sortix compatible initrd, the file that contains the
initial filesystem used to bootstrap the real root filesystem.
cd /src/mkinitrd
make
make install
### Building regress ###
### regress ###
This is a collection of operating system test cases run using the `regress`
driver program.
cd /src/regress
make
make install
### Building carray ###
### carray ###
This program converts a binary file to an C array.
cd /src/carray
make
make install
### Building the Sortix Kernel ###
### Sortix Kernel ###
The Sortix kernel is the core of the Sortix operating system. It provides all
the primitives libc needs to implement a Unix-like environment.
cd /src/kernel
make
make install
Note that you need to reboot the system to use the new kernel and that you need
a permanent root filesystem or your local changes will be lost.

View File

@ -1,6 +1,7 @@
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
@ -26,8 +27,7 @@ install: all
install $(BINARIES) $(DESTDIR)$(BINDIR)
extfs: *.cpp *.h
$(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $(wildcard *.cpp) -o $@ $(LIBS)
$(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) *.cpp -o $@ $(LIBS)
clean:
rm -f $(BINARIES) *.o

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
@ -26,4 +27,3 @@ install: all
clean:
rm -f $(BINARIES) *.o

View File

@ -25,9 +25,3 @@ menuentry "Sortix" {
multiboot /boot/sortix.bin
module /boot/sortix.initrd
}
menuentry "Sortix (local harddisk)" {
search --file --set=root --no-floppy /sortix.bin
multiboot /sortix.bin
module /sortix.initrd.gz
}

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
# Default values in case the user doesn't override these variables.
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
@ -190,8 +191,8 @@ endif
clean:
rm -f $(ALLOBJS) sortix.bin
rm -f $(wildcard *.bin) $(wildcard *.out) $(wildcard *.tmp)
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o)
rm -f *.bin *.out *.tmp
rm -f *.o */*.o */*/*.o
# Installation into sysroot
install: install-headers install-kernel
@ -207,4 +208,3 @@ install-kernel: install-kernel-binary
install-kernel-binary: sortix.bin
mkdir -p $(DESTDIR)$(BOOTDIR)/$(HOST)
cp sortix.bin $(DESTDIR)$(BOOTDIR)/$(HOST)

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
@ -650,7 +651,7 @@ crtn.o \
MISCOBJ=\
$(CRTOBJ) \
HEADERS:=$(shell find include -type d)
HEADERS:=$(shell find include -type f)
LIBK_OBJS:=$(FREEOBJS:.o=.libk.o)
LIBK_CPPFLAGS:=$(CPPFLAGS) -D__is_sortix_kernel
@ -726,8 +727,11 @@ headers:
%.libk.o: %.cpp
$(HOSTCXX) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CXXFLAGS)
%.libk.o: %.S
$(HOSTCC) -c $< -o $@ $(LIBK_CPPFLAGS) $(LIBK_FLAGS) $(LIBK_CFLAGS)
clean:
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a)
rm -f *.o */*.o */*/*.o *.a
# Installation into sysroot
install: install-headers install-libs install-libs-kernel
@ -753,4 +757,3 @@ install-lib-dirs: $(DESTDIR)$(LIBDIR)
install-libs: $(INSTALLLIBS)
install-libs-kernel: $(INSTALLLIBSKERNEL)

View File

@ -1,7 +1,7 @@
include ../platform.mak
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
CFLAGS?=$(OPTLEVEL)
@ -413,4 +413,3 @@ install-libm-dirs:
install-libm: install-libm-dirs libm.a
cp -P libm.a $(DESTDIR)$(LIBDIR)

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_HOST_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
@ -23,4 +24,3 @@ install: all
clean:
rm -f $(BINARY) *.o

View File

@ -1,6 +1,7 @@
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
@ -25,4 +26,3 @@ clean:
install: all
mkdir -p $(DESTDIR)$(BINDIR)
install $(BINARIES) $(DESTDIR)$(BINDIR)

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
@ -40,4 +41,3 @@ endif
clean:
rm -f $(BINARIES) $(TESTS) *.o

View File

@ -1,146 +0,0 @@
include ../platform.mak
# Protect the user from accidentally replacing his build operating system with a broken Sortix.
ifeq ($(HOST_IS_SORTIX),0)
$(error You are about to build Sortix as $(HOST) and possibly overwrite your root filesystem. Use the HOST=cpu-sortix environmental variable if you wish to cross-compile)
endif
SRCDIR:=..
BOOTDIR:=$(ROOT)/boot/$(cputype)
KERNEL:=$(BOOTDIR)/sortix.bin
INITRD_COMPRESSION:=.gz
INITRD:=$(BOOTDIR)/sortix.initrd
INITRD_FILTER:=$(BOOTDIR)/sortix.initrd.filter
all: $(KERNEL) $(INITRD)$(INITRD_COMPRESSION)
# Delete various temporary build files.
clean:
$(MAKE) -B -C $(SRCDIR)/doc clean
$(MAKE) -B -C $(SRCDIR)/libc clean
$(MAKE) -B -C $(SRCDIR)/libm clean
$(MAKE) -B -C $(SRCDIR)/libpthread clean
$(MAKE) -B -C $(SRCDIR)/dispd clean
$(MAKE) -B -C $(SRCDIR)/bench clean
$(MAKE) -B -C $(SRCDIR)/carray clean
$(MAKE) -B -C $(SRCDIR)/games clean
$(MAKE) -B -C $(SRCDIR)/mkinitrd clean
$(MAKE) -B -C $(SRCDIR)/utils clean
$(MAKE) -B -C $(SRCDIR)/ext clean
$(MAKE) -B -C $(SRCDIR)/mbr clean
$(MAKE) -B -C $(SRCDIR)/systest clean
$(MAKE) -B -C $(SRCDIR)/tix clean
$(MAKE) -B -C $(SRCDIR)/kernel clean
# Set up the base filesystem.
fsh:
mkdir -p $(ROOT)/
mkdir -p $(ROOT)/boot
mkdir -p $(ROOT)/boot/$(cputype)
mkdir -p $(ROOT)/dev
mkdir -p $(ROOT)/etc
mkdir -p $(ROOT)/etc/$(cputype)
mkdir -p $(ROOT)/etc/skel
mkdir -p $(ROOT)/home
mkdir -p $(ROOT)/include
mkdir -p $(ROOT)/include/$(cputype)
mkdir -p $(ROOT)/mnt
mkdir -p $(ROOT)/root
mkdir -p $(ROOT)/share
mkdir -p $(ROOT)/src
mkdir -p $(ROOT)/tmp
mkdir -p $(ROOT)/$(cputype)/bin
mkdir -p $(ROOT)/$(cputype)/lib
mkdir -p $(ROOT)/$(cputype)/libexec
# Install the system headers.
system-headers:
$(MAKE) fsh ROOT=$(ROOT)
$(MAKE) system-headers_internal ROOT=$(ROOT)
system-headers_internal:
$(MAKE) -B -C $(SRCDIR)/kernel install-headers DESTDIR=$(ROOT)
$(MAKE) -B -C $(SRCDIR)/libc install-headers DESTDIR=$(ROOT)
$(MAKE) -B -C $(SRCDIR)/libm install-headers DESTDIR=$(ROOT)
$(MAKE) -B -C $(SRCDIR)/libpthread install-headers DESTDIR=$(ROOT)
# Rebuild and install the entire system.
system:
$(MAKE) fsh ROOT=$(ROOT)
$(MAKE) system-headers_internal ROOT=$(ROOT)
$(MAKE) -B -C $(SRCDIR)/doc install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/libc install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/libm install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/libpthread install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/dispd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/bench install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/games install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/mkinitrd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/utils install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/bench install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/ext install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/mbr install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/systest install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/tix install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
$(MAKE) -B -C $(SRCDIR)/kernel install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/libs
# Rebuild and install the kernel
kernel:
$(MAKE) -B -C $(SRCDIR)/kernel install-headers DESTDIR=$(ROOT)
$(MAKE) -B -C $(SRCDIR)/kernel install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/libs
# Rebuild the initrd and the kernel.
boot-files: initrd kernel
# Regenerate the initrd from $ROOT.
initrd:
mkdir -p $(BOOTDIR)
rm -f $(INITRD_FILTER)
echo exclude /boot >> $(INITRD_FILTER)
echo exclude /dev >> $(INITRD_FILTER)
echo exclude /next >> $(INITRD_FILTER)
echo exclude /tmp >> $(INITRD_FILTER)
echo exclude /$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
echo exclude /etc/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
echo exclude /include/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
echo exclude /tix/$(OTHER_PLATFORM_1) >> $(INITRD_FILTER)
mkinitrd $(ROOT)/ -o $(INITRD) --format=sortix-initrd-2 --filter=$(INITRD_FILTER)
rm -f $(INITRD_FILTER)
gzip -v $(INITRD)
# Format a device with a tar filesystem.
device-format-tar:
tar cvf DEVICE=$(DEVICE)
# Update the kernel on a device.
update-tar-device-kernel: $(KERNEL)
cd $(BOOTDIR) ; head sortix.bin > /dev/null
cd $(BOOTDIR) ; tar --delete --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.bin
cd $(BOOTDIR) ; tar --append --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.bin
# Update the initrd on a device.
update-tar-device-initrd: $(INITRD)$(INITRD_COMPRESSION)
cd $(BOOTDIR) ; head sortix.initrd$(INITRD_COMPRESSION) > /dev/null
cd $(BOOTDIR) ; tar --delete --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.initrd$(INITRD_COMPRESSION)
cd $(BOOTDIR) ; tar --append --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.initrd$(INITRD_COMPRESSION)
# Update the kernel and initrd on a device.
update-tar-device-image: $(KERNEL) $(INITRD)$(INITRD_COMPRESSION)
cd $(BOOTDIR) ; head sortix.bin sortix.initrd$(INITRD_COMPRESSION) > /dev/null
cd $(BOOTDIR) ; tar --create --verbose --checkpoint=1 --blocking-factor=2048 --file=$(DEVICE) sortix.bin sortix.initrd$(INITRD_COMPRESSION)
# Build an entire new Sortix system and install onto this device.
install-onto-device:
$(MAKE) system ROOT=/next
$(MAKE) initrd ROOT=/next
$(MAKE) update-tar-device-image ROOT=/next DEVICE=$(DEVICE)
# Misc. stuff down here.
fetch-device-stuff: fetch-device-kernel fetch-device-initrd
fetch-device-kernel:
cd $(BOOTDIR) ; tar xvf $(DEVICE) sortix.bin
fetch-device-initrd:
cd $(BOOTDIR) ; tar xvf $(DEVICE)
#

View File

@ -1,6 +1,7 @@
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CPPFLAGS?=

View File

@ -1,7 +1,8 @@
SOFTWARE_MEANT_FOR_SORTIX=1
include ../compiler.mak
include ../version.mak
include ../dirs.mak
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
@ -76,4 +77,3 @@ install: all
clean:
rm -f $(BINARIES) *.o