summaryrefslogtreecommitdiff
path: root/yosys-config.in
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-11-19 22:48:48 +0100
committerClifford Wolf <clifford@clifford.at>2013-11-19 23:04:27 +0100
commit7ea7342c18590b945bd8064bb63c8030d74327cc (patch)
tree567a496207b46b94ea0834a03f81a6b109f2fa26 /yosys-config.in
parent0dfdbd991afcbcc38110d22d489969ae33fb1f68 (diff)
Large improvements in yosys-config
Diffstat (limited to 'yosys-config.in')
-rw-r--r--yosys-config.in95
1 files changed, 81 insertions, 14 deletions
diff --git a/yosys-config.in b/yosys-config.in
index d67d881c..8f8dd06c 100644
--- a/yosys-config.in
+++ b/yosys-config.in
@@ -1,7 +1,35 @@
-#!/bin/sh
+#!/bin/bash
help() {
- { echo; echo "Usage: $0 { --cxx | --cxxflags | --ldflags | --ldlibs }"; } >&2
+ {
+ echo ""
+ echo "Usage: $0 [-exec] [--prefix pf] args.."
+ echo ""
+ echo "Replecement args:"
+ echo " --cxx @CXX@"
+ echo " --cxxflags $( echo '@CXXFLAGS@' | fmt -w60 | sed ':a;N;$!ba;s/\n/ \\\n /g' )"
+ echo " --ldflags @LDFLAGS@"
+ echo " --ldlibs @LDLIBS@"
+ echo " --bindir @BINDIR@"
+ echo " --datdir @DATDIR@"
+ echo ""
+ echo "All other args are passed trhough as they are."
+ echo ""
+ echo "Use -exec to call a command instead of generating output. Example usage:"
+ echo ""
+ echo " yosys-config --exec --cxx --cxxflags --ldflags -o plugin.so -shared plugin.cc --ldlibs"
+ echo ""
+ echo "Use --prefix to change the prefix for the special args from '--' to"
+ echo "something else. Example:"
+ echo ""
+ echo " yosys-config --prefix @ bindir: @bindir"
+ echo ""
+ echo "The args --bindir and --datdir can be directly followed by a slash and"
+ echo "additional text. Example:"
+ echo ""
+ echo " yosys-config --datdir/simlib.v"
+ echo ""
+ } >&2
exit 1
}
@@ -9,22 +37,61 @@ if [ $# -eq 0 ]; then
help
fi
+prefix="--"
+get_prefix=false
+exec_mode=false
+declare -a tokens=()
+
for opt; do
+ if $get_prefix; then
+ prefix="$opt"
+ get_prefix=false
+ continue
+ fi
case "$opt" in
- --cxx)
- echo -n '@CXX@ ' ;;
- --cxxflags)
- echo -n '@CXXFLAGS@ ' ;;
- --ldflags)
- echo -n '@LDFLAGS@ ' ;;
- --ldlibs)
- echo -n '@LDLIBS@ ' ;;
- --help|-\?)
- help ;;
+ "$prefix"cxx)
+ tokens=( "${tokens[@]}" @CXX@ ) ;;
+ "$prefix"cxxflags)
+ tokens=( "${tokens[@]}" @CXXFLAGS@ ) ;;
+ "$prefix"ldflags)
+ tokens=( "${tokens[@]}" @LDFLAGS@ ) ;;
+ "$prefix"ldlibs)
+ tokens=( "${tokens[@]}" @LDLIBS@ ) ;;
+ "$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 ;;
*)
- echo -n "$opt "
+ tokens=( "${tokens[@]}" "$opt" )
esac
done
-echo
+if $exec_mode; then
+ exec "${tokens[@]}"
+fi
+
+echo "${tokens[@]}"
exit 0
+