fix lbmk shellcheck errors

There was also a condition in run_make_command that is now
an OR, where it was an AND, on script/trees, to fix the use
of mixed (and erroneous) OR/AND operators.

I'm planning a much more invasive audit than this. These are
light fixes, intended for Libreboot 20241206 rev8.

Signed-off-by: Leah Rowe <leah@libreboot.org>
master
Leah Rowe 2025-01-02 23:52:45 +00:00
parent 8276560cc9
commit 0cf58c2273
7 changed files with 62 additions and 54 deletions

4
build
View File

@ -14,7 +14,7 @@ fi
. "include/vendor.sh" . "include/vendor.sh"
. "include/mrc.sh" . "include/mrc.sh"
eval `setvars "" vdir src_dirname srcdir mode xp ser` eval "`setvars "" vdir src_dirname srcdir mode xp ser`"
err="fail" err="fail"
main() main()
@ -48,7 +48,7 @@ git_init()
{ {
[ -L ".git" ] && return 1 [ -L ".git" ] && return 1
[ -e ".git" ] && return 0 [ -e ".git" ] && return 0
eval `setvars "$(date -Rud @$versiondate)" cdate _nogit` eval "`setvars "$(date -Rud @$versiondate)" cdate _nogit`"
git init || return 1 git init || return 1
git add -A . || return 1 git add -A . || return 1

View File

@ -2,8 +2,8 @@
# Copyright (c) 2020-2021,2023-2024 Leah Rowe <leah@libreboot.org> # Copyright (c) 2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com> # Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
eval `setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \ eval "`setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
depend subfile_bkup repofail` depend subfile_bkup repofail`"
fetch_targets() fetch_targets()
{ {
@ -18,8 +18,8 @@ fetch_targets()
fetch_project() fetch_project()
{ {
eval `setvars "" xtree tree_depend` eval "`setvars "" xtree tree_depend`"
eval `setcfg "config/git/$project/pkg.cfg"` eval "`setcfg "config/git/$project/pkg.cfg"`"
chkvars url chkvars url
@ -71,7 +71,8 @@ prep_submodules()
fetch_submodule() fetch_submodule()
{ {
mcfgdir="$mdir/${1##*/}" mcfgdir="$mdir/${1##*/}"
eval `setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup st` eval "`setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup \
st`"
[ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \ [ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \
$err "! . $mcfgdir/module.cfg" $err "! . $mcfgdir/module.cfg"
@ -103,7 +104,7 @@ tmpclone()
mkdir -p "$XBMK_CACHE/repo" || $err "!rmdir $XBMK_CACHE/repo" mkdir -p "$XBMK_CACHE/repo" || $err "!rmdir $XBMK_CACHE/repo"
if [ "$livepull" = "y" ] && [ ! -d "$repodir" ]; then if [ "$livepull" = "y" ] && [ ! -d "$repodir" ]; then
git clone $1 "$repodir" || git clone $2 "$repodir" || \ git clone "$1" "$repodir" || git clone $2 "$repodir" || \
$err "!clone $1 $2 $repodir $4 $5" # $err "!clone $1 $2 $repodir $4 $5" #
elif [ -d "$repodir" ] && [ $# -lt 6 ]; then elif [ -d "$repodir" ] && [ $# -lt 6 ]; then
git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \ git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \

View File

@ -33,23 +33,23 @@ err_()
setvars() setvars()
{ {
_setvars="" && [ $# -lt 2 ] && $err "setvars: too few arguments" _setvars="" && [ $# -lt 2 ] && $err "setvars: too few arguments"
val="$1" && shift 1 && for var in $@; do val="$1" && shift 1 && for var in "$@"; do
_setvars="$var=\"$val\"; $_setvars" _setvars="$var=\"$val\"; $_setvars"
done; printf "%s\n" "${_setvars% }" done; printf "%s\n" "${_setvars% }"
} }
chkvars() chkvars()
{ {
for var in $@; do for var in "$@"; do
eval "[ -n "\${$var+x}" ] || \$err \"$var unset\"" eval "[ -n "\${$var+x}" ] || \$err \"$var unset\""
eval "[ -n "\$$var" ] || \$err \"$var unset\"" eval "[ -n "\$$var" ] || \$err \"$var unset\""
done; return 0 done; return 0
} }
eval `setvars "" _nogit board xbmk_parent versiondate projectsite projectname \ eval "`setvars "" _nogit board reinstall versiondate projectsite projectname \
aur_notice configdir datadir version relname reinstall` aur_notice configdir datadir version relname xbmk_parent`"
for fv in projectname projectsite version versiondate; do for fv in projectname projectsite version versiondate; do
eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :" eval "[ ! -f \"$fv\" ] || read -r $fv < \"$fv\" || :"
done; chkvars projectname projectsite done; chkvars projectname projectsite
setcfg() setcfg()
@ -75,12 +75,13 @@ install_packages()
[ $# -lt 2 ] && $err "fewer than two arguments" [ $# -lt 2 ] && $err "fewer than two arguments"
[ $# -gt 2 ] && reinstall="$3" [ $# -gt 2 ] && reinstall="$3"
eval `setcfg "config/dependencies/$2"` eval "`setcfg "config/dependencies/$2"`"
chkvars pkg_add pkglist
$pkg_add $pkglist || $err "Cannot install packages" $pkg_add $pkglist || $err "Cannot install packages"
[ -n "$aur_notice" ] && \ [ -n "$aur_notice" ] && \
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; return 0 printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; :
} }
if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then
install_packages "$@" || exit 1 install_packages "$@" || exit 1
@ -267,7 +268,7 @@ cbfs()
mk() mk()
{ {
mk_flag="$1" || $err "No argument given" mk_flag="$1" || $err "No argument given"
shift 1 && for mk_arg in $@; do shift 1 && for mk_arg in "$@"; do
./mk $mk_flag $mk_arg || $err "./mk $mk_flag $mk_arg"; : ./mk $mk_flag $mk_arg || $err "./mk $mk_flag $mk_arg"; :
done; : done; :
} }

View File

@ -4,7 +4,7 @@
# Modifications in this version are Copyright 2021, 2023 and 2024 Leah Rowe. # Modifications in this version are Copyright 2021, 2023 and 2024 Leah Rowe.
# Original copyright detailed in repo: https://review.coreboot.org/coreboot/ # Original copyright detailed in repo: https://review.coreboot.org/coreboot/
eval `setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board SHELLBALL` eval "`setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board SHELLBALL`"
extract_mrc() extract_mrc()
{ {

View File

@ -43,8 +43,9 @@ copyps1bios()
mkpayload_grub() mkpayload_grub()
{ {
eval `setvars "" grub_modules grub_install_modules` eval "`setvars "" grub_modules grub_install_modules`"
$dry eval `setcfg "$grubdata/module/$tree"` $dry eval "`setcfg "$grubdata/module/$tree"`"
$dry chkvars grub_modules grub_install_modules
$dry x_ rm -f "$srcdir/grub.elf"; $dry \ $dry x_ rm -f "$srcdir/grub.elf"; $dry \
"$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \ "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \
-O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \ -O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \
@ -62,7 +63,7 @@ mkvendorfiles()
printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
$err "!mk $srcdir .coreboot-version" $err "!mk $srcdir .coreboot-version"
[ -z "$mode" ] && [ "$target" != "$tree" ] && \ [ -z "$mode" ] && [ "$target" != "$tree" ] && \
x_ ./mk download $target; return 0 x_ ./mk download "$target"; return 0
} }
cook_coreboot_config() cook_coreboot_config()
@ -113,7 +114,8 @@ mkcorebootbin()
if [ "$payload_uboot_i386" = "y" ] || \ if [ "$payload_uboot_i386" = "y" ] || \
[ "$payload_uboot_amd64" = "y" ]; then [ "$payload_uboot_amd64" = "y" ]; then
printf "'$target' has x86 U-Boot; assuming SeaBIOS=y\n" 1>&2 printf "'%s' has x86 U-Boot; assuming SeaBIOS=y\n" \
"$target" 1>&2
payload_seabios="y" payload_seabios="y"
fi fi
@ -204,10 +206,12 @@ mkseagrub()
add_uboot() add_uboot()
{ {
if [ "$displaymode" = "txtmode" ]; then if [ "$displaymode" = "txtmode" ]; then
printf "cb/$target: Cannot use U-Boot in text mode\n" 1>&2 printf "cb/%s: Cannot use U-Boot in text mode\n" \
"$target" 1>&2
return 0 return 0
elif [ "$initmode" = "normal" ]; then elif [ "$initmode" = "normal" ]; then
printf "cb/$target: Cannot use U-Boot in normal initmode\n" 1>&2 printf "cb/%s: Cannot use U-Boot in normal initmode\n" \
"$target" 1>&2
return 0 return 0
fi fi

View File

@ -26,14 +26,14 @@ cv="CONFIG_HAVE_ME_BIN CONFIG_ME_BIN_PATH CONFIG_INCLUDE_SMSC_SCH5545_EC_FW \
CONFIG_FSP_S_FILE CONFIG_FSP_S_CBFS CONFIG_FSP_M_CBFS CONFIG_FSP_USE_REPO \ CONFIG_FSP_S_FILE CONFIG_FSP_S_CBFS CONFIG_FSP_M_CBFS CONFIG_FSP_USE_REPO \
CONFIG_FSP_FULL_FD" CONFIG_FSP_FULL_FD"
eval `setvars "" EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \
E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \
E6400_VGA_romname SCH5545EC_DL_url_bkup SCH5545EC_DL_hash _dest tree \ E6400_VGA_romname SCH5545EC_DL_url_bkup SCH5545EC_DL_hash _dest tree \
mecleaner kbc1126_ec_dump MRC_refcode_cbtree new_mac _dl SCH5545EC_DL_url \ mecleaner kbc1126_ec_dump MRC_refcode_cbtree new_mac _dl SCH5545EC_DL_url \
archive EC_url boarddir rom cbdir DL_url nukemode cbfstoolref FSPFD_hash \ archive EC_url boarddir rom cbdir DL_url nukemode cbfstoolref FSPFD_hash \
_7ztest ME11bootguard ME11delta ME11version ME11sku ME11pch tmpromdir \ _7ztest ME11bootguard ME11delta ME11version ME11sku ME11pch tmpromdir \
IFD_platform ifdprefix cdir sdir _me _metmp mfs TBFW_url_bkup TBFW_url \ IFD_platform ifdprefix cdir sdir _me _metmp mfs TBFW_url_bkup TBFW_url \
TBFW_hash TBFW_size hashfile has_hashes xromsize xchanged $cv` TBFW_hash TBFW_size hashfile xromsize xchanged EC_url_bkup $cv`"
vendor_download() vendor_download()
{ {
@ -58,14 +58,14 @@ readkconfig()
done done
done < "$TMPDIR/vendorcfg.list" done < "$TMPDIR/vendorcfg.list"
eval `setcfg "$TMPDIR/tmpcbcfg"` eval "`setcfg "$TMPDIR/tmpcbcfg"`"
for c in CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN CONFIG_KBC1126_FIRMWARE \ for c in CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN CONFIG_KBC1126_FIRMWARE \
CONFIG_VGA_BIOS_FILE CONFIG_INCLUDE_SMSC_SCH5545_EC_FW \ CONFIG_VGA_BIOS_FILE CONFIG_INCLUDE_SMSC_SCH5545_EC_FW \
CONFIG_LENOVO_TBFW_BIN CONFIG_FSP_M_FILE CONFIG_FSP_S_FILE; do CONFIG_LENOVO_TBFW_BIN CONFIG_FSP_M_FILE CONFIG_FSP_S_FILE; do
eval "[ \"\${$c}\" = \"/dev/null\" ] && continue" eval "[ \"\${$c}\" = \"/dev/null\" ] && continue"
eval "[ -z \"\${$c}\" ] && continue" eval "[ -z \"\${$c}\" ] && continue"
eval `setcfg "config/vendor/$vcfg/pkg.cfg"`; return 0 eval "`setcfg "config/vendor/$vcfg/pkg.cfg"`"; return 0
done done
printf "Vendor files not needed for: %s\n" "$board" 1>&2; return 1 printf "Vendor files not needed for: %s\n" "$board" 1>&2; return 1
} }
@ -77,7 +77,7 @@ bootstrap()
[ -d "${kbc1126_ec_dump%/*}" ] && x_ make -C "$cbdir/util/kbc1126" [ -d "${kbc1126_ec_dump%/*}" ] && x_ make -C "$cbdir/util/kbc1126"
[ -n "$MRC_refcode_cbtree" ] && \ [ -n "$MRC_refcode_cbtree" ] && \
cbfstoolref="elf/cbfstool/$MRC_refcode_cbtree/cbfstool" && \ cbfstoolref="elf/cbfstool/$MRC_refcode_cbtree/cbfstool" && \
x_ ./mk -d coreboot $MRC_refcode_cbtree; return 0 x_ ./mk -d coreboot "$MRC_refcode_cbtree"; return 0
} }
getfiles() getfiles()
@ -345,7 +345,7 @@ vendor_inject()
remkdir "$tmpromdel" remkdir "$tmpromdel"
set +u +e; [ $# -lt 1 ] && $err "No options specified. - $dontflash" set +u +e; [ $# -lt 1 ] && $err "No options specified. - $dontflash"
eval `setvars "" nukemode new_mac xchanged` eval "`setvars "" nukemode new_mac xchanged`"
archive="$1"; archive="$1";
[ $# -gt 1 ] && case "$2" in [ $# -gt 1 ] && case "$2" in
@ -359,7 +359,7 @@ vendor_inject()
check_release "$archive" || \ check_release "$archive" || \
$err "You must run this script on a release archive. - $dontflash" $err "You must run this script on a release archive. - $dontflash"
if readcfg; then if readcfg; then
[ "$nukemode" = "nuke" ] || x_ ./mk download $board [ "$nukemode" = "nuke" ] || x_ ./mk download "$board"
patch_release_roms patch_release_roms
else else
printf "Tarball '%s' (board '%s) doesn't need vendorfiles.\n" \ printf "Tarball '%s' (board '%s) doesn't need vendorfiles.\n" \
@ -407,7 +407,7 @@ readcfg()
[ "$board" = "serprog_pico" ]; then [ "$board" = "serprog_pico" ]; then
return 1 return 1
fi; boarddir="$cbcfgsdir/$board" fi; boarddir="$cbcfgsdir/$board"
eval `setcfg "$boarddir/target.cfg"`; chkvars vcfg tree eval "`setcfg "$boarddir/target.cfg"`"; chkvars vcfg tree
cbdir="src/coreboot/$tree" cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool" cbfstool="elf/cbfstool/$tree/cbfstool"
@ -418,7 +418,7 @@ readcfg()
ifdtool="elf/ifdtool/$tree/ifdtool" ifdtool="elf/ifdtool/$tree/ifdtool"
[ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform" [ -n "$IFD_platform" ] && ifdprefix="-p $IFD_platform"
x_ ./mk -d coreboot $tree x_ ./mk -d coreboot "$tree"
} }
patch_release_roms() patch_release_roms()
@ -454,7 +454,7 @@ patch_release_roms()
printf "Make sure you inserted vendor files: %s\n" \ printf "Make sure you inserted vendor files: %s\n" \
"$vguide" > "$tmpromdir/README.md" || : "$vguide" > "$tmpromdir/README.md" || :
else else
printf "Skipping vendorfiles on '$archive'" printf "Skipping vendorfiles on '%s'\n" "$archive" 1>&2
fi fi
( (
@ -471,7 +471,7 @@ patch_release_roms()
if [ -n "$new_mac" ]; then if [ -n "$new_mac" ]; then
if ! modify_mac_addresses; then if ! modify_mac_addresses; then
printf "\nNo GbE region defined for '$board'\n" \ printf "\nNo GbE region defined for '%s'\n" "$board" \
1>&2 1>&2
printf "Therefore, changing the MAC is impossible.\n" \ printf "Therefore, changing the MAC is impossible.\n" \
1>&2 1>&2
@ -596,17 +596,17 @@ patch_rom()
inject() inject()
{ {
[ $# -lt 3 ] && $err "$@, $rom: usage: inject name path type (offset)" [ $# -lt 3 ] && $err "$*, $rom: usage: inject name path type (offset)"
[ "$2" = "/dev/null" ] && return 0 [ "$2" = "/dev/null" ] && return 0
eval `setvars "" cbfsname _dest _t _offset` eval "`setvars "" cbfsname _dest _t _offset`"
cbfsname="$1"; _dest="${2##*../}"; _t="$3" cbfsname="$1"; _dest="${2##*../}"; _t="$3"
if [ "$_t" = "fsp" ]; then if [ "$_t" = "fsp" ]; then
[ $# -gt 3 ] && _offset="$4" [ $# -gt 3 ] && _offset="$4"
else else
[ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ] && \ [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ] && \
$err "inject $@, $rom: offset given but empty (undefined)" $err "inject $*, $rom: offset given but empty (undefined)"
fi fi
e "$_dest" f n && [ "$nukemode" != "nuke" ] && $err "!inject $dl_type" e "$_dest" f n && [ "$nukemode" != "nuke" ] && $err "!inject $dl_type"
@ -666,6 +666,7 @@ modify_mac_addresses()
"$_xrom" || $err "'$_xrom': Can't insert new GbE file" "$_xrom" || $err "'$_xrom': Can't insert new GbE file"
xchanged="y" xchanged="y"
done < "tmp/rom.list" done < "tmp/rom.list"
printf "\nThe following GbE NVM words were written in '$archive':\n" printf "\nThe following GbE NVM words were written in '%s':\n" \
"$archive"
x_ util/nvmutil/nvm tmp/gbe dump x_ util/nvmutil/nvm tmp/gbe dump
} }

View File

@ -11,13 +11,13 @@ set -u -e
XBMKPATH="$PATH" XBMKPATH="$PATH"
eval `setvars "" xarch srcdir premake cmakedir xlang mode makeargs elfdir cmd \ eval "`setvars "" xarch srcdir premake gnatdir xlang mode makeargs elfdir cmd \
project target target_dir targets xtree _f release bootstrapargs mkhelper \ project target target_dir targets xtree _f release bootstrapargs mkhelper \
autoconfargs listfile autogenargs btype tree rev tree_depend build_depend \ autoconfargs listfile autogenargs btype tree rev tree_depend build_depend \
defconfig postmake mkhelpercfg dry dest_dir mdir cleanargs gccver gccfull \ defconfig postmake mkhelpercfg dry dest_dir mdir cleanargs gccver gccfull \
gnatver gnatfull gccdir gnatdir`; badhash="n" gnatver gnatfull gccdir cmakedir`"; badhash="n"
tree() main()
{ {
while getopts f:b:m:u:c:x:s:l:n:d: option; do while getopts f:b:m:u:c:x:s:l:n:d: option; do
[ -n "$_f" ] && $err "only one flag is permitted" [ -n "$_f" ] && $err "only one flag is permitted"
@ -53,7 +53,7 @@ tree()
e "$mkhelpercfg" f missing && mkhelpercfg="$TMPDIR/mkhelper.cfg" && \ e "$mkhelpercfg" f missing && mkhelpercfg="$TMPDIR/mkhelper.cfg" && \
x_ touch "$mkhelpercfg" x_ touch "$mkhelpercfg"
targets="$@"; cmd="build_targets $targets" targets="$*"; cmd="build_targets $targets"
singletree "$project" && cmd="build_project" singletree "$project" && cmd="build_project"
remkdir "${tmpgit%/*}" remkdir "${tmpgit%/*}"
@ -115,14 +115,15 @@ handle_defconfig()
configure_project() configure_project()
{ {
eval `setvars "" xarch xlang build_depend autoconfargs xtree postmake \ eval "`setvars "" cleanargs build_depend autoconfargs xtree postmake \
tree_depend makeargs btype mkhelper bootstrapargs premake release \ tree_depend makeargs btype mkhelper bootstrapargs premake release \
cleanargs` xarch xlang`"
_tcfg="$1/target.cfg"; badhash="n"; [ -f "$_tcfg" ] || btype="auto" _tcfg="$1/target.cfg"; badhash="n"; [ -f "$_tcfg" ] || btype="auto"
[ -f "$datadir/mkhelper.cfg" ] && eval `setcfg "$datadir/mkhelper.cfg"` [ -f "$datadir/mkhelper.cfg" ] && \
eval "`setcfg "$datadir/mkhelper.cfg"`"
while [ -f "$_tcfg" ] || [ "$cmd" != "build_project" ]; do while [ -f "$_tcfg" ] || [ "$cmd" != "build_project" ]; do
eval `setvars "" rev tree`; eval `setcfg "$_tcfg"` eval "`setvars "" rev tree`"; eval "`setcfg "$_tcfg"`"
printf "Loading %s config: %s\n" "$project" "$_tcfg" printf "Loading %s config: %s\n" "$project" "$_tcfg"
[ "$_f" = "-d" ] && build_depend="" # dry run [ "$_f" = "-d" ] && build_depend="" # dry run
@ -140,7 +141,7 @@ configure_project()
[ -n "$tree" ] && mdir="$mdir/$tree" [ -n "$tree" ] && mdir="$mdir/$tree"
[ -f "CHANGELOG" ] || check_project_hashes [ -f "CHANGELOG" ] || check_project_hashes
[ "$mode" = "fetch" ] || x_ ./mk -f "$project" $target [ "$mode" = "fetch" ] || x_ ./mk -f "$project" "$target"
[ "$mode" = "fetch" ] || return 0 [ "$mode" = "fetch" ] || return 0
[ -f "CHANGELOG" ] && return 1; fetch_${cmd#build_}; return 1 [ -f "CHANGELOG" ] && return 1; fetch_${cmd#build_}; return 1
} }
@ -198,7 +199,7 @@ check_cross_compiler()
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default" [ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
[ -n "$xtree" ] && cbdir="src/coreboot/$xtree" [ -n "$xtree" ] && cbdir="src/coreboot/$xtree"
x_ ./mk -f coreboot ${cbdir#src/coreboot/} x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
export PATH="$PWD/$cbdir/util/crossgcc/xgcc/bin:$PATH" export PATH="$PWD/$cbdir/util/crossgcc/xgcc/bin:$PATH"
export CROSS_COMPILE="${xarch% *}-" export CROSS_COMPILE="${xarch% *}-"
@ -234,16 +235,16 @@ check_gnu_path()
eval "[ \"\$$_gnuarg\" = \"gnat\" ] && continue" eval "[ \"\$$_gnuarg\" = \"gnat\" ] && continue"
$err "check_gnu_path: Invalid argument \"$_gnuarg\"" $err "check_gnu_path: Invalid argument \"$_gnuarg\""
done done
command -v $1 1>/dev/null || $err "Host '$1' unavailable" command -v "$1" 1>/dev/null || $err "Host '$1' unavailable"
eval `setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir` eval "`setvars "" gccver gccfull gnatver gnatfull gccdir gnatdir`"
gnu_setver "$1" "$1" || $err "Command '$1' unavailable." gnu_setver "$1" "$1" || $err "Command '$1' unavailable."
gnu_setver "$2" "$2" || : gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && $err \"Cannot detect host '$1' version\"" eval "[ -z \"\$$1ver\" ] && $err \"Cannot detect host '$1' version\""
[ "$gnatfull" = "$gccfull" ] && return 0 [ "$gnatfull" = "$gccfull" ] && return 0
eval "$1dir="$(dirname "$(command -v $1)")"" eval "$1dir=\"$(dirname "$(command -v "$1")")\""
eval "_gnudir=\"\$$1dir\"; _gnuver=\"\$$1ver\"" eval "_gnudir=\"\$$1dir\"; _gnuver=\"\$$1ver\""
for _gnubin in "$_gnudir/$2-"*; do for _gnubin in "$_gnudir/$2-"*; do
[ -f "$_gnubin" ] || continue [ -f "$_gnubin" ] || continue
@ -266,7 +267,7 @@ check_gnu_path()
gnu_setver() gnu_setver()
{ {
eval "$2 --version 1>/dev/null 2>/dev/null || return 1" eval "$2 --version 1>/dev/null 2>/dev/null || return 1"
eval "$1ver=\"`$2 --version 2>/dev/null | head -n1`\"" eval "$1ver=\"`"$2" --version 2>/dev/null | head -n1`\""
eval "$1ver=\"\${$1ver##* }\"" eval "$1ver=\"\${$1ver##* }\""
eval "$1full=\"\$$1ver\"" eval "$1full=\"\$$1ver\""
eval "$1ver=\"\${$1ver%%.*}\""; : eval "$1ver=\"\${$1ver%%.*}\""; :
@ -316,7 +317,7 @@ run_make_command()
$dry make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs || $err "!$mode" $dry make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs || $err "!$mode"
[ -z "$mkhelper" ] || [ -n "$mode" ] || $mkhelper || $err "!$mkhelper" [ -z "$mkhelper" ] || [ -n "$mode" ] || $mkhelper || $err "!$mkhelper"
[ "$mode" = "clean" ] && \ [ "$mode" != "clean" ] || \
$dry make -C "$srcdir" $cleanargs distclean || :; : $dry make -C "$srcdir" $cleanargs distclean || :; :
} }
@ -352,6 +353,6 @@ copy_elf()
done < "$listfile"; x_ make clean -C "$srcdir" $cleanargs done < "$listfile"; x_ make clean -C "$srcdir" $cleanargs
} }
tree "$@" || exit 0 main "$@" || exit 0
. "$mkhelpercfg" . "$mkhelpercfg"
$cmd $cmd