/ src / configure.ac
configure.ac
   1  #                                               -*- Autoconf -*-
   2  # Process this file with autoconf to produce a configure script.
   3  # 
   4  # Description: configure.ac
   5  #   Autonconf produce a ./configure from this file
   6  #   that's used to discover various programs/dependencies
   7  #   usage: autoconf
   8  #
   9  # Authors: paul_c alex_joni jepler
  10  # License: GPL Version 2
  11  # System: Linux
  12  #    
  13  # Copyright (c) 2004 All rights reserved.
  14  #
  15  # Last change:
  16  # This file is released under GPL, refer to docs/README for details
  17  #
  18  # This file is adapted to replace the old ./configure script
  19  # therefor it includes parts of that script
  20  
  21  ##############################################################################
  22  # Section 1                                                                  #
  23  # Autoconf initialisation                                                    #
  24  ##############################################################################
  25  
  26  AC_PREREQ(2.53)
  27  AC_INIT(LinuxCNC, m4_normalize(esyscmd([cat ../VERSION])), emc-developers@lists.sourceforge.net)
  28  AC_CONFIG_SRCDIR(emc/motion/motion.c)
  29  if test "$srcdir" != "."; then
  30      AC_MSG_ERROR([Building outside of srcdir is not supported])
  31  fi
  32  
  33  AC_PROG_CXX
  34  
  35  AC_LANG_PUSH([C++])
  36  AC_CHECK_HEADER([boost/lockfree/queue.hpp],
  37      [], [RTAPI_APP_CFLAGS="$RTAPI_APP_CFLAGS -I external"])
  38  AC_LANG_POP([C++])
  39  AC_SUBST([RTAPI_APP_CFLAGS])
  40  
  41  m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
  42  # make this optional - it will likely only result in warnings
  43  AX_CXX_COMPILE_STDCXX_11(noext,optional)
  44  
  45  ## _PYTHON_SYSCONFIG(expression, [action-if-succeeded], [action-if-failed])
  46  ##
  47  m4_define([_PYTHON_SYSCONFIG],
  48  [dnl
  49  py_val=`$PYTHON -c "dnl
  50  [import sys; from distutils import sysconfig; sys.stdout.write]dnl
  51  ([sysconfig.]$1 or '')" 2>&AS_MESSAGE_LOG_FD`
  52  AS_IF([test "[$]?" -eq 0 && test "x$py_val" != x], [$2], [$3])[]dnl
  53  ])
  54  
  55  # adapted from AX_BOOST_PYTHON_MURRAYC
  56  # http://ftp.gnome.org/pub/GNOME/sources/glom/1.19/
  57  m4_define([AX_BOOST_PYTHON_EMC],
  58  [
  59  AC_LANG_PUSH([C++])
  60  saved_CPPFLAGS=$CPPFLAGS
  61  saved_LIBS=$LIBS
  62  # Note that this requires PYTHON_CPPFLAGS 
  63  # Note that this expects boost/ to be at some top-level such as /usr/include/
  64  # We couldn't check for anything else anyway because there's no pkg-config file to tell us where it is
  65  CPPFLAGS="$PYTHON_CPPFLAGS $saved_CPPFLAGS"
  66  AC_CACHE_CHECK([whether the Boost::Python headers are available],
  67                 [ac_cv_boost_python],
  68                 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  69  #include <boost/python/object_fwd.hpp>
  70  using namespace boost::python;
  71  ]], [])],
  72      [ac_cv_boost_python=yes], [ac_cv_boost_python=no])])
  73  
  74  AS_IF([test "x$ac_cv_boost_python" = xyes],
  75  [
  76    BOOST_PYTHON_LIBS=
  77    ax_python_lib=boost_python
  78    AC_ARG_WITH([boost-python],
  79      AS_HELP_STRING(
  80          [--with-boost-python],
  81          [Specify the boost python shared library to use. For
  82          instance, --with-boost-python=boost_python-py25. Defaults to
  83          boost-python. If you use this then you should probably set PYTHON
  84          too, to avoid using multiple python versions.]
  85      ),
  86    [if test "x$with_boost_python" != xno; then
  87      ax_python_lib=$with_boost_python
  88      ax_boost_python_lib=boost_python-$with_boost_python
  89    fi])
  90    AC_MSG_CHECKING([for boost::python shared library])
  91    for ax_lib in "$ax_python_lib" "$ax_boost_python_lib" boost_python
  92    do
  93      # Note that this requires LIBPYTHON from configure.ac
  94      LIBS="$saved_LIBS -l$LIBPYTHON -l$ax_lib"
  95      AC_LINK_IFELSE(
  96        [AC_LANG_PROGRAM([[#include <boost/python/object_fwd.hpp>]], [[boost::python::object *test_object;]])],
  97        [BOOST_PYTHON_LIBS="-l$ax_lib"; break])
  98    done
  99    AS_IF([test "x$BOOST_PYTHON_LIBS" != x], [ax_result=$BOOST_PYTHON_LIBS], [ax_result=])
 100    AC_MSG_RESULT([$ax_result])
 101  ])
 102  CPPFLAGS=$saved_CPPFLAGS
 103  LIBS=$saved_LIBS
 104  AC_LANG_POP([C++])
 105  AS_IF([test "x$ac_cv_boost_python" = xyes && test "x$BOOST_PYTHON_LIBS" != x],
 106        [AC_DEFINE([HAVE_BOOST_PYTHON], [1],
 107                   [define if the Boost::Python headers and library are available])],
 108        [AC_MSG_ERROR([[boost::python is required to build $PACKAGE_NAME]])])
 109  AC_SUBST([BOOST_PYTHON_LIBS])
 110  ])
 111  
 112  AC_MSG_CHECKING(build toplevel)
 113  BUILD_TOPLEVEL="$(cd ..; pwd -P)"
 114  AC_MSG_RESULT($BUILD_TOPLEVEL)
 115  
 116  AC_CONFIG_HEADER(config.h)
 117  
 118  # Support some of the standard configure options for directories
 119  AC_PREFIX_DEFAULT(run-in-place)
 120  
 121  AC_MSG_CHECKING(installation prefix)
 122  if test "x$prefix" = "xNONE"; then
 123    RUN_IN_PLACE=yes
 124    AC_MSG_RESULT(run in place)
 125    prefix=${BUILD_TOPLEVEL}
 126  else
 127    RUN_IN_PLACE=no
 128    AC_MSG_RESULT($prefix)
 129  fi
 130  AC_SUBST(AUTODIRS)
 131  
 132  # internationalisation package name:
 133  PACKAGE="linuxcnc"
 134  AC_SUBST([PACKAGE])
 135  
 136  if test -f ../VERSION; then
 137      EMC2VERSION="$(cat ../VERSION)"
 138  else
 139      EMC2VERSION="Undetermined"
 140  fi
 141  AC_SUBST([EMC2VERSION])
 142  
 143  AC_PATH_PROG(GREP, grep)
 144  AC_PATH_PROG(EGREP, egrep)
 145  
 146  #
 147  # check for pkg-config
 148  #
 149  AC_PATH_PROG([PKG_CONFIG], [pkg-config])
 150  if test -z "$PKG_CONFIG"; then
 151    AC_MSG_ERROR([pkg-config is required to build LinuxCNC])
 152  fi
 153  
 154  #
 155  # check for rpc/rpc.h
 156  #
 157  AC_CHECK_HEADER([rpc/rpc.h],[], [
 158    if ! test -z "$PKG_CONFIG libtirpc"; then
 159  
 160      LIBTIRPC_CFLAGS=`pkg-config libtirpc --cflags`
 161      AC_SUBST([LIBTIRPC_CFLAGS])
 162  
 163      LIBTIRPC_LIBS=`pkg-config libtirpc --libs`
 164      AC_SUBST([LIBTIRPC_LIBS])
 165  
 166      CFLAGS+=" `pkg-config libtirpc --cflags` "
 167    fi
 168  
 169    # Update path
 170    AC_CHECK_LIB([tirpc], [get_myaddress], [], [
 171      AC_MSG_ERROR([Didn't find tirpc])
 172    ])
 173  
 174    # Clear the cached check
 175    $as_unset ac_cv_header_rpc_rpc_h
 176    AC_CHECK_HEADER([rpc/rpc.h],[],[
 177      AC_MSG_ERROR([glibc rpc.h missing, please install libtirpc])
 178    ])
 179  ])
 180  
 181  
 182  ##############################################################################
 183  # Section 2                                                                  #
 184  # RealTime checking (either RTAI, or RT-Linux)                               #
 185  # Subsection 2.1 - arguments to ./configure (--with-realtime)                #
 186  # Subsection 2.2 - if none specified above, RTDIR needs to be found by search#
 187  # Subsection 2.3 - RTS(RT-script) is found, it gets queried for values       #
 188  ##############################################################################
 189  
 190  # set up some default values
 191  RTDIR=""
 192  RTAI=""
 193  RTPREFIX=""
 194  KERNELDIR=""
 195  RTFLAGS=""
 196  
 197  NONDISTRIBUTABLE=false
 198  AC_ARG_ENABLE(non-distributable,
 199      AS_HELP_STRING(
 200          [--enable-non-distributable],
 201          [To build LinuxCNC even if a license problem would render the resulting binaries non-distributable under the terms of the LinuxCNC license]),
 202      [
 203          case "$enableval" in
 204          (yes) NONDISTRIBUTABLE=true ;;
 205          esac
 206      ])
 207  
 208  ##############################################################################
 209  # Subsection 2.1                                                             #
 210  # Check for arguments to ./configure                                         #
 211  # accept --with-realtime=<path> from commandline                             #
 212  ##############################################################################
 213  
 214  RTDIR=""
 215  AC_ARG_ENABLE(simulator,
 216      AS_HELP_STRING(
 217          [--enable-simulator],
 218          [Deprecated!  Use --with-realtime=uspace instead.]
 219      ),
 220      [
 221          case "$enableval" in
 222          Y*|y*)
 223              RTS=uspace
 224              AC_MSG_WARN([--enable-simulator is deprecated.  Use --with-realtime=uspace instead.])
 225          ;;
 226          esac
 227      ])
 228  
 229  AC_ARG_WITH(realtime,
 230      AS_HELP_STRING(
 231          [--with-realtime=PATH],
 232          [Path where RTAI is installed, or "uspace" for POSIX userspace.]
 233      ),
 234      [   case "$withval" in
 235  	"" | y | ye | yes | n | no)
 236  	    AC_MSG_ERROR([You must supply a path or "uspace" for --with-realtime.]) ;;
 237  	*)
 238              RTS="$withval" ;;
 239          esac
 240          ])
 241  AC_SUBST([RTS])
 242  
 243  ##############################################################################
 244  # Subsection 2.2                                                             #
 245  # 1. If a RT has been specified by the user it needs to be checked for       #
 246  # validity. That is done by checking default locations for a certain script  #
 247  # (similar to 2)                                                             #
 248  #                                                                            #
 249  # 2. If no RT has been specified explicitely by the user, one has to be      #
 250  # found by search. In order to do that the following code will search for a  #
 251  # RT-specific script:                                                        #
 252  # rtai-config for RTAI 3.x                                                   #
 253  ##############################################################################
 254  
 255  #at this point if RTS is empty, we need to find RT ourselves
 256  AC_MSG_CHECKING([for rtai-config])
 257  if test -z "$RTDIR"; then
 258    DIRS="/usr/realtime-`uname -r` /usr/realtime /usr/realtime* /usr /usr/src/rtai*"
 259  else
 260    DIRS="$RTS"
 261  fi
 262    RTAI_CONFIG=none
 263    for location in $DIRS; do
 264      for subdir in . scripts bin; do
 265      for signature in rtai; do
 266        candidate=$location/$subdir/$signature-config
 267        if test "$RTAI_CONFIG" = "none" -a -x $candidate; then
 268          RTAI_CONFIG=$candidate
 269        fi
 270      done
 271    done
 272  done
 273  
 274  AC_MSG_RESULT([$RTAI_CONFIG])
 275  AC_SUBST([RTAI_CONFIG])
 276  
 277  AC_PATH_PROG([XENOMAI_CONFIG], [xeno-config], [none])
 278  AC_SUBST([XENOMAI_CONFIG])
 279  
 280  AC_MSG_CHECKING([for realtime API(s) to use])
 281  if test "$RTS" = uspace || test -z "$RTS" -a "$RTAI_CONFIG" = "none" ; then
 282    RTS=uspace
 283    if test "$RTAI_CONFIG" = "none" ; then
 284      USPACE_RTAI=
 285      CONFIG_USPACE_RTAI=n
 286      RTAI_LXRT_CFLAGS=
 287      RTAI_LXRT_LDFLAGS=
 288    else
 289      USPACE_RTAI=+lxrt
 290      CONFIG_USPACE_RTAI=y
 291      RTAI_LXRT_CFLAGS=`$RTAI_CONFIG --lxrt-cflags`
 292      RTAI_LXRT_LDFLAGS=`$RTAI_CONFIG --lxrt-ldflags`
 293      AC_DEFINE([USPACE_RTAI], [], [Define if uspace realtime should optionally support RTAI LXRT])
 294    fi
 295    AC_SUBST([CONFIG_USPACE_RTAI])
 296    AC_SUBST([RTAI_LXRT_CFLAGS])
 297    AC_SUBST([RTAI_LXRT_LDFLAGS])
 298  
 299    if test "$XENOMAI_CONFIG" = "none" ; then
 300      USPACE_XENOMAI=
 301      CONFIG_USPACE_XENOMAI=n
 302      XENOMAI_CFLAGS=
 303      XENOMAI_LDFLAGS=
 304    else
 305      USPACE_XENOMAI=+xenomai
 306      CONFIG_USPACE_XENOMAI=y
 307      XENOMAI_CFLAGS=`$XENOMAI_CONFIG --skin posix --cflags`
 308      XENOMAI_LDFLAGS=`$XENOMAI_CONFIG --skin posix --ldflags`
 309      AC_DEFINE([USPACE_XENOMAI], [], [Define if uspace realtime should optionally support Xenomai])
 310    fi
 311    AC_SUBST([CONFIG_USPACE_XENOMAI])
 312    AC_SUBST([XENOMAI_CFLAGS])
 313    AC_SUBST([XENOMAI_LDFLAGS])
 314  
 315    AC_MSG_RESULT([$RTS$USPACE_RTAI$USPACE_XENOMAI])
 316  
 317    AC_MSG_CHECKING([whether to enable userspace PCI access])
 318    AC_ARG_ENABLE(userspace-pci,
 319        AS_HELP_STRING(
 320          [--disable-userspace-pci],
 321          [Disable userspace PCI access (use this if libudev is unavailable).],
 322        ),
 323        [
 324  	case "$enableval" in
 325  	(Y*|y*)
 326  	    BUILD_UDEV=yes ;;
 327  	(*)
 328  	    BUILD_UDEV=no ;;
 329  	esac
 330        ],
 331        [
 332          case "`uname -s`" in
 333          (*BSD*) BUILD_UDEV=no ;;
 334          (*) BUILD_UDEV=yes ;;
 335          esac
 336        ])
 337    AC_MSG_RESULT([$BUILD_UDEV])
 338    AC_SUBST([BUILD_UDEV])
 339  
 340    if test "$BUILD_UDEV" = "yes"; then
 341      AC_MSG_CHECKING([for libudev])
 342      if pkg-config libudev >/dev/null 2>&1; then
 343          LIBUDEV_VER=`pkg-config udev --modversion`
 344          AC_MSG_RESULT(yes - version [$LIBUDEV_VER])
 345          LIBUDEV_CFLAGS=`pkg-config libudev --cflags`
 346          LIBUDEV_LIBS=`pkg-config libudev --libs`
 347      else
 348        AC_MSG_ERROR([libudev-dev not found])
 349      fi
 350    else
 351      LIBUDEV_CFLAGS=-DNO_LIBUDEV
 352    fi
 353    AC_SUBST([LIBUDEV_CFLAGS])
 354    AC_SUBST([LIBUDEV_LIBS])
 355  else
 356    RTS="$RTAI_CONFIG"
 357    AC_MSG_RESULT([$RTS])
 358  fi
 359  
 360  
 361  ##############################################################################
 362  # Subsection 2.3                                                             #
 363  # we have the RT-script now, it's time to query it for some values           #
 364  # it can provide us with default values such as CC, CFLAGS, etc              #
 365  # see each case for more details                                             #
 366  ##############################################################################
 367  
 368  RTARCH=`uname -m | sed s/i.86/i386/`
 369  case $RTS in
 370  */rtai-config)
 371      RTPREFIX=rtai
 372      RTAI_VERSION=$($RTS --version)
 373      RTAI=$(echo $RTAI_VERSION | cut -f 1 -d .)
 374      RTDIR=`$RTS --prefix`
 375      RTDIR=$(cd $RTDIR ; pwd -P )
 376      RTFLAGS=`$RTS --module-cflags`
 377      RTFLAGS="$RTFLAGS -DRTAI=$RTAI"
 378      KERNELDIR=`$RTS --linux-dir`
 379      RTARCH=`$RTS --arch`
 380      ULAPI_CFLAGS=`$RTS --lxrt-cflags`
 381      ULAPI_LDFLAGS=`$RTS --lxrt-ldflags`
 382  ;;
 383  uspace|uspace+*)
 384      RTPREFIX=uspace
 385      RTDIR=$(pwd -P)
 386      ULAPI_CFLAGS=""
 387      RTFLAGS="-DUSPACE"
 388      BUILD_SYS=uspace
 389      MODEXT=.so
 390      MODULE_DIR=${prefix}/lib/linuxcnc/modules
 391      ULAPI_LDFLAGS=""
 392  esac
 393  
 394  if test "$RTS" != uspace; then
 395      AC_MSG_CHECKING([for location of kernel headers])
 396      AC_ARG_WITH(kernel-headers,
 397          AS_HELP_STRING(
 398              [--with-kernel-headers=PATH],
 399              [Location for kernel headers.]
 400          ),
 401  	[
 402  	    KERNELDIR="$withval"
 403  	    AC_MSG_RESULT(using specified value: $KERNELDIR)
 404  	],[
 405  	    AC_MSG_RESULT(using value from RTS: $KERNELDIR)
 406  	])
 407  fi
 408  
 409  AC_SUBST([RTAI])
 410  AC_SUBST([RTPREFIX])
 411  AC_SUBST([KERNELDIR])
 412  AC_SUBST([RTFLAGS])
 413  AC_SUBST([RTDIR])
 414  AC_SUBST([RTARCH])
 415  AC_SUBST([ULAPI_CFLAGS])
 416  AC_SUBST([ULAPI_LDFLAGS])
 417  
 418  case "$RTPREFIX" in
 419  uspace)
 420      AC_DEFINE(RTAPI_USPACE, [], [Realtime system is userspace]) ;;
 421  rtai)
 422      AC_DEFINE(RTAPI_RTAI, [], [Realtime system is RTAI]) ;;
 423  esac
 424  
 425  
 426  EMC2_HOME=`(cd .. ; pwd)`
 427  AC_SUBST([EMC2_HOME])
 428  
 429  AC_DEFINE_UNQUOTED([RTDIR], "$RTDIR", [Directory of the installed realtime system])
 430  
 431  ##############################################################################
 432  # Section 3                                                                  #
 433  # aditional checking                                                         #
 434  # Subsection 3.1 - checking for a CC (we must use the same one used for RT)  #
 435  # Subsection 3.2 - check for the kernel version, with RT patches             #
 436  # Subsection 3.3 - check the moduledir where modules can get installed       #
 437  # Subsection 3.4 - check for GTK                                             #
 438  # Subsection 3.5 - check for utility programs needed to build and run EMC    #
 439  ##############################################################################
 440  
 441  
 442  ##############################################################################
 443  # Subsection 3.1 - checking for a CC (we must use the same one used for RT)  #
 444  ##############################################################################
 445  AC_MSG_CHECKING([for cc version])
 446  
 447  if (test ${RTS##*/} = rtai-config ) ; then
 448    RTSCC=`$RTS --cc`
 449    AC_MSG_RESULT(found $RTSCC in rtai-config)
 450  else
 451    AC_MSG_RESULT(not specified)
 452  fi
 453  
 454  AC_PROG_CC([$RTSCC gcc clang])
 455  AC_PROG_CPP()
 456  
 457  if test -z "$CC"; then
 458    AC_MSG_ERROR([no acceptable cc found])
 459  elif ! test `$CC -dumpversion | cut -d '.' -f 1` -gt 2 ; then
 460    AC_MSG_ERROR([Compilers older than gcc 3.x are no longer supported])
 461  fi
 462  
 463  AC_MSG_CHECKING([for usability of linux/hidraw.h])
 464  AC_TRY_LINK(
 465      [
 466  #include <sys/ioctl.h>
 467  #include <linux/hidraw.h>
 468  long hidiocgrawinfo = HIDIOCGRAWINFO;
 469      ],
 470      [],
 471      [
 472  	HIDRAW_H_USABLE=yes
 473          AC_DEFINE([HIDRAW_H_USABLE], [], [Define to 1 if linux/hidraw.h is usable and defines HIDIOCGRAWINFO])
 474  ],
 475      [HIDRAW_H_USABLE=no])
 476  AC_MSG_RESULT($HIDRAW_H_USABLE)
 477  AC_SUBST([HIDRAW_H_USABLE])
 478  
 479  #
 480  # Check for rpc/rpc.h
 481  #
 482  
 483  AC_MSG_CHECKING([for usability of rpc/rpc.h])
 484  AC_TRY_LINK(
 485      [
 486  #include <rpc/rpc.h>
 487      ],
 488      [
 489  struct sockaddr_in *foo;
 490  get_myaddress(foo);
 491      ],
 492      [
 493          AC_MSG_RESULT(yes)
 494      ],
 495      [
 496          AC_MSG_RESULT(no)
 497          AC_MSG_ERROR([Unable to use rpc.h])
 498      ]
 499  )
 500  
 501  #
 502  # check for libmodbus3
 503  #
 504  
 505  AC_ARG_WITH(
 506      [libmodbus],
 507      AS_HELP_STRING(
 508          [--with-libmodbus],
 509          [Specify whether or not to build the drivers that use libmodbus
 510          (defaults to "yes").]
 511      ),
 512      [WITH_LIBMODBUS=$withval],
 513      [WITH_LIBMODBUS=yes]
 514  )
 515  
 516  AS_IF(
 517      [test "x$WITH_LIBMODBUS" = "xyes"],
 518      [
 519          AC_MSG_CHECKING([for libmodbus3])
 520          if pkg-config libmodbus --atleast-version 3 >/dev/null 2>&1; then
 521              LIBMODBUS_VER=`pkg-config libmodbus --modversion`
 522              AC_MSG_RESULT(yes - version [$LIBMODBUS_VER])
 523              LIBMODBUS_CFLAGS=`pkg-config libmodbus --cflags`
 524              AC_SUBST([LIBMODBUS_CFLAGS])
 525              LIBMODBUS_LIBS=`pkg-config libmodbus --libs`
 526              AC_SUBST([LIBMODBUS_LIBS])
 527              AC_DEFINE(
 528                  [HAVE_LIBMODBUS3],
 529                  [yes],
 530                  [define if the libmodbus3 headers and library are available]
 531              )
 532              AC_SUBST(HAVE_LIBMODBUS3, yes)
 533          else
 534            AC_MSG_RESULT(no)
 535            AC_MSG_ERROR([libmodbus3 not found!
 536  install with "sudo apt-get install libmodbus-dev" or disable with
 537  "configure --without-libmodbus"])
 538          fi
 539      ]
 540  )
 541  
 542  
 543  #
 544  # check for libusb-1.0
 545  #
 546  
 547  AC_ARG_WITH(
 548      [libusb-1.0],
 549      AS_HELP_STRING(
 550          [--with-libusb-1.0],
 551          [Specify whether or not to build the drivers that use libusb-1.0
 552          (defaults to "yes").]
 553      ),
 554      [WITH_LIBUSB10=$withval],
 555      [WITH_LIBUSB10=yes]
 556  )
 557  
 558  AS_IF(
 559      [test "x$WITH_LIBUSB10" = "xyes"],
 560      [
 561          AC_MSG_CHECKING([for libusb-1.0])
 562          if pkg-config libusb-1.0 >/dev/null 2>&1; then
 563              AC_MSG_RESULT(yes)
 564              LIBUSB10_CFLAGS=`pkg-config libusb-1.0 --cflags`
 565              AC_SUBST([LIBUSB10_CFLAGS])
 566              LIBUSB10_LIBS=`pkg-config libusb-1.0 --libs`
 567              AC_SUBST([LIBUSB10_LIBS])
 568              AC_DEFINE(
 569                  [HAVE_LIBUSB10],
 570                  [yes],
 571                  [define if the libusb-1.0 headers and library are available]
 572              )
 573              AC_SUBST(HAVE_LIBUSB10, yes)
 574          else
 575            AC_MSG_RESULT(no)
 576            AC_MSG_ERROR([libusb-1.0 not found!
 577  install with "sudo apt-get install libusb-1.0-0-dev" or disable with
 578  "configure --without-libusb-1.0"])
 579          fi
 580      ]
 581  )
 582  
 583  
 584  ##############################################################################
 585  # Subsection 3.2 - check for the kernel version, with RT patches             #
 586  #----------------------------------------------------------------------------#
 587  # Check the kernel headers to find the uts-kernel version.                   #
 588  # This should be a more reliable way of determining the kernel that          #
 589  # is being used to compile against - `uname -r` only returns the             #
 590  # running kernel version which is may not be the one the code is             #
 591  # compiled against.                                                          #
 592  ##############################################################################
 593  
 594  if test $RTS '!=' uspace; then
 595  AC_MSG_CHECKING([for kernel version string])
 596  
 597  if test -e $KERNELDIR/include/linux/utsrelease.h; then
 598      VERSION_FILE=$KERNELDIR/include/linux/utsrelease.h
 599  elif test -e $KERNELDIR/include/generated/utsrelease.h; then
 600      VERSION_FILE=$KERNELDIR/include/generated/utsrelease.h
 601  else
 602      VERSION_FILE=$KERNELDIR/include/linux/version.h
 603  fi
 604  KERNEL_VERS=`$CC -E -dM ${VERSION_FILE} | grep UTS | cut -s -d '"' -f 2`
 605  
 606  if test -z "$KERNEL_VERS"; then 
 607      AC_MSG_ERROR(Kernel version string not found)
 608  fi
 609  
 610  AC_MSG_RESULT([$KERNEL_VERS])
 611  AC_SUBST([KERNEL_VERS])
 612  AC_DEFINE_UNQUOTED([RTAPI_KERNEL_VERSION], "$KERNEL_VERS", [Required kernel version])
 613  
 614  # Do a quick test for module extension..
 615  AC_MSG_CHECKING([for kernel module extension])
 616  MODEXT=`$RTS --module-ext 2>/dev/null` || MODEXT=".o"
 617  if test "x" = "x$MODEXT"; then
 618      MODEXT=".o"
 619  fi
 620  AC_MSG_RESULT([$MODEXT])
 621  
 622  # This check should see if kbuild is or isn't used
 623  AC_MSG_CHECKING([kernel build system])
 624  # FIXME FIXME FIXME
 625  # right now it will assume based on the kernel module extension
 626  EXT_RTFLAGS=""
 627  BUILD_SYS="normal"
 628  
 629  if test "x$MODEXT" = "x.ko" ; then
 630      BUILD_SYS="kbuild"
 631  else
 632      EXT_RTFLAGS="-DEXPORT_SYMTAB"
 633  fi
 634  
 635  AC_ARG_WITH(kbuild,
 636      AS_HELP_STRING(
 637          [--with-kbuild],
 638          [Specify if your kernel uses kbuild or not.]
 639      ),
 640      [
 641          case "$withval" in
 642          "" | y | ye | yes )
 643  	    BUILD_SYS="kbuild"
 644            ;;
 645          n | no )
 646  	    BUILD_SYS="normal"
 647            ;;
 648          esac
 649      ])
 650  AC_MSG_RESULT([$BUILD_SYS])
 651  fi
 652  AC_SUBST([MODEXT])
 653  AC_DEFINE_UNQUOTED([MODULE_EXT], "$MODEXT", [Extension for realtime modules])
 654  AC_SUBST([BUILD_SYS])
 655  AC_SUBST([EXT_RTFLAGS])
 656  
 657  ##############################################################################
 658  # Subsection 3.3 - check the moduledir where modules can get installed       #
 659  #                                                                            #
 660  # Provides the user the possibility to specify (--with-module-dir=<path>)    #
 661  # If not specified default inside /lib/modules/${KERNEL_VERS}/               #
 662  # to the location where a RT-module gets found (mbuff.o or rtai_shed.o)     #
 663  # (maybe the default should be /lib/modules/$KERNEL_VERS/extra if it exists? #
 664  ##############################################################################
 665  
 666  # Create a module-dir option, similar to rtai's...
 667  AC_MSG_CHECKING([for module installation directory])
 668  
 669  AC_ARG_WITH(module-dir,
 670      AS_HELP_STRING(
 671          [--with-module-dir=PATH],
 672          [Installation directory for kernel modules.]
 673      ),
 674      [
 675          case "$withval" in
 676          "" | y | ye | yes | n | no)
 677              AC_MSG_ERROR([You must supply a path for --with-module-dir.])
 678            ;;
 679          esac
 680          MODULE_DIR="$withval"
 681      ])
 682  
 683  
 684  # if not specified, ask the realtime config script where the directory is
 685  # if the config script returns an error, set MODULE_DIR to nothing
 686  if test "x" = "x$MODULE_DIR" ; then
 687    MODULE_DIR=`$RTS --module-dir 2>/dev/null`
 688    if ! test -d $MODULE_DIR ; then
 689      AC_MSG_ERROR([$RTS --module-dir did not specify an existing directory.  You must use specify it using --with-module-dir=...])
 690    fi
 691  fi
 692      
 693  if test "$RUN_IN_PLACE" = "yes"; then
 694      RIP_MODULE_DIR="${BUILD_TOPLEVEL}/rtlib"
 695      AC_MSG_RESULT([configuring for run-in-place])
 696      prefix=${BUILD_TOPLEVEL}
 697      DEFAULT_NMLFILE=${prefix}/configs/common/linuxcnc.nml
 698      DEFAULT_TOOLTABLE=${prefix}/configs/sim/sim.tbl
 699      AC_MSG_RESULT([$RIP_MODULE_DIR])
 700  else
 701      RUN_IN_PLACE=no
 702      EMC2_HOME=$prefix
 703      DEFAULT_NMLFILE=${prefix}/share/linuxcnc/linuxcnc.nml
 704      AC_MSG_RESULT([$MODULE_DIR])
 705  fi
 706  
 707  AC_SUBST([MODULE_DIR])
 708  AC_SUBST([RIP_MODULE_DIR])
 709  AC_SUBST([RUN_IN_PLACE])
 710  AC_SUBST([DEFAULT_NMLFILE])
 711  AC_DEFINE_UNQUOTED([EMC2_DEFAULT_NMLFILE], "$DEFAULT_NMLFILE", [Default nml file])
 712  AC_DEFINE_UNQUOTED([EMC2_DEFAULT_TOOLTABLE], "$DEFAULT_TOOLTABLE", [Default nml file])
 713  
 714  ##############################################################################
 715  # Subsection 3.4 - define default dirs, these get used in a lot of places    #
 716  # we decide based on RIP or install where stuff goes                         #
 717  ##############################################################################
 718  
 719  fe () {
 720      # Fully expand argument.  Example:
 721      # ${datadir} -> ${datarootdir} -> ${prefix}/share -> /usr/local
 722      case "$1" in
 723      *\$*) eval fe \""$1"\" ;;
 724      *) echo "$1" ;;
 725      esac
 726  }
 727  
 728  if test "xyes" = "x$RUN_IN_PLACE"; then
 729      EMC2_LATENCY_SCRIPT=$EMC2_HOME/scripts/latency-test
 730      EMC2_SCRIPT=$EMC2_HOME/scripts/linuxcnc
 731      EMC2_SUFFIX=" (run-in-place)"
 732      EMC2_ICON=$EMC2_HOME/linuxcncicon.png
 733      EMC2_BIN_DIR=$EMC2_HOME/bin
 734      EMC2_TCL_DIR=$EMC2_HOME/tcl
 735      EMC2_TCL_LIB_DIR=$EMC2_HOME/tcl
 736      EMC2_LANG_DIR=$EMC2_HOME/src/objects
 737      EMC2_PO_DIR=$EMC2_HOME/share/locale
 738      EMC2_HELP_DIR=$EMC2_HOME/docs/help
 739      EMC2_RTLIB_DIR=$EMC2_HOME/rtlib
 740      LINUXCNC_CONFIG_PATH="~/linuxcnc/configs:$EMC2_HOME/configs"
 741      EMC2_NCFILES_DIR=$EMC2_HOME/nc_files
 742      REALTIME=$EMC2_HOME/scripts/realtime
 743      EMC2_IMAGE_DIR=$EMC2_HOME
 744      HALLIB_DIR=$EMC2_HOME/lib/hallib
 745  else
 746      EMC2_HOME=${prefix}
 747      EMC2_BIN_DIR=${prefix}/bin
 748      EMC2_LATENCY_SCRIPT=$EMC2_BIN_DIR/latency-test
 749      EMC2_SCRIPT=$EMC2_BIN_DIR/linuxcnc
 750      EMC2_SUFFIX=""
 751      EMC2_ICON=linuxcncicon
 752      EMC2_TCL_DIR=${prefix}/lib/tcltk/linuxcnc
 753      EMC2_TCL_LIB_DIR=${prefix}/lib/tcltk/linuxcnc
 754      EMC2_LANG_DIR=${prefix}/lib/tcltk/linuxcnc/msgs
 755      EMC2_PO_DIR=${prefix}/share/locale
 756      EMC2_HELP_DIR=${prefix}/share/doc/linuxcnc
 757      case $MODULE_DIR in
 758          */linuxcnc*) EMC2_RTLIB_DIR=$MODULE_DIR ;;
 759  	*) EMC2_RTLIB_DIR=$MODULE_DIR/linuxcnc
 760      esac
 761      LINUXCNC_CONFIG_PATH="~/linuxcnc/configs:/usr/local/etc/linuxcnc/configs:"$(eval echo $EMC2_HELP_DIR)"/examples/sample-configs"
 762      EMC2_NCFILES_DIR=${prefix}/share/linuxcnc/ncfiles
 763      REALTIME=/etc/init.d/realtime
 764      EMC2_IMAGE_DIR=$(fe "$datadir")/linuxcnc
 765      HALLIB_DIR=${prefix}/share/linuxcnc/hallib
 766  fi
 767  
 768  AC_DEFINE_UNQUOTED([EMC2_HOME], "$EMC2_HOME", [Prefix or RIP directory])
 769  AC_DEFINE_UNQUOTED([EMC2_BIN_DIR], "$EMC2_BIN_DIR", [Directory for binaries])
 770  AC_DEFINE_UNQUOTED([EMC2_TCL_DIR], "$EMC2_TCL_DIR", [Directory for tcl scripts])
 771  AC_DEFINE_UNQUOTED([EMC2_HELP_DIR], "$EMC2_HELP_DIR", [Directory for help files])
 772  AC_DEFINE_UNQUOTED([EMC2_RTLIB_DIR], "$EMC2_RTLIB_DIR", [Directory of realtime system])
 773  AC_DEFINE_UNQUOTED([EMC2_LANG_DIR], "$EMC2_LANG_DIR", [Directory for tcl translation files])
 774  AC_DEFINE_UNQUOTED([EMC2_PO_DIR], "$EMC2_PO_DIR", [Directory for po/mo translation files])
 775  AC_DEFINE_UNQUOTED([EMC2_CONFIG_DIR], "$EMC2_CONFIG_DIR", [Directory for configuration files])
 776  AC_DEFINE_UNQUOTED([EMC2_NCFILES_DIR], "$EMC2_NCFILES_DIR", [Directory for nc files])
 777  AC_DEFINE_UNQUOTED([EMC2_IMAGE_DIR], "$EMC2_IMAGE_DIR", [Directory for images])
 778  
 779  AC_SUBST([EMC2_BIN_DIR])
 780  AC_SUBST([EMC2_TCL_DIR])
 781  AC_SUBST([EMC2_TCL_LIB_DIR])
 782  AC_SUBST([EMC2_HELP_DIR])
 783  AC_SUBST([EMC2_RTLIB_DIR])
 784  AC_SUBST([EMC2_LANG_DIR])
 785  AC_SUBST([LINUXCNC_CONFIG_PATH])
 786  AC_SUBST([EMC2_NCFILES_DIR])
 787  AC_SUBST([REALTIME])
 788  AC_SUBST([EMC2_IMAGE_DIR])
 789  AC_SUBST([EMC2_SCRIPT])
 790  AC_SUBST([EMC2_LATENCY_SCRIPT])
 791  AC_SUBST([EMC2_SUFFIX])
 792  AC_SUBST([EMC2_ICON])
 793  AC_SUBST([HALLIB_DIR])
 794  
 795  # coordinate installed auxiliary applications (not RIP or deb dependent):
 796  LINUXCNC_AUX_GLADEVCP=/usr/share/linuxcnc/aux_gladevcp
 797  LINUXCNC_AUX_EXAMPLES=/usr/share/linuxcnc/aux_examples
 798  AC_SUBST([LINUXCNC_AUX_GLADEVCP])
 799  AC_SUBST([LINUXCNC_AUX_EXAMPLES])
 800  
 801  ##############################################################################
 802  # Subsection 3.5 - check for GTK                                             #
 803  # FIXME: allow it to be enabled or disabled command line                     #
 804  ##############################################################################
 805  
 806  AC_MSG_CHECKING([for glib])
 807  if pkg-config glib-2.0 >/dev/null 2>&1; then
 808    GLIB_VER=`pkg-config glib-2.0 --modversion`
 809    AC_MSG_RESULT(yes - $GLIB_VER)
 810    GLIB_CFLAGS=`pkg-config glib-2.0 --cflags`
 811    GLIB_LIBS=`pkg-config glib-2.0 --libs`
 812  else
 813    AC_MSG_ERROR(no -- required until somebody makes glib optional)
 814  fi
 815  
 816  
 817  AC_ARG_ENABLE(gtk,
 818      AS_HELP_STRING(
 819          [--disable-gtk],
 820          [Disable the parts of LinuxCNC that depend on GTK.]
 821      ),
 822      [
 823  	case "$enableval" in
 824  	Y*|y*)
 825  	    BUILD_GTK=yes ;;
 826  	*)
 827  	    BUILD_GTK=no ;;
 828  	esac
 829      ],
 830      [BUILD_GTK=yes])
 831  
 832  if test "$BUILD_GTK" = "yes"; then
 833    AC_MSG_CHECKING([for GTK 2.4.0 or above])
 834    if pkg-config gtk+-2.0 --atleast-version 2.4.0 >/dev/null 2>&1; then
 835      GTK_VER=`pkg-config gtk+-2.0 --modversion`
 836      AC_MSG_RESULT(yes - $GTK_VER)
 837      GTK_CFLAGS=`pkg-config gtk+-2.0 --cflags`
 838      GTK_LIBS=`pkg-config gtk+-2.0 --libs`
 839      AC_MSG_CHECKING(for libgnomeprintui-2.2)
 840      if pkg-config --exists libgnomeprintui-2.2; then
 841        AC_MSG_RESULT(yes)
 842        GTK_CFLAGS="$GTK_CFLAGS `pkg-config --cflags libgnomeprintui-2.2`"
 843        GTK_LIBS="$GTK_LIBS `pkg-config --libs libgnomeprintui-2.2`"
 844        HAVE_GNOMEPRINT=yes
 845      else
 846        AC_MSG_RESULT(no -- printing from classicladder will not be possible)
 847        HAVE_GNOMEPRINT= 
 848      fi
 849    else
 850      AC_MSG_RESULT(no)
 851      AC_MSG_ERROR([GTK2 missing.  Install it or specify --disable-gtk to skip the parts of LinuxCNC that depend on GTK])
 852    fi
 853  fi
 854  
 855  AC_SUBST(HAVE_GNOMEPRINT)
 856  AC_SUBST(GTK_VER)
 857  AC_SUBST(GTK_LIBS)
 858  AC_SUBST(GTK_CFLAGS)
 859  AC_SUBST(GLIB_LIBS)
 860  AC_SUBST(GLIB_CFLAGS)
 861  
 862  ##############################################################################
 863  # Subsection 3.6 - check for utility programs needed to build and run EMC    #
 864  #                                                                            #
 865  # Check for all the utility programs we need to build and install emc        #
 866  # as well as those we use in the emc scripts...                              #
 867  ##############################################################################
 868  
 869  SPATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
 870  AC_PROG_MAKE_SET
 871  AC_PROG_RANLIB
 872  AC_PATH_PROG(AR,ar)
 873  AC_PATH_PROG(INSTALL, install)
 874  
 875  AC_PATH_PROG(SED, sed, "none")
 876  if test $SED = "none"
 877  then
 878      AC_MSG_ERROR([sed not found])
 879  fi
 880  
 881  AC_PATH_PROG(PS, ps, "none")
 882  if test $PS = "none"
 883  then
 884      AC_MSG_ERROR([ps not found])
 885  fi
 886  
 887  AC_PATH_PROG(KILL, kill, "none")
 888  if test $KILL = "none"
 889  then
 890      AC_MSG_ERROR([kill not found])
 891  fi
 892  
 893  AC_PATH_PROG(WHOAMI, whoami, "none")
 894  if test $WHOAMI = "none"
 895  then
 896      AC_MSG_ERROR([whoami not found])
 897  fi
 898  
 899  AC_PATH_PROG(AWK, awk, "none")
 900  if test $AWK = "none"
 901  then
 902      AC_MSG_ERROR([awk not found])
 903  fi
 904  
 905  AC_PATH_PROG(INSMOD, insmod, "none", $SPATH)
 906  if test $INSMOD = "none"
 907  then
 908      AC_MSG_ERROR([insmod not found])
 909  fi
 910  
 911  AC_PATH_PROG(RMMOD, rmmod, "none", $SPATH)
 912  if test $RMMOD = "none"
 913  then
 914      AC_MSG_ERROR([rmmod not found])
 915  fi
 916  
 917  AC_PATH_PROG(LSMOD, lsmod, "none", $SPATH)
 918  if test $LSMOD = "none"
 919  then
 920      AC_MSG_ERROR([lsmod not found])
 921  fi
 922  
 923  AC_PATH_PROG(PIDOF, pidof, "none", $SPATH)
 924  if test $PIDOF = "none"
 925  then
 926      AC_MSG_ERROR([pidof not found])
 927  fi
 928  
 929  AC_PATH_PROG(IPCS, ipcs, "none")
 930  if test $IPCS = "none"
 931  then
 932      AC_MSG_ERROR([ipcs not found])
 933  fi
 934  
 935  AC_PATH_PROG(FUSER, fuser, "none", $SPATH)
 936  if test $FUSER = "none"
 937  then
 938      AC_MSG_ERROR([fuser not found])
 939  fi
 940  
 941  AC_PATH_PROGS(YAPPS, yapps yapps2, "none", $SPATH)
 942  if test $YAPPS = "none"
 943  then
 944      AC_MSG_ERROR([yapps/yapps2 and not found])
 945  fi
 946  AC_SUBST(YAPPS)
 947  
 948  # MANDB empty is handled in doc/Submakefile
 949  AC_PATH_PROG(MANDB, mandb, "")
 950  
 951  AC_PATH_PROG(INTLTOOL_EXTRACT, intltool-extract, "none", $SPATH)
 952  if test $INTLTOOL_EXTRACT = "none"
 953  then
 954      AC_MSG_ERROR([intltool-extract not found])
 955  fi
 956  
 957  AC_ARG_WITH(rmmod,
 958      AS_HELP_STRING(
 959          [--with-rmmod=PATH],
 960          [Location of the rmmod program to use.]
 961      ),
 962      [
 963  	case "$withval" in
 964  	"" | y | ye | yes)
 965  	    AC_MSG_ERROR([You must supply an argument to --with-rmmod.])
 966  	  ;;
 967  	n | no | none)
 968  	    RMMOD=""
 969  	  ;;
 970  	*)
 971  	    RMMOD="$withval"
 972  	esac
 973      ],
 974      [
 975              RMMOD="$EMC2_BIN_DIR/linuxcnc_module_helper remove"
 976      ])
 977  
 978  AC_ARG_WITH(insmod,
 979      AS_HELP_STRING(
 980          [--with-insmod=PATH],
 981          [Location of the insmod program to use.]
 982      ),
 983      [
 984  	case "$withval" in
 985  	"" | y | ye | yes)
 986  	    AC_MSG_ERROR([You must supply an argument to --with-insmod.])
 987  	  ;;
 988  	n | no | none)
 989  	    INSMOD=""
 990  	  ;;
 991  	*)
 992  	    INSMOD="$withval"
 993  	esac
 994      ],
 995      [
 996              INSMOD="$EMC2_BIN_DIR/linuxcnc_module_helper insert"
 997      ])
 998  
 999  AC_PATH_PROGS(YAPPS, [yapps yapps2])
1000  if test -z "$YAPPS"; then
1001    AC_MSG_ERROR([yapps is required to build LinuxCNC
1002  install with "sudo apt-get install yapps2"])
1003  fi
1004  AC_SUBST(YAPPS)
1005  
1006  ##############################################################################
1007  # Subsection 3.7 - check for programs needed to build documentation          #
1008  #                                                                            #
1009  # Check for LyX and other programs we need to build and install docs.        #
1010  # (Optional, if not present, just don't build the docs.)                     #
1011  ##############################################################################
1012  
1013  AC_ARG_WITH(python,
1014      AS_HELP_STRING(
1015          [--with-python=PATH],
1016          [Specify the Python interpreter.]
1017      ),
1018      [
1019          PYTHON=$withval
1020      ],[
1021          PYTHON=python
1022      ])
1023  AC_PATH_PROG(PYTHON,$PYTHON,"none")
1024  if test $PYTHON = "none"
1025  then
1026      AC_MSG_ERROR([python not found])
1027  fi
1028  
1029  AC_MSG_CHECKING([whether to build documentation])
1030  AC_ARG_ENABLE(build-documentation,
1031      AS_HELP_STRING(
1032          [--enable-build-documentation[=FORMAT]],
1033          [Build documentation.  FORMAT may be "pdf" or "html" if only one format is desired.]
1034      ),
1035      [
1036          case "$enableval" in
1037          Y*|y*|html,pdf|pdf,html)
1038              BUILD_DOCS=yes
1039              BUILD_DOCS_PDF=yes
1040              BUILD_DOCS_HTML=yes
1041              AC_MSG_RESULT([PDF and HTML requested])
1042          ;;
1043          html)
1044              BUILD_DOCS=yes
1045              BUILD_DOCS_PDF=no
1046              BUILD_DOCS_HTML=yes
1047              AC_MSG_RESULT([HTML requested])
1048  	;;
1049          pdf)
1050              BUILD_DOCS=yes
1051              BUILD_DOCS_PDF=yes
1052              BUILD_DOCS_HTML=no
1053              AC_MSG_RESULT([PDF requested])
1054  	;;
1055          *)
1056              BUILD_DOCS=no
1057              AC_MSG_RESULT([no])
1058          ;;
1059      esac
1060      ],
1061      [
1062          BUILD_DOCS=no
1063          AC_MSG_RESULT([no])
1064      ])
1065  
1066  # Programs required for building all documentation
1067  if ( test "$BUILD_DOCS" = "yes" ) ; then
1068      if ( test "none" = "$PYTHON" ) ; then
1069          AC_MSG_ERROR([no python, documentation cannot be built])
1070      fi
1071  
1072      AC_PATH_PROG(ASCIIDOC,asciidoc,"none")
1073      if ( test "none" = "$ASCIIDOC" ) ; then
1074  	AC_MSG_ERROR([no AsciiDoc, documentation cannot be built])
1075      fi
1076  
1077      AC_PATH_PROG(A2X,a2x,"none")
1078      if ( test "none" = "$A2X" ) ; then
1079  	AC_MSG_ERROR([no a2x, documentation cannot be built])
1080      fi
1081  
1082      AC_MSG_CHECKING([whether to specify latex.encoding])
1083      temp_asciidoc=`tempfile --suffix=.txt`
1084      cat > $temp_asciidoc <<EOF
1085  :lang: fr
1086  :ascii-ids:
1087  
1088  ....
1089  umläut nuß
1090  ....
1091  EOF
1092      if $A2X --dblatex-opts "-P latex.encoding=utf8" $temp_asciidoc > /dev/null 2>&1;
1093      then
1094          A2X_LATEX_ENCODING="-P latex.encoding=utf8"
1095          AC_MSG_RESULT(yes)
1096      else
1097          A2X_LATEX_ENCODING=""
1098          AC_MSG_RESULT(no)
1099      fi
1100      AC_SUBST(A2X_LATEX_ENCODING)
1101      rm -f $temp_asciidoc ${temp_asciidoc%.txt}.pdf
1102  
1103      AC_PATH_PROG(DBLATEX,dblatex,"none")
1104      if ( test "none" = "$DBLATEX" ) ; then
1105  	AC_MSG_ERROR([no dblatex, documentation cannot be built])
1106      fi
1107  
1108      AC_MSG_CHECKING([dblatex version])
1109      set -- `dblatex --version`; DBLATEX_VER=$3
1110      set -- `echo $DBLATEX_VER | sed 's/[[.-]]/ /g'`
1111  
1112      if test $1 -eq 0 -a \( $2 -lt 2 -o \( $2 -eq 2 -a ${3:-0} -lt 12 \) \); then
1113          AC_MSG_ERROR([dblatex version $DBLATEX_VER less than 0.2.12.
1114  Documentation cannot be built.])
1115      fi
1116      AC_MSG_RESULT([$DBLATEX_VER])
1117  
1118  
1119      AC_PATH_PROG(SOURCE_HIGHLIGHT,source-highlight,"none")
1120      if ( test "none" = "$SOURCE_HIGHLIGHT" ) ; then
1121  	AC_MSG_ERROR([no source-highlight, documentation cannot be built])
1122      fi
1123  
1124  
1125      AC_PATH_PROG(CONVERT,convert,"none")
1126      if ( test "none" = "$CONVERT" ) ; then
1127  	AC_MSG_ERROR([no convert, documentation cannot be built])
1128      fi
1129  
1130      AC_PATH_PROG(GS,gs,"none")
1131      if ( test "none" = "$GS" ) ; then
1132  	AC_MSG_ERROR([no gs, documentation cannot be built])
1133      fi
1134  fi
1135  
1136  # Programs required only for building the PDF documentation
1137  if ( test "$BUILD_DOCS_PDF" = "yes" ) ; then
1138      AC_PATH_PROG(DBLATEX,dblatex,"none")
1139      if ( test "none" = "$DBLATEX" ) ; then
1140  	AC_MSG_ERROR([no dblatex, PDF documentation cannot be built])
1141      fi
1142  
1143      AC_PATH_PROG(PDFLATEX,pdflatex,"none")
1144      if ( test "none" = "$PDFLATEX" ) ; then
1145  	AC_MSG_ERROR([no pdflatex, PDF documentation cannot be built])
1146      fi
1147  fi
1148  
1149  # Programs required only for building the HTML documentation
1150  if ( test "$BUILD_DOCS_HTML" = "yes" ) ; then
1151      AC_PATH_PROG(XSLTPROC,xsltproc,"none")
1152      if ( test "none" = "$XSLTPROC" ) ; then
1153  	AC_MSG_ERROR([no xsltproc, HTML documentation cannot be built])
1154      fi
1155  
1156      AC_PATH_PROG(DVIPNG,dvipng,"none")
1157      if ( test "none" = "$DVIPNG" ) ; then
1158  	AC_MSG_ERROR([no dvipng, HTML documentation cannot be built])
1159      fi
1160  
1161      AC_MSG_CHECKING([for HTML support in groff])
1162      if ! groff -Thtml < /dev/null > /dev/null 2>&1 ; then
1163          AC_MSG_ERROR([no groff -Thtml, HTML documentation cannot be built])
1164      else
1165          AC_MSG_RESULT(yes)
1166      fi
1167  
1168      AC_PATH_PROG(CHECKLINK,checklink,"none")
1169      if ( test "none" = "$CHECKLINK" ) ; then
1170  	AC_MSG_ERROR([no checklink, HTML documentation cannot be built
1171  install with "sudo apt-get install w3c-linkchecker"])
1172      fi
1173  fi
1174  AC_SUBST(BUILD_DOCS)
1175  AC_SUBST(BUILD_DOCS_PDF)
1176  AC_SUBST(BUILD_DOCS_HTML)
1177  
1178  if test "$RTS" '!=' uspace
1179  then
1180  for m in adeos rtai_hal rtai_ksched rtai_sched rtai_fifos rtai_sem rtai_math \
1181  ; do
1182      AC_MSG_CHECKING([for $m])
1183      TMP=$(find $MODULE_DIR -name $m$MODEXT 2>/dev/null)
1184      if test -z "$TMP"; then
1185          TMP=$(find /lib/modules/$KERNEL_VERS -name $m$MODEXT)
1186      fi
1187      eval MODPATH_$m=${TMP/$KERNEL_VERS/\\\$\\\(uname\\\ -r\\\)}
1188      AC_MSG_RESULT([${TMP:-not found}])
1189  done
1190  
1191  AC_SUBST(MODPATH_adeos)
1192  AC_SUBST(MODPATH_rtai_hal)
1193  AC_SUBST(MODPATH_rtai_ksched)
1194  AC_SUBST(MODPATH_rtai_sched)
1195  AC_SUBST(MODPATH_rtai_fifos)
1196  AC_SUBST(MODPATH_rtai_sem)
1197  AC_SUBST(MODPATH_rtai_math)
1198  fi
1199  
1200  # Checks for header files.
1201  
1202  ##############################################################################
1203  # Section 4.1 - Important headers, functions and global defines.             #
1204  #                                                                            #
1205  ##############################################################################
1206  
1207  # This section gets inserted in to config.h.in when autoheader is run.
1208  # Global and common defines should be here rather than duplicated in
1209  # multiple places. Keep screwball constructs out of this, and it can
1210  # be used in both kernel space and user space.
1211  AH_TOP([/********************************************************************
1212  * Description: config.h
1213  *
1214  *	Common defines used in many emc2 source files.
1215  *       To add to this file, edit Section 4.1 in configure.ac
1216  *       and then run autoheader.
1217  *
1218  * Author: Autogenerated by autoheader
1219  * License: LGPL Version 2
1220  * System: Linux
1221  *    
1222  * Copyright (c) 2004 All rights reserved.
1223  ********************************************************************/
1224  #ifndef EMC2_CONFIG_H
1225  #define EMC2_CONFIG_H
1226  
1227  /* LINELEN is used throughout for buffer sizes, length of file name strings,
1228     etc. Let's just have one instead of a multitude of defines all the same. */
1229  #define LINELEN 255
1230  /* Used in a number of places for sprintf() buffers. */
1231  #define BUFFERLEN 80
1232  
1233  #define MM_PER_INCH 25.4
1234  #define INCH_PER_MM (1.0/25.4)
1235  ])
1236  
1237  AC_CHECK_HEADERS([sys/io.h])
1238  
1239  AH_VERBATIM([_GNU_SOURCE],
1240  [/* Enable GNU extensions on systems that have them.  */
1241  #ifndef _GNU_SOURCE
1242  # define _GNU_SOURCE
1243  #endif
1244  ])
1245  
1246  AC_HEADER_STDC
1247  AC_HEADER_SYS_WAIT
1248  AC_CHECK_FUNCS(semtimedop)
1249  LIBS_hold=$LIBS
1250  LIBS="$LIBS -lm"
1251  
1252  AC_MSG_CHECKING([for sincos function])
1253  sincos_ok=yes
1254  AC_TRY_LINK(
1255      [double a, b;],
1256      [sincos(1.0, &a, &b);],
1257      AC_DEFINE(
1258          [HAVE_SINCOS],
1259          1,
1260          [Define to 1 if sincos is available.]
1261      ),
1262      [sincos_ok=no]
1263  )
1264  AC_MSG_RESULT([$sincos_ok])
1265  
1266  AC_CHECK_FUNCS(__sincos)
1267  LIBS=$LIBS_hold
1268  
1269  AC_MSG_CHECKING([for optreset])
1270  AC_TRY_LINK(
1271      [
1272  #include <unistd.h>
1273  extern int optreset;
1274      ],
1275      [ optreset = 1; ],
1276      [
1277  	HAVE_OPTRESET=yes
1278          AC_DEFINE([HAVE_OPTRESET], [], [Define to 1 if getopt has the BSD 'optreset' extension])
1279  ],
1280      [HAVE_OPTRESET=no])
1281  AC_MSG_RESULT($HAVE_OPTRESET)
1282  AC_SUBST([HAVE_OPTRESET])
1283  
1284  
1285  
1286  LIBS_hold=$LIBS
1287  LIBS=
1288  AC_SEARCH_LIBS(dlopen, [c dl], [
1289      case "$LIBS" in
1290      (-lc) LIBDL= ;;
1291      (*)   LIBDL="$LIBS"
1292      esac
1293  
1294      AC_DEFINE([LIBDL], [$LIBDL], [Define to the library that dlopen comes from, if it is not a part of libc])
1295  ], [AC_MSG_ERROR([not found])])
1296  AC_SUBST([LIBDL])
1297  LIBS=$LIBS_hold
1298  
1299  AC_SEARCH_LIBS(clock_nanosleep, [rt], [
1300      AC_DEFINE([HAVE_CLOCK_NANOSLEEP], 1,
1301          [Define to 1 if clock_nanosleep is available (in -lc or -lrt)])
1302  ])
1303  
1304  AH_BOTTOM(#endif
1305  )
1306  
1307  ##############################################################################
1308  # Section 5 - Check for tcl/tk support                                       #
1309  #                                                                            #
1310  # Test for tcl/tk headers fails if they are not in /usr/include              #
1311  # so testing is done by finding tclConfig.sh and tkConfig.sh                 #
1312  # if the search fails the traditional check is done                          #
1313  ##############################################################################
1314  AC_MSG_CHECKING([for tcl])
1315  
1316  AC_ARG_WITH(tclConfig,
1317      AS_HELP_STRING(
1318          [--with-tclConfig=PATH],
1319          [Specify the path to tclConfig.]
1320      ),
1321      [
1322          TCLCONFIG=$withval
1323      ],[
1324          TCLCONFIG=
1325      ])
1326  
1327  # if not specified, search for tclConfig.sh
1328  if (test "x$TCLCONFIG" = "x"); then
1329      TCLCONFIG=$(find /usr/lib* -maxdepth 2 -name tclConfig.sh | sort -r | head -n1)
1330      if (test "x$TCLCONFIG" = "x"); then
1331  	TCLCONFIG=$(find /usr/local/lib* -maxdepth 2 -name tclConfig.sh | sort -r | head -n1)
1332      fi
1333  fi
1334  
1335  if (test "x$TCLCONFIG" = "x"); then
1336     AC_MSG_RESULT([tclConfig.sh not found, trying tcl.h and libs.
1337  		  If it doesn't work try running ./configure --with-tclConfig=<path to tclConfig.sh>])
1338     AC_CHECK_HEADERS([tcl.h])
1339     AC_SEARCH_LIBS(Tcl_Init,[tcl tcl8.1 tcl8.2 tcl8.3 tcl8.4 tcl8.5],[],[AC_MSG_ERROR([tcl lib not found])])
1340  else
1341  # tclConfig.sh found,
1342  # extracting vars
1343     AC_MSG_RESULT([$TCLCONFIG found])
1344     . "$TCLCONFIG"
1345     TCL_CFLAGS="$TCL_INCLUDE_SPEC -DUSE_TCL_STUBS"
1346     TCL_LIBS="$TCL_STUB_LIB_SPEC"
1347  fi
1348  
1349  AC_MSG_CHECKING([for tk])
1350  
1351  AC_ARG_WITH(tkConfig,
1352      AS_HELP_STRING(
1353          [--with-tkConfig=PATH],
1354          [Specify the path to tkConfig.]
1355      ),
1356      [
1357          TKCONFIG=$withval
1358      ],[
1359          TKCONFIG=
1360      ])
1361  
1362  # if not specified, search for tclConfig.sh
1363  if test -z "$TKCONFIG"; then
1364      TKCONFIG=$(dirname $TCLCONFIG)/tkConfig.sh
1365      if ! test -f $TKCONFIG; then unset TKCONFIG; fi
1366  fi
1367  if (test "x$TKCONFIG" = "x"); then
1368      # search for tkConfig.sh
1369      TKCONFIG=$(find /usr/lib -maxdepth 2 -name tkConfig.sh | sort -r | head -n1)
1370      if (test "x$TKCONFIG" = "x"); then
1371  	TKCONFIG=$(find /usr/local/lib -maxdepth 2 -name tkConfig.sh | head -n1)
1372      fi
1373  fi
1374  
1375  if (test "x$TKCONFIG" = "x"); then
1376     AC_MSG_RESULT([tkConfig.sh not found, trying tk.h and libs.
1377  		  If it doesn't work try running ./configure --with-tkConfig=<path to tkConfig.sh>])
1378     AC_CHECK_HEADERS([tk.h])
1379     AC_SEARCH_LIBS(Tk_Init,[tk tk80 tk8.0 tk8.1 tk8.2 tk8.3 tk8.4 tk8.5],[],[AC_MSG_ERROR([tk lib not found])])
1380  else
1381  # tkConfig.sh found,
1382  # extracting vars
1383     AC_MSG_RESULT([$TKCONFIG found])
1384     . "$TKCONFIG"
1385     TK_CFLAGS="$TK_INCLUDE_SPEC $TK_XINCLUDES" 
1386     TK_LIBS="$TK_LIBS $TK_LIB_SPEC"
1387  fi
1388  
1389  if ! test -z "$TCL_VERSION" && ! test -z "$TK_VERSION" && ! test "$TCL_VERSION" = "$TK_VERSION" ; then
1390      AC_MSG_ERROR([Tcl and Tk versions must be the same, but configure found
1391  Tcl $TCL_VERSION and Tk $TK_VERSION.  You can use --with-tkConfig= and --with-tclConfig=
1392  to override the autodetected versions.])
1393  fi
1394  
1395  if test -f $TCL_EXEC_PREFIX/bin/wish$TCL_VERSION; then
1396      WISH=$TCL_EXEC_PREFIX/bin/wish$TCL_VERSION
1397  elif test -f $TCL_EXEC_PREFIX/bin/wish; then
1398      WISH=$TCL_EXEC_PREFIX/bin/wish
1399  else
1400      WISH=wish
1401  fi
1402  
1403  if test -f $TCL_EXEC_PREFIX/bin/tclsh$TCL_VERSION; then
1404      TCLSH=$TCL_EXEC_PREFIX/bin/tclsh$TCL_VERSION
1405  elif test -f $TCL_EXEC_PREFIX/bin/tclsh; then
1406      TCLSH=$TCL_EXEC_PREFIX/bin/tclsh
1407  else
1408      TCLSH=tclsh
1409  fi
1410  
1411  AC_ARG_ENABLE(check-runtime-deps,
1412      AS_HELP_STRING(
1413          [--disable-check-runtime-deps],
1414          [Skip checks for runtime requirements not needed during the
1415          build process.]
1416      ),
1417      [RUNTIME_CHECK=$enableval],
1418      [RUNTIME_CHECK=yes])
1419  AC_MSG_CHECKING([whether to check for runtime dependencies])
1420  AC_MSG_RESULT($RUNTIME_CHECK)
1421  
1422  if test "$RUNTIME_CHECK" = "yes"; then
1423  AC_MSG_CHECKING([for BWidget using $TCLSH])
1424  if (unset DISPLAY; echo ["catch { package require bwidget }; exit [expr [lsearch [package names] BWidget] == -1]"] | $TCLSH); then
1425      AC_MSG_RESULT([found])
1426  else
1427      AC_MSG_RESULT(no)
1428      AC_MSG_ERROR([BWidget not found!
1429  install with "sudo apt-get install bwidget"])
1430  fi
1431  
1432  AC_MSG_CHECKING([for BLT using tclsh8.5])
1433  if (test -f $TCL_EXEC_PREFIX/bin/tclsh8.5) && (echo ['if [catch {package require BLT}] { exit 1; } else { exit 0; }'] | tclsh8.5); then
1434      AC_MSG_RESULT([found])
1435  else
1436      AC_MSG_RESULT([not found])
1437  fi
1438  
1439  AC_MSG_CHECKING([for img::png using $TCLSH])
1440  if (unset DISPLAY; echo ["catch { package require img::png }; exit [expr [lsearch [package names] img::png] == -1]"] | $TCLSH); then
1441      AC_MSG_RESULT([found])
1442      HAVE_WORKING_BLT=yes
1443  else
1444      AC_MSG_RESULT(no)
1445      AC_MSG_ERROR([Tk img::png not found!
1446  install with "sudo apt-get install libtk-img"])
1447  fi
1448  
1449  AC_MSG_CHECKING([for tclX using $TCLSH])
1450  if (unset DISPLAY; echo ["catch { package require Tclx }; exit [expr [lsearch [package names] Tclx] == -1]"] | $TCLSH); then
1451      AC_MSG_RESULT([found])
1452  else
1453      AC_MSG_RESULT(no)
1454      AC_MSG_ERROR([Tclx not found!
1455  install with "sudo apt-get install tclx"])
1456  fi
1457  
1458  AC_MSG_CHECKING([for python pango and cairo modules])
1459  if $PYTHON -c 'import sys;raise SystemExit(sys.hexversion<0x3040000)'
1460  then
1461  
1462  	if $PYTHON -c "import gi;gi.require_version('Pango', '1.0');from gi.repository import Pango"; then
1463  	    AC_MSG_RESULT([found])
1464  	else
1465  	    AC_MSG_RESULT(no)
1466  	    AC_MSG_ERROR([Python pango and cairo modules not found!\ninstall with "sudo apt-get install python3-gi"])
1467  	fi
1468  
1469  else
1470  
1471  	if $PYTHON -c 'import pango,cairo'; then
1472  	    AC_MSG_RESULT([found])
1473  	else
1474  	    AC_MSG_RESULT(no)
1475  	    AC_MSG_ERROR([Python pango and cairo modules not found!\ninstall with "sudo apt-get install python-gtk2"])
1476  	fi
1477  	fi
1478  fi
1479  
1480  AC_SUBST([TCL_DBGX])
1481  AC_SUBST([TK_DBGX])
1482  AC_SUBST([TCL_CFLAGS])
1483  AC_SUBST([TK_CFLAGS])
1484  AC_SUBST([TCL_LIBS])
1485  AC_SUBST([TK_LIBS])
1486  AC_SUBST([WISH])
1487  AC_SUBST([TCLSH])
1488  
1489  ##############################################################################
1490  # Section 6 - Miscelaneous support                                           #
1491  #                                                                            #
1492  # Subsection 6.1. - provides DATE to output it to the generated files        #
1493  # Subsection 6.2. - user option to convince make to be quiet during make     #
1494  ##############################################################################
1495  
1496  # provides DATE in order to output it to the generated files
1497  DATE=$(date)
1498  AC_SUBST([DATE])
1499  AC_PATH_XTRA
1500  #X_CFLAGS gets set
1501  #X_LIBS and X_EXTRA_LIBS likewise
1502  
1503  AC_SUBST([X_LIBS])
1504  AC_SUBST([X_CFLAGS])
1505  
1506  AC_CHECK_HEADERS(X11/extensions/Xinerama.h,
1507  	    [HAVE_XINERAMA=yes],
1508  	    [HAVE_XINERAMA=no])
1509  
1510  AC_CHECK_LIB(Xinerama, XineramaQueryExtension,
1511  	    [],
1512  	    [HAVE_XINERAMA=no])
1513  
1514  if test "x$HAVE_XINERAMA" = "xno"; then
1515      AC_MSG_ERROR([Xinerama library or headers not found])
1516  fi
1517  
1518  #clean out LIBS
1519  temp_LIBS=$LIBS
1520  LIBS=
1521  
1522  # check for readline.h and friends, optional for halcmd
1523  AC_CHECK_HEADERS(readline/readline.h, [HAVE_READLINE=yes], [HAVE_READLINE=no])
1524  AC_CHECK_HEADERS(readline/history.h, [], [HAVE_READLINE=no])
1525  
1526  echo "Trying readline without -ltermcap"
1527  AC_CHECK_LIB(readline, readline, [HAVE_READLINE_NOTERMCAP=yes], [])
1528  unset ac_cv_lib_readline_readline
1529  echo "Trying readline with -ltermcap"
1530  AC_CHECK_LIB(readline, readline, [HAVE_READLINE_TERMCAP=yes], [], -ltermcap)
1531  unset ac_cv_lib_readline_readline
1532  
1533  if test "x$HAVE_READLINE_NOTERMCAP" = "xyes"; then
1534      echo "Readline does not require -ltermcap"
1535      READLINE_LIBS="-lreadline"
1536  elif test "x$HAVE_READLINE_TERMCAP" = "xyes"; then
1537      echo "Readline requires -ltermcap"
1538      READLINE_LIBS="-lreadline -ltermcap"
1539  else
1540      HAVE_READLINE=no
1541  fi
1542  
1543  AC_MSG_CHECKING([whether readline license is compatible with GPL-2])
1544  AC_TRY_COMPILE([
1545          #include <readline/readline.h>
1546      ],[
1547          #if RL_VERSION_MAJOR > 5
1548          #error Readline version 6 and up are not compatible with GPL-2
1549          #endif
1550      ],[AC_MSG_RESULT(yes)],[
1551          AC_MSG_RESULT(no)
1552          AC_MSG_WARN(
1553  [The LinuxCNC binary you are building may not be
1554  distributable due to a license incompatibility with LinuxCNC (some portions
1555  GPL-2 only) and Readline version 6 and greater (GPL-3 or later).])
1556          if $NONDISTRIBUTABLE; then
1557              AC_MSG_WARN(
1558  [User requested to enable non-distributable builds.  Continuing.])
1559          else
1560              AC_MSG_ERROR(
1561  [To configure LinuxCNC in this way, you must
1562  invoke configure with "--enable-non-distributable=yes".  Note that on
1563  Debian-based systems, you may be able to use libreadline-gplv2-dev instead.])
1564          fi
1565  ])
1566  
1567  if test "x$HAVE_READLINE" = "xyes"; then
1568      AC_DEFINE([HAVE_READLINE], [], [Define to 1 if you have the 'readline' library (-lreadline) and required headers])
1569  else
1570      AC_MSG_ERROR([Required library 'readline' missing.])
1571  fi
1572  AC_SUBST([HAVE_READLINE])
1573  AC_SUBST([READLINE_LIBS])
1574  
1575  ##############################################################################
1576  # Section 7 - Language support                                               #
1577  #                                                                            #
1578  # i18n Language support:                                                     #
1579  # see http://cvs.gnome.org/viewcvs/intltool/doc/I18N-HOWTO?rev=1.3           #
1580  ##############################################################################
1581  
1582  # if you don't have nls tools, allow a way out!
1583  
1584  AC_ARG_ENABLE(nls,
1585      AS_HELP_STRING([--disable-nls], [Don't use NLS.]),
1586                USE_NLS=no, USE_NLS=yes)
1587  AC_SUBST(USE_NLS)
1588  
1589  if test "$USE_NLS" = "yes"; then
1590    AC_CHECK_HEADERS(locale.h)
1591    AC_CHECK_FUNCS(setlocale)
1592    AC_SUBST(HAVE_LOCALE_H)  
1593  
1594  # Add languages here when they are translated.
1595  # Grep the LINGUAS file.
1596    LANGUAGES=""
1597    AC_SUBST(LANGUAGES)  
1598    AC_CHECK_HEADERS(libintl.h)
1599    AC_CHECK_LIB(intl,gettext)
1600    AC_SUBST(HAVE_LIBINTL_H)  
1601    AC_SUBST(HAVE_LIBINTL)
1602  
1603  # The default locale directory is /usr/share/locale - This is generally fixed
1604  # by the distribution....
1605    dnl Handle localedir
1606    LOCALEDIR='/usr/share/locale'
1607    AC_ARG_WITH(locale-dir,
1608    AS_HELP_STRING(
1609      [--with-locale-dir=DIR],
1610      [Location of the locale file(s) [DATADIR/locale].]
1611    ),[
1612      if test x$withval = xyes; then
1613        AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
1614      else
1615        if test x$withval = xno; then
1616          AC_MSG_WARN(Usage is: --with-locale-dir=basedir)
1617        else
1618          LOCALEDIR=$withval
1619        fi
1620      fi
1621    ])
1622    AC_SUBST(LOCALEDIR)
1623  fi
1624  
1625  #restore LIBS
1626  LIBS="$X_LIBS $temp_LIBS"
1627  
1628  AC_PATH_PROG(XGETTEXT,xgettext,none)
1629  XGETTEXT_TCL_WORKS=no
1630  if test "$XGETTEXT" = "none"; then
1631     AC_MSG_ERROR(install gettext 0.14.5 or above)
1632  fi
1633  AC_SUBST(XGETTEXT)
1634  
1635  AC_PATH_PROG(MSGFMT,msgfmt,none)
1636  if test "$MSGFMT" = "none"; then
1637     AC_MSG_ERROR(install gettext 0.14.5 or above)
1638  fi
1639  AC_SUBST(MSGFMT)
1640  
1641  if test "$PYTHON" = "none"; then
1642      AC_MSG_ERROR([Python missing.  Install it or specify --disable-python to skip the parts of LinuxCNC that depend on Python])
1643  fi
1644  
1645  AC_MSG_CHECKING([python version])
1646  if ! $PYTHON -c 'import sys;raise SystemExit(sys.hexversion<0x2070000)'
1647  then
1648      AC_MSG_ERROR(Python version too old (2.7 or newer required))
1649  fi
1650  AC_MSG_RESULT(OK)
1651  
1652  AC_MSG_CHECKING([version of python libraries])
1653  LIBPYTHON=`$PYTHON -c 'import distutils.sysconfig; print("python" + (distutils.sysconfig.get_config_vars().get("LDVERSION") or distutils.sysconfig.get_config_vars().get("VERSION")))'`
1654  AC_MSG_RESULT($LIBPYTHON)
1655  
1656  AC_MSG_CHECKING([match between tk and Tkinter versions])
1657  if $PYTHON -c 'import sys;raise SystemExit(sys.hexversion<0x3040000)'
1658  then
1659  
1660  	PYTHON_TK_VERSION="`$PYTHON -c 'import tkinter; print(tkinter.TkVersion)'`"
1661  	PYTHON_TCL_VERSION="`$PYTHON -c 'import tkinter; print(tkinter.TclVersion)'`"
1662  
1663  else
1664  
1665  	PYTHON_TK_VERSION="`$PYTHON -c 'import _tkinter; print(_tkinter.TK_VERSION)'`"
1666  	PYTHON_TCL_VERSION="`$PYTHON -c 'import _tkinter; print(_tkinter.TCL_VERSION)'`"
1667  
1668  fi
1669  
1670  if test "$PYTHON_TCL_VERSION" != "$TCL_VERSION"; then
1671      AC_MSG_RESULT([TCL mismatch: $TCL_VERSION vs $PYTHON_TCL_VERSION])
1672      AC_MSG_ERROR([Python requires use of Tcl $PYTHON_TCL_VERSION and Tk $PYTHON_TK_VERSION.
1673  Install this version and specify --with-tclConfig and --with-tkConfig if necessary])
1674  fi
1675  if test "$PYTHON_TK_VERSION" != "$TK_VERSION"; then
1676      AC_MSG_RESULT([Tk mismatch: $TK_VERSION vs $PYTHON_TK_VERSION])
1677      AC_MSG_ERROR(["Python requires use of Tk $TK_VERSION.  Install this version and specify --with-tkConfig if necessary"])
1678  fi
1679  AC_MSG_RESULT([$PYTHON_TK_VERSION])
1680  
1681  ############################
1682  
1683  AC_MSG_CHECKING(location of Python header files)
1684  INCLUDEPY=`$PYTHON -c 'import distutils.sysconfig; print(distutils.sysconfig.get_config_vars().get("INCLUDEPY"))'`
1685  AC_MSG_RESULT($INCLUDEPY)
1686  
1687  AC_MSG_CHECKING([for Python headers])
1688  AS_IF([test "x$PYTHON_CPPFLAGS" = x],
1689  [
1690      _PYTHON_SYSCONFIG([[get_python_inc()]], [PYTHON_CPPFLAGS="-I$py_val"])
1691      _PYTHON_SYSCONFIG([[get_python_inc(True)]],
1692      [test "x$PYTHON_CPPFLAGS" = "x-I$py_val" || PYTHON_CPPFLAGS="$PYTHON_CPPFLAGS -I$py_val"])
1693  ])
1694  AC_MSG_RESULT([$PYTHON_CPPFLAGS])
1695  AC_SUBST(PYTHON_CPPFLAGS)
1696  
1697  AC_MSG_CHECKING([for Python libraries])
1698  AS_IF([test "x$PYTHON_LIBS" = x],
1699  [
1700      _PYTHON_SYSCONFIG([[get_config_var('LIBS')]], [PYTHON_LIBS=$py_val])
1701  ])
1702  AC_MSG_RESULT([$PYTHON_LIBS])
1703  AC_SUBST(PYTHON_LIBS)
1704  
1705  # Get the CFLAGS and LIBS for boost::python.
1706  # This does an AC_SUBST() of BOOST_PYTHON_LIBS
1707  # For the CFLAGS we must assume that boost is at the top-level, for instance in /usr/include/:
1708  AX_BOOST_PYTHON_EMC
1709  
1710  AC_CHECK_HEADER($INCLUDEPY/Python.h,[],
1711      [AC_MSG_ERROR([Required header Python.h missing.  Install it, or specify --disable-python to skip the parts of LinuxCNC that depend on Python])])
1712  
1713  AC_MSG_CHECKING(for site-package location)
1714  SITEPY=`$PYTHON -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())'`
1715  AC_MSG_RESULT($SITEPY)
1716  
1717  AC_CHECK_HEADERS(GL/gl.h GL/glu.h,[],[AC_MSG_ERROR([Required OpenGL header missing.  Install it, or specify --disable-python to skip the parts of LinuxCNC that depend on Python])])
1718  
1719  AC_CHECK_LIB(GL, glBegin, [], [AC_MSG_ERROR([Required GL library missing.  Install it, or specify --disable-python to skip the parts of LinuxCNC that depend on Python])])
1720  
1721  AC_MSG_CHECKING(for working GLU quadrics)
1722  AC_TRY_COMPILE([
1723  #include <GL/gl.h>
1724  #include <GL/glu.h>
1725  ],
1726      [GLUquadric *q;],
1727      [AC_MSG_RESULT(yes)],[
1728              AC_MSG_ERROR([Required GLU library missing.  Install it or specify --disable-python to skip the parts of LinuxCNC that depend on Python])]
1729      
1730  )
1731  
1732  AC_MSG_CHECKING(for Xmu headers)
1733  AC_CHECK_HEADERS(X11/Xmu/Xmu.h,[],[AC_MSG_ERROR([Required Xmu header missing.  Install it, or specify --disable-python to skip the parts of LinuxCNC that depend on Python])])
1734  
1735  AC_SUBST([LIBPYTHON])
1736  AC_SUBST([INCLUDEPY])
1737  AC_SUBST([SITEPY])
1738  
1739  
1740  ##############################################################################
1741  # files that get created by ./configure                                      #
1742  ##############################################################################
1743  #AC_CONFIG_FILES([../configs/rtapi.conf ../configs/emc.conf ../configs/hal.conf config.h])
1744  AC_CONFIG_FILES([../scripts/rtapi.conf])
1745  AC_CONFIG_FILES([../scripts/linuxcnc], [chmod +x ../scripts/linuxcnc])
1746  AC_CONFIG_FILES([../scripts/halrun], [chmod +x ../scripts/halrun])
1747  AC_CONFIG_FILES([../scripts/rip-environment], [chmod +x ../scripts/rip-environment])
1748  AC_CONFIG_FILES([../scripts/haltcl], [chmod +x ../scripts/haltcl])
1749  AC_CONFIG_FILES([../scripts/halcmd_twopass], [chmod +x ../scripts/halcmd_twopass])
1750  AC_CONFIG_FILES([../scripts/realtime], [chmod +x ../scripts/realtime])
1751  AC_CONFIG_FILES([../scripts/linuxcnc_var], [chmod +x ../scripts/linuxcnc_var])
1752  AC_CONFIG_FILES(Makefile.inc)
1753  AC_CONFIG_FILES(Makefile.modinc)
1754  AC_CONFIG_FILES(../tcl/linuxcnc.tcl)
1755  AC_CONFIG_FILES(../lib/python/nf.py)
1756  AC_CONFIG_FILES([../scripts/linuxcncmkdesktop], [chmod +x ../scripts/linuxcncmkdesktop])
1757  AC_CONFIG_FILES(../share/applications/linuxcnc-latency.desktop)
1758  AC_CONFIG_FILES(../share/applications/linuxcnc.desktop)
1759  AC_CONFIG_FILES(../share/desktop-directories/cnc.directory)
1760  AC_CONFIG_FILES(../share/menus/CNC.menu)
1761  AC_OUTPUT()
1762  
1763  ##############################################################################
1764  # message to the user what to do next, after a succesfull ./configure        #
1765  ##############################################################################
1766  bold () {
1767      if tty > /dev/null 2>&1 && type -path tput > /dev/null 2>&1;
1768      then
1769          tput smso
1770      fi
1771  }
1772  
1773  offbold () {
1774      if tty > /dev/null 2>&1 && type -path tput > /dev/null 2>&1;
1775      then
1776          tput rmso
1777      fi
1778  }
1779  
1780  echo ""
1781  echo ""
1782  echo "######################################################################"
1783  echo "#                LinuxCNC - Enhanced Machine Controller              #"
1784  echo "######################################################################"
1785  echo "#                                                                    #"
1786  echo "#   LinuxCNC is a software system for computer control of machine    #"
1787  echo "#   tools such as milling machines. LinuxCNC is released under the   #"
1788  echo "#   GPL.  Check out http://www.linuxcnc.org/ for more details.       #"
1789  echo "#                                                                    #"
1790  echo "#                                                                    #"
1791  echo "#   It seems that ./configure completed successfully.                #"
1792  echo "#   This means that RT is properly installed                         #"
1793  echo "#   If things don't work check config.log for errors & warnings      #"
1794  echo "#                                                                    #"
1795  
1796  if test "xyes" = "x$RUN_IN_PLACE"; then
1797  echo "#   Next compile by typing                                           #"
1798  echo "#         make                                                       #"
1799  echo "#         sudo make setuid                                           #"
1800  if test $RTS = uspace; then
1801  echo "#          (if realtime behavior and hardware access are required)   #"
1802  fi
1803  echo "#                                                                    #"
1804  echo "#   Before running the software, set the environment:                #"
1805  echo "#         . (top dir)/scripts/rip-environment                        #"
1806  else
1807  bold
1808  echo "#   warning: If you already have an installed linuxcnc, this will    #"
1809  echo "#         replace an existing installation.  If you have installed   #"
1810  echo "#         a linuxcnc package, this will damage the package.          #"
1811  offbold
1812  echo "#   hint: To test a self-built version of linuxcnc without damaging  #"
1813  echo "#         the package version, don't specify a --prefix              #"
1814  echo "#                                                                    #"
1815  echo "#   Next compile by typing                                           #"
1816  echo "#         make                                                       #"
1817  echo "#   then install it by typing                                        #"
1818  echo "#         sudo make install                                          #"
1819  fi
1820  echo "#                                                                    #"
1821  echo "#   To run the software type                                         #"
1822  echo "#         linuxcnc                                                   #"
1823  echo "#                                                                    #"
1824  echo "######################################################################"
1825  echo ""
1826  echo ""