-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk-cctype
executable file
·223 lines (215 loc) · 3.83 KB
/
mk-cctype
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/bin/sh
cleanup()
{
rm -f _mk_cctype.c _mk_cctype _mk_cctype.exe
}
fatal()
{
echo "mk-cctype: fatal: $1" 1>&2
cleanup
exit 1
}
#
# check if base directory was specified
#
BASE_DIR="."
echo "$1" | grep '^@' 2>&1 >/dev/null
if [ $? -eq 0 ]
then
BASE_DIR=`echo $1 | sed 's/^@//g'`
shift
fi
SYS_CC=`head -n 1 ${BASE_DIR}/conf-cc`
if [ $? -ne 0 ]
then
fatal "could not read ${BASE_DIR}/conf-cc"
exit 1
fi
#
# If conf-x-cctype exists, compiler is attempting to cross compile and
# the compiler cannot be assumed to output executables compatible with
# this system.
#
if [ -f ${BASE_DIR}/conf-x-cctype ]
then
TYPE=`head -n 1 ${BASE_DIR}/conf-x-cctype`
if [ $? -ne 0 ]
then
fatal "could not read ${BASE_DIR}/conf-x-cctype"
cleanup
exit 1
fi
echo "${TYPE}"
else
( cat <<EOF
#include <stdio.h>
const char *var;
int main()
{
var = "UNKNOWN";
#if defined(__BORLANDC__)
var = "BORLAND_CXX";
#endif
#if defined(__TURBOC__)
var = "BORLAND_TURBO_C";
#endif
#if defined(__MWERKS__)
var = "CODEWARRIOR";
#endif
#if defined(__COMO__)
var = "COMEAU_CXX";
#endif
#if defined(__DECC) || defined(__VAXC) || defined(VAXC)
var = "COMPAQ_C";
#endif
#if defined(__DECCXX) || defined(__VAXC) || defined(VAXC)
var = "COMPAQ_CXX";
#endif
#if defined(_CRAYC)
var = "CRAY_C";
#endif
#if defined(__DCC__)
var = "DIAB";
#endif
#if defined(__DMC__) || defined(__SC__) || defined(__ZTC__)
var = "DIGITAL_MARS";
#endif
#if defined(__DJGPP__) || defined(__GO32__)
var = "DJGPP";
#endif
#if defined(__PATHCC__)
var = "EKOPATH";
#endif
#if defined(__GNUC__)
var = "GCC";
#endif
#if defined(__ghs__)
var = "GREENHILL";
#endif
#if defined(__HP_aCC)
var = "HP_ACC";
#endif
#if defined(__HP_cc)
var = "HP_C";
#endif
#if defined(__IAR_SYSTEMS_ICC__)
var = "IAR";
#endif
#if defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
var = "IBM_XL";
#endif
#if defined(__INTEL_COMPILER) || defined(__ICC) || defined(__ECC) || defined(__ICL)
var = "INTEL";
#endif
#if defined(__KCC)
var = "KAI";
#endif
#if defined(__C166__)
var = "KEIL_C166";
#endif
#if defined(__C51__) || defined(__CX51__)
var = "KEIL_C51";
#endif
#if defined(__CA__) || defined(__KEIL__)
var = "KEIL_CARM";
#endif
#if defined(__LCC__)
var = "LCC";
#endif
#if defined(__llvm__)
var = "LLVM";
#endif
#if defined(__HIGHC__)
var = "METAWARE";
#endif
#if defined(_MRI)
var = "MICROTEC";
#endif
#if defined(__MINGW32__)
var = "MINGW32";
#endif
#if defined(__sgi) || defined(sgi)
var = "MIPSPRO";
#endif
#if defined(__MRC__) || defined(MPW_C) || defined(MPW_CPLUS)
var = "MPW";
#endif
#if defined(__CC_NORCROFT)
var = "NORCROFT";
#endif
#if defined(__PACIFIC__)
var = "PACIFIC";
#endif
#if defined(_PACC_VER)
var = "PALM";
#endif
#if defined(__PCC__)
var = "PCC";
#endif
#if defined(__POCC__)
var = "PELLES";
#endif
#if defined(__PGI)
var = "PORTLAND";
#endif
#if defined(__CC_ARM)
var = "REALVIEW";
#endif
#if defined(SASC) || defined(__SASC) || defined(__SASC__)
var = "SAS";
#endif
#if defined(_SCO_DS)
var = "SCO";
#endif
#if defined(SDCC)
var = "SMALLDEV";
#endif
#if defined(__SUNPRO_C)
var = "SUN_C";
#endif
#if defined(__SUNPRO_CC)
var = "SUN_CXX";
#endif
#if defined(__SYSC__)
var = "SYSTEMS";
#endif
#if defined(__TenDRA__)
var = "TENDRA";
#endif
#if defined(__TINYC__)
var = "TINYC";
#endif
#if defined(_UCC)
var = "ULTIMATE";
#endif
#if defined(__USLC__)
var = "USL_C";
#endif
#if defined(_MSC_VER)
var = "VISUAL_CXX";
#endif
#if defined(__WATCOMC__)
var = "WATCOM";
#endif
printf("%s\n", var);
return 0;
}
EOF
) > _mk_cctype.c
if [ $? -ne 0 ]
then
fatal "could not create _mk_cctype.c"
fi
${SYS_CC} -o _mk_cctype _mk_cctype.c
if [ $? -ne 0 ]
then
fatal "could not create _mk_cctype"
fi
./_mk_cctype | tr -cd '[[:alnum:]_\n]'
if [ $? -ne 0 ]
then
fatal "could not execute _mk_cctype"
fi
fi
cleanup
exit 0