|
#---------------------------------------------------------------------------------------------# |
|
# make sure this file is LINUX EOL (\n) and not WINDOWS EOL (\r\n) if you edit it in Windows. # |
|
#---------------------------------------------------------------------------------------------# |
|
|
|
set -o nounset #treat unset variables as an error (ON set -u OFF set +u). |
|
set -o errexit #exit on any command failure (set -e). |
|
set -o pipefail #make a pipeline fail if any component fails. |
|
#set -o xtrace #print each command before executing it (set -x). |
|
set -o verbose #print shell input lines as read (set -v). |
|
#set -o noexec #read commands but do not execute (syntax check) (set -n). |
|
set -o noglob #disable filename globbing (wildcards) (set -f). |
|
set -o notify #notify of job completion immediately (set -b). |
|
set -o noclobber #prevent > from overwriting existing files (set -C). |
|
|
|
#-------------------------------------------------- Target host (cross-compile triplet) |
|
#export HOST="i686-w64-mingw32" |
|
export HOST="x86_64-w64-mingw32" |
|
|
|
#-------------------------------------------------- Cross-tool prefix and installation prefix for staged sysroot |
|
export CROSS_PREFIX="${HOST}-" |
|
|
|
export INSTALL_PREFIX="${HOME}/.local/${HOST}" #I prefer full path. keep it, used in many scripts. |
|
export SYSROOT="${HOME}/.local/${HOST}" #same. I prefer full path. keep it, used in many scripts. |
|
|
|
#-------------------------------------------------- Toolchain binaries (use cross-prefixed tools) |
|
export ADDR2LINE="${CROSS_PREFIX}addr2line" # convert addresses to source locations |
|
export AR="${CROSS_PREFIX}ar" # archive librarian |
|
export CC="${CROSS_PREFIX}gcc" # C compiler |
|
export CPP="${CROSS_PREFIX}cpp" # C preprocessor |
|
export CXX_POSIX="${CROSS_PREFIX}c++-posix" # posix variant of C++ compiler, if available |
|
export CXX="${CROSS_PREFIX}g++" # C++ compiler |
|
export DLLTOOL="${CROSS_PREFIX}dlltool" # create import libraries |
|
export DLLWRAP="${CROSS_PREFIX}dllwrap" # wrap DLLs (optional) |
|
export ELFEDIT="${CROSS_PREFIX}elfedit" # edit ELF files |
|
export GCC_AR="${CROSS_PREFIX}gcc-ar" # gcc wrapper for ar (for LTO) |
|
export GCC_NM="${CROSS_PREFIX}nm" # name lister (gcc-aware) |
|
export GCOV_TOOL="${CROSS_PREFIX}gcov-tool" # gcov tool for coverage |
|
export GCOV="${CROSS_PREFIX}gcov" # coverage analyzer |
|
export GPROF="${CROSS_PREFIX}gprof" # profiler |
|
export GXX="${CROSS_PREFIX}g++" # alt C++ compiler name |
|
export LD="${CROSS_PREFIX}ld" # linker |
|
export LTO_DUMP="${CROSS_PREFIX}lto-dump-posix" # LTO dump tool (posix) |
|
export NM="${CROSS_PREFIX}nm" # symbol table dumper |
|
export OBJCOPY="${CROSS_PREFIX}objcopy" # copy and translate object files |
|
export RANLIB="${CROSS_PREFIX}ranlib" # index archives |
|
export READELF="${CROSS_PREFIX}readelf" # display ELF info |
|
export SIZE="${CROSS_PREFIX}size" # list section sizes |
|
export STRINGS="${CROSS_PREFIX}strings" # print strings in binaries |
|
export STRIP="${CROSS_PREFIX}strip" # strip symbols |
|
export WIDL="${CROSS_PREFIX}widl" # IDL compiler (Wine) |
|
export WINDMC="${CROSS_PREFIX}windmc" # message compiler (Windows) |
|
export WINDRES="${CROSS_PREFIX}windres" # resource compiler |
|
export PKG_CONFIG="${CROSS_PREFIX}pkg-config" # pkg-config wrapper for cross prefix |
|
|
|
#-------------------------------------------------- search path for pkg-config .pc files |
|
if [ "${PKG_CONFIG_PATH+defined}" = defined ] && [ -n "${PKG_CONFIG_PATH}" ]; then |
|
# defined and not empty |
|
export PKG_CONFIG_PATH="${HOME}/.local/${HOST}/lib/pkgconfig:${PKG_CONFIG_PATH}" |
|
else |
|
# either undefined or empty — set to INSTALL_PREFIX only |
|
export PKG_CONFIG_PATH="${HOME}/.local/${HOST}/lib/pkgconfig" |
|
fi |
|
|
|
|
|
#-------------------------------------------------- Preprocessor and include paths. |
|
export CPPFLAGS="-I. -I${HOME}/.local/${HOST}/include -I${HOME}/.local/${HOST}/usr/include -I/usr/${HOST}/include" # add current dir and staged include dir |
|
|
|
#-------------------------------------------------- Compiler flags: sysroot, staged includes, tuning and optimization |
|
export CFLAGS="--sysroot=${HOME}/.local/${HOST} -I. -I${HOME}/.local/${HOST}/include -I${HOME}/.local/${HOST}/usr/include -I/usr/${HOST}/include -mtune=generic -O2 -g0" |
|
|
|
#-------------------------------------------------- Linker flags: set sysroot and staged lib dir |
|
export LDFLAGS="--sysroot=${HOME}/.local/${HOST} -L. -L${HOME}/.local/${HOST}/lib -L${HOME}/.local/${HOST}/usr/lib -L/usr/${HOST}/lib" |
|
|
|
|
|
#-------------------------------------------------- Native compilers used to build host tools (not the target) |
|
export CC_FOR_BUILD="gcc" |
|
export CXX_FOR_BUILD="g++" |
|
|
|
#-------------------------------------------------- Configure flags for distcheck |
|
export DISTCHECK_CONFIGURE_FLAGS="--disable-check" |
|
|
|
#-------------------------------------------------- Optional: create symlink for windres in staged bin (uncomment to enable) |
|
####ln -s "/usr/bin/${WINDRES}" "${HOME}/.local/${HOST}/bin/windres" |
|
|
|
|
|
|
|
|
|
#-------------------------------------------------- Ensure core system and staged bin come before user PATH entries |
|
#export PATH="/usr/bin:${HOME}/.local/${HOST}/bin:${PATH}" |
|
|
|
#-------------------------------------------------- optional. minimal PATH. since WSL also carry the entire PATH of Windows, there is a chance of breaking stuff while building due to lanching by mistake tools at same name from Windows (Visual Studio). this is minimal set of PATH folders needed. you can comment it and uncomment the above line which will just put stuff before older PATH entries. |
|
unset PATH |
|
|
|
export PATH="/usr/bin:${HOME}/.local/${HOST}/bin:${HOME}/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib/snap/bin" |
|
|
|
|
|
#--- have to turn it off when using source to this file, otherwise exit codes other than zero, will exit your wsl or shell ;) |
|
set +o nounset #treat unset variables as an error (ON set -u OFF set +u). |
|
set +o errexit #exit on any command failure (set -e). |
|
set +o pipefail #make a pipeline fail if any component fails. |
|
#set +o xtrace #print each command before executing it (set -x). |
|
set +o verbose #print shell input lines as read (set -v). |
|
#set +o noexec #read commands but do not execute (syntax check) (set -n). |
|
set +o noglob #disable filename globbing (wildcards) (set -f). |
|
set +o notify #notify of job completion immediately (set -b). |
|
set +o noclobber #prevent > from overwriting existing files (set -C). |
|
|
|
|
|
# |