From bdca65ac71681663ddc86cca06127898ab3df99a Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 13 Feb 2021 14:55:00 +0100 Subject: Split the generic setup out of the crosscc chapter Signed-off-by: David Oberhollenzer --- README.md | 3 +++ crosscc.md | 72 ++------------------------------------------------------------ setup.md | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 70 deletions(-) create mode 100644 setup.md diff --git a/README.md b/README.md index 4a6ec3d..9008315 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ command lines around (I'm looking at you, LFS). This guide is divided into the following parts: +* [Basic Setup](setup.md). Lists some tools that you should have installed and + walks through the steps of setting up the directory tree that we work in, as + well as a few handy environment variables. * [Building a cross compiler toolchain](crosscc.md). * [Cross compiling a statically linked BusyBox and the kernel](kernel.md). The BusyBox is packaged into a small initrd. We will make it boot on the diff --git a/crosscc.md b/crosscc.md index 5176f0a..74f2d07 100644 --- a/crosscc.md +++ b/crosscc.md @@ -11,43 +11,7 @@ The toolchain we are building generates 32 bit ARM code intended to run on a Raspberry Pi 3. [Musl](https://www.musl-libc.org/) is used as a C standard library implementation. -## Directory Setup - -First of all, you should create an empty directory somewhere where you want -to build the cross toolchain and later the entire system. - -For convenience, we will store the absolute path to this directory inside a -shell variable called **BUILDROOT** and create a few directories to organize -our stuff in: - - BUILDROOT=$(pwd) - - mkdir -p "build" "src" "download" "toolchain/bin" "sysroot" - -I stored the downloaded packages in the **download** directory and extracted -them to a directory called **src**. - -We will later build packages outside the source tree (GCC even requires that -nowadays), inside a sub directory of **build**. - -Our final toolchain will end up in a directory called **toolchain**. - -We store the toolchain location inside another shell variable that I called -**TCDIR** and prepend the executable path of our toolchain to the **PATH** -variable: - - TCDIR="$BUILDROOT/toolchain" - export PATH="$TCDIR/bin:$PATH" - - -The **sysroot** directory will hold the cross compiled binaries for our target -system, as well as headers and libraries used for cross compiling stuff. It is -basically the `/` directory of the system we are going to build. For -convenience, we will also store its absolute path in a shell variable: - - SYSROOT="$BUILDROOT/sysroot" - -## Prerequisites +## Downloading and unpacking everything The following source packages are required for building the toolchain. The links below point to the exact versions that I used. @@ -63,43 +27,11 @@ links below point to the exact versions that I used. * [GCC](https://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.xz), the GNU compiler collection. Contains compilers for C and other languages. -For compiling the packages you will need: - -* gcc -* g++ -* make -* flex -* bison -* gperf -* makeinfo -* ncurses (with headers) -* awk -* automake -* help2man -* curl -* pkg-config -* libtool -* openssl (with headers) - - -In case you wonder: you need the C++ compiler to build GCC. The GCC code base -mainly uses C99, but with some additional C++ features. makeinfo is used by -the GNU utilities that generate info pages from texinfo. ncurses is mainly -needed by the kernel build system for `menuconfig`. OpenSSL is requried to -compile the kernel later on. - -The list should be fairly complete, but I can't guarantee that I didn't miss -something. Normally I work on systems with tons of development tools and -libraries already installed, so if something is missing, please install it -and maybe let me know. - -## Downloading and unpacking everything - Simply download the packages listed above into `download` and unpack them into `src`. For convenience, I provided a small shell script called `download.sh` that, -when run inside `$BUILDROOT`, does this and also verifies the `sha256sum` +when run inside `$BUILDROOT` does this and also verifies the `sha256sum` of the packages, which will further make sure that you are using the **exact** same versions as I am. diff --git a/setup.md b/setup.md new file mode 100644 index 0000000..465c1d7 --- /dev/null +++ b/setup.md @@ -0,0 +1,72 @@ +# Prerequisites and Directory Setup + +This section deals with the packages we need on our system to cross bootstrap +our mini distro, as well as the basic directory setup before we get started. + +## Prerequisites + +For compiling the packages you will need: + +* gcc +* g++ +* make +* flex +* bison +* gperf +* makeinfo +* ncurses (with headers) +* awk +* automake +* help2man +* curl +* pkg-config +* libtool +* openssl (with headers) + + +In case you wonder: even if you don't build any C++ package, you need the C++ +compiler to build GCC. The GCC code base mainly uses C99, but with some +additional C++ features. `makeinfo` is used by the GNU utilities that generate +info pages from texinfo. ncurses is mainly needed by the kernel build system +for `menuconfig`. OpenSSL is also requried to compile the kernel later on. + +The list should be fairly complete, but I can't guarantee that I didn't miss +something. Normally I work on systems with tons of development tools and +libraries already installed, so if something is missing, please install it +and maybe let me know. + +## Directory Setup + +First of all, you should create an empty directory somewhere where you want +to build the cross toolchain and later the entire system. + +For convenience, we will store the absolute path to this directory inside a +shell variable called **BUILDROOT** and create a few directories to organize +our stuff in: + + BUILDROOT=$(pwd) + + mkdir -p "build" "src" "download" "toolchain/bin" "sysroot" + +I stored the downloaded packages in the **download** directory and extracted +them to a directory called **src**. + +We will later build packages outside the source tree (GCC even requires that +nowadays), inside a sub directory of **build**. + +Our final toolchain will end up in a directory called **toolchain**. + +We store the toolchain location inside another shell variable that I called +**TCDIR** and prepend the executable path of our toolchain to the **PATH** +variable: + + TCDIR="$BUILDROOT/toolchain" + export PATH="$TCDIR/bin:$PATH" + + +The **sysroot** directory will hold the cross compiled binaries for our target +system, as well as headers and libraries used for cross compiling stuff. It is +basically the `/` directory of the system we are going to build. For +convenience, we will also store its absolute path in a shell variable: + + SYSROOT="$BUILDROOT/sysroot" -- cgit v1.2.3