]> rtime.felk.cvut.cz Git - CanFestival-3.git/blobdiff - configure
Added more correct signal handling to unix timers.
[CanFestival-3.git] / configure
index a553f562dc77e1873e5ea1ace7413ab3149893a8..0c62ce38d69f133236f037fa26d66628fb1d47b9 100755 (executable)
--- a/configure
+++ b/configure
@@ -67,11 +67,6 @@ LSS_FS_TIMEOUT_MS=100
 #                             DEFAULT BUILD OPTIONS                       #
 ###########################################################################
 
-# Leave empty for automatic detection
-CC=
-CXX=
-LD=
-
 #default target
 SUB_TARGET=
 
@@ -92,6 +87,10 @@ if [ "$XENO_CONFIG" = "" ]; then
        XENO_CONFIG=/usr/xenomai/bin/xeno-config
 fi
 
+if [ "$RTAI_CONFIG" = "" ]; then
+       RTAI_CONFIG=/usr/realtime/bin/rtai-config
+fi
+
 ###########################################################################
 #                          ARGUMENTS PARSING                              #
 ###########################################################################
@@ -102,12 +101,16 @@ while [ $# -ge 1 ]; do
        --cc=*)         CC=$optarg;;
        --cxx=*)        CXX=$optarg;;
        --ld=*)         LD=$optarg;;
+       --binutils=*)   BINUTILS_PREFIX=$optarg;;
        --arch=*)       SUB_ARCH_NAME=$optarg;;
        --os=*)         SUB_OS_NAME=$optarg;;
+       --kerneldir=*)  SUB_KERNELDIR=$optarg;;
        --prefix=*)     SUB_PREFIX=$optarg;;
        --target=*)     SUB_TARGET=$optarg;;
        --can=*)        SUB_CAN_DRIVER=$optarg;;
        --timers=*)     SUB_TIMERS_DRIVER=$optarg;;
+       --wx=*)         SUB_WX=$optarg;
+                       echo "Forced wx detection to $optarg";;
        --disable-Ox)   DISABLE_OPT=1;
                        echo "On user request: Won't optimize with \"-Ox\"";;
        --disable-dll)  DISABLE_DLL=1;
