# Cook packages builder configuration file
#

# SliTaz working directory
SLITAZ="/home/slitaz"

# Directory paths for cookutils DB and files.
WOK="$SLITAZ/wok"
PKGS="$SLITAZ/packages"
SRC="$SLITAZ/src"
CACHE="$SLITAZ/cache"
LOGS="$SLITAZ/log"
FEEDS="$SLITAZ/xml"
DATA="/usr/share/cook"

# System packages DB.
DB="/var/lib/tazpkg"
INSTALLED="$DB/installed"

# Result of "ls $INSTALLED | md5sum | cut -c1-32"
SETUP_MD5=""

# Quality Assurance (empty to disable receipt_quality).
QA="0"

# Automatically cook missing build dependencies (empty to disable).
AUTO_COOK=""

# Hg wok for setup and flavors URL for the Cooker.
WOK_URL="https://hg.slitaz.org/wok"
FLAVORS_URL="https://hg.slitaz.org/flavors"

# Cooker URL for RSS feed link (http://localhost/cgi-bin/cooker/cooker.cgi)
COOKER_URL="http://cook.slitaz.org/"

# Translation files to be included in packages.
LOCALE=""

# List of packages installed in build chroot by cook or the Cooker setup.
SETUP_PKGS="slitaz-toolchain pkg-config intltool gettext zlib-dev bzip2
aufs-utils aufs m4 syslinux-extra pcre pcre-dev bash xorg-dev mercurial 
rsync dropbear tazlito"

# Target host architecture type (Glibc doesn't support i386 anymore).
ARCH="i486"

# Build and host. These options are for cross-compiling. If you specify
# both options and BUILD_SYSTEM is different from HOST_SYSTEM, configure
# will prepare to cross-compile from BUILD_SYSTEM to be used on HOST_SYSTEM.
#BUILD_SYSTEM="$(uname -m)-slitaz-linux"
BUILD_SYSTEM="$ARCH-slitaz-linux"
HOST_SYSTEM="$ARCH-slitaz-linux"

# SliTaz uses the sysroot method, this tells GCC to consider dir as the root
# of a tree that contains a (subset of) the root filesystem of the target
# operating system. Target system headers, libraries and run-time object
# files will be searched in there. Cook will use the tools and sysroot in
# the CROSS_TREE for cross compiling. Example: CROSS_TREE="/cross/$ARCH"
CROSS_TREE=""

# List of packages installed in chroot by cook or the Cooker setup.
# When cross compiling we need some build system tools installed and
# some cross-compiled bdeps installed in: $PREFIX (cross host root)
CROSS_SETUP="slitaz-toolchain zlib-dev bzip2 aufs-utils aufs bash m4 \
autoconf automake libtool gettext bison texinfo"

# SliTaz optimisation flags - Wide compatibility & optimized for ARCH.
#
# With -O2: binutils: Produce 14.0M Packed 5.5M Compressed 1.2M
# With -Os: binutils: Produce 13.4M Packed 4.9M Compressed 1.1M
#
# ARM:  don't use -Os but -O2
# ARM: -mcpu=name [arm9|xscale|...] or -march=name [armv4|armv6|...]
# x86_64: CFLAGS="-march=nocona -Os -pipe"
#
#MAKEFLAGS="-j$(($(grep processor /proc/cpuinfo | wc -l)+1))"
MAKEFLAGS="-j$(grep processor /proc/cpuinfo | wc -l)"

# Note '-mindirect-branch=thunk' and friends appeared since GCC-7.3 and
# earlier versions will produce compile errors.
# We use this flag against some flavors of the Spectre vulnerability.
# FIXME: it looks like the flag '-mindirect-branch=thunk-extern' is recommended,
# but no one app is compiled using it even using GCC-7.3. Is something wrong?
#
# Curl configure says:
# configure: CFLAGS note: CFLAGS should only be used to specify C compiler flags,
# not macro definitions. Use CPPFLAGS for: -D_GLIBCXX_USE_C99_MATH=1
#
case "$ARCH" in
	i?86)
		CFLAGS="-march=$ARCH -Os -pipe -mindirect-branch=thunk"
		CPPFLAGS="-D_GLIBCXX_USE_C99_MATH=1"
		;;
	x86_64)
		CFLAGS="-march=nocona -Os -pipe -mindirect-branch=thunk"
		CPPFLAGS="-D_GLIBCXX_USE_C99_MATH=1"
		;;
	arm*)
		CFLAGS="-march=armv6  -O2" # FIXME
		;;
esac
CXXFLAGS="$CFLAGS"
export CFLAGS CXXFLAGS CPPFLAGS

# Binutils 2.22 breaks many packages built without LDFLAGS set correctly.
#LDFLAGS="-Wl,--copy-dt-needed-entries -lXt"

# These LDFLAGS will minify runtime dependencies (shown by ldd)
# in the most cases when libtool used.
#   https://bugzilla.gnome.org/show_bug.cgi?id=655517
#   https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed
export LDFLAGS="-Wl,-Os,--as-needed"

# Default tool prefix for Binutils.
TOOLPREFIX="${HOST_SYSTEM}-"

# Default arguments for GNU configure. CONFIGURE_ARGS is needed for some
# packages since --build and --host is not set at all by cook.site (bug ?).
CONFIG_SITE=/etc/slitaz/cook.site
CONFIGURE_ARGS="--build=$BUILD_SYSTEM --host=$HOST_SYSTEM"

# Mirrors URLs. To download sources near your location.
GNU_MIRROR="https://ftp.igh.cnrs.fr/pub/gnu" # see https://www.gnu.org/prep/ftp.html
SF_MIRROR="https://downloads.sourceforge.net"
XORG_MIRROR="https://www.x.org/archive/individual"
GNOME_MIRROR="http://ftp.gnome.org/pub/GNOME/sources"
GITHUB="https://api.github.com/repos"

# List of filesystems into the aufs chroot (to protect / against modifications)
# Default tank config:
AUFS_MOUNTS="/ /proc /sys /dev/shm /dev/pts /var/cache/tazpkg \
/home /home/slitaz/src /home/slitaz/packages"

# Old way/tazwok compatibility.
BUILD_HOST="$HOST_SYSTEM"
SOURCES_REPOSITORY=$SRC

# Maximum log size in MB per receipt function call (unset it to disable)
DEFAULT_LOG_LIMIT=50

# Command to run wget. Please use wget from chroot for SliTaz Tank:
# HOST_WGET="chroot /home/slitaz/next/chroot/ wget"
HOST_WGET="wget"
