-
Notifications
You must be signed in to change notification settings - Fork 5
/
configure.in
168 lines (118 loc) · 3.4 KB
/
configure.in
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
dnl # Initialize configure
AC_INIT([./configure])
AM_INIT_AUTOMAKE(CaOS, 1.0)
dnl # Check required autoconf version
AC_PREREQ([2.13])
dnl # platform output file
AC_CONFIG_HEADER([./src/include/platform.h])
dnl # tools
dnl # gawk
AC_PROG_AWK
dnl # nasm install check
AC_PATH_PROG([NASM], [nasm])
if test -z "$NASM"; then
AC_MSG_ERROR([Cannot find Netwide Assembler])
fi
AC_SUBST(NASM)
dnl # nasm version check
${NASM} -v | grep version > nasm_version.tmp
AC_MSG_CHECKING([whether NASM version >= 2.0 for 64bit assembly])
result=`cat nasm_version.tmp | awk '{print $3}'`
nasm_major=`echo $result | awk -F . '{print $1}'`
rm -f nasm_version.tmp
if test "$nasm_major" -lt 2; then
AC_MSG_ERROR([nasm version is below than 2.0])
else
AC_MSG_RESULT([yes])
fi
dnl # gcc install
if test -z "$CC"; then
CC=gcc
fi
dnl # gcc version >= 4.3 for -mcmodel=large option
AC_MSG_CHECKING([whether GCC version >= 4.3.2 for -mcmodel=large option])
${CC} -v 2> gcc_version.tmp
result=`grep "gcc version" gcc_version.tmp | awk '{print $3}'`
rm -f gcc_version.tmp
echo "result=${result}"
gcc_major=`echo $result | awk -F . '{print $1}'`
gcc_minor=`echo $result | awk -F . '{print $2}'`
gcc_minor_minor=`echo $result | awk -F . '{print $3}'`
if test "$gcc_major" -ge 4 && test "$gcc_minor" = 3 && test "$gcc_minor_minor" -ge 2
then
AC_MSG_RESULT([yes])
elif test "$gcc_major" -ge 4 && test "$gcc_minor" -ge 4
then
AC_MSG_RESULT([yes])
else
echo "current gcc is \"${CC}\"-${gcc_major}.${gcc_minor}.${gcc_minor_minor}"
echo "you can define gcc as \"CC=your-gcc ./configure\""
AC_MSG_ERROR([current gcc version cannot process 64bit address])
fi
AC_SUBST(CC)
dnl # ld support x86_64
AC_MSG_CHECKING([whether ld supports elf_x86_64])
if test -z "${LD}" ; then
LD=ld
fi
result=`${LD} -V | grep elf_x86_64`
if test -z "$result" ; then
echo "current ld is \"${LD}\""
echo "you can define ld as \"LD=your-ld ./configure\""
AC_MSG_ERROR([current ld do not support elf_x86_64, please install 64bit ld])
else
AC_MSG_RESULT([yes])
fi
AC_SUBST(LD)
dnl # objcopy support x86_64
AC_MSG_CHECKING([whether objcopy supports elf64-x86-64])
if test -z "$OBJCOPY" ; then
OBJCOPY=objcopy
fi
result=`${OBJCOPY} -h | grep elf64-x86-64`
if test -z "$result" ; then
echo "current objcopy is \"${OBJCOPY}\""
echo "you can define objcopy as \"OBJCOPY=your-objcopy ./configure\""
AC_MSG_ERROR([current objcopy do not support elf-x86-64, please install
64bit objcopy])
else
AC_MSG_RESULT([yes])
fi
AC_SUBST(OBJCOPY)
dnl # extra tools
AC_PATH_PROG([DD], [dd])
AC_PATH_PROG([NM], [nm])
AC_SUBST(DD)
AC_SUBST(NM)
dnl # host
AC_CANONICAL_HOST()
CAOS_CFG_CPU=UNKNOWN
CAOS_CFG_CPU_BIT=0
CAOS_CFG_MAJOR_VER=0
CAOS_CFG_MINOR_VER=0
echo ""
echo "HOST PLATFORM: ${host}"
echo ""
case "${host}" in
i[3456]86-* )
CAOS_CFG_CPU=i386
CAOS_CFG_CPU_BIT=32
;;
amd64-*-* )
CAOS_CFG_CPU=AMD64
CAOS_CFG_CPU_BIT=64
;;
x86_64-* )
CAOS_CFG_CPU=X86_64
CAOS_CFG_CPU_BIT=64
;;
esac
AC_DEFINE_UNQUOTED(CAOS_CFG_CPU_$CAOS_CFG_CPU, 1)
AC_DEFINE_UNQUOTED(CAOS_CFG_CPU, "$CAOS_CFG_CPU")
AC_DEFINE_UNQUOTED(CAOS_CFG_CPU_BIT_$CAOS_CFG_CPU_BIT, 1)
AC_DEFINE_UNQUOTED(CAOS_CFG_CPU_BIT, "$CAOS_CFG_CPU_BIT")
AC_SUBST(CAOS_CFG_CPU)
AC_SUBST(CAOS_CFG_CPU_BIT)
AC_OUTPUT([config.mk])
dnl # remove temporary files
rm -f ./config.cache ./config.log ./config.status