Fast compilation

Install ccache.

Install as xdg-config-dir:

#!/bin/sh
# Print the XDG configuration directory
# Reuben Thomas 14th April 2014, 24th September 2020
printf "%s\n" ${XDG_CONFIG_HOME:-~/.config}

Install as xdg-cache-dir:

#!/bin/sh
# Print the XDG cache directory
# Reuben Thomas 29th August 2017, 24th September 2020
printf "%s\n" ${XDG_CACHE_HOME:-~/.cache}
mkdir repo
cd repo
git clone https://git.savannah.gnu.org/git/gnulib.git

In .profile, comment out adding bin directories to PATH, and add to end:

# Interactive environment
INTERACTIVE_ENV="$HOME/.shvars_interactive"
ENV="$INTERACTIVE_ENV"; export ENV
if test -n "$PS1"; then
    . "$INTERACTIVE_ENV"
fi

Add to .bashrc:

. "$HOME/.shvars"

Add to $HOME/.shvars

export arch=`gcc -dumpmachine`

export HOME_LOCAL="$HOME/.local"
export PATH="$HOME_LOCAL/bin/override:$HOME_LOCAL/bin/$arch:$HOME_LOCAL/bin:$HOME_LOCAL/sbin:$HOME_LOCAL/games:$HOME/.cargo/bin:/usr/lib/ccache:$PATH"

export xdg_config_home=$(xdg-config-dir)
export xdg_cache_home=$(xdg-cache-dir)
export cpus=$(nproc)
export nice_cpus=$(($cpus))

export RRT_MAKEFLAGS="-j $nice_cpus" # Set this here so it can be selectively copied elsewhere e.g. Emacs; --output-sync breaks colouring
# Don't set "-l ${nice_cpus}.0" as load average doesn't work well on some OSes
export CARGO_BUILD_JOBS="$nice_cpus"
export GNULIB_SRCDIR=$HOME/repo/gnulib

export LIBRARY_PATH=$HOME_LOCAL/lib/$arch
export CPATH=$HOME_LOCAL/include
export PKG_CONFIG_PATH=$HOME_LOCAL/lib/$arch/pkgconfig:$HOME_LOCAL/lib/pkgconfig:$HOME_LOCAL/share/pkgconfig
export CCACHE_DIR=$xdg_cache_home/ccache

Add to $HOME/.shvars_interactive

export CONFIG_SITE=$HOME/.config/config.site
export MAKEFLAGS="$RRT_MAKEFLAGS"

Contents of $HOME/.config/config.site:

# config.site for autoconf 2.x

# Give configure scripts a per-project per-architecture cache file for
# feature test results.
if test "$cache_file" = /dev/null; then
  # FIXME: ac_abs_confdir is undocumented; works with autoconf 2.69
  # Use an absolute path so as not to break "make distcheck"; however, this
  # does not play well with AX_SUBDIRS_CONFIGURE, which needs a relative
  # path.
  cache_file="$ac_abs_confdir/.config_`uname -m`.cache"
fi

enable_silent_rules=yes

# --prefix defaults to $HOME_LOCAL
test "$prefix" = NONE && prefix="$HOME_LOCAL"

# Fix paths for multi-arch for my home directory
if test "$prefix" = "$HOME_LOCAL"; then
  arch=`gcc -dumpmachine`
  if test "$bindir" = '${exec_prefix}/bin'; then bindir='${exec_prefix}/bin/'"$arch"; fi
  if test "$libdir" = '${exec_prefix}/lib'; then libdir='${exec_prefix}/lib/'"$arch"; fi
fi

Last updated 2022/03/28