@@ -135,24 +138,30 @@ while [ $# -ge 1 ]; do
                echo    " --ld=foo      Use linker 'foo' instead of ld."
                echo    " --arch=foo    Use architecture 'foo' instead of trying to autodetect."
                echo    " --os=foo      Use operative system 'foo' instead of trying to autodetect."
+               echo    " --kerneldir=foo   Use 'foo' as kernel source directory instead of default"
                echo    " --prefix=foo  Use prefix 'foo' instead of default ${SUB_PREFIX}."
                echo    " --target=foo  Use 'foo' as build target."
                echo    "               \"unix\" for unix-like systems (Linux, Cygwin)"
                echo    "               \"win32\" for win32 systems (native, mingw or VC++)"
                echo    "               \"hcs12\" for HCS12 micro-controller"
                echo    " --can=foo     Use 'foo' as CAN driver"
+               echo    "               \"anagate_linux\" use AnaGate CAN(duo) driver for linux"        
+               echo    "               \"anagate_win32\" use AnaGate CAN(duo) driver for win32"                                
                echo    "               \"peak_linux\" use Linux build host installed Peak driver and library"
                echo    "                 see http://www.peak-system.com/linux/"
                echo    "               \"peak_win32\" use win32 PcanLight Peak driver and library with Cygwin" 
                echo    "                 see http://www.peak-system.com/themen/download_gb.html"
                echo    "               \"virtual\" use unix pipe based virtual can driver"
+               echo    "               \"virtual_kernel\" use kernel module virtual can driver"
                echo    "               \"socket\" use socket-can  "
                echo    "                 see http://developer.berlios.de/projects/socketcan/"
                echo    "               \"lincan\" lincan driver"
                echo    "                 see http://www.ocera.org/download/components/WP7/lincan-0.3.3.html"
                echo    "               \"can4linux\" can4linux driver"
                echo    "                 see http://www.port.de/engl/canprod/hw_can4linux.html"
-               echo    " --timers=foo  Use 'foo' as TIMERS driver (can be either 'unix' or 'xeno')"
+               echo    " --timers=foo  Use 'foo' as TIMERS driver (can be 'unix', 'xeno', 'rtai' or 'kernel')"
+               echo    " --wx=foo      Force result of WxWidgets detection (0 or 1)"
+               echo    " --binutils=path   Override binutils path detection (as regards \$CC content)"
                echo    " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers"
                echo    " --enable-lss  Enable the LSS services"
                echo    " --enable-lss-fs  Enable the LSS FastScan service"
@@ -223,14 +232,19 @@ if [ "$A_NAME" = "arm" ]; then
        SUB_ARCH_NAME=arm
 fi
 
+# mingw32
+if [ "$A_NAME" = "mingw32" ]; then
+       SUB_ARCH_NAME=mingw32
+fi
+
 if [ "$SUB_ARCH_NAME" = "" ]; then
        echo "Error: could not detect what architecture this system is running!"
        echo "Please supply manually instead with \"--arch=foo\""
        exit -1
 fi
 
-echo "Using OS: ${SUB_OS_NAME}"
-echo "Using architecture: ${SUB_ARCH_NAME}"
+echo "Host OS: ${SUB_OS_NAME}"
+echo "Host arch: ${SUB_ARCH_NAME}"
 
 if [ "$SUB_ARCH_NAME" = "x86_64" -a "$CC" = "gcc" ]; then
        # Only if we are on x86_64 and using gcc
@@ -246,7 +260,7 @@ fi
 ###########################################################################
 #                      DEFAULT TARGET/DRIVERS GUESSING                    #
 ###########################################################################
-# If target not specified, try to gess one
+# If target not specified, try to guess one
 if [ "$SUB_TARGET" = "" ]; then
        if [ "$SUB_OS_NAME" = "CYGWIN" ]; then
                echo "Choosing unix (cygwin) target"
@@ -262,7 +276,7 @@ if [ "$SUB_TARGET" = "" ]; then
        fi
 fi
 
-# Try to gess can
+# Try to guess can
 if [ "$SUB_CAN_DRIVER" = "" ]; then
        if [ "$SUB_TARGET" = "unix" ]; then
                if [ -e /usr/lib/libpcan.so ]; then 
@@ -271,6 +285,15 @@ if [ "$SUB_CAN_DRIVER" = "" ]; then
                elif [ "$SUB_OS_NAME" = "CYGWIN" -a "PCAN_LIB" != "" ]; then
                        echo "Choosing installed Peak driver as CAN driver."
                        SUB_CAN_DRIVER=peak_win32               
+               elif [ -e /usr/lib/libcanlib.so ]; then 
+                       echo "Choosing installed Kvaser driver as CAN driver. (unix)"
+                       SUB_CAN_DRIVER=kvaser
+               elif [ -e /usr/local/lib/libAnaGateAPIDLL.so ]; then 
+                       echo "Choosing installed AnaGate driver as CAN driver. (unix)"
+                       SUB_CAN_DRIVER=anagate_linux
+               elif [ "$SUB_OS_NAME" = "CYGWIN" -a "$KVASER_DLL_PATH" != "" ]; then
+                       echo "Choosing installed Kvaser driver as CAN driver. (cygwin)"
+                       SUB_CAN_DRIVER=kvaser
                else
                        echo "Choosing virtual CAN driver."
                        SUB_CAN_DRIVER=virtual
@@ -298,6 +321,29 @@ if [ "$SUB_CAN_DRIVER" = "peak" ]; then
        fi
 fi
 
+# Warn for unstalled peak driver if choosen
+if [ "$SUB_CAN_DRIVER" = "anagate_linux" ]; then
+       if [ ! -e /usr/local/lib/libAnaGateAPIDLL.so ]; then 
+               echo "AnaGateCAN driver hasn't been installed !"
+               exit -1
+       fi
+fi
+
+# Warn for unstalled kvaser driver if choosen
+if [ "$SUB_CAN_DRIVER" = "kvaser" ]; then
+       if [ "$SUB_OS_NAME" = "CYGWIN" ]; then
+        if [ ! -e "$KVASER_DLL_PATH/canlib32.dll" ]; then 
+            echo "Kvaser driver hasn't been installed (cygwin)"
+            exit -1
+        fi
+    elif  [ "$SUB_OS_NAME" = "LINUX" ]; then
+        if [ ! -e /usr/lib/libcanlib.so ]; then 
+            echo "Kvaser driver hasn't been installed (unix)"
+            exit -1
+        fi
+       fi
+fi
+
 ###########################################################################
 #              TARGET/DRIVER SPECIFIC CFLAGS and OPTIONS                  #
 ###########################################################################
@@ -325,13 +371,42 @@ fi
 
 #### CAN_DRIVER ####
 
+if [ "$SUB_CAN_DRIVER" = "kvaser" ]; then
+       if [ "$SUB_TARGET" = "unix" ]; then
+        if  [ "$SUB_OS_NAME" = "LINUX" ]; then
+            SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lcanlib
+               elif [ "$SUB_OS_NAME" = "CYGWIN" ]; then
+               if [ "$KVASER_INCLUDE_PATH" = "" -o "$KVASER_DLL_PATH" = "" ]; then
+                       echo "!!! ERROR !!! Please set KVASER_DLL_PATH and KVASER_INCLUDE_PATH to appropriate paths ! "
+            else
+                SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -L$KVASER_DLL_PATH\ -lcanlib32
+                SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -I$KVASER_INCLUDE_PATH
+            fi
+        fi
+    fi        
+fi
+
 if [ "$SUB_CAN_DRIVER" = "peak_linux" ]; then
     SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lpcan
 fi
 
+if [ "$SUB_CAN_DRIVER" = "anagate_linux" ]; then
+    SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lAnaGateAPIDLL
+    SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lAnaCommon
+fi
+
+
+if [ "$SUB_CAN_DRIVER" = "vscom" ]; then
+    SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lvs_can_api
+fi
+
+if [ "$SUB_CAN_DRIVER" = "anagate_win32" ]; then
+    SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lAnaGateCan
+fi
+
 PW32DIR=drivers/can_peak_win32
 if [ "$SUB_CAN_DRIVER" = "peak_win32" ]; then
-       if [ "$PCAN_HEADER" = "" -o "PCAN_LIB" = "" ]; then
+       if [ "$PCAN_HEADER" = "" -o "$PCAN_LIB" = "" ]; then
                echo "!!! ERROR !!! Please set PCAN_LIB PCAN_HEADER [PCAN_INCLUDE] to appropriate paths ! "
        fi
        SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -liberty\ \'$PCAN_LIB\'
@@ -377,9 +452,25 @@ if [ "$SUB_TIMERS_DRIVER" = "unix" ]; then
 fi
 
 if [ "$SUB_TIMERS_DRIVER" = "xeno" ]; then
-       SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lnative\ -lrtdm\ -L`$XENO_CONFIG --library-dir`
-       SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ `$XENO_CONFIG --xeno-cflags`
-       RTCAN_SOCKET=1
+       RT_LIB_DIR=`$XENO_CONFIG --library-dir`\ -Wl,-rpath\ `$XENO_CONFIG --library-dir`
+    SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ `$XENO_CONFIG --xeno-ldflags`\ -L$RT_LIB_DIR\ -lnative\ -lrtdm
+       SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DUSE_XENO\ `$XENO_CONFIG --xeno-cflags`
+    RTCAN_SOCKET=1
+fi
+
+if [ "$SUB_TIMERS_DRIVER" = "rtai" ]; then
+       RT_LIB_DIR=`$RTAI_CONFIG --library-dir`\ -Wl,-rpath\ `$RTAI_CONFIG --library-dir`
+    SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ `$RTAI_CONFIG --lxrt-ldflags`\ -L$RT_LIB_DIR\ -llxrt\ -lrtdm
+       SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DUSE_RTAI\ `$RTAI_CONFIG --lxrt-cflags`
+    RTCAN_SOCKET=1
+fi
+
+if [ "$SUB_TIMERS_DRIVER" = "kernel" ]; then
+       DISABLE_DLL=1
+       if [ "$SUB_KERNELDIR" = "" ]; then
+               # use directory of current kernel
+               SUB_KERNELDIR=/lib/modules/$(uname -r)/build
+       fi
 fi
 
 if [ "$SUB_TIMERS_DRIVER" = "none" ]; then
@@ -425,7 +516,11 @@ fi
 
 echo "Using ${CC} as a C compiler"
 
-SUB_BINUTILS_PREFIX=`echo "$CC" | sed 's/gcc$//'`
+if [ "$BINUTILS_PREFIX" = "" ]; then
+       SUB_BINUTILS_PREFIX=`echo "$CC" | sed 's/gcc$//'`
+else
+       SUB_BINUTILS_PREFIX=$BINUTILS_PREFIX
+fi
 
 if [ "$CXX" = "" ]; then
        CXX=${SUB_BINUTILS_PREFIX}g++
@@ -469,28 +564,29 @@ echo "Using prefix: ${SUB_PREFIX}"
 #                           GUESS DEPENDENCIES                            #
 ###########################################################################
 
-if which wx-config >/dev/null 2>&1; then
-       echo -n "Testing wxWidgets compiles ... "
-       cat > /tmp/wx_test.cpp <<EOF
+if [ "$SUB_WX" = "" ]; then
+       if which wx-config >/dev/null 2>&1; then
+               echo -n "Testing wxWidgets compiles ... "
+               cat > /tmp/wx_test.cpp <<EOF
 #include "wx/wx.h"
 class MyApp : public wxApp
 {
 };
 IMPLEMENT_APP(MyApp)
 EOF
-       if $CXX /tmp/wx_test.cpp `wx-config --cxxflags` `wx-config --libs` -o /tmp/wx_test >/dev/null 2>&1 ; then
-               SUB_WX=1
-               echo "Yes"
+               if $CXX /tmp/wx_test.cpp `wx-config --cxxflags` `wx-config --libs` -o /tmp/wx_test >/dev/null 2>&1 ; then
+                       SUB_WX=1
+                       echo "Yes"
+               else
+                       SUB_WX=0
+                       echo "No"
+               fi
+               rm -f /tmp/wx_test*
        else
                SUB_WX=0
-               echo "No"
+               echo "No wxWidgets available"
        fi
-       rm -f /tmp/wx_test*
-else
-       SUB_WX=0
-       echo "No wxWidgets available"
 fi
-
 ###########################################################################
 #                   CANFESTIVAL DEFINES --> config.h                      #
 ###########################################################################
@@ -665,19 +761,23 @@ fi
 # Target dependent Makefiles
 MAKEFILES=$MAKEFILES\ drivers/$SUB_TARGET/Makefile.in
 
-if [ "$SUB_TARGET" = "unix" ]; then
+if [ "$SUB_TARGET" = "unix" -a "$SUB_TIMERS_DRIVER" = "kernel" ]; then
        MAKEFILES=$MAKEFILES\
-\      examples/TestMasterSlave/Makefile.in
-fi
+\      examples/kerneltest/Makefile.in
 
-if [ "$SUB_TARGET" = "unix" ]; then
+elif [ "$SUB_TARGET" = "unix" ]; then
        MAKEFILES=$MAKEFILES\
+\      examples/TestMasterSlave/Makefile.in\
+\      examples/TestMasterSlaveLSS/Makefile.in\
+\      examples/SillySlave/Makefile.in\
 \      examples/TestMasterMicroMod/Makefile.in
 fi
 
 if [ "$SUB_TARGET" = "win32" ]; then
        MAKEFILES=$MAKEFILES\
 \      examples/TestMasterSlave/Makefile.in\
+\      examples/TestMasterSlaveLSS/Makefile.in\
+\      examples/SillySlave/Makefile.in\
 \      examples/TestMasterMicroMod/Makefile.in
 fi
 
@@ -701,6 +801,7 @@ for makefile_in in $MAKEFILES; do
        s:SUB_LD:${LD}:
        s:SUB_PROG_CFLAGS:${SUB_PROG_CFLAGS}:
        s:SUB_EXE_CFLAGS:${SUB_EXE_CFLAGS}:
+       s:SUB_KERNELDIR:${SUB_KERNELDIR}:
        s:SUB_PREFIX:${SUB_PREFIX}:
        s:SUB_OS_NAME:${SUB_OS_NAME}:
        s:SUB_ARCH_NAME:${SUB_ARCH_NAME}: