Advertisement
stiansjogren

Xlinix source script

Apr 27th, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Change the following definition to reflect any given install location
  4. ROOTDIR=/packages/LabSoC/Xilinx
  5.  
  6. declare -A tools
  7. # tools["ISE"]="ISE"
  8. tools["Vivado"]="VIVADO"
  9.  
  10. # Echoes
  11. str=''
  12. idt='  '
  13. tab=''
  14. function indent {
  15.     tab+="${idt}"
  16. }
  17. function dedent {
  18.     tab="${tab/%$idt}"
  19. }
  20. function append {
  21.     str+="${1}"
  22. }
  23. function eol {
  24.     append $'\n'
  25. }
  26. function log {
  27.     append "${tab}${*}"
  28.     eol
  29. }
  30.  
  31. # Common environment variables modifications
  32. function vappend {
  33.     tmp="${!1}"
  34.     if [ "x${tmp}" == "x" ]; then
  35.         export ${1}=${2}
  36.     elif [[ "${tmp}" != ${2} && "${tmp}" != ${2}:* && "${tmp}" != *:${2} && "${tmp}" != *:${2}:* ]]; then
  37.         export ${1}=${tmp}:${2}
  38.     fi
  39. }
  40. function vprepend {
  41.     tmp="${!1}"
  42.     if [ "x${tmp}" == "x" ]; then
  43.         export ${1}=${2}
  44.     elif [[ "${tmp}" != ${2} && "${tmp}" != ${2}:* && "${tmp}" != *:${2} && "${tmp}" != *:${2}:* ]]; then
  45.         export ${1}=${2}:${tmp}
  46.     fi
  47. }
  48. lm_license_file=${LM_LICENSE_FILE}
  49. path=${PATH}
  50. lang=${LANG}
  51. lc_ctype=${LC_CTYPE}
  52. lc_numeric=${LC_NUMERIC}
  53. ld_library_path=${LD_LIBRARY_PATH}
  54.  
  55. # Architecture
  56. arch="32"
  57. brch=""
  58. uname -a | grep x86_64 > /dev/null
  59. if [ $? -eq 0 ]; then
  60.     arch="64"
  61.     brch="_x86_64"
  62. fi
  63.  
  64. echo "Xilinx tools configuration:"
  65. indent
  66. log $'Selected architecture:'
  67. indent
  68. if [ "x${XILINX_ARCH}" = "x" ]; then
  69.     XILINX_ARCH="${arch}"
  70.     log "None, trying ${XILINX_ARCH} bits. Please set the XILINX_ARCH environment variable to 32 or 64 in order to change this"
  71. else
  72.     log "${XILINX_ARCH} bits. Please set the XILINX_ARCH environment variable to 32 or 64 in order to change this"
  73. fi
  74. dedent
  75.  
  76. for tool in "${!tools[@]}"; do
  77.     TOOL=${tools[$tool]}
  78.     v="XILINX_${TOOL}_VERSION"
  79.     if [ "x${!v}" = "x" ]; then
  80.         version=Default
  81.     else
  82.         version="${!v}"
  83.     fi
  84.     if [ -d "${ROOTDIR}/$tool" ]; then
  85.         log "${tool}:"
  86.         indent
  87.         log "Selected version: ${version}. Please set the XILINX_${TOOL}_VERSION environment variable to change this. Available versions:"
  88.         indent
  89.         for n in ${ROOTDIR}/${tool}/*; do
  90.             n=$(basename "${n}")
  91.             log "${n}"
  92.         done
  93.         dedent
  94.         log "Configuring ${tool}:"
  95.         indent
  96.         root="${ROOTDIR}/${tool}/${version}"
  97.         if [ "${tool}" = "ISE" ]; then
  98.             root+="/ISE_DS"
  99.         fi
  100.         if [ -f "${root}/settings${XILINX_ARCH}.sh" ]; then
  101.             log "source ${root}/settings${XILINX_ARCH}.sh"
  102.             source ${root}/settings${XILINX_ARCH}.sh
  103.         else
  104.             log "${root} does not seam to be a valid installation directory for ${tool} (${version} version) ${arch} bits. Skipping ${tool} configuration."
  105.         fi
  106.         dedent
  107.         dedent
  108.     elif [ "x${!v}" != "x" ]; then
  109.         log "Could not find installation directory of ${tool} (${version} version) ${arch} bits. Skipping ${tool} configuration."
  110.     fi
  111. done
  112.  
  113. # Licenses
  114. log "Licenses:"
  115. indent
  116. export LM_LICENSE_FILE="27000@lmgrd"
  117. log "LM_LICENSE_FILE=${LM_LICENSE_FILE}"
  118. dedent
  119.  
  120. # Locales
  121. export LANG="en_US.UTF-8"
  122. export LC_CTYPE="en_US.UTF-8"
  123. export LC_NUMERIC="en_US.UTF-8"
  124.  
  125. # Prompt, message
  126. cp=0
  127. for V in LM_LICENSE_FILE PATH LD_LIBRARY_PATH LANG LC_CTYPE LC_NUMERIC; do
  128.     v=${V,,}
  129.     if [ "x${!V}" != "x${!v}" ]; then
  130.         log "Warning: the $V environment variable has been modified:"
  131.         indent
  132.         log "Was: ${!v}"
  133.         log "Now: ${!V}"
  134.         dedent
  135.         cp=1
  136.     fi
  137. done
  138. if [ "$cp" == 1 ]; then
  139.     log 'The prompt is modified to reflect these changes.'
  140.     PS1="\[\e[0;31m\]XILINX\[\e[0m\] $PS1"
  141. fi
  142. echo "$str"
  143. str=''
  144. tab=''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement