dos2unix
[nios2ecos.git] / packages / hal / nios2 / arch / current / host / nios2configgen
blobe22a268d78c5e1c0650d2b2e890cb2e107604423
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                           rm -f $TMP/nios2_auto.cdl
85                           
86                           sopc_builder --update_classes_and_exit --no_splash -s --projectpath `cygpath -m $ptf_name`
87                 `cygpath -m \`which gtf-generate\`` \
88                 --gtf=`cygpath -m $NIOS_ECOS/hal/nios2/arch/current/gtf/nios2_auto.cdl.gtf` \
89                 --output-directory=`cygpath -m $TMP` --ptf="$ptf_name" --cpu="$cpu_name" 
91                         else              
92                           echo "No such PTF file"
93                           print_help
94             fi
95           else
96                     echo "Invalid Parameter usage"
97             print_help
98           fi
99                 fi
100           else
101             echo "Invalid Parameter usage"
102                 print_help
103       fi
104     else
105       echo "Too many paramaters"
106           print_help
107     fi
108   fi