Add install-cross-toolchain Makefile target.
This commit is contained in:
parent
85e9fcde94
commit
3ae81f08b3
58
Makefile
58
Makefile
|
@ -113,6 +113,49 @@ install-build-tools:
|
||||||
$(MAKE) -C sf install
|
$(MAKE) -C sf install
|
||||||
$(MAKE) -C tix install
|
$(MAKE) -C tix install
|
||||||
|
|
||||||
|
.PHONY: clean-cross-compiler
|
||||||
|
clean-cross-compiler:
|
||||||
|
rm -rf ports/binutils/binutils.build
|
||||||
|
rm -rf ports/gcc/gcc.build
|
||||||
|
|
||||||
|
.PHONY: install-cross-compiler
|
||||||
|
install-cross-compiler:
|
||||||
|
PATH="$(PREFIX)/sbin:$(PREFIX)/bin:$(PATH)" \
|
||||||
|
$(MAKE) extract-ports PACKAGES='binutils gcc'
|
||||||
|
rm -rf ports/binutils/binutils.build
|
||||||
|
mkdir ports/binutils/binutils.build
|
||||||
|
cd ports/binutils/binutils.build && \
|
||||||
|
../binutils/configure \
|
||||||
|
--target="$(TARGET)" \
|
||||||
|
--prefix="$(PREFIX)" \
|
||||||
|
--with-sysroot="$(SYSROOT)" \
|
||||||
|
--disable-werror
|
||||||
|
$(MAKE) -C ports/binutils/binutils.build
|
||||||
|
$(MAKE) -C ports/binutils/binutils.build install
|
||||||
|
rm -rf ports/gcc/gcc.build
|
||||||
|
mkdir ports/gcc/gcc.build
|
||||||
|
cd ports/gcc/gcc.build && \
|
||||||
|
PATH="$(PREFIX)/bin:$(PATH)" \
|
||||||
|
../gcc/configure \
|
||||||
|
--target="$(TARGET)" \
|
||||||
|
--prefix="$(PREFIX)" \
|
||||||
|
--with-sysroot="$(SYSROOT)" \
|
||||||
|
--enable-languages=c,c++
|
||||||
|
PATH="$(PREFIX)/bin:$(PATH)" \
|
||||||
|
$(MAKE) -C ports/gcc/gcc.build all-gcc all-target-libgcc
|
||||||
|
PATH="$(PREFIX)/bin:$(PATH)" \
|
||||||
|
$(MAKE) -C ports/gcc/gcc.build install-gcc install-target-libgcc
|
||||||
|
rm -rf ports/gcc/gcc.build
|
||||||
|
|
||||||
|
.PHONY: clean-cross-toolchain
|
||||||
|
clean-cross-toolchain: clean-sysroot clean-build-tools clean-cross-compiler
|
||||||
|
|
||||||
|
.PHONY: install-cross-toolchain
|
||||||
|
install-cross-toolchain: install-build-tools
|
||||||
|
$(MAKE) clean-sysroot
|
||||||
|
$(MAKE) sysroot-base-headers HOST=$(TARGET) PREFIX=
|
||||||
|
$(MAKE) install-cross-compiler
|
||||||
|
|
||||||
.PHONY: sysroot-fsh
|
.PHONY: sysroot-fsh
|
||||||
sysroot-fsh:
|
sysroot-fsh:
|
||||||
mkdir -p "$(SYSROOT)"
|
mkdir -p "$(SYSROOT)"
|
||||||
|
@ -331,10 +374,10 @@ distclean-ports:
|
||||||
build-aux/clean-ports.sh distclean
|
build-aux/clean-ports.sh distclean
|
||||||
|
|
||||||
.PHONY: mostlyclean
|
.PHONY: mostlyclean
|
||||||
mostlyclean: clean-core distclean-ports clean-builds clean-release clean-sysroot
|
mostlyclean: clean-core distclean-ports clean-builds clean-release clean-sysroot clean-cross-compiler
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
distclean: clean-core distclean-ports clean-builds clean-release clean-mirror clean-repository clean-sysroot
|
distclean: clean-core distclean-ports clean-builds clean-release clean-mirror clean-repository clean-sysroot clean-cross-compiler
|
||||||
|
|
||||||
.PHONY: most-things
|
.PHONY: most-things
|
||||||
most-things: sysroot iso
|
most-things: sysroot iso
|
||||||
|
@ -351,6 +394,17 @@ sysroot-base-headers-all-archs:
|
||||||
$(MAKE) clean clean-sysroot
|
$(MAKE) clean clean-sysroot
|
||||||
$(MAKE) sysroot-base-headers HOST=x86_64-sortix
|
$(MAKE) sysroot-base-headers HOST=x86_64-sortix
|
||||||
|
|
||||||
|
.PHONY: install-cross-compiler-all-archs
|
||||||
|
install-cross-compiler-all-archs:
|
||||||
|
$(MAKE) clean-cross-compiler
|
||||||
|
$(MAKE) install-cross-compiler TARGET=i686-sortix
|
||||||
|
$(MAKE) clean-cross-compiler
|
||||||
|
$(MAKE) install-cross-compiler TARGET=x86_64-sortix
|
||||||
|
|
||||||
|
.PHONY: install-cross-toolchain-all-archs
|
||||||
|
install-cross-toolchain-all-archs: install-build-tools
|
||||||
|
$(MAKE) install-cross-compiler-all-archs
|
||||||
|
|
||||||
.PHONY: all-archs
|
.PHONY: all-archs
|
||||||
all-archs:
|
all-archs:
|
||||||
$(MAKE) clean clean-sysroot
|
$(MAKE) clean clean-sysroot
|
||||||
|
|
|
@ -43,25 +43,13 @@ For instance, on an apt-based system you might install the
|
||||||
.Sy grub-pc-bin
|
.Sy grub-pc-bin
|
||||||
package.
|
package.
|
||||||
.Pp
|
.Pp
|
||||||
You will also need the source code for:
|
|
||||||
.Bl -bullet -compact
|
|
||||||
.It
|
|
||||||
Sortix
|
|
||||||
.It
|
|
||||||
Sortix binutils
|
|
||||||
.It
|
|
||||||
Sortix gcc
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
The overall process is:
|
The overall process is:
|
||||||
.Bl -bullet -compact
|
.Bl -bullet -compact
|
||||||
.It
|
.It
|
||||||
Retrieving all the source code.
|
Retrieving the source code.
|
||||||
.It
|
.It
|
||||||
Installing the build tools.
|
Installing the build tools.
|
||||||
.It
|
.It
|
||||||
Creating a system root with the system headers.
|
|
||||||
.It
|
|
||||||
Creating a cross-compiler.
|
Creating a cross-compiler.
|
||||||
.It
|
.It
|
||||||
Cross-compiling the operating system.
|
Cross-compiling the operating system.
|
||||||
|
@ -70,15 +58,9 @@ Cross-compiling the operating system.
|
||||||
You can find the latest Sortix source code at
|
You can find the latest Sortix source code at
|
||||||
.Lk https://sortix.org/source/
|
.Lk https://sortix.org/source/
|
||||||
.Pp
|
.Pp
|
||||||
You can find the latest Sortix binutils source code at
|
The source code for the ports are in the ports subdirectory as URLs to the
|
||||||
.Lk https://sortix.org/toolchain/sortix-binutils-latest.tar.xz
|
upstream tarball, alongside any patches to the upstream release, which are
|
||||||
.Pp
|
downloaded when each port is built.
|
||||||
You can find the latest Sortix gcc source code at
|
|
||||||
.Lk https://sortix.org/toolchain/sortix-gcc-latest.tar.xz
|
|
||||||
.Pp
|
|
||||||
This is a compiler toolchain that has been modified to support Sortix.
|
|
||||||
The toolchain is sometimes updated and you will need the latest toolchain to
|
|
||||||
keep building the latest code.
|
|
||||||
.Ss Variables
|
.Ss Variables
|
||||||
This document will use meta-syntactic shell variables to denote where you have
|
This document will use meta-syntactic shell variables to denote where you have
|
||||||
choice.
|
choice.
|
||||||
|
@ -98,7 +80,7 @@ This could for instance be
|
||||||
.It Sy $CROSS_PREFIX
|
.It Sy $CROSS_PREFIX
|
||||||
The directory path where the cross-toolchain will be installed.
|
The directory path where the cross-toolchain will be installed.
|
||||||
This could for instance be
|
This could for instance be
|
||||||
.Pa /home/user/opt/x86_64-sortix .
|
.Pa /home/user/opt/sortix-toolchain .
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
The following sections describe these variables in detail.
|
The following sections describe these variables in detail.
|
||||||
|
@ -111,14 +93,6 @@ This place will contain the operating system code.
|
||||||
We'll refer to that location as
|
We'll refer to that location as
|
||||||
.Sy $SORTIX.
|
.Sy $SORTIX.
|
||||||
.Pp
|
.Pp
|
||||||
Don't store the source code for the cross-toolchain (binutils and gcc) here.
|
|
||||||
Store the source code for those programs somewhere else, such as in
|
|
||||||
.Pa ~/src .
|
|
||||||
It doesn't make any sense to store the cross toolchain within the Sortix
|
|
||||||
directory.
|
|
||||||
The only toolchain that belongs here is the native toolchain that runs on Sortix
|
|
||||||
(and not on your current operating system).
|
|
||||||
.Pp
|
|
||||||
Don't make a sortix directory and git clone inside it, you redundantly get a
|
Don't make a sortix directory and git clone inside it, you redundantly get a
|
||||||
.Pa ~/sortix/sortix
|
.Pa ~/sortix/sortix
|
||||||
directory instead.
|
directory instead.
|
||||||
|
@ -130,12 +104,12 @@ and
|
||||||
.Sy x86_64-sortix .
|
.Sy x86_64-sortix .
|
||||||
In this guide we will refer to that platform triplet as
|
In this guide we will refer to that platform triplet as
|
||||||
.Sy $SORTIX_PLATFORM .
|
.Sy $SORTIX_PLATFORM .
|
||||||
If you want to build another platform afterwards, then you will have to follow
|
If you want to build another platform afterwards, then repeat the steps with
|
||||||
this guide again.
|
the other platform.
|
||||||
.Ss Cross-Prefix
|
.Ss Cross-Prefix
|
||||||
You should install your cross-toolchain into a useful and isolated directory
|
You should install your cross-toolchain into a useful and isolated directory
|
||||||
such as
|
such as
|
||||||
.Pa $HOME/opt/$SORTIX_PLATFORM .
|
.Pa $HOME/opt/sortix-toolchain .
|
||||||
This allows you to easily dispose of the directory and keeps it isolated from
|
This allows you to easily dispose of the directory and keeps it isolated from
|
||||||
the rest of the system.
|
the rest of the system.
|
||||||
We'll refer to that location as
|
We'll refer to that location as
|
||||||
|
@ -160,44 +134,6 @@ You can make this permanent by adding that line to your
|
||||||
or the applicable file for your shell and system.
|
or the applicable file for your shell and system.
|
||||||
Consult your shell documentation.
|
Consult your shell documentation.
|
||||||
Otherwise type it in all Sortix-related shells before doing anything.
|
Otherwise type it in all Sortix-related shells before doing anything.
|
||||||
.Ss Build Tools
|
|
||||||
You need to install some additional build tools as they are needed to build the
|
|
||||||
operating system.
|
|
||||||
The installed build tools must be in sync with the source code as described in
|
|
||||||
.Xr development 7 .
|
|
||||||
You can install the build utilities by running:
|
|
||||||
.Bd -literal
|
|
||||||
cd "$SORTIX" &&
|
|
||||||
make clean-build-tools &&
|
|
||||||
make PREFIX="$CROSS_PREFIX" build-tools &&
|
|
||||||
make PREFIX="$CROSS_PREFIX" install-build-tools
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
These tools produce platform independent output so you may wish to install them
|
|
||||||
into
|
|
||||||
.Pa $HOME/bin
|
|
||||||
and
|
|
||||||
.Pa $HOME/sbin
|
|
||||||
or
|
|
||||||
.Pa /usr/local/bin
|
|
||||||
and
|
|
||||||
.Pa /usr/local/sbin
|
|
||||||
or where it suits you in your
|
|
||||||
.Ev PATH .
|
|
||||||
.Ss System Root with System Headers
|
|
||||||
Building the compiler requires the standard library headers being available.
|
|
||||||
This can be satisfies by creating a system root with the system headers:
|
|
||||||
.Bd -literal
|
|
||||||
cd "$SORTIX" &&
|
|
||||||
make distclean &&
|
|
||||||
make sysroot-base-headers HOST=$SORTIX_PLATFORM
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
This will create a system root at
|
|
||||||
.Pa $SORTIX/sysroot .
|
|
||||||
The system root directory is always the
|
|
||||||
.Pa sysroot
|
|
||||||
subdirectory of the main source code directory.
|
|
||||||
.Ss Cross-toolchain Dependencies
|
.Ss Cross-toolchain Dependencies
|
||||||
You need to install these libraries (and the development packages) before
|
You need to install these libraries (and the development packages) before
|
||||||
building binutils and gcc:
|
building binutils and gcc:
|
||||||
|
@ -215,46 +151,43 @@ libmpc
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Consult the official binutils and gcc documentation for the exact dependencies.
|
Consult the official binutils and gcc documentation for the exact dependencies.
|
||||||
.Ss binutils
|
.Ss Cross-toolchain
|
||||||
Assuming you extracted the binutils to
|
You can build the full cross-toolchain containing the build tools and the
|
||||||
.Pa ~/src/sortix-binutils ,
|
cross-compiler (binutils and gcc) by running:
|
||||||
you can build binutils out-of-directory by running:
|
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
mkdir ~/src/binutils-build &&
|
cd "$SORTIX" &&
|
||||||
cd ~/src/binutils-build &&
|
make clean-cross-toolchain &&
|
||||||
../sortix-binutils/configure \\
|
make PREFIX="$CROSS_PREFIX" TARGET=$SORTIX_PLATFORM install-cross-toolchain
|
||||||
--target=$SORTIX_PLATFORM \\
|
|
||||||
--with-sysroot="$SORTIX/sysroot" \\
|
|
||||||
--prefix="$CROSS_PREFIX" \\
|
|
||||||
--disable-werror &&
|
|
||||||
make &&
|
|
||||||
make install
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
You can remove the temporary
|
This command builds and installs the build tools and the cross-compiler.
|
||||||
.Pa ~/src/binutils-build
|
The build downloads the source code for binutils and gcc modified with support
|
||||||
directory when finished.
|
for this operating system.
|
||||||
.Ss gcc
|
.Pp
|
||||||
Assuming you extracted the gcc to
|
If you want to build a toolchain for every architecture at once, use the
|
||||||
.Pa ~/src/sortix-gcc ,
|
.Sy install-cross-toolchain-all-archs
|
||||||
you can build gcc out-of-directory by running:
|
makefile target instead and omit the
|
||||||
|
.Sy TARGET
|
||||||
|
variable.
|
||||||
|
.Pp
|
||||||
|
.Xr following-development 7
|
||||||
|
gains a notice whenever the build tools or cross-compiler must be upgraded.
|
||||||
|
.Ss Build Tools
|
||||||
|
The above
|
||||||
|
.Sy install-cross-toolchain
|
||||||
|
command already built the build tools needed to bootstrap the operating system.
|
||||||
|
.Pp
|
||||||
|
However, whenever they change you can reinstall the build utilities only by
|
||||||
|
running:
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
mkdir ~/src/gcc-build &&
|
cd "$SORTIX" &&
|
||||||
cd ~/src/gcc-build &&
|
make clean-build-tools &&
|
||||||
../sortix-gcc/configure \\
|
make PREFIX="$CROSS_PREFIX" install-build-tools
|
||||||
--target=$SORTIX_PLATFORM \\
|
|
||||||
--with-sysroot="$SORTIX/sysroot" \\
|
|
||||||
--prefix="$CROSS_PREFIX" \\
|
|
||||||
--enable-languages=c,c++ &&
|
|
||||||
make all-gcc all-target-libgcc &&
|
|
||||||
make install-gcc install-target-libgcc
|
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
You can remove the temporary
|
.Xr following-development 7
|
||||||
.Pa ~/src/gcc-build
|
gains a notice whenever the build tools must be upgraded, as they must match the
|
||||||
directory when finished.
|
source code being built.
|
||||||
Notice how special make targets are used to selectively build only parts of gcc.
|
|
||||||
It is not possible or desirable to build all of gcc here.
|
|
||||||
.Ss Building Sortix
|
.Ss Building Sortix
|
||||||
With the build tools and cross-compiler in the
|
With the build tools and cross-compiler in the
|
||||||
.Ev PATH
|
.Ev PATH
|
||||||
|
|
|
@ -96,9 +96,14 @@ Clean the component directories and the port source code.
|
||||||
.Sy ( clean-core , clean-ports )
|
.Sy ( clean-core , clean-ports )
|
||||||
.It Sy clean-build-tools
|
.It Sy clean-build-tools
|
||||||
Clean the directories of all build tools.
|
Clean the directories of all build tools.
|
||||||
|
.It Sy clean-cross-compiler
|
||||||
|
Clean the directories for the cross-compiler.
|
||||||
|
.It Sy clean-cross-toolchain
|
||||||
|
Clean the directories for the build tools and cross-compiler.
|
||||||
|
.Sy ( clean-build-tools , clean-cross-compiler )
|
||||||
.It Sy distclean
|
.It Sy distclean
|
||||||
Run every clean target such that the source code is ready for distribution.
|
Run every clean target such that the source code is ready for distribution.
|
||||||
.Sy ( clean-builds , clean-core , clean-mirror , clean-release , clean-repository , clean-sysroot , distclean-ports )
|
.Sy ( clean-builds , clean-core , clean-mirror , clean-release , clean-repository , clean-sysroot , distclean-ports, clean-cross-compiler )
|
||||||
.It Sy distclean-ports
|
.It Sy distclean-ports
|
||||||
Remove the port source code extractions.
|
Remove the port source code extractions.
|
||||||
.It Sy extract-ports
|
.It Sy extract-ports
|
||||||
|
@ -109,6 +114,11 @@ in
|
||||||
and apply the appropriate patches.
|
and apply the appropriate patches.
|
||||||
.It Sy install-build-tools
|
.It Sy install-build-tools
|
||||||
Install all build tools after making them.
|
Install all build tools after making them.
|
||||||
|
.It Sy install-cross-compiler
|
||||||
|
Install the cross-compiler after making it.
|
||||||
|
.It Sy install-cross-toolchain
|
||||||
|
Install the build tools and cross-compiler after making them.
|
||||||
|
.Sy ( install-build-tools , install-cross-compiler )
|
||||||
.It Sy iso
|
.It Sy iso
|
||||||
Create a release iso in the
|
Create a release iso in the
|
||||||
.Pa /src/builds
|
.Pa /src/builds
|
||||||
|
@ -130,7 +140,7 @@ The local mirror has the same structure as the remote mirror and can be used as
|
||||||
a remote mirror.
|
a remote mirror.
|
||||||
.It Sy mostlyclean
|
.It Sy mostlyclean
|
||||||
Clean everything except binary packages and the mirror of upstream releases.
|
Clean everything except binary packages and the mirror of upstream releases.
|
||||||
.Sy ( clean-builds , clean-ports , clean-release , clean-sysroot , distclean-ports )
|
.Sy ( clean-builds , clean-ports , clean-release , clean-sysroot , distclean-ports, clean-cross-compiler )
|
||||||
.It Sy presubmit
|
.It Sy presubmit
|
||||||
Verify the port configuration
|
Verify the port configuration
|
||||||
.Sy ( verify-ports ) ,
|
.Sy ( verify-ports ) ,
|
||||||
|
|
Loading…
Reference in New Issue