##// END OF EJS Templates
Fusion avec alexis
pellion -
r137:83bb918de8c6 merge JC
parent child
Show More
@@ -0,0 +1,82
1 #!/bin/bash
2 #"======================================================================================="
3 #"---------------------------------------------------------------------------------------"
4 #" LPP VHDL lib makeDirs "
5 #" Copyright (C) 2010 Laboratory of Plasmas Physic. "
6 #"======================================================================================="
7 #----------------------------------------------------------------------------------------
8 # This file is a part of the LPP VHDL IP LIBRARY
9 # Copyright (C) 2010, Laboratory of Plasmas Physic - CNRS
10 #
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #----------------------------------------------------------------------------------------
25
26
27
28 # Full path function
29 function fullpath() {
30 if test $# -gt 0
31 then
32 cd $1
33 echo `pwd`
34 fi
35 }
36
37
38
39 # Relative path function
40 # both $1 and $2 are absolute paths (biginning with /)
41 # returns $2 relative to $1
42 function relpath() {
43 if test $# -gt 1
44 then
45 source=`fullpath $1`
46 target=`fullpath $2`
47
48 common_part=$source # for now
49 result="" # for now
50
51 while [[ "${target#$common_part}" == "${target}" ]]; do
52 # no match, means that candidate common part is not correct
53 # go up one level (reduce common part)
54 common_part="$(dirname $common_part)"
55 # and record that we went back, with correct / handling
56 if [[ -z $result ]]; then
57 result=".."
58 else
59 result="../$result"
60 fi
61 done
62
63 if [[ $common_part == "/" ]]; then
64 # special case for root (no common path)
65 result="$result/"
66 fi
67
68 # since we now have identified the common part,
69 # compute the non-common part
70 forward_part="${target#$common_part}"
71
72 # and now stick all parts together
73 if [[ -n $result ]] && [[ -n $forward_part ]]; then
74 result="$result$forward_part"
75 elif [[ -n $forward_part ]]; then
76 # extra slash removal
77 result="${forward_part:1}"
78 fi
79
80 echo $result
81 fi
82 }
@@ -25,17 +25,14 echo
25 echo
25 echo
26 echo
26 echo
27
27
28 # Absolute path to this script. /home/user/bin/foo.sh
29 #SCRIPT=$(readlink -f $0)
30 # Absolute path this script is in. /home/user/bin
31
28
32 #LPP_PATCHPATH=`dirname $SCRIPT`
29 VHDLIB_LIB_PATH=`pwd -L`
33 LPP_PATCHPATH=`pwd -L`
30 source $VHDLIB_LIB_PATH/scripts/lpp_bash_functions.sh
34
35 GRLIBPATH=$1
31 GRLIBPATH=$1
36
32
37 echo $LPP_PATCHPATH
38 if [ -d "$GRLIBPATH" ]; then
33 if [ -d "$GRLIBPATH" ]; then
34 LPP_PATCHPATH=`relpath $GRLIBPATH $VHDLIB_LIB_PATH`
35 echo $LPP_PATCHPATH
39 if [ -d "$GRLIBPATH/lib" ]; then
36 if [ -d "$GRLIBPATH/lib" ]; then
40 if [ -d "$GRLIBPATH/designs" ]; then
37 if [ -d "$GRLIBPATH/designs" ]; then
41 if [ -d "$GRLIBPATH/boards" ]; then
38 if [ -d "$GRLIBPATH/boards" ]; then
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now