# /etc/bldpkg.conf
# Part of the SMLinux distribution

# This file allows you to define paths and variable values and prepares a 
# complete build environment for creating SMLinux-compatible packages

# Please refer to sample.SMBuild.explained in the buildsamples directory 
# for complete explanation.

# Set the package extension. Makepkg will use this to figure out the 
# compression utility. Pick one out of tbz/tgz/txz/tlz. 
PKGEXT="tlz"

# Set compressor options. These will be exported in the mkfinalpkg function 
# for makepkg to pickup.
SM_GZIPOPTS="-9c"
SM_BZIPOPTS="-9c"
SM_LZIPOPTS="-0c"
SM_XZOPTS="-9c"

# Set this variable if you wish to be prompted for installing (or upgrading) 
# the package after it has been built successfully. 0 to disable, 1 to 
# enable. Ignored for SSB autobuilds.
SM_INSTALLPROMPT=0

# Set this variable if you wish to be prompted for extracting contents of 
# the newly-built package installer file into a new subdirectory called 
# "test" within the current source directory the build was invoked from. 0 
# to disable, 1 to enable. Ignored for SSB autobuilds.
SM_EXTRACTPROMPT=0

# Whether to use distcc for distributed compilations. 0 to disable, 1 to 
# enable.
SM_GLOBALDISTCC=1

# Whether to use ccache for faster consecutive rebuilds. Set 0 to disable, 
# 1 to enable.
SM_GLOBALCCACHE=1

# Whether to use sccache for faster consecutive builds. Set 0 to disable,
# 1 to enable.
SM_GLOBALSCCACHE=0

# Typical $PATH layout when using ccache + distcc + gcc, assuming gcc is in 
# /bin, should be:
# /opt/ccache/bin:/opt/distcc/bin:/bin:
# ccache first, then distcc and then local gcc. Kindly ensure your $PATH is 
# set in a similar manner.
# 
# HINT:
# To create distcc/ccache symlinks, run this for distcc as an example:
# $ mkdir -p /opt/distcc/bin
# $ for f in cc c++ gcc g++ ; do ln -s /bin/distcc /opt/distcc/bin/$f ; done
# Replace distcc with ccache for creating distcc symlinks

# Distcc binary location
SM_DISTCCBINPATH="/bin/distcc"
# Distcc symlink paths created for cc/gcc/c++/g++
SM_DISTCCSYMPATH="/opt/distcc/bin"

# Ccache binary location
SM_CCACHEBINPATH="/bin/ccache"
# Ccache symlink paths created for cc/gcc/c++/g++
SM_CCACHESYMPATH="/opt/ccache/bin"

# Sccache binary location
SM_SCCACHEBINPATH="/bin/sccache"
# Scache hardlink paths created for cc/gcc/c++/g++
SM_SCCACHEPATH="/opt/sccache/bin"

# Define the distcc timeout period in seconds. This prevents distcc from 
# falling back to local compiler if a distributed job takes a long time to 
# complete. We set it to 30 minutes instead of 5 minutes which is default.
DISTCC_IO_TIMEOUT="1800"

# Define network hosts who will take part in the compile. Please refer to 
# distcc manual for complete info. Must be defined in /etc/hosts unless they
# are an IP. Tip: Distcc by default will use only 2 cores on the local 
# machine.
DISTCC_HOSTS="--randomize localhost/3 mx/3,lzo"

# Add sum total of the above CPU cores/threads or add your own count 
# prepended with "-j". 
SM_CPUTHREADS="-j6"

# Declare a parent temporary directory
SM_PARENTTMP="/tmp"

# Whether to use tmpfs for the package build. The package source will be
# extracted and compiled inside the tmpfs directory and ccache will be 
# disabled to prevent writes to the disk. 1 to enable, 0 to disable.
SM_USETMPFS=0

# Set the tmpfs directory if the above variable is enabled
SM_TMPFSDIR="$SM_PARENTTMP/tmpfsdir"

# Define the nontmpfs base directory
SM_NONTMPFSDIR="$SM_PARENTTMP/sml"

# Directory where the final package installer, example: 
# openssh-8.1-x86_64-1sml.tlz should be placed in. Again, should be outside 
# tmpfs dir. Also declared and defined in autobuild section file, so values 
# may differ. This is for manual builds.
PKGDEST=${PKGDEST:-$SM_PARENTTMP/sml/packages/}

