dos2unix
[nios2ecos.git] / packages / hal / nios2 / arch / current / host / nios2configtool
blob840bcd814778f19a91bc2d6817a3b76e58a437ca
2 # This script is a wrapper around configtool to restrict some options within
3 # configtool to those that make sense for your hardware as described in the 
4 # PTF file.
6 # Copyright (C) 2004 Altera Corporation
8 # This configure script is free software; the Free Software Foundation
9 # gives unlimited permission to copy, distribute and modify it.
11 # Altera gives unlimited permission to copy, distribute and modify
12 # this script.
15 #!/bin/sh
18 # Print general help message
20 print_help()
22   echo "usage : nios2configtool --ptf= --cpu="
23   echo "--ptf= : points to your PTF file"
24   echo "--cpu= : Is the name of the cpu within that PTF you wish to run eCos on"
29 # Did they request the help option
31 if [ "$1" = "--help" ]
32   then 
33   print_help
34 else
35   #
36   # Are either of the first two parameters non zero
37   #
38   if [ -z "$1" ] || [ -z "$2" ] 
39     then
40     echo "Too few paramaters"
41         print_help
42   else
43     #
44         # Is the 3rd parameter zero?
45         #
46     if [ -z "$3" ]
47           then
48           #
49           # Cut off all but the --cmd=
50           #
51           opt1=`echo "$1" | cut -c -6` 
52       opt2=`echo "$2" | cut -c -6` 
53           if [ "$opt1" = "--ptf=" ] || [ "$opt1" = "--cpu=" ]
54         then
55                 if [ "$opt1" = "$opt2" ]
56                   then
57                   echo "Invalid Parameter usage"
58                 else
59           #
60               # Check that the second options is valid
61               #
62               if [ "$opt2" = "--cpu=" ] || [ "$opt2" = "--ptf=" ]
63                     then
64             #
65             # Cut the --ptf= off the appropriate parameter and check that this 
66                         # PTF file exists
67                 #
68                         if [ "$opt1" = "--ptf=" ]
69                           then
70                   ptf_name=`echo "$1" | cut -c 7-`
71                           cpu_name=`echo "$2" | cut -c 7-` 
72                         else
73                   ptf_name=`echo "$2" | cut -c 7-` 
74                           cpu_name=`echo "$1" | cut -c 7-` 
75                         fi
77                         ptf_name=`cygpath -a -u "$ptf_name"`
79                         if [ -f "$ptf_name" ] 
80                           then
81                           #
82                           # If the file nios2_auto.cdl already exists we have another session running or crashed
83                           #
84                           if [ -f "$TMP/nios2_auto.cdl" ]
85                             then
86                             echo -e "\nnios2configtool is already running. " 
87                 echo "Close down the other nios2configtool before starting this instance. "
88                                 echo -e "If you are not running nios2configtool, please delete the file \n""$TMP/nios2_auto.cdl"
89               else
90                 sopc_builder --update_classes_and_exit --no_splash -s --projectpath `cygpath -m $ptf_name`
91                 `cygpath -m \`which gtf-generate\`` \
92                 --gtf=`cygpath -m $NIOS_ECOS/hal/nios2/arch/current/gtf/nios2_auto.cdl.gtf` \
93                 --output-directory=`cygpath -m $TMP` --ptf="$ptf_name" --cpu="$cpu_name" 
94                 configtool
96                 rm -f $TMP/nios2_auto.cdl
97                           fi
99                         else              
100                           echo "No such PTF file"
101                           print_help
102             fi
103           else
104                     echo "Invalid Parameter usage"
105             print_help
106           fi
107                 fi
108           else
109             echo "Invalid Parameter usage"
110                 print_help
111       fi
112     else
113       echo "Too many paramaters"
114           print_help
115     fi
116   fi