File: Configure

package info (click to toggle)
spim 8.0%2Bdfsg-5.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,628 kB
  • sloc: asm: 8,560; ansic: 8,441; yacc: 2,298; makefile: 1,114; lex: 705; sh: 219
file content (199 lines) | stat: -rwxr-xr-x 5,565 bytes parent folder | download | duplicates (3)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env bash
#
# Shell script to configure SPIM.
#
# SPIM is covered by a BSD license.
#
# Copyright (c) 1990-2010, James R. Larus.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# Neither the name of the James R. Larus nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#


#
# Shell script to create proper links to machine-dependent files for SPIM.
#
# Usage: Configure
#
# (Environment variable CC can be set to name a compiler--besides the
# default of cc)


set CC = ${CC:=cc}
echo $CC


export CPU_DIR=../CPU
export TEST_DIR=../Tests


rm -f ./configuration $TEST_DIR/tt.endian.s

echo Check if this machine is big-endian or little-endian.
echo This may take a few minutes.

$CC $CPU_DIR/endian.c -o endian

if ./endian; then
  # Big endian
  rm -f $TEST_DIR/tt.s ./configuration
  ln -s $TEST_DIR/tt.be.s $TEST_DIR/tt.endian.s
  echo "-DBIGENDIAN" > ./configuration
  echo I believe this is a big-endian machine.
else
  # Little endian
  rm -f $TEST_DIR/tt.s ./configuration
  ln -s $TEST_DIR/tt.le.s $TEST_DIR/tt.endian.s
  echo "-DLITTLEENDIAN" > ./configuration
  echo I believe this is a little-endian machine.
fi;
rm -f endian endian.exe


multiarch=$(dpkg-architecture -qDEB_HOST_MULTIARCH)

if [ -f /usr/lib/$multiarch/libc.a ]; then
  # Debian Universe:
  echo Looks like a Debian universe exists...
  echo Scaning libc
  nm /usr/lib/$multiarch/libc.a > library_contents
  set flag = -s
else if [ -f /usr/lib/libc.a ]; then
  # BSD Universe:
  echo Looks like a BSD universe exists...
  echo Scaning libc
  nm /usr/lib/libc.a > library_contents
  set flag = -s
else if [ -f /lib/libc.a ]; then
  # System V Universe:
  echo Looks like a System V universe exists...
  echo Scaning libc
  nm /lib/libc.a > library_contents
  set flag = -q
else if [ -f /usr/lib/libc.so ]; then
  # System V Universe?
  echo Looks like a System V universe exists...
  echo Scaning libc
  nm /usr/lib/libc.so > library_contents
  set flag = -q
else if [ -f /usr/lib/libc.dylib ]; then
  # Mac OS X Universe:
  echo Looks like a Mac OS X / OpenStep universe exists...
  echo Scanning libc.dylib
  nm /usr/lib/libc.dylib > library_contents
  set flag = -q
else if [ -f /usr/lib64/libc.a ]; then
  echo Look like a 64 bits linux universe exists...
  echo Scanning libc
  nm /usr/lib64/libc.a > library_contents
  set flag = -q
fi;
fi;
fi;
fi;
fi;
fi;


echo
echo Checking if libc on this machine contains:


if  grep $flag 'vsprintf' library_contents > /dev/null; then
  echo "  vsprintf: Yes, I think so"
else
  echo "-DNEED_VSPRINTF" >> ./configuration
  echo "  vsprintf: No, I don't think"

  if  grep $flag '_doprnt' library_contents > /dev/null; then
    echo "    _doprnt: Yes, I think, so I will use it instead"
  else
    echo "    _doprnt: NO, THIS IS A PROBLEM: NO VSPRINTF AND NO _DOPRNT"
    echo "SPIM WILL NOT RUN PROPERLY"
  fi;
fi;


if  grep $flag 'vfprintf' library_contents > /dev/null; then
  echo "  vfprintf: Yes, I think"
else
  echo "-DNO_VFPRINTF" >> ./configuration
  echo "  vfprintf: No, I don't think"

  if  grep $flag '_doprnt' library_contents > /dev/null; then
    echo "    _doprnt: Yes, I think"
  else
    echo "    _doprnt: NO, THIS IS A PROBLEM: NO VFPRINTF AND NO _DOPRNT"
    echo "SPIM WILL NOT RUN PROPERLY"
  fi;
fi;


if grep $flag 'strtoul' library_contents > /dev/null; then
  echo "  strtoul: Yes, I think"
else
  # No strtol
  echo "-DNEED_STRTOUL" >> ./configuration
  echo "  strtoul: No, I don't think"
fi;


if grep $flag 'strtol' library_contents > /dev/null; then
    echo "  strtol: Yes, I think"
else
  # No strtol
  echo "-DNEED_STRTOL" >> ./configuration
  echo "  strtol: No, I don't think"
fi;


if grep $flag 'memcpy' library_contents > /dev/null; then
  echo "  memcpy: Yes, I think"
else
  # No memcpy
  echo "-DNO_MEM_FUNCTIONS" >> ./configuration
  echo "  memcpy: No, I don't think"
fi;


echo
echo Checking for /usr/include/termios.h
if [ -f /usr/include/termios.h ]; then
  echo "-DUSE_TERMIOS" >> ./configuration
  echo "Yes, it is there"
else
  # No termios
  echo "No, it is not there"
fi;


if [ -f /usr/lib/libc.dylib ]; then
  # Darwin headers restricted if _POSIX_SOURCE
  echo "-U_POSIX_SOURCE" >> ./configuration
fi;

rm -f library_contents