-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·166 lines (139 loc) · 3.98 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
#!/bin/sh
undo=1
show_region=1
zlib=0
spell=0
termcap=0
terminfo=0
count=0
do_help() {
echo "Optional features:"
echo " --enable-clang Enable clang compiler"
echo " --enable-spell Enable spell commands"
echo " --enable-zlib Enable gzip compression support"
echo " --enable-termcap Enable termcap."
echo " --enable-terminfo Enable terminfo."
echo " --enable-sysv4 Enable if signal handlers cannot reset themselves"
echo " --enable-undo Enable undo"
echo " --enable-huge Enable HUGE_FILES"
echo " --enable-huge-threaded Enable HUGE_THREADED"
echo
echo "To disable a feature replace --enable with --disable."
exit 0
}
set_one() {
[ -n "$2" ] && echo "#define $1 $2" >> config.h
}
set_if_one() {
[ -n "$2" -a "$2" -eq 1 ] && echo "#define $1 $2" >> config.h
}
while [ -n "$1" ]; do
case "$1" in
--enable-*) enable=1;;
--disable-*) enable=0;;
--help) do_help;;
-h) do_help;;
*) echo "Unknown arg '$1' ignored"; shift; continue;;
esac
case "$1" in
*-clang) clang=$enable;;
*-termcap) termcap=$enable;;
*-terminfo) terminfo=$enable;;
*-spell) spell=$enable;;
*-zlib) zlib=$enable;;
*-sysv4) sysv4=$enable;;
*-undo) undo=$enable;;
*-huge) huge=$enable;;
*-huge-threaded) huge_threaded=$enable;;
*) echo "Unknown arg '$1' ignored";;
esac
count=$(($count + 1))
shift
done
if [ "$termcap" = 1 -a "$terminfo" = 1 ]; then
echo "Make up your mind... termcap OR terminfo"
exit 1
fi
if [ "$clang" = 1 ]; then
sed 's/^#CC = clang/CC = clang/' Makefile > Makefile.tmp
mv Makefile.tmp Makefile
[ $count -eq 1 ] && exit 0
else
sed 's/^CC = clang/#CC = clang/' Makefile > Makefile.tmp
mv Makefile.tmp Makefile
fi
if [ $zlib = 1 -a ! -f /usr/include/zlib.h ]; then
echo "Missing zlib.h"
exit 1
fi
if [ $spell = 1 ]; then
if [ ! -f /usr/include/aspell.h -o ! -f /usr/include/dlfcn.h ]; then
echo "Missing aspell.h and/or dhfcn.h"
exit 1
fi
fi
echo "/* Generated by configure `date` */" > config.h
if [ $termcap = 1 ]; then
sed 's/#LIBS += -ltermcap/LIBS += -ltermcap/' Makefile > Makefile.tmp
mv Makefile.tmp Makefile
fi
set_if_one TERMCAP $termcap
if [ $terminfo = 1 ]; then
sed 's/#LIBS += -lncurses/LIBS += -lncurses/' Makefile > Makefile.tmp
mv Makefile.tmp Makefile
fi
set_if_one TERMINFO $terminfo
if [ -f /usr/include/termios.h ]; then
true
elif [ -f /usr/include/termio.h ]; then
echo "#define HAVE_TERMIO 1" >> config.h
else
echo "WARNING: No terminal setup found."
fi
echo >> config.h
[ "$sysv4" = 1 ] && echo "#define SYSV4" >> config.h
set_one SPELL $spell
set_one ZLIB $zlib
set_one UNDO $undo
if [ "$spell" = 1 ]; then
sed 's/^#LIBS += -ldl/LIBS += -ldl/' Makefile > Makefile.tmp
else
sed 's/^LIBS += -ldl/#LIBS += -ldl/' Makefile > Makefile.tmp
fi
mv Makefile.tmp Makefile
if [ "$zlib" = 1 ]; then
sed 's/^#LIBS += -lz/LIBS += -lz/' Makefile > Makefile.tmp
else
sed 's/^LIBS += -lz/#LIBS += -lz/' Makefile > Makefile.tmp
fi
mv Makefile.tmp Makefile
if [ "$huge" = 1 ]; then
echo "--enable-huge is very experimental. IT CAN CORRUPT FILES."
echo "You have been warned!!!"
echo >> config.h
echo "#define HUGE_FILES 1" >> config.h
if [ "$huge_threaded" = 1 ]; then
echo "#define HUGE_THREADED 1" >> config.h
sed 's/^#LIBS += -lpthread/LIBS += -lpthread/' Makefile > Makefile.tmp
mv Makefile.tmp Makefile
fi
else
sed 's/^LIBS += -lpthread/#LIBS += -lpthread/' Makefile > Makefile.tmp
mv Makefile.tmp Makefile
fi
cat >> config.h <<EOF
#ifdef __unix__
#define DOPIPES
#endif
/* Don't touch these unless you really know what you are doing. */
#define UNSIGNED_BYTES
#define HAVE_GLOBAL_MARKS
#define HAVE_BUFFER_MARKS
EOF
cat > ztmp.c <<EOF
#define _GNU_SOURCE
#include <string.h>
void *foo(const void *s) { return memrchr(s, ' ', 1); }
EOF
cc -Wall -Werror -c ztmp.c >/dev/null 2>&1 || echo "#define NO_MEMRCHR" >> config.h
rm -f ztmp.c ztmp.o