# Whether you want to preserve the build directory which contains the 
# extracted source, for example /tmp/sml/openssh.src/openssh-8.1. 
# SM_USETMPFS, if set to 1, will auto-reset this variable to 0 and the build
# directory will be deleted. Set 1 to preserve it, 0 to rm -rf it 
# automatically at the end of each build
SM_PRESERVEBUILDDIR=1

# Whether you want to preserve the package directory. for example 
# /tmp/sml/package-openssh SM_USETMPFS, if set to 1, will auto-reset this 
# variable to 0 and the package directory will be deleted. Set 1 to preserve
# it, 0 to rm -rf it automatically at the end of each build
SM_PRESERVEPACKAGEDIR=1

# Whether to show build summary. Set to 1 to enable, 0 to disable.
SM_SHOWSUMMARY=1

# Whether to show colours in the build summary. Set 1 to enable, 0 to 
# disable. Also, only show colours if the build is invoked manually and not 
# through the SSB autobuild system where logging is automatic or when 
# logging is invoked using log ./<package.SMBuild>.
[ -z "$SM_COLOURS" ] && SM_COLOURS=1

# Define whether to check for swap. 1 to enable, 0 to disable.
SM_SWAPCHECK=1

# If above variable is set to 1, define minimum swap size required for huge 
# compiles in KiB
SM_SWAPSIZE=2048000

# Define your compilers here. They must be in $PATH *AFTER* ccache and 
# distcc directories
CC="gcc"
CXX="g++"
export CC CXX

# Set CPU-specific compiler variables. Only aarch64 and x86_64 supported. 
# https://github.com/sakaki-/gentoo-on-rpi-64bit/blob/master/reference/compile_run_benchmarks.sh
# https://www.raspberrypi.org/forums/viewtopic.php?t=11629
# Set debug flag
SM_GCCDEBUG="-g3"
# For aarch64
# aarch64-musl-linux is not recognised by most configure scripts and I haven't
# seen any compile except for gmp going wrong with arm-musl-linux
SM_AARCH64HOSTDIST="--host=arm-musl-linux"
SM_AARCH64BUILDDIST="--build=arm-musl-linux"
SM_AARCH64CFLAGS="-O2 -fPIC -pipe -march=armv8-a+crc -mtune=cortex-a53"
# For x86_64
SM_X8664BUILDDIST="--build=x86_64-musl-linux"
SM_X8664CFLAGS="-O2 -fPIC -pipe"

# Set path to configure cache file that contains predefined answers to several
# tests autoconf scripts run. Credits: Sabotage Linux. 
SM_CONFIGSITE="/etc/config.cache"

# Whether to verify tarball checksums contained in checksums.$APP files inside
# source directories. Path to smlinux public key file and signify binaries 
# handled by the mkchecksums script.
SM_VERIFYCHECKSUMS=0

# This array lists the packages whose sources will not be extracted and 
# compiled inside tmpfs, if tmpfs is <= 2GB. If your tmpfs is >= 2GB, empty
# out this entire list.
SM_TMPFSEXCEPTIONLIST=( firefox palemoon qemu dovecot gdb gimp gnumeric \
gtk+2 gtk+3 guile llvm mariadb mesa mesa-demos mupdf perl postfix python2 \
python3 rtorrent spice python-lxml qtbase kernel libreoffice mono \
qtwebengine kernel-source rust )

# This array lists the packages which require additional swap for
# compilation to prevent the system from becoming completely unresponsive 
# for want of more memory.
SM_PACKAGESREQUIRINGSWAP=( firefox palemoon qemu gdb gimp gnumeric gtk+2 \
gtk+3 guile llvm mariadb mesa mupdf libtorrent rtorrent qtbase \
qtwebengine )

# This array is to protect important system directories from being rm -rf'd 
# accidentally. Sometimes you never know what value the variable being 
# expanded as an argument for rm -rf holds, so prevention is better. 
# Populate this list appropriately and use it inside an if/else whenever 
# rm -rf is about to be called.
SM_PROTECTEDDIRECTORIES=( "/bin" "/boot" "/dev" "/etc" "/home" "/include" \
"/lib" "/lib64" "/libexec" "/local" "/man" "/media" "/mnt" "/opt" "/proc" \
"/root" "/run" "/sbin" "/share" "/srv" "/sys" "/tmp" "/usr" "/var" )

# Whether to output application build status in HTML format. Set 1 to enable,
# 0 to disable.
SM_HTMLOUTPUT=1

