forked from QW-Group/mvdsv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·183 lines (168 loc) · 4.75 KB
/
configure
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
#!/bin/sh
#
# Copyright (C) 2004-2006 VVD (vvd0@users.sourceforge.net).
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# $Id$
#
# C Compiler
CC=gcc
echo CC="${CC}" > Makefile
FILE=conftest
# Byte order determination
echo "Checking byte order..."
cat > "${FILE}.c" << _EOF
#include <stdio.h>
/*
__LITTLE_ENDIAN__ 1234
__BIG_ENDIAN__ 4321
__PDP_ENDIAN__ 3412
*/
int main()
{
unsigned a = 0x11223344;
if (((unsigned char*)&a)[0] == 0x44 &&
((unsigned char*)&a)[1] == 0x33 &&
((unsigned char*)&a)[2] == 0x22 &&
((unsigned char*)&a)[3] == 0x11)
printf("__LITTLE_ENDIAN__\n");
else if (
((unsigned char*)&a)[0] == 0x11 &&
((unsigned char*)&a)[1] == 0x22 &&
((unsigned char*)&a)[2] == 0x33 &&
((unsigned char*)&a)[3] == 0x44)
printf("__BIG_ENDIAN__\n");
else if (
((unsigned char*)&a)[0] == 0x22 &&
((unsigned char*)&a)[1] == 0x11 &&
((unsigned char*)&a)[2] == 0x44 &&
((unsigned char*)&a)[3] == 0x33)
printf("__PDP_ENDIAN__\n");
else
printf("UNKNOWN\n");
return 0;
}
_EOF
if "${CC}" -o "${FILE}" "${FILE}.c"; then
BYTE_ORDER=`"./${FILE}"`
rm -f "${FILE}" "${FILE}.c"
if test "x${BYTE_ORDER}" != xUNKNOWN; then
echo "Byte order is: ${BYTE_ORDER}"
echo "BYTE_ORDER=${BYTE_ORDER}" >> Makefile
else
rm Makefile
echo "can't determine"
echo "Error: can't continue"
return 1
fi
else
rm Makefile
echo "can't determine"
echo "Error: can't continue"
return 1
fi
# OS determination
if [ x$1 != x ]; then
UNAME=$1
else
UNAME=`uname`
fi
ARCH=`uname -m | sed -e 's/i.86/x86/g' -e 's/Power Macintosh/ppc/g' -e 's/amd64/x86_64/g'`
# on windows, always be 32bit
if [ ${UNAME} = CYGWIN_NT-10.0 ]; then
BITS=32
ARCH=x86
fi
echo UNAME="${UNAME}" >> Makefile
echo ARCH="${ARCH}" >> Makefile
# check for second paramater
if [ x$2 = x64 ]; then
BITS=64
elif [ x$2 = x32 ]; then
BITS=32
else
BITS=
fi
# if BITS not set try autodetection...
if [ x${BITS} = x ]; then
if [ x${ARCH} = xx86_64 ] || [ x${ARCH} = xaarch64 ]; then
BITS=64
elif [ x${ARCH} = xarmv7l ]; then
# arm7 /rasberry pi 3 compilers will fail saying -m32 is unknown flag
BITS=
else
BITS=32
fi
fi
# put FORCE32BITFLAGS=-m32 in Makefile if required...
if [ x$BITS = x32 ]; then
echo FORCE32BITFLAGS=-m32 >> Makefile
fi
case ${UNAME} in
FreeBSD | OpenBSD | NetBSD | DragonFly | BSD)
echo "${UNAME} ${ARCH} ${BITS}bits system - using BSD Makefile."
echo "SV_OBJS = \$(SV_DIR)/sv_sys_unix.o" >> Makefile
cat Makefile.BSD >> Makefile
echo "Configuration completed."
;;
CYGWIN_NT-10.0)
echo "${UNAME} ${ARCH} ${BITS}bits system - using GNU Makefile."
echo "SV_OBJS = \$(SV_DIR)/sv_sys_win.o" >> Makefile
cat Makefile.GNU >> Makefile
echo "Configuration completed."
;;
Darwin | MacOSX | Linux | SunOS | GNU)
echo "${UNAME} ${ARCH} ${BITS}bits system - using GNU Makefile."
echo "SV_OBJS = \$(SV_DIR)/sv_sys_unix.o" >> Makefile
cat Makefile.GNU >> Makefile
echo "Configuration completed."
;;
Usage)
echo "Usage:"
echo "./configure SYSTEM BITS"
echo "SYSTEM: used `uname`"
echo "Possible values are: FreeBSD, OpenBSD, NetBSD, DragonFly, Darwin, MacOSX, Linux, SunOS, BSD, GNU"
echo "Other systems not supported yet."
echo "BITS: used ${BITS}"
echo "Possible values are: 32, 64"
echo "If you want to force compile 32 bits on 64 bits system use BITS parameter."
echo ""
;;
*)
echo ""
echo "Unknown system: ${UNAME}."
echo ""
echo "You must specify the system which you want to compile for:"
echo ""
echo "./configure FreeBSD FreeBSD"
echo "./configure OpenBSD OpenBSD"
echo "./configure NetBSD NetBSD"
echo "./configure DragonFly DragonFly BSD"
echo "./configure Darwin Darwin/MacOS X"
echo "./configure MacOSX Darwin/MacOS X"
echo "./configure Linux Linux"
echo "./configure SunOS SunOS/Solaris"
echo "or"
echo "./configure BSD for build with BSD Makefile"
echo "./configure GNU for build with GNU Makefile"
echo "./configure for auto configure"
echo "./configure Usage for see usage information"
echo ""
echo "Other systems not supported yet."
echo ""
;;
esac