mirror of https://github.com/YosysHQ/yosys.git
Large improvements in yosys-config
This commit is contained in:
parent
0dfdbd991a
commit
7ea7342c18
3
Makefile
3
Makefile
|
@ -90,7 +90,8 @@ kernel/version_$(GIT_REV).cc: Makefile
|
||||||
echo "extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys $(YOSYS_VER) (git sha1 $(GIT_REV))\";" > kernel/version_$(GIT_REV).cc
|
echo "extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys $(YOSYS_VER) (git sha1 $(GIT_REV))\";" > kernel/version_$(GIT_REV).cc
|
||||||
|
|
||||||
yosys-config: yosys-config.in
|
yosys-config: yosys-config.in
|
||||||
sed 's,@CXX@,$(CXX),; s,@CXXFLAGS@,$(CXXFLAGS),; s,@LDFLAGS@,$(LDFLAGS),; s,@LDLIBS@,$(LDLIBS),;' < yosys-config.in > yosys-config
|
sed -e 's,@CXX@,$(CXX),;' -e 's,@CXXFLAGS@,$(CXXFLAGS),;' -e 's,@LDFLAGS@,$(LDFLAGS),;' -e 's,@LDLIBS@,$(LDLIBS),;' \
|
||||||
|
-e 's,@BINDIR@,$(DESTDIR)/bin,;' -e 's,@DATDIR@,$(DESTDIR)/share/yosys,;' < yosys-config.in > yosys-config
|
||||||
chmod +x yosys-config
|
chmod +x yosys-config
|
||||||
|
|
||||||
yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp
|
yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp
|
||||||
|
|
|
@ -5,8 +5,7 @@ test: stubnets.so
|
||||||
tail test1.log test2.log test3.log
|
tail test1.log test2.log test3.log
|
||||||
|
|
||||||
stubnets.so: stubnets.cc
|
stubnets.so: stubnets.cc
|
||||||
$(shell yosys-config --cxx --cxxflags --ldflags -o stubnets.so \
|
yosys-config --exec --cxx --cxxflags --ldflags -o $@ -shared $^ --ldlibs
|
||||||
-shared stubnets.cc --ldlibs )
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f test1.log test2.log test3.log
|
rm -f test1.log test2.log test3.log
|
||||||
|
|
|
@ -1,7 +1,35 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
help() {
|
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
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,22 +37,61 @@ if [ $# -eq 0 ]; then
|
||||||
help
|
help
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
prefix="--"
|
||||||
|
get_prefix=false
|
||||||
|
exec_mode=false
|
||||||
|
declare -a tokens=()
|
||||||
|
|
||||||
for opt; do
|
for opt; do
|
||||||
|
if $get_prefix; then
|
||||||
|
prefix="$opt"
|
||||||
|
get_prefix=false
|
||||||
|
continue
|
||||||
|
fi
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
--cxx)
|
"$prefix"cxx)
|
||||||
echo -n '@CXX@ ' ;;
|
tokens=( "${tokens[@]}" @CXX@ ) ;;
|
||||||
--cxxflags)
|
"$prefix"cxxflags)
|
||||||
echo -n '@CXXFLAGS@ ' ;;
|
tokens=( "${tokens[@]}" @CXXFLAGS@ ) ;;
|
||||||
--ldflags)
|
"$prefix"ldflags)
|
||||||
echo -n '@LDFLAGS@ ' ;;
|
tokens=( "${tokens[@]}" @LDFLAGS@ ) ;;
|
||||||
--ldlibs)
|
"$prefix"ldlibs)
|
||||||
echo -n '@LDLIBS@ ' ;;
|
tokens=( "${tokens[@]}" @LDLIBS@ ) ;;
|
||||||
--help|-\?)
|
"$prefix"bindir)
|
||||||
help ;;
|
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
|
esac
|
||||||
done
|
done
|
||||||
echo
|
|
||||||
|
|
||||||
|
if $exec_mode; then
|
||||||
|
exec "${tokens[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${tokens[@]}"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue