summaryrefslogtreecommitdiffstats
path: root/rtems/common.sh
blob: ebf4f16ff5807d8114cec23f0110bbbff4850991 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#
#  Some shell functions and shared setup shared across the build scripts
#
#  Including this file assumes these are defined:
#
#  CPU        - user argument
#  my_exit()  - shell script specific exit routine
#  usage()    - shell script usage routine
#
#  Including this file sets:
#
#  target   - to the GNU tools target name
#  CPU      - to the canonical RTEMS CPU
#

#
#  Checks the status returned by executables and exits if it is non-zero.
#
check_fatal()
{
  if [ $1 -ne 0 ] ; then
    shift
    echo "ERROR: $*" >&2
    my_exit 1
  fi
  #echo
  #echo "End of $*"
  #echo -n "Press return to continue> "
  #echo
  #read line
}

print_rtems_cpus()
{
  echo
  echo "CPU is one of the following: "
  echo "  arm           h8300		i386	lm32		m32c"
  echo "  m32r 		mips		nios2	powerpc		sh"
  echo "  sparc		sparc64    	v850"
  echo 
  echo "Formats without a -XXX suffix are the preferred target."
  echo 
  echo "CPU-rtems is used as the GNU target and results in:"
  echo "    arm-rtems         -- ARM"
  echo "    avr-rtems         -- Atmel AVR"
  echo "    bfin-rtems        -- Blackfin"
  echo "    h8300-rtems       -- Renesas H8/300"
  echo "    i386-rtems        -- Intel i386 and above in protected mode (ELF)"
  echo "    lm32-rtems        -- Lattice Micro (ELF)"
  echo "    m32c-rtems        -- Renesas M32C (ELF)"
  echo "    m32R-rtems        -- Renesas M32R (ELF)"
  echo "    m68k-rtems        -- Motorola mc680x0, mc683xx, and ColdFire (ELF)"
  echo "    nios2-rtems       -- Altera NIOS2"
  echo "    powerpc-rtems     -- IBM and Motorola PowerPC"
  echo "    sh-rtems          -- Renesas SH (COFF)"
  echo "    sparc-rtems       -- SPARC (ELF)"
  echo "    sparc64-rtems     -- SPARC64 (ELF)"
  echo "    v850-rtems        -- Renesas v850 (ELF)"
}

# CPU must be set before we run any of this stuff
test "x${CPU}" != "x" || check_fatal $? "(common.sh) CPU not set"

# The argument to the "--target" argument of configure.
target=${CPU}-rtems

case ${CPU} in
  a29k)        ;;
  #arm)         ;;
  arm)
    # Cover up some insanity
    CPU=arm
    type arm-rtemseabi4.11-gcc >/dev/null 2>&1
    if [ $? -eq 0 ] ; then
      target=arm-rtemseabi4.11
    fi
    ;;
  avr)         ;;
  bfin)         ;;
  c3x)         CPU=c4x ; target=c4x-rtems ;;
  c4x)         ;;
  h8300)       ;;
  hppa1.1)     ;;
  i386)        ;;
  lm32)        ;;
  m32c)        ;;
  m32r)        ;;
  m68k)        ;;
  mips)        ;;
  nios2)       ;;
  or32)        ;;
  powerpc)     ;;
  sh)          ;;
  tic4x)       ;;
  sparc)       ;;
  sparc64)     ;;
  v850)        ;;
  native)      CPU=unix;;
  unix)        ;;
  *)  
     echo ${CPU} is not a supported CPU
     echo
     usage
     exit 1
     ;;
esac
 
# insert the os version
target=`echo $target | sed -e 's/-rtems$/-rtems4.11/' -e 's/-rtemself$/-rtemself4.11/'`

#
#  Figure out if GNU make is available
#
gmake_found=no
for name in gmake make
do
  if [ ${gmake_found} = "no" ] ; then
    ${name} --version >/dev/null 2>&1
    if [ $? -eq 0 ] ; then
      MAKE=${name}
      gmake_found=yes 
    fi
  fi

done

if [ ${gmake_found} = "no" ] ; then
   echo "Unable to locate a version of GNU make in your PATH"
   echo "GNU Make is required to build these tools."
   exit 1
fi