yosys/misc/yosys-config.in

113 lines
2.7 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
help() {
2013-11-19 15:48:48 -06:00
{
echo ""
echo "Usage: $0 [--exec] [--prefix pf] args.."
echo " $0 --build modname.so cppsources.."
2013-11-19 15:48:48 -06:00
echo ""
2020-04-22 10:30:03 -05:00
echo "Replacement args:"
2013-11-19 15:48:48 -06:00
echo " --cxx @CXX@"
echo " --cxxflags $( echo '@CXXFLAGS@' | fmt -w60 | sed ':a;N;$!ba;s/\n/ \\\n /g' )"
echo " --linkflags @LINKFLAGS@"
echo " --ldflags (alias of --linkflags)"
echo " --libs @LIBS@"
echo " --ldlibs (alias of --libs)"
2013-11-19 15:48:48 -06:00
echo " --bindir @BINDIR@"
echo " --datdir @DATDIR@"
echo ""
2015-02-07 17:16:59 -06:00
echo "All other args are passed through as they are."
2013-11-19 15:48:48 -06:00
echo ""
echo "Use --exec to call a command instead of generating output. Example usage:"
2013-11-19 15:48:48 -06:00
echo ""
echo " $0 --exec --cxx --cxxflags --ldflags -o plugin.so -shared plugin.cc --libs"
2013-11-19 15:48:48 -06:00
echo ""
echo "The above command can be abbreviated as:"
echo ""
2020-04-10 03:38:40 -05:00
echo " $0 --build plugin.so plugin.cc"
echo ""
2013-11-19 15:48:48 -06:00
echo "Use --prefix to change the prefix for the special args from '--' to"
echo "something else. Example:"
echo ""
2020-04-10 03:38:40 -05:00
echo " $0 --prefix @ bindir: @bindir"
2013-11-19 15:48:48 -06:00
echo ""
echo "The args --bindir and --datdir can be directly followed by a slash and"
echo "additional text. Example:"
echo ""
2020-04-10 03:38:40 -05:00
echo " $0 --datdir/simlib.v"
2013-11-19 15:48:48 -06:00
echo ""
} >&2
exit 1
}
if [ $# -eq 0 ]; then
help
fi
if [ "$1" = "--build" ]; then
modname="$2"; shift 2
set -- --exec --cxx --cxxflags --ldflags -o "$modname" -shared "$@" --libs
fi
2013-11-19 15:48:48 -06:00
prefix="--"
get_prefix=false
exec_mode=false
declare -a tokens=()
for opt; do
2013-11-19 15:48:48 -06:00
if $get_prefix; then
prefix="$opt"
get_prefix=false
continue
fi
case "$opt" in
2013-11-19 15:48:48 -06:00
"$prefix"cxx)
tokens=( "${tokens[@]}" @CXX@ ) ;;
"$prefix"cxxflags)
tokens=( "${tokens[@]}" @CXXFLAGS@ ) ;;
"$prefix"linkflags)
tokens=( "${tokens[@]}" @LINKFLAGS@ ) ;;
"$prefix"libs)
tokens=( "${tokens[@]}" @LIBS@ ) ;;
2013-11-19 15:48:48 -06:00
"$prefix"ldflags)
tokens=( "${tokens[@]}" @LINKFLAGS@ ) ;;
2013-11-19 15:48:48 -06:00
"$prefix"ldlibs)
tokens=( "${tokens[@]}" @LIBS@ ) ;;
2013-11-19 15:48:48 -06:00
"$prefix"bindir)
tokens=( "${tokens[@]}" '@BINDIR@' ) ;;
"$prefix"datdir)
tokens=( "${tokens[@]}" '@DATDIR@' ) ;;
"$prefix"bindir/*)
tokens=( "${tokens[@]}" '@BINDIR@'"${opt#${prefix}bindir}" ) ;;
"$prefix"datdir/*)
tokens=( "${tokens[@]}" '@DATDIR@'"${opt#${prefix}datdir}" ) ;;
--help|-\?|-h)
if [ ${#tokens[@]} -eq 0 ]; then
help
else
tokens=( "${tokens[@]}" "$opt" )
fi ;;
--exec)
if [ ${#tokens[@]} -eq 0 ]; then
exec_mode=true
else
tokens=( "${tokens[@]}" "$opt" )
fi ;;
--prefix)
if [ ${#tokens[@]} -eq 0 ]; then
get_prefix=true
else
tokens=( "${tokens[@]}" "$opt" )
fi ;;
*)
2013-11-19 15:48:48 -06:00
tokens=( "${tokens[@]}" "$opt" )
esac
done
2013-11-19 15:48:48 -06:00
if $exec_mode; then
exec "${tokens[@]}"
fi
echo "${tokens[@]}"
exit 0