#!/bin/bash # # This script is the first stage in bootstrapping a Slackware build to # a new platform or architecture. Running with no arguments builds a # cross-development environment, then cross-builds a minimal rootfs. # Once you have this minimal rootfs booted, run stage2 in that rootfs # to build the rest of the bootstrap packages. # # This script assumes that all the needed sources and SlackBuild # scripts are available in $SLACKROOT/source (below). # The resulting rootfs will be build in $ROOTFS (below). # # Note that SLACKSOURCE_LOCAL is for local SlackBuilds that override # the official ones, for example, board-specific kernel packages. # # You may pass a single module name on the command line to rebuild # just that one module. Module names match the big case statement # below. # # For reference, when a package is built multiple times... # # foo-host is the "runs on host" part of a standard cross-compiler # foo-target is the target libraries etc # target-foo is a cross-built target-native # # Note that the "dev" step requires sudo, as it installs special files # in $ROOTFS/dev/ # # The routine is: # - Find the Slackware package source (either in $SLACKSOURCES_LOCAL/ # or in $SLACKROOT/source) # - Run the SlackBuild script with "--prep" parameter which unpacks # source tarballs, does any patching but does not actually compile # (the package source tarball is unpacked into $SLACKSOURCE) # - Cross-compilation happens in $BUILDDIR # # ------------------------------------------------------------ export LANG=en_US # What are we cross-compiling for? export DISTRO=slackware export ARCH=aarch64 export HWSPEC=sunxi #export KVER=4.3.5 export KARCH=arm64 export CHOST="$ARCH-$DISTRO-linux" export CPU=cortex-a53 export MARCH=armv8-a export WITH_TUNE="--with-abi=ilp32" #export WITH_FPU=neon-fp-armv8 #export WITH_ABI=lp64 export SLKCFLAGS="-O2 -march=$MARCH -mabi=ilp32" export SLKLDFLAGS="" export LIBDIRSUFFIX="64ilp32" export DIR_INSTALL=install$LIBDIRSUFFIX export DIR_BUILDS=builds$LIBDIRSUFFIX export DIR_ROOTFS=rootfs$LIBDIRSUFFIX export DONE="done$LIBDIRSUFFIX" export LIBDIRSUFFIX="" # Bootstrap should be done to "/lib" # Where will we create the cross-compiler binaries? TOP=`cd $(dirname $BASH_SOURCE);pwd` # Where do we look for sources? #SRCDIR=$(cd $(dirname $0); pwd) # Script to run in the rootfs, on the target: STAGE2=$SRCDIR/stage2.sh # Where to find the package sources; # The symlink '$DISTRO' points to your distro development tree # (with 'source' as a subdirectory): SLACKROOT=$TOP/$DISTRO # Local sources: SLACKSOURCE_LOCAL=$SRCDIR/source.local NUMJOBS=${NUMJOBS:--j4} # Where we configure and build our cross-tools: BUILDDIR=$TOP/$DIR_BUILDS # Where we extract our original Slackware sources: SLACKSOURCE=$TOP/sources # Where we store our Slackware packages: SLACKBUILD=$TOP/pkgs # Cross-tools have their own specific prefix: PREFIX=$TOP/$DIR_INSTALL # Kernel specifics: KCONFIGDIR=$SLACKSOURCE_LOCAL/k/configs-$ARCH KCONFIG=config-$HWSPEC-$KVER # The cross-compiler target TARGET=$CHOST # This is where the new rootfs will be built ROOTFS=$TOP/$DIR_ROOTFS # Needed during build: export CFLAGS="$SLKCFLAGS" export LDFLAGS="$SLKLDFLAGS" if [ -f $SRCDIR/local.conf ]; then . $SRCDIR/local.conf fi # ------------------------------------------------------------ # Sanity checks KERNELARGS="ARCH=${KARCH} CROSS_COMPILE=${TARGET}-" export PATH=$PREFIX/bin:$PATH