1dnl $Id: configure.in,v 1.12 2014/03/17 17:19:43 mwesdorp Exp $ 2dnl 3dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. 4dnl This file is free software, distributed under the terms of the GNU 5dnl General Public License. As a special exception to the GNU General 6dnl Public License, this file may be distributed as part of a program 7dnl that contains a configuration script generated by Autoconf, under 8dnl the same distribution terms as the rest of that program. 9dnl 10dnl configure.in script to configure sqsh build environment 11dnl 12AC_INIT(src/sqsh_main.c) 13AC_CONFIG_HEADER(src/config.h) 14AC_CONFIG_AUX_DIR(autoconf) 15AC_CANONICAL_HOST 16 17dnl 18dnl Define the possible configure options 19dnl 20AC_ARG_WITH([gcc], 21 [ --with-gcc Use gcc, regardless of path], 22 [], [with_gcc="yes"]) 23 24AC_ARG_WITH([debug], 25 [ --with-debug Enable sqsh debugging options], 26 [], [with_debug="no"]) 27 28AC_ARG_WITH([readline], 29 [ --with-readline support fancy command line editing], 30 [], [with_readline="yes"]) 31 32AC_ARG_WITH([old-readline], 33 [ --with-old-readline Force readline backwards compatibilty], 34 [], [with_old_readline="no"]) 35 36AC_ARG_WITH([static], 37 [ --with-static Statically link in Sybase libraries], 38 [], [with_static="no"]) 39 40AC_ARG_WITH([devlib], 41 [ --with-devlib Compile against Open Client devlibs], 42 [], [with_devlib="no"]) 43 44AC_ARG_WITH([x], 45 [], 46 [], [with_x="no"]) 47 48AC_ARG_WITH([motif], 49 [ --with-motif support X11/Motif widgets], 50 [ 51 if test "$with_motif" != "no"; then 52 if test "$with_motif" != "yes"; then 53 MOTIF_PATH=$with_motif 54 with_motif="yes" 55 MOTIF_INCDIR="-I$MOTIF_PATH/include/X11" 56 MOTIF_LIBDIR="-L$MOTIF_PATH/lib" 57 else 58 MOTIF_INCDIR="# -I/usr/X11/include" 59 MOTIF_LIBDIR="# -L/usr/X11/lib" 60 fi 61 with_x="yes" 62 DEF_MOTIF="-DUSE_MOTIF" 63 fi 64 ],[ 65 with_motif="no" 66 DEF_MOTIF="# -DUSE_MOTIF" 67 ]) 68 69if test "$with_debug" != "no"; then 70 DEF_DEBUG="-DDEBUG" 71fi 72 73AC_SUBST(with_gcc) 74AC_SUBST(with_debug) 75AC_SUBST(with_readline) 76AC_SUBST(with_old_readline) 77AC_SUBST(with_static) 78AC_SUBST(with_devlib) 79AC_SUBST(with_x) 80AC_SUBST(with_motif) 81AC_SUBST(DEF_DEBUG) 82AC_SUBST(DEF_MOTIF) 83AC_SUBST(MOTIF_PATH) 84AC_SUBST(MOTIF_INCDIR) 85AC_SUBST(MOTIF_LIBDIR) 86 87dnl 88dnl Check Compiler characteristics, typedefs and structures 89dnl 90AC_PROG_CC 91AC_PROG_CPP 92AC_ISC_POSIX 93AC_VOLATILE 94AC_C_CONST 95AC_TYPE_MODE_T 96AC_TYPE_PID_T 97AC_TYPE_UID_T 98AC_BIT_MODE 99 100if test "${ISC}" = "yes"; then 101 DEF_POSIX="-D_POSIX_SOURCE" 102 AC_SUBST(DEF_POSIX) 103fi 104 105dnl 106dnl Set flags and variables depending on host_os 107dnl 108case "$host_os" in 109 aix*) 110 DEF_AIX_FIX="-DUSE_AIX_FIX" 111 AC_SUBST(DEF_AIX_FIX) 112 OBJMODE="-X32_64" 113 AC_SUBST(OBJMODE) 114 ;; 115 *) 116 ;; 117esac 118 119dnl 120dnl Check SYBASE/FreeTDS libraries 121dnl 122AC_SYBASE_ASE 123 124dnl 125dnl Check READLINE environment 126dnl 127if test "$with_old_readline" = "yes"; then 128 with_readline="yes" 129fi 130 131if test "$with_readline" = "no"; then 132 DEF_READLINE="# -DUSE_READLINE" 133 READLINE_INCDIR="# -I/usr/local/include" 134 READLINE_LIBDIR="# -L/usr/local/lib" 135 READLINE_LIBS="# -lreadline -lcurses" 136else 137 DEF_READLINE="-DUSE_READLINE" 138 139 AC_FIND_LIB(readline, [$LIBDIRS], 140 [ 141 READLINE_LIBDIR="${libdir}" 142 inc_search="`echo ${libdir} | sed -e 's,/[[^/]]*$,,g'`/include" 143 ],[ 144 READLINE_LIBDIR="" 145 inc_search="" 146 ]) 147 148 if test "$INCDIRS" != ""; then 149 if test "$inc_search" = ""; then 150 inc_search=$INCDIRS 151 else 152 inc_search=$inc_search:$INCDIRS 153 fi 154 fi 155 AC_FIND_HDR([readline/readline.h],[$inc_search], 156 [READLINE_INCDIR="${include_dir}"],[READLINE_INCDIR=""]) 157 158 AC_MSG_CHECKING(for readline link) 159 160 AC_CACHE_VAL(ac_cv_readline_libs, 161 [ 162 readline_libs="" 163 164 ORIG_CPPFLAGS="${CPPFLAGS}" 165 ORIG_LDFLAGS="${LDFLAGS}" 166 ORIG_LIBS="${LIBS}" 167 168 if test "${READLINE_INCDIR}" != ""; then 169 CPPFLAGS="${CPPFLAGS} -I${READLINE_INCDIR}" 170 fi 171 172 if test "${READLINE_LIBDIR}" != ""; then 173 LDFLAGS="${LDFLAGS} -L${READLINE_LIBDIR}" 174 fi 175 176 for lib in "-lHcurses" "-lncurses" "-lcurses" "-ltermcap" "-lucb" "-lhistory" 177 do 178 LIBS="${ORIG_LIBS} -lreadline ${lib}" 179 AC_TRY_LINK([ 180#include <stdio.h> 181#include <readline/readline.h> 182#include <readline/history.h> 183 ],[ 184 char *c; 185 add_history( c ); 186 readline( c ); 187 ],[ 188 readline_libs="${lib}" 189 ]) 190 191 if test "${readline_libs}" != ""; then 192 break; 193 fi 194 done 195 196 CPPFLAGS="${ORIG_CPPFLAGS}" 197 LDFLAGS="${ORIG_LDFLAGS}" 198 LIBS="${ORIG_LIBS}" 199 200 ac_cv_readline_libs=${readline_libs} 201 ]) 202 203 READLINE_LIBS=${ac_cv_readline_libs} 204 205 if test "${READLINE_LIBS}" = ""; then 206 AC_MSG_RESULT(not found) 207 READLINE_LIBS="-lreadline -lcurses" 208 else 209 READLINE_LIBS="-lreadline ${READLINE_LIBS}" 210 AC_MSG_RESULT(${READLINE_LIBS}) 211 fi 212 213 if test "$READLINE_INCDIR" = ""; then 214 READLINE_INCDIR="-I/usr/local/include" 215 else 216 if test "$READLINE_INCDIR" = "/usr/include"; then 217 READLINE_INCDIR="# -I${READLINE_INCDIR}" 218 else 219 READLINE_INCDIR="-I${READLINE_INCDIR}" 220 fi 221 fi 222 223 if test "$READLINE_LIBDIR" = ""; then 224 READLINE_LIBDIR="-L/usr/local/lib" 225 else 226 if test "$READLINE_LIBDIR" = "/usr/lib" -o ${READLINE_LIBDIR} = "/lib"; then 227 READLINE_LIBDIR="" 228 else 229 READLINE_LIBDIR="-L${READLINE_LIBDIR}" 230 fi 231 fi 232 233 if [[ "$with_old_readline" = "yes" ]]; then 234 DEF_READLINE="${DEF_READLINE} -DOLD_READLINE" 235 else 236 ORIG_LDFLAGS=${LDFLAGS} 237 if test "$READLINE_LIBDIR" != ""; then 238 LDFLAGS="${LDFLAGS} -L${READLINE_LIBDIR}" 239 fi 240 AC_CHECK_LIB(readline, 241 rl_completion_matches,:,DEF_READLINE="${DEF_READLINE} -DOLD_READLINE", 242 ${READLINE_LIBDIR} ${READLINE_LIBS}) 243 LDFLAGS=${ORIG_LDFLAGS} 244 fi 245 246 if [[ "$with_readline" = "yes" ]]; then 247 SQSH_PARSE_LIB="sqsh_parser/sqsh_parser.a" 248 else 249 SQSH_PARSE_LIB="" 250 fi 251fi 252 253AC_SUBST(DEF_READLINE) 254AC_SUBST(READLINE_INCDIR) 255AC_SUBST(READLINE_LIBDIR) 256AC_SUBST(READLINE_LIBS) 257AC_SUBST(SQSH_PARSE_LIB) 258 259dnl 260dnl Check X/Motif settings 261dnl 262if test "$with_x" != "no"; then 263 if test "$with_motif" != "no"; then 264 MOTIF_LIBS=-lXm 265 ATHENA_LIBS= 266 else 267 MOTIF_LIBS= 268 ATHENA_LIBS=-lXaw 269 fi 270 DEF_X11="-DUSE_X11" 271 272 # The AC PATH EXTRA macro uses xmkmf to figure out where to 273 # find the X include directory and X lib directories, so lets 274 # make sure that it can find the xmkmf executable. 275 276 AC_PATH_PROG(xmkmfpath, xmkmf) 277 278 # When complete, the following macro should define x_includes, 279 # x_libraries, X_CFLAGS, X_LIBS, X_EXTRA_LIBS, and X_PRE_LIBS. 280 281 AC_PATH_X 282 283 # On some systems the X include directory may be found but not 284 # the library directory. In these cases we attempt to guess 285 # the lib directory. 286 287 if test -d "${x_includes}" -a ! -d "${x_libraries}"; then 288 x_libraries=`echo ${x_includes} | sed -e 's,include,lib,g'` 289 fi 290 291 # Reverse the test above to see if the lib directory has been 292 # defined but not the include directory. 293 294 if test -d "${x_libraries}" -a ! -d "${x_includes}"; then 295 x_includes=`echo "${x_libraries}" | sed -e 's,lib,include,g'` 296 fi 297 298 # If we found the include directory in the standard /usr/include, then 299 # don't bother to add it to our cpp line..it'll be found anyway. If 300 # it wasn't found then we'll assume /usr/X11R6/include. 301 302 if test "${x_includes}" != ""; then 303 if test "${x_includes}" != "/usr/include"; then 304 X_INCDIR="-I${x_includes}" 305 else 306 X_INCDIR="# -I${x_includes}" 307 fi 308 else 309 X_INCDIR="# -I/usr/X11R6/include" 310 fi 311 312 # Repeat pretty much the same thing for the library directory. If 313 # it was found in /usr/lib or /lib, then comment it out, or if 314 # it wasn't found then assume /usr/X11R6/lib. 315 316 if test "${x_libraries}" != ""; then 317 if test "${x_libraries}" != "/usr/lib" -a "${x_libraries}" != "/lib"; then 318 X_LIBDIR="-L${x_libraries}" 319 else 320 X_LIBDIR="# -L${x_libraries}" 321 fi 322 else 323 X_LIBDIR="# -L/usr/X11R6/lib" 324 fi 325 326 # This link line may product more libraries than actually needed 327 # but hopefuly it'll work for most systems; besides the linker 328 # should clean things up for us. 329 330 X_LIBS="${X_WIDGETLIB} -lXt -lXext -lXmu ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS}" 331else 332 DEF_X11="# ${DEF_X11}" 333 X_LIBS="# -lXaw -lXt -lXext -lXmu -lX11" 334 X_INCDIR="# -I/usr/X11R6/include" 335 X_LIBDIR="# -L/usr/X11R6/lib" 336fi 337 338AC_SUBST(DEF_X11) 339AC_SUBST(X_LIBS) 340AC_SUBST(X_INCDIR) 341AC_SUBST(X_LIBDIR) 342AC_SUBST(MOTIF_LIBS) 343AC_SUBST(ATHENA_LIBS) 344 345dnl 346dnl Checks for header files. 347dnl 348AC_HEADER_STDC 349AC_HEADER_SYS_WAIT 350AC_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) 351 352dnl 353dnl Check for crypt, pthread and iconv libraries 354dnl 355AC_FIND_LIB(crypt, [$LIBDIRS], [ LIBS="${LIBS} -lcrypt" ],[ ]) 356if test "$with_static" = "yes"; then 357 AC_FIND_LIB(pthread, [$LIBDIRS], [ LIBS="${LIBS} -lpthread" ],[ ]) 358fi 359if test "$SYBASE_VERSION" = "FreeTDS"; then 360 AC_FIND_LIB(iconv, [$LIBDIRS], [ LIBS="${LIBS} -liconv" ],[ ]) 361fi 362 363dnl 364dnl Checks for library functions. 365dnl 366AC_CHECK_FUNCS(sigaction strcasecmp strerror cftime strftime memcpy memmove localtime timelocal strchr gettimeofday get_process_stats crypt poll localeconv setlocale) 367 368dnl 369dnl Checks function behaviour 370dnl 371AC_TYPE_SIGNAL 372AC_SIGSETJMP 373AC_SYSV_SIGNALS 374AC_PROG_INSTALL 375 376dnl 377dnl Produce the required output files 378dnl 379AC_OUTPUT(Makefile src/Makefile src/sqsh_parser/Makefile scripts/install.sh scripts/make_wrapper.sh) 380 381dnl 382dnl Output some final messages 383dnl 384case "${host_os}" in 385 *cygwin) 386 if test "$SYBASE_VERSION" != "FreeTDS"; then 387 AC_MSG_NOTICE([Cygwin/Sybase target detected: Please make sure you have local user]) 388 AC_MSG_NOTICE([environment variables defined for SYBASE and SYBASE_OCS.]) 389 AC_MSG_NOTICE([See cygwin/README for more information.]) 390 fi 391 ;; 392 *) 393 ;; 394esac 395AC_MSG_NOTICE([Completed successfully. Please run 'make clean && make' to build sqsh.]) 396