# This is free software, licensed under the GNU Public License V2. # See the file COPYING for details. AC_INIT(include/pi-version.h.in) AC_PREFIX_DEFAULT(/usr/local) dnl ****************************** dnl Limit to a specific ac version dnl ****************************** dnl AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) AC_SUBST(CFLAGS) AC_SUBST(CXXFLAGS) AC_PATH_PROG(ID, id) dnl ****************************** dnl Warn re: config/build as root dnl ****************************** if test `$ID -u` = 0; then echo "" echo " WARNING: Please do not configure or build this software as root.." echo "" echo " You should not need to be the root user, or superuser to build or" echo " configure software. You will only need to use the root user to" echo " install the software to its final destination, not to build it." echo "" echo " You probably want to build this as a normal user, not root." echo "" fi dnl ****************************** dnl Pilot Link Version dnl ****************************** PILOT_LINK_VERS=0 PILOT_LINK_MAJOR=11 PILOT_LINK_MINOR=8 PILOT_LINK_PATCH= AC_SUBST(PILOT_LINK_VERS) AC_SUBST(PILOT_LINK_MAJOR) AC_SUBST(PILOT_LINK_MINOR) AC_SUBST(PILOT_LINK_PATCH) VERSION="$PILOT_LINK_VERS.$PILOT_LINK_MAJOR.$PILOT_LINK_MINOR$PILOT_LINK_PATCH" dnl ****************************** dnl Pilot Link Library Version dnl libpisock.so dnl ****************************** PISOCK_CURRENT=8 PISOCK_REVISION=5 PISOCK_AGE=0 AC_SUBST(PISOCK_CURRENT) AC_SUBST(PISOCK_REVISION) AC_SUBST(PISOCK_AGE) dnl ****************************** dnl Pilot Link Sync Library Version dnl libpisync.so dnl ****************************** PISYNC_CURRENT=0 PISYNC_REVISION=1 PISYNC_AGE=0 AC_SUBST(PISYNC_CURRENT) AC_SUBST(PISYNC_REVISION) AC_SUBST(PISYNC_AGE) dnl ****************************** dnl Pilot Link C++ Library Version dnl libpisock++ dnl ****************************** PISOCKPP_CURRENT=0 PISOCKPP_REVISION=0 PISOCKPP_AGE=0 AC_SUBST(PISOCKPP_CURRENT) AC_SUBST(PISOCKPP_REVISION) AC_SUBST(PISOCKPP_AGE) dnl Check host type AC_CANONICAL_HOST AC_CANONICAL_SYSTEM AC_DEFINE_UNQUOTED(HOST_OS, "$host", [Host type]) AM_INIT_AUTOMAKE(pilot-link, [$VERSION]) dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL AM_PROG_LIBTOOL AC_PROG_YACC dnl ****************************** dnl Check if this was CVS source dnl ****************************** if test -d "${srcdir}/CVS" ; then PL_FROM_CVS=yes dnl CFLAGS="$CFLAGS -Werror" fi dnl ****************************** dnl Pilot Link Checks dnl ****************************** AC_HEADER_STDC AC_C_CONST AC_HEADER_TIME AC_STRUCT_TM AC_PROG_GCC_TRADITIONAL AC_TYPE_SIGNAL AC_CHECK_HEADERS( dirent.h errno.h fcntl.h inttypes.h memory.h netdb.h \ netinet/in.h readline/history.h readline/readline.h stdint.h \ stdlib.h string.h strings.h sys/ioctl_compat.h sys/ioctl.h \ sys/malloc.h sys/select.h sys/sockio.h sys/time.h sys/utsname.h \ unistd.h) AC_CHECK_FUNCS( atexit cfmakeraw cfsetispeed cfsetospeed cfsetspeed dup2 \ gethostname inet_aton malloc memcpy memmove putenv sigaction \ snprintf strchr strdup strtok strtoul uname) dnl Find optional libraries (borrowed from Tcl) tcl_checkBoth=0 AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1) if test "$tcl_checkSocket" = 1; then AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tcl_checkBoth=1) fi if test "$tcl_checkBoth" = 1; then tk_oldLibs=$LIBS LIBS="$LIBS -lsocket -lnsl" AC_CHECK_FUNC( accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs]) fi AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])) AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"]) AC_CACHE_CHECK([for cispeed and cospeed members of struct termios], ac_cv_termios_cspeed, [AC_TRY_COMPILE( [#include ], [int main(void) { struct termios t;t.c_ispeed=t.c_ospeed=0;}], ac_cv_termios_cspeed=yes,ac_cv_termios_cspeed=no)]) if test $ac_cv_termios_cspeed = yes; then AC_DEFINE(TERMIOS_CSPEED, 1, [Define if we have termios(3) support]) fi dnl ****************************** dnl PNG Support dnl ****************************** have_png=no msg_png=no AC_ARG_WITH(libpng, [ --with-libpng Prefix where libpng is installed]) case $withval in /*) PNG_CFLAGS="-I$withval/include" PNG_LIBS="-L$withval/lib" ;; esac save_CFLAGS="$CFLAGS" save_LDFLAGS="$LDFLAGS" CFLAGS="$CFLAGS $PNG_CFLAGS" LDFLAGS="$LDFLAGS $PNG_LIBS" AC_CHECK_LIB(png, main, [have_png=yes; PNG_LIBS="$PNG_LIBS -lpng"],[have_png=no],[-lm]) if test "$have_png" = yes; then AC_CHECK_HEADER(png.h, , have_png=no) if test "$have_png" = yes; then AC_MSG_CHECKING(for png setjmp support) AC_EGREP_CPP(yes, [#include #ifdef PNG_SETJMP_SUPPORTED yes #endif], , have_png=no) AC_MSG_RESULT($have_png) if test "$have_png" = yes; then AC_DEFINE(HAVE_PNG, 1, [Define if we have PNG support]) msg_png=yes fi fi fi CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS" AC_SUBST(PNG_CFLAGS) AC_SUBST(PNG_LIBS) dnl ****************************** dnl Test if building USB Support dnl for Linux or FreeBSD dnl ****************************** msg_usb=no usb_type= case "$host" in *linux*) AC_DEFINE(HAVE_USB, 1, [Define if we have USB support]) usb_type=linux msg_usb="yes, Linux" ;; *freebsd*) AC_DEFINE(HAVE_USB, 1, [Define if we have USB support]) usb_type=freebsd msg_usb="yes, FreeBSD" ;; esac AM_CONDITIONAL(WITH_LINUXUSB, test x$usb_type = xlinux) AM_CONDITIONAL(WITH_FREEBSDUSB, test x$usb_type = xfreebsd) dnl ****************************** dnl Test for getopt dnl ****************************** dnl use our included getopt if the system doesn't have getopt() or dnl getopt_long() unistd_getopt=yes getopt_getopt=yes AC_CHECK_HEADER([unistd.h], [ AC_CHECK_FUNCS( [getopt getopt_long], , unistd_getopt=no)], unistd_getopt=no) AC_CHECK_HEADER([getopt.h], [ AC_CHECK_FUNCS( [getopt getopt_long], , getopt_getopt=no)], getopt_getopt=no) AM_CONDITIONAL(NEED_GETOPT, test x$unistd_getopt = xno -a x$getopt_getopt = xno) dnl ****************************** dnl iconv checking dnl ****************************** have_iconv=no AC_ARG_WITH(libiconv, [ --with-libiconv Prefix where libiconv is installed]) case $withval in /*) ICONV_CFLAGS="-I$withval/include" ICONV_LIBS="-L$withval/lib" ;; esac save_CFLAGS="$CFLAGS" save_LDFLAGS="$LDFLAGS" CFLAGS="$CFLAGS $ICONV_CFLAGS" LDFLAGS="$LDFLAGS $ICONV_LIBS" AC_CHECK_LIB( iconv, libiconv, [have_iconv=yes; ICONV_LIBS="$ICONV_LIBS -liconv"], [ AC_CHECK_FUNC(iconv, [ AC_CHECK_FUNCS(gnu_get_libc_version) AC_MSG_CHECKING(if system iconv handles CP1252) AC_TRY_RUN([ #include #include #include #ifdef HAVE_GNU_GET_LIBC_VERSION #include #endif int main (int argc, char **argv) { const char *pc = "\x66\x66\x66\x66\x66\x66\x66\xA9"; const char *utf8 = "\x66\x66\x66\x66\x66\x66\x66\xC2\xA9"; char transbuf[10], *trans = transbuf; iconv_t cd; size_t pc_len = strlen (pc), utf8_len = 10; size_t utf8_real_len = strlen (utf8); cd = iconv_open ("UTF-8", "CP1252"); if (!cd) exit (1); if (iconv (cd, &pc, &pc_len, &trans, &utf8_len) == -1 || pc_len != 0) exit (1); if (memcmp (utf8, transbuf, utf8_real_len) != 0) exit (1); exit (0); }], AC_MSG_RESULT(yes); have_iconv=yes, [AC_MSG_RESULT(no);], AC_MSG_RESULT(not cross compiling);)])]) dnl ## Fixed AC_TRY_RUN warning, missing third argument. -DD 22/01/2002 dnl dnl AC_TRY_RUN is a macro that's basically like an if-then-else structure. If dnl the test program (whose text is the first argument) succeeds, the second dnl argument is executed; if the test fails, the third argument is executed; and dnl if autoconf knows it is cross-compiling for another machine and therefore dnl can't run a test program at all, it doesn't try but just executes the fourth dnl argument. Usually that last alternative should be the most conservative dnl assumption. CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS" if test "$have_iconv" = yes; then AC_DEFINE(HAVE_ICONV, 1, [Define if we have libiconv support]) msg_iconv=yes else msg_iconv=no fi AC_SUBST(ICONV_CFLAGS) AC_SUBST(ICONV_LIBS) dnl ****************************** dnl C++ dnl ****************************** use_cpp=false msg_cpp=no AC_ARG_WITH(cpp, [ --with-cpp=cppexec use C++ [default=yes]]) if test "x$with_cpp" != "xno"; then AC_PROG_CXX use_cpp=true fi AM_CONDITIONAL(WITH_CXX, $use_cpp) if $use_cpp; then msg_cpp=yes CXXFLAGS="$CXXFLAGS -Wno-deprecated" fi dnl ****************************** dnl readline checking dnl ****************************** msg_readline=no AC_ARG_WITH(readline, [ --with-readline use readline [default=yes]]) if test "x$with_readline" != "xno"; then LIBS="$LIBS -lreadline" dnl Let's check all the possible places for readline for termlib in ncurses curses termcap terminfo termlib ; do AC_CHECK_LIB(${termlib}, add_history, [LIBS="-l${termlib} $LIBS"; break]) LIBS="$ac_save_LIBS" done AC_MSG_CHECKING(for readline) AC_TRY_LINK([ #include #include ],[(void)readline(0);], RL_LIBS="-lreadline", AC_TRY_LINK(,[(void)readline(0);], RL_LIBS="-lreadline -l${termlib}")) if test "x$RL_LIBS" = "x"; then AC_MSG_RESULT(not found) AC_MSG_ERROR([Development headers for readline were not found. Please correct.]) else AC_MSG_RESULT(found) fi fi if test "x$RL_LIBS" != "x"; then AC_MSG_CHECKING(for basic readline functions) ac_save_LIBS="$LIBS" LIBS="$LIBS $RL_LIBS" AC_TRY_LINK([ #include #include ], [ char *line; line = readline("prompt");], [AC_TRY_LINK([ #include #include ], [ add_history("test");], [msg_readline=partial])]) LIBS="$ac_save_LIBS" if test "xmsg_readline" = "xno"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi fi if test "x$msg_readline" != "xno"; then AC_MSG_CHECKING(for extra readline functions) ac_save_LIBS="$LIBS" LIBS="$LIBS $RL_LIBS" AC_TRY_LINK([ #include #include ], [ rl_callback_read_char();], [AC_TRY_LINK([ #include #include ], [ static void execline(char *line) {} rl_callback_handler_install("prompt", execline);], [AC_TRY_LINK([ #include #include ], [ rl_callback_handler_remove();], [AC_TRY_LINK([ #include #include ], [ rl_forced_update_display();], [msg_readline=full])])])]) LIBS="$ac_save_LIBS" if test "x$msg_readline" != "xfull"; then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi fi if test "x$msg_readline" = "xpartial"; then AC_DEFINE(HAVE_READLINE, 1, [Define if we have readline support]) fi if test "x$msg_readline" = "xfull"; then AC_DEFINE(HAVE_READLINE, 1, [Define if we have readline support]) AC_DEFINE(HAVE_READLINE_EXTRA, 1, [Define if we have extra readline support]) fi AC_SUBST(RL_CFLAGS) AC_SUBST(RL_LIBS) dnl ****************************** dnl Perl dnl ****************************** use_perl=false msg_perl=no AC_ARG_WITH(perl, [ --with-perl=perlexec use Perl [default=no]], , with_perl=no) if test "x$with_perl" = "xno"; then AC_MSG_CHECKING(if perl was enabled) AC_MSG_RESULT(no) PERL='' else if test "x$with_perl" != "xyes" && test "x$with_perl" != "x"; then PERL="$with_perl" else AC_CHECK_PROG(PERL, perl, perl) fi fi dnl Check if version of Perl is sufficient PERL_MINVERSION="5.000_00" if test "x$PERL" != "x"; then AC_MSG_CHECKING(for perl version greater than or equal to $PERL_MINVERSION) $PERL -e "exit ! eval 'use $PERL_MINVERSION; 1'" if test $? -ne 0; then AC_MSG_RESULT(no); use_perl=false else AC_MSG_RESULT(yes); PERL_VERSION=`$PERL -e 'print $]'` use_perl=true fi fi AM_CONDITIONAL(WITH_PERL, $use_perl) if $use_perl; then msg_perl=yes fi AC_SUBST(PERL) dnl ****************************** dnl Java dnl ****************************** use_java=false msg_java=no AC_ARG_WITH(java, [ --with-java=jdkbase use Java [default=no]], , with_java=no) if test "x$with_java" != "xno"; then AC_PATH_PROG(JAVAC, javac, , $with_java/bin:$PATH) AC_PATH_PROG(JAVA, java, , $with_java/bin:$PATH) AC_PATH_PROG(JAR, jar, ,$with_java/bin:$PATH) fi if test "x$JAVA" != "x" && test "x$JAVAC" != "x" && test "x$JAR" != "x"; then AC_MSG_CHECKING(for Java Development Kit) JAVABASE=`echo "$JAVAC" | sed -e "s/\/bin\/javac//"` if test -f "$JAVABASE/include/jni.h"; then use_java=true AC_MSG_RESULT(looks good) else AC_MSG_RESULT(not usable) fi fi AM_CONDITIONAL(WITH_JAVA, $use_java) if $use_java; then msg_java=yes JAVA_VERSION=`java -version 2>&1 | grep '^java version' | awk -F\" '{print $2}'` fi AC_SUBST(JAVA) AC_SUBST(JAVAC) AC_SUBST(JAR) AC_SUBST(JAVABASE) AC_SUBST(JAVA_VERSION) dnl ****************************** dnl TCL dnl ****************************** msg_tcl=no PILOT_LINK_PATH_TCLCONFIG if $use_tcl; then PILOT_LINK_LOAD_TCLCONFIG PILOT_LINK_PUBLIC_TCL_HEADERS PILOT_LINK_PROG_TCLSH PILOT_LINK_PROG_WISH fi AC_SUBST(TCL_INCLUDES) AC_SUBST(TCL_LIB_FILE) AC_SUBST(TCL_LIB_FLAG) AC_SUBST(TCL_LIB_SPEC) AC_SUBST(TCL_LIBS) AC_SUBST(TCL_VERSION) AC_SUBST(TCLSH_PROG) AC_SUBST(WISH_PROG) AM_CONDITIONAL(WITH_TCL, $use_tcl) if $use_tcl; then msg_tcl=yes fi dnl ****************************** dnl Python dnl ****************************** use_python=false msg_python=no AC_ARG_WITH(python, [ --with-python=pybase use Python [default=no]], , with_python=no) if test "x$with_python" != "xno"; then AC_PATH_PROGS(PYTHON, [python2 python]) if test "x$PYTHON" != "x"; then use_python=true fi fi if $use_python; then AC_MSG_CHECKING(python development kit) # sys.stdout = StringIO.StringIO(); sends all strings to memory, # more portable than the previous '>/dev/null' call PYTHONVER=[`$PYTHON -c "import sys, string; print string.split(sys.version)[0]"`] if `$PYTHON -c "from distutils.core import setup, Extension;"`; then use_python=true AC_MSG_RESULT(looks good) else use_python=false AC_MSG_RESULT(not usable) fi fi AM_CONDITIONAL(WITH_PYTHON, $use_python) if $use_python; then msg_python=yes fi AC_SUBST(PYTHON) dnl ************************************* dnl ElectricFence (optional) dnl ************************************* use_efence=false msg_efence=no AC_ARG_WITH(efence, [ --with-efence use ElectricFence checking [default=no]], , with_efence=no) if test "x$with_efence" != "xno"; then AC_CHECK_LIB(efence, malloc, LIBS="$LIBS -lefence") if test "$ac_cv_lib_efence_malloc" = yes; then use_efence=true else use_efence=false echo "Unable to locate ElectricFence malloc() debugging library!" echo "Please download from ftp://ftp.perens.com/pub/ElectricFence/" echo "You may also try omitting --with-efence when running configure." echo "" exit 1; fi fi if $use_efence; then msg_efence=yes else msg_efence=no fi dnl ************************************* dnl Runtime debugging dnl ************************************* AC_ARG_ENABLE(debug, [ --disable-debug Shunt runtime debugging], set_debug=no) if test "${enable_debug+set}" = set; then enableval="$enable_debug" if eval "test x$enable_debug = xyes"; then CFLAGS="-g $CFLAGS" CXXFLAGS="-g $CXXFLAGS" fi fi if test "$set_debug" != "no"; then AC_DEFINE(PI_DEBUG, 1, [Define if we have debugging enabled]) else CFLAGS=`echo "$CFLAGS" | sed -e "s/-g //"` CXXFLAGS=`echo "$CXXFLAGS" | sed -e "s/-g //"` fi dnl ************************************* dnl Profiling information dnl ************************************* AC_ARG_ENABLE(profile, [ --enable-profile use gprof profiling [default no]], CFLAGS="-pg $CFLAGS") dnl ************************************* dnl Extra warnings dnl ************************************* set_compile_warnings=no AC_ARG_ENABLE(compile-warnings, [ --enable-compile-warnings Enable verbose compiler warnings], set_compile_warnings=yes) if test "$GCC" = "yes" -a "$set_compile_warnings" != "no"; then CFLAGS="$CFLAGS \ -Wall -Wstrict-prototypes -Wmissing-declarations \ -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ -pedantic" fi case "$host" in *bsd*) AC_DEFINE(TTYPrompt, "/dev/cua[<0..n>]", [Define verbose tty device]) ;; *) AC_DEFINE(TTYPrompt, "/dev/tty[<0..n>]", [Define verbose tty device]) ;; esac AC_OUTPUT([ Makefile pilot-link.m4 libpisock/Makefile include/Makefile include/pi-version.h ]) echo " Options detected/selected -------------------------. pilot-link version...... : $VERSION libpisock version....... : $PISOCK_CURRENT.$PISOCK_AGE.$PISOCK_REVISION libpisync version....... : $PISYNC_CURRENT.$PISYNC_AGE.$PISYNC_REVISION Build for host.......... : $host Extra Warnings.......... : $set_compile_warnings Direct USB support...... : $msg_usb ElectricFence checks.... : $msg_efence CFLAGS.................. : $CFLAGS CXXFLAGS................ : $CXXFLAGS Internal Language Support -------------------------. C++ support............. : $msg_cpp Iconv support........... : $msg_iconv PNG support............. : $msg_png Readline support........ : $msg_readline External Language Support -------------------------. TCL support............. : $msg_tcl $TCL_VERSION Java support............ : $msg_java $JAVA_VERSION Python support.......... : $msg_python $PYTHONVER Perl support............ : $msg_perl $PERL_VERSION " if [[ x"$PL_FROM_CVS" = xyes ]]; then echo " .----- NOTICE ------------------------------." echo " | You are using pilot-link from CVS source. |" echo " | |" echo " | This is likely to be unstable, or contain |" echo " | some incomplete features, or just plain |" echo " | not work at all. Use it at your own risk. |" echo " \`-------------------------------------------'" echo "" fi