-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfigure.in
395 lines (339 loc) · 9.44 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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
dnl $Id: configure.in,v 1.12 2014/03/17 17:19:43 mwesdorp Exp $
dnl
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
dnl
dnl configure.in script to configure sqsh build environment
dnl
AC_INIT(src/sqsh_main.c)
AC_CONFIG_HEADER(src/config.h)
AC_CONFIG_AUX_DIR(autoconf)
AC_CANONICAL_HOST
dnl
dnl Define the possible configure options
dnl
AC_ARG_WITH([gcc],
[ --with-gcc Use gcc, regardless of path],
[], [with_gcc="yes"])
AC_ARG_WITH([debug],
[ --with-debug Enable sqsh debugging options],
[], [with_debug="no"])
AC_ARG_WITH([readline],
[ --with-readline support fancy command line editing],
[], [with_readline="yes"])
AC_ARG_WITH([old-readline],
[ --with-old-readline Force readline backwards compatibilty],
[], [with_old_readline="no"])
AC_ARG_WITH([static],
[ --with-static Statically link in Sybase libraries],
[], [with_static="no"])
AC_ARG_WITH([devlib],
[ --with-devlib Compile against Open Client devlibs],
[], [with_devlib="no"])
AC_ARG_WITH([x],
[],
[], [with_x="no"])
AC_ARG_WITH([motif],
[ --with-motif support X11/Motif widgets],
[
if test "$with_motif" != "no"; then
if test "$with_motif" != "yes"; then
MOTIF_PATH=$with_motif
with_motif="yes"
MOTIF_INCDIR="-I$MOTIF_PATH/include/X11"
MOTIF_LIBDIR="-L$MOTIF_PATH/lib"
else
MOTIF_INCDIR="# -I/usr/X11/include"
MOTIF_LIBDIR="# -L/usr/X11/lib"
fi
with_x="yes"
DEF_MOTIF="-DUSE_MOTIF"
fi
],[
with_motif="no"
DEF_MOTIF="# -DUSE_MOTIF"
])
if test "$with_debug" != "no"; then
DEF_DEBUG="-DDEBUG"
fi
AC_SUBST(with_gcc)
AC_SUBST(with_debug)
AC_SUBST(with_readline)
AC_SUBST(with_old_readline)
AC_SUBST(with_static)
AC_SUBST(with_devlib)
AC_SUBST(with_x)
AC_SUBST(with_motif)
AC_SUBST(DEF_DEBUG)
AC_SUBST(DEF_MOTIF)
AC_SUBST(MOTIF_PATH)
AC_SUBST(MOTIF_INCDIR)
AC_SUBST(MOTIF_LIBDIR)
dnl
dnl Check Compiler characteristics, typedefs and structures
dnl
AC_PROG_CC
AC_PROG_CPP
AC_ISC_POSIX
AC_VOLATILE
AC_C_CONST
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_BIT_MODE
if test "${ISC}" = "yes"; then
DEF_POSIX="-D_POSIX_SOURCE"
AC_SUBST(DEF_POSIX)
fi
dnl
dnl Set flags and variables depending on host_os
dnl
case "$host_os" in
aix*)
DEF_AIX_FIX="-DUSE_AIX_FIX"
AC_SUBST(DEF_AIX_FIX)
OBJMODE="-X32_64"
AC_SUBST(OBJMODE)
;;
*)
;;
esac
dnl
dnl Check SYBASE/FreeTDS libraries
dnl
AC_SYBASE_ASE
dnl
dnl Check READLINE environment
dnl
if test "$with_old_readline" = "yes"; then
with_readline="yes"
fi
if test "$with_readline" = "no"; then
DEF_READLINE="# -DUSE_READLINE"
READLINE_INCDIR="# -I/usr/local/include"
READLINE_LIBDIR="# -L/usr/local/lib"
READLINE_LIBS="# -lreadline -lcurses"
else
DEF_READLINE="-DUSE_READLINE"
AC_FIND_LIB(readline, [$LIBDIRS],
[
READLINE_LIBDIR="${libdir}"
inc_search="`echo ${libdir} | sed -e 's,/[[^/]]*$,,g'`/include"
],[
READLINE_LIBDIR=""
inc_search=""
])
if test "$INCDIRS" != ""; then
if test "$inc_search" = ""; then
inc_search=$INCDIRS
else
inc_search=$inc_search:$INCDIRS
fi
fi
AC_FIND_HDR([readline/readline.h],[$inc_search],
[READLINE_INCDIR="${include_dir}"],[READLINE_INCDIR=""])
AC_MSG_CHECKING(for readline link)
AC_CACHE_VAL(ac_cv_readline_libs,
[
readline_libs=""
ORIG_CPPFLAGS="${CPPFLAGS}"
ORIG_LDFLAGS="${LDFLAGS}"
ORIG_LIBS="${LIBS}"
if test "${READLINE_INCDIR}" != ""; then
CPPFLAGS="${CPPFLAGS} -I${READLINE_INCDIR}"
fi
if test "${READLINE_LIBDIR}" != ""; then
LDFLAGS="${LDFLAGS} -L${READLINE_LIBDIR}"
fi
for lib in "-lHcurses" "-lncurses" "-lcurses" "-ltermcap" "-lucb" "-lhistory"
do
LIBS="${ORIG_LIBS} -lreadline ${lib}"
AC_TRY_LINK([
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
],[
char *c;
add_history( c );
readline( c );
],[
readline_libs="${lib}"
])
if test "${readline_libs}" != ""; then
break;
fi
done
CPPFLAGS="${ORIG_CPPFLAGS}"
LDFLAGS="${ORIG_LDFLAGS}"
LIBS="${ORIG_LIBS}"
ac_cv_readline_libs=${readline_libs}
])
READLINE_LIBS=${ac_cv_readline_libs}
if test "${READLINE_LIBS}" = ""; then
AC_MSG_RESULT(not found)
READLINE_LIBS="-lreadline -lcurses"
else
READLINE_LIBS="-lreadline ${READLINE_LIBS}"
AC_MSG_RESULT(${READLINE_LIBS})
fi
if test "$READLINE_INCDIR" = ""; then
READLINE_INCDIR="-I/usr/local/include"
else
if test "$READLINE_INCDIR" = "/usr/include"; then
READLINE_INCDIR="# -I${READLINE_INCDIR}"
else
READLINE_INCDIR="-I${READLINE_INCDIR}"
fi
fi
if test "$READLINE_LIBDIR" = ""; then
READLINE_LIBDIR="-L/usr/local/lib"
else
if test "$READLINE_LIBDIR" = "/usr/lib" -o ${READLINE_LIBDIR} = "/lib"; then
READLINE_LIBDIR=""
else
READLINE_LIBDIR="-L${READLINE_LIBDIR}"
fi
fi
if [[ "$with_old_readline" = "yes" ]]; then
DEF_READLINE="${DEF_READLINE} -DOLD_READLINE"
else
ORIG_LDFLAGS=${LDFLAGS}
if test "$READLINE_LIBDIR" != ""; then
LDFLAGS="${LDFLAGS} -L${READLINE_LIBDIR}"
fi
AC_CHECK_LIB(readline,
rl_completion_matches,:,DEF_READLINE="${DEF_READLINE} -DOLD_READLINE",
${READLINE_LIBDIR} ${READLINE_LIBS})
LDFLAGS=${ORIG_LDFLAGS}
fi
if [[ "$with_readline" = "yes" ]]; then
SQSH_PARSE_LIB="sqsh_parser/sqsh_parser.a"
else
SQSH_PARSE_LIB=""
fi
fi
AC_SUBST(DEF_READLINE)
AC_SUBST(READLINE_INCDIR)
AC_SUBST(READLINE_LIBDIR)
AC_SUBST(READLINE_LIBS)
AC_SUBST(SQSH_PARSE_LIB)
dnl
dnl Check X/Motif settings
dnl
if test "$with_x" != "no"; then
if test "$with_motif" != "no"; then
MOTIF_LIBS=-lXm
ATHENA_LIBS=
else
MOTIF_LIBS=
ATHENA_LIBS=-lXaw
fi
DEF_X11="-DUSE_X11"
# The AC PATH EXTRA macro uses xmkmf to figure out where to
# find the X include directory and X lib directories, so lets
# make sure that it can find the xmkmf executable.
AC_PATH_PROG(xmkmfpath, xmkmf)
# When complete, the following macro should define x_includes,
# x_libraries, X_CFLAGS, X_LIBS, X_EXTRA_LIBS, and X_PRE_LIBS.
AC_PATH_X
# On some systems the X include directory may be found but not
# the library directory. In these cases we attempt to guess
# the lib directory.
if test -d "${x_includes}" -a ! -d "${x_libraries}"; then
x_libraries=`echo ${x_includes} | sed -e 's,include,lib,g'`
fi
# Reverse the test above to see if the lib directory has been
# defined but not the include directory.
if test -d "${x_libraries}" -a ! -d "${x_includes}"; then
x_includes=`echo "${x_libraries}" | sed -e 's,lib,include,g'`
fi
# If we found the include directory in the standard /usr/include, then
# don't bother to add it to our cpp line..it'll be found anyway. If
# it wasn't found then we'll assume /usr/X11R6/include.
if test "${x_includes}" != ""; then
if test "${x_includes}" != "/usr/include"; then
X_INCDIR="-I${x_includes}"
else
X_INCDIR="# -I${x_includes}"
fi
else
X_INCDIR="# -I/usr/X11R6/include"
fi
# Repeat pretty much the same thing for the library directory. If
# it was found in /usr/lib or /lib, then comment it out, or if
# it wasn't found then assume /usr/X11R6/lib.
if test "${x_libraries}" != ""; then
if test "${x_libraries}" != "/usr/lib" -a "${x_libraries}" != "/lib"; then
X_LIBDIR="-L${x_libraries}"
else
X_LIBDIR="# -L${x_libraries}"
fi
else
X_LIBDIR="# -L/usr/X11R6/lib"
fi
# This link line may product more libraries than actually needed
# but hopefuly it'll work for most systems; besides the linker
# should clean things up for us.
X_LIBS="${X_WIDGETLIB} -lXt -lXext -lXmu ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS}"
else
DEF_X11="# ${DEF_X11}"
X_LIBS="# -lXaw -lXt -lXext -lXmu -lX11"
X_INCDIR="# -I/usr/X11R6/include"
X_LIBDIR="# -L/usr/X11R6/lib"
fi
AC_SUBST(DEF_X11)
AC_SUBST(X_LIBS)
AC_SUBST(X_INCDIR)
AC_SUBST(X_LIBDIR)
AC_SUBST(MOTIF_LIBS)
AC_SUBST(ATHENA_LIBS)
dnl
dnl Checks for header files.
dnl
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stropts.h memory.h stdlib.h time.h sys/time.h sys/types.h string.h strings.h fcntl.h unistd.h errno.h limits.h sys/param.h crypt.h shadow.h locale.h readline/history.h)
dnl
dnl Check for crypt, pthread and iconv libraries
dnl
AC_FIND_LIB(crypt, [$LIBDIRS], [ LIBS="${LIBS} -lcrypt" ],[ ])
if test "$with_static" = "yes"; then
AC_FIND_LIB(pthread, [$LIBDIRS], [ LIBS="${LIBS} -lpthread" ],[ ])
fi
if test "$SYBASE_VERSION" = "FreeTDS"; then
AC_FIND_LIB(iconv, [$LIBDIRS], [ LIBS="${LIBS} -liconv" ],[ ])
fi
dnl
dnl Checks for library functions.
dnl
AC_CHECK_FUNCS(sigaction strcasecmp strerror cftime strftime memcpy memmove localtime timelocal strchr gettimeofday get_process_stats crypt poll localeconv setlocale)
dnl
dnl Checks function behaviour
dnl
AC_TYPE_SIGNAL
AC_SIGSETJMP
AC_SYSV_SIGNALS
AC_PROG_INSTALL
dnl
dnl Produce the required output files
dnl
AC_OUTPUT(Makefile src/Makefile src/sqsh_parser/Makefile scripts/install.sh scripts/make_wrapper.sh)
dnl
dnl Output some final messages
dnl
case "${host_os}" in
*cygwin)
if test "$SYBASE_VERSION" != "FreeTDS"; then
AC_MSG_NOTICE([Cygwin/Sybase target detected: Please make sure you have local user])
AC_MSG_NOTICE([environment variables defined for SYBASE and SYBASE_OCS.])
AC_MSG_NOTICE([See cygwin/README for more information.])
fi
;;
*)
;;
esac
AC_MSG_NOTICE([Completed successfully. Please run 'make clean && make' to build sqsh.])