-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·172 lines (141 loc) · 3.71 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
#!/bin/sh
_usage="./configure -- configure the DGED build.
Options:
--[enable|disable]-syntax Enable or disable syntax highlighting support. Default: enabled.
--[enable|disable]-lsp Enable or disable Language Server Protocol support. Default: disabled (experimental).
--enable-asan Build DGED with address sanitizer enabled. Default: disabled.
--prefix=<PREFIX> Set the build prefix path to <PREFIX>. Default: /usr/local.
-h/--help Show this help text.
"
enable_syntax=1
enable_lsp=0
enable_asan=0
prefix=
while [ "$#" -gt 0 ]; do
case $1 in
--disable-syntax)
enable_syntax=0
shift 1
;;
--enable-syntax)
enable_syntax=1
shift 1
;;
--enable-lsp)
enable_lsp=1
shift 1
;;
--disable-lsp)
enable_lsp=0
shift 1
;;
--enable-asan)
enable_asan=1
shift 1
;;
--prefix)
prefix="$2"
shift 2
;;
--prefix=*)
prefix="${1#*=}"
shift 1
;;
-h|--help)
echo "$_usage"
exit
;;
# TODO: support the *dir flags
--bindir=*)
shift 1
;;
--sbindir=*)
shift 1
;;
--includedir=*)
shift 1
;;
--oldincludedir=*)
shift 1
;;
--mandir=*)
shift 1
;;
--infodir=*)
shift 1
;;
--docdir=*)
shift 1
;;
--libdir=*)
shift 1
;;
--libexecdir=*)
shift 1
;;
--localedir=*)
shift 1
;;
-*)
echo "Unknown flag \"$1\". Usage:"
echo "$_usage"
exit 1
;;
*)
shift 1
;;
esac
done
echo "/* Generated by configure */" > src/config.h
echo "#ifndef _CONFIG_H" >> src/config.h
echo "#define _CONFIG_H" >> src/config.h
echo "# generated by configure" > config.mk
echo -n "detecting event system... "
if ./scripts/has_header "sys/epoll.h"; then
echo "epoll."
echo "#define HAS_EPOLL 1" >> src/config.h
echo "HAS_EPOLL ?= true" >> config.mk
elif ./scripts/has_header "sys/event.h"; then
echo "kqueue."
echo "#define HAS_KQUEUE 1" >> src/config.h
echo "HAS_KQUEUE ?= true" >> config.mk
else
echo "none."
fi
echo -n "detecting process model..."
if ./scripts/has_header "unistd.h"; then
echo "posix."
echo "#define PROCESS_MODEL posix" >> src/config.h
echo "PROCESS_MODEL ?= posix" >> config.mk
else
echo "unknown."
fi
if [ "$enable_syntax" -ne 0 ]; then
echo "enabling syntax highlighting."
echo "SYNTAX_ENABLE = true" >> config.mk
echo "#define SYNTAX_ENABLE 1" >> src/config.h
else
echo "disabling syntax highlighting."
echo "SYNTAX_ENABLE = false" >> config.mk
echo "#undef SYNTAX_ENABLE" >> src/config.h
fi
if [ "$enable_lsp" -ne 0 ]; then
echo "enabling language server support."
echo "LSP_ENABLE = true" >> config.mk
echo "#define LSP_ENABLE 1" >> src/config.h
else
echo "disabling language server support."
echo "LSP_ENABLE = false" >> config.mk
echo "#undef LSP_ENABLE" >> src/config.h
fi
if [ "$enable_asan" -ne 0 ]; then
echo "enabling address sanitizer."
echo "ASAN = true" >> config.mk
fi
if [ -n "$prefix" ]; then
echo "setting prefix to \"$prefix\"."
echo "prefix = $prefix" >> config.mk
fi
echo "#endif" >> src/config.h
echo "wrote src/config.h"
echo "wrote config.mk"