1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16+ # Determine the current working directory
17+ CURRENT_DIR=$( pwd)
18+
1619# Function to detect current OS
1720detect_osversion () {
1821 local osversion=" unsupported"
@@ -60,7 +63,7 @@ copy_files() {
6063 filename_no_ext=" ${filename% .in} "
6164 dest_file=" $dest_dir /$filename_no_ext "
6265 mkdir -p " $dest_dir "
63- sed " s|@VORTEX_HOME@|$SCRIPT_DIR |g; s|@XLEN@|$XLEN |g; s|@TOOLDIR@|$TOOLDIR |g; s|@OSVERSION@|$OSVERSION |g" " $file " > " $dest_file "
66+ sed " s|@VORTEX_HOME@|$SCRIPT_DIR |g; s|@XLEN@|$XLEN |g; s|@TOOLDIR@|$TOOLDIR |g; s|@OSVERSION@|$OSVERSION |g; s|@PREFIX@| $PREFIX |g " " $file " > " $dest_file "
6467 # apply permissions to bash scripts
6568 read -r firstline < " $dest_file "
6669 if [[ " $firstline " =~ ^#! .*bash ]]; then
@@ -110,6 +113,7 @@ copy_files() {
110113default_xlen= 32
111114default_tooldir= /opt
112115default_osversion= $( detect_osversion)
116+ default_prefix= $CURRENT_DIR
113117
114118# load default configuration parameters from existing config.mk
115119if [ -f " config.mk" ]; then
@@ -121,6 +125,7 @@ if [ -f "config.mk" ]; then
121125 XLEN\ ?* ) default_xlen=${value// \? =/ } ;;
122126 TOOLDIR\ ?* ) default_tooldir=${value// \? =/ } ;;
123127 OSVERSION\ ?* ) default_osversion=${value// \? =/ } ;;
128+ PREFIX\ ?* ) default_prefix=${value// \? =/ } ;;
124129 esac
125130 done < config.mk
126131fi
129134XLEN= ${XLEN:= $default_xlen }
130135TOOLDIR= ${TOOLDIR:= $default_tooldir }
131136OSVERSION= ${OSVERSION:= $default_osversion }
137+ PREFIX= ${PREFIX:= $default_prefix }
132138
133139# parse command line arguments
134140usage () {
135141 echo " Usage: $0 [--xlen=<value>] [--tooldir=<path>] [--osversion=<version>]"
136142 echo " --xlen=<value> Set the XLEN value (default: 32)"
137143 echo " --tooldir=<path> Set the TOOLDIR path (default: /opt)"
138- echo " --osversion=<version> Set the OS Version (default: $( detect_os) )"
144+ echo " --osversion=<version> Set the OS Version (default: $( detect_os) )"
145+ echo " --prefix=<path> Set installation directory"
139146 exit 1
140147}
141148while [[ " $# " -gt 0 ]]; do
142149 case $1 in
143150 --xlen=* ) XLEN=" ${1#* =} " ;;
144151 --tooldir=* ) TOOLDIR=" ${1#* =} " ;;
145152 --osversion=* ) OSVERSION=" ${1#* =} " ;;
153+ --prefix=* ) PREFIX=" ${1#* =} " ;;
146154 -h|--help) usage ;;
147155 * ) echo " Unknown parameter passed: $1 " ; usage ;;
148156 esac
@@ -161,9 +169,6 @@ SUBDIRS=("." "!ci" "!perf" "hw*" "kernel*" "runtime*" "sim*" "tests*")
161169# Get the directory of the script
162170SCRIPT_DIR= " $( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) "
163171
164- # Determine the current working directory
165- CURRENT_DIR= $( pwd)
166-
167172THIRD_PARTY_DIR= $SCRIPT_DIR /third_party
168173
169174copy_files " $SCRIPT_DIR " " $CURRENT_DIR "
0 commit comments