forked from versat/cntlm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·122 lines (111 loc) · 2.79 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
#!/bin/sh
#
# Search for GCC or XL C/C++, former if both exist
#
# To add another compiler, just create Makefile.XXX and add XXX to $CCS
#
# To prevent ugly Makefile extensions, underscore and chars following it
# in the name XXX are automatically removed before locating relevant
# Makefile. This is why compiler "xlc_r" has Makefile extension "xlc".
# This can be disabled if necessary.
#
#set -x
if [ -n "$CC" ]; then
# If compiler is specified look for the path
CCPATH=$(which $CC 2>&1)
if [ -n "${CCPATH%%/*}" ]; then
echo "Unable to find $CC, will search for a compatible compiler ..."
CC=
fi
fi
if [ -z "$CC" ]; then
CCS="aarch64-linux-gnu-gcc xlc_r clang gcc"
#
# Look for supported compilers
#
for c in $CCS; do
if CCPATH=$(which $c 2>&1) && [ -z "${CCPATH%%/*}" ] && $(echo "#include <sys/socket.h>" | $c -fsyntax-only -x c -); then
CC="$c"
break
fi
done
fi
#
# Make a link to a proper Makefile.*
#
if [ -z "$CC" ]; then
echo "Unable to find GNU GCC, IBM XL C/C++ or clang. Fix your PATH!"
exit 1
else
echo "Using $CCPATH to compile Cntlm"
[ -h Makefile ] && rm -f Makefile 2>/dev/null
case "$CC" in
gcc)
# default Makefile is for GCC; just revert back to
# GCC if Makefile is linked to other compiler version
if [ ! -f Makefile ]; then
mv Makefile.gcc Makefile
fi
;;
*)
EXT=$(echo "$CC" | sed 's/_.*//')
if [ ! -f "Makefile.$EXT" ]; then
echo "There must be a file 'Makefile.$EXT' to compile it with $CC"
exit 1
else
# backup default GCC Makefile and create a link to other
if [ -f Makefile ]; then
mv Makefile Makefile.gcc
fi
ln -s Makefile.$EXT Makefile
fi
;;
esac
fi
STAMP=configure-stamp
CONFIG=config/config.h
TESTS="endian strdup socklen_t gethostname arc4random_buf strlcat strlcpy"
#[ -f $STAMP ] && exit 0
touch $STAMP
rm -f $CONFIG
echo "#ifndef CONFIGURE_CONFIG_H" > $CONFIG
echo "#define CONFIGURE_CONFIG_H" >> $CONFIG
echo "" >> $CONFIG
for i in $TESTS; do
printf "Checking $i... "
printf "#define config_$i " >> $CONFIG
$CC -std=c99 -D__BSD_VISIBLE -D_ALL_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112 -D_ISOC99_SOURCE -D_REENTRANT -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE -o config/$i config/$i.c 2> /dev/null
rc=$?
if [ $rc -ne 0 ]; then # -o -n "$OUT" ]; then
rc=0
RET=no
else
RET=$(./config/$i)
rc=$?
[ -z "$RET" ] && if [ $rc -eq 0 ]; then RET="no"; else RET=yes; fi
fi
echo $rc >> $CONFIG
echo $RET
done
while [ $1 ]
do
case $1 in
--enable-kerberos)
printf "#define ENABLE_KERBEROS" >> $CONFIG
echo "" >> $CONFIG
;;
--enable-static)
printf "#define ENABLE_STATIC" >> $CONFIG
echo "" >> $CONFIG
;;
*)
echo "Unknown flag $1"
rm -f $CONFIG
;;
esac
shift
done
if [ -f $CONFIG ]; then
echo "" >> $CONFIG
echo "#endif // CONFIGURE_CONFIG_H" >> $CONFIG
fi