-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.in
304 lines (237 loc) · 9.45 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
AC_INIT(src/main.c)
AC_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_INSTALL
AC_C_BIGENDIAN
if test $prefix = NONE
then
myprefix=/usr/local
else
myprefix=$prefix
fi
######################################################################
# configure arguments
######################################################################
DEBUGGING=0
LOGGING=0
AC_ARG_WITH(debug, [ --with-debug include debug info ], [ DEBUGGING=1; ], [])
AC_ARG_WITH(gprof-debug, [ --with-gprof-debug include debug info and gprof debug info ], [ DEBUGGING=2; ], [])
AC_ARG_WITH(log, [ --with-log create log ], [ LOGGING=1; ], [])
AC_ARG_WITH(console-log, [ --with-console-log create console log ], [ LOGGING=2; ], [])
AC_ARG_WITH(optimize, [ --with-optimize with optimize(-O in CFLAGS) ], [ ENABLE_OPTIMIZE=1 ], [ ENABLE_OPTIMIZE=0 ])
AC_ARG_WITH(onig-dir, [ --with-onig-dir=DIR set install prefix of oniguruma which located at non standerd directory and installed by user ], [ ONIG_DIR="$withval"; ], [ ONIG_DIR=; ])
AC_ARG_WITH(static, [ --with-static link xyzsh used libraries with static to make xyzsh doesn't require any libraries.], [ STATIC_LINK=1 ], [STATIC_LINK= ] )
#####################################################################
# check cpu type
#####################################################################
AC_MSG_CHECKING(CPU type)
if test `uname -m` = x86_64
then
echo x86_64
AC_DEFINE(__64BIT_CPU__, 1)
else
echo 32BIT_CPU
AC_DEFINE(__32BIT_CPU__, 1)
fi
#####################################################################
# check operating systems
#####################################################################
SO_VERSION=1.0.0
AC_SUBST(SO_VERSION)
AC_MSG_CHECKING(Operating System)
OBJ="src/main.o src/utf_mb_str.o src/heap.o src/buffer.o src/klass.o src/vm.o src/debug.o src/xfunc.o src/interface.o src/type.o src/c_to_clover.o src/obj_clover.o src/obj_int.o src/obj_byte.o src/obj_short.o src/obj_uint.o src/obj_long.o src/obj_char.o src/obj_bytes.o src/obj_float.o src/obj_double.o src/obj_bool.o src/obj_pointer.o src/obj_null.o src/obj_class_object.o src/obj_user_object.o src/obj_string.o src/obj_string_buffer.o src/obj_parser.o src/obj_oniguruma_regex.o src/obj_array.o src/obj_hash.o src/obj_range.o src/obj_block.o src/obj_system.o src/obj_thread.o src/obj_mutex.o src/obj_file.o src/obj_file.o src/obj_type_object.o src/obj_void.o src/obj_anonymous.o src/obj_field.o src/obj_method.o src/obj_enum.o src/obj_wait_status.o src/obj_tm.o src/clover2llvm.o"
AC_SUBST(OBJ)
CFLAGS='-DSYSCONFDIR="\"${sysconfdir}/\"" -DDOCDIR="\"${docdir}/\"" -DDATAROOTDIR="\"${datarootdir}/\""'
if test `uname -s` = "Darwin"; then
echo "Darwin"
OS=DARWIN
AC_DEFINE(__DARWIN__, 1)
LIBSONAME=libclover.dylib
LIBSO2NAME=libclover.$SO_VERSION.dylib
if test $myprefix = /usr/local; then
CFLAGS="-Isrc/ -I. -L . -fPIC $CFLAGS"
else
CFLAGS="-Isrc/ -I. -L . -I$myprefix/include -L$myprefix/lib -fPIC $CFLAGS"
fi
elif test `uname -s` = "SunOS"; then
echo "SunOS"
OS=SUNOS
AC_DEFINE(__SUNOS__, 1)
LIBSONAME=libclover.so
LIBSO2NAME=libclover.so.$SO_VERSION
if test $myprefix = /usr/local; then
CFLAGS="-Isrc/ -I. -L . -fPIC $CFLAGS"
else
CFLAGS="-Isrc/ -I. -L . -I$myprefix/include -L$myprefix/lib -fPIC $CFLAGS"
fi
elif test `uname -s` = "FreeBSD"; then
echo "FreeBSD"
OS=FREEBSD
AC_DEFINE(__FREEBSD__, 1)
LIBSONAME=libclover.so
LIBSO2NAME=libclover.so.$SO_VERSION
CFLAGS="-Isrc/ -I. -L . -I$myprefix/include -L$myprefix/lib -fPIC $CFLAGS"
elif uname -s | grep -q CYGWIN_NT; then
echo CYGWIN
OS=CYGWIN
AC_DEFINE(__CYGWIN__, 1)
LIBSONAME=libclover.so
LIBSO2NAME=libclover.so.$SO_VERSION
if test $myprefix = /usr/local; then
CFLAGS="-Isrc/ -I. -L . $CFLAGS"
else
CFLAGS="-Isrc/ -I. -L . -I$myprefix/include -L$myprefix/lib $CFLAGS"
fi
else
echo "Linux"
OS=LINUX
AC_DEFINE(__LINUX__, 1)
LIBSONAME=libclover.so
LIBSO2NAME=libclover.so.$SO_VERSION
if test $myprefix = /usr/local; then
CFLAGS="-Isrc/ -I. -L . -fPIC $CFLAGS"
else
CFLAGS="-Isrc/ -I. -L . -I$myprefix/include -L$myprefix/lib -fPIC $CFLAGS"
fi
AC_HAVE_LIBRARY(util, [ LIBS="$LIBS -lutil"; ], [])
fi
##########################################################################
# CFLAGS settings
##########################################################################
if test -d /usr/local/include
then
CFLAGS="$CFLAGS -I/usr/local/include"
fi
if test -d /usr/local/lib
then
CFLAGS="$CFLAGS -L /usr/local/lib"
fi
if test -d /opt/local/include
then
CFLAGS="$CFLAGS -I/opt/local/include"
fi
if test -d /opt/local/lib
then
CFLAGS="$CFLAGS -L /opt/local/lib"
fi
if test -n "$ONIG_DIR"
then
if test -e "$ONIG_DIR/include/oniguruma.h" && test -e "$ONIG_DIR/lib/libonig.a"
then
CFLAGS="$CFLAGS -I$ONIG_DIR/include -L $ONIG_DIR/lib"
else
echo "can't found oniguruma.h in $ONIG_DIR/include or libonig.a in $ONIG_DIR/lib"
fi
fi
if test $ENABLE_OPTIMIZE = 1
then
CFLAGS="$CFLAGS -O3"
fi
if test $DEBUGGING = 1
then
CFLAGS="$CFLAGS -g -DMDEBUG -Werror"
elif test $DEBUGGING = 2
then
CFLAGS="$CFLAGS -pg"
else
CFLAGS="$CFLAGS"
fi
if test $LOGGING = 1
then
CFLAGS="$CFLAGS -DVM_DEBUG"
fi
if test $LOGGING = 2
then
CFLAGS="$CFLAGS -DVM_DEBUG2"
fi
if test "$STATIC_LINK" = 1
then
CFLAGS="$CFLAGS -static"
LIBANAME=libclover.a
LIBSONAME=
LIBSO2NAME=
fi
AC_SUBST(OS)
AC_SUBST(LIBANAME)
AC_SUBST(LIBSONAME)
AC_SUBST(LIBSO2NAME)
##########################################################
# environmnet variables
##########################################################
CC=gcc
INSTALL="/usr/bin/install -c"
#####################################################################
# oniguruma settings
#####################################################################
AC_CHECK_HEADER(oniguruma.h, [AC_DEFINE(HAVE_ONIGURUMA_H, 1)], [ exit ])
AC_HAVE_LIBRARY(onig, [ LIBS="$LIBS -lonig"; ], [ exit ])
#####################################################################
# pthread settings
#####################################################################
AC_CHECK_HEADER(pthread.h, [AC_DEFINE(HAVE_PTHREAD_H, 1)], [ exit ])
AC_HAVE_LIBRARY(pthread, [ LIBS="$LIBS -lpthread"; ], [ exit ])
#####################################################################
# readline settings
#####################################################################
AC_CHECK_HEADER(readline/readline.h, [AC_DEFINE(HAVE_READLINE_H, 1)], [ exit ])
AC_HAVE_LIBRARY(readline, [ LIBS="$LIBS -lreadline"; ], [ exit ])
#####################################################################
# dl settings(optional)
#####################################################################
if test "$OS" != FREEBSD
then
AC_HAVE_LIBRARY(dl, [ LIBS="$LIBS -ldl"; ], [])
fi
#####################################################################
# math settings(optional)
#####################################################################
AC_CHECK_HEADER(math.h, [AC_DEFINE(HAVE_MATH_H,1)], [])
AC_HAVE_LIBRARY(m, [ LIBS="$LIBS -lm"; ], [])
####################################################################
# iconv settings(optional)
####################################################################
AC_CHECK_HEADER(iconv.h, [AC_DEFINE(HAVE_ICONV_H, 1)], [])
if test "$OS" = CYGWIN|| test "$OS" = DARWIN || test "$OS" = FREEBSD
then
LIBS="$LIBS -liconv"
fi
#####################################################################
# nanosleep settings
#####################################################################
AC_CHECK_FUNCS(nanosleep, [AC_DEFINE(HAVE_NANOSLEEP, 1)], [])
AC_SUBST(LIBS)
#####################################################################
# ncurses settings(optiolanl)
#####################################################################
AC_CHECK_HEADER(ncurses.h, [NCURSES_H_OK=1; AC_DEFINE(HAVE_NCURSES_H, 1)])
AC_CHECK_HEADER(ncurses/ncurses.h, [NCURSES_H_OK=1; AC_DEFINE(HAVE_NCURSES_NCURSES_H, 1)])
AC_HAVE_LIBRARY(cursesw, [ NCURSES_LIB_OK=1; LIBS="$LIBS -lcursesw" ])
AC_HAVE_LIBRARY(ncursesw, [ NCURSES_LIB_OK=1; LIBS="$LIBS -lncursesw" ])
if test -z "$NCURSES_LIB_OK"
then
AC_HAVE_LIBRARY(curses, [ NCURSES_LIB_OK=1; LIBS="$LIBS -lcurses" ])
AC_HAVE_LIBRARY(ncurses, [ NCURSES_LIB_OK=1; LIBS="$LIBS -lncurses" ])
fi
#####################################################################
# editline settings(optional)
#####################################################################
#AC_CHECK_HEADER(histedit.h, [EDITLINE_H_OK=1; AC_DEFINE(HAVE_HISTEDIT_H, 1)], [])
#AC_HAVE_LIBRARY(edit, [ EDITLINE_LIB_OK=1; LIBS="$LIBS -ledit"; ], [])
#####################################################################
# interructive clover settings
#####################################################################
#if test -n "$NCURSES_H_OK" && test -n "$NCURSES_LIB_OK" && test -n "$EDITLINE_H_OK" && test -n "$EDITLINE_LIB_OK"
#then
# ICLOVER=iclover
# AC_SUBST(ICLOVER)
#fi
##########################################################################
# type checking
###########################################################################
AC_EGREP_HEADER(OnigUChar, oniguruma.h, AC_DEFINE(HAVE_ONIGUCHAR))
CC=clang
AC_SUBST(CC)
CFLAGS="$CFLAGS -Qunused-arguments"
#CFLAGS="$CFLAGS -Qunused-arguments -Wunused-variable"
AC_SUBST(CFLAGS)
AC_OUTPUT(Makefile)