greg@275: #!/bin/bash etisserant@0: etisserant@0: # etisserant@0: # Copyright (C) 2004 Edouard TISSERRANT, Laurent BESSARD etisserant@0: # Based on Gabriel Gerhardsson's cacheprobe configure script. etisserant@0: # etisserant@0: # This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@0: # etisserant@0: # This library is free software; you can redistribute it and/or etisserant@0: # modify it under the terms of the GNU Lesser General Public etisserant@0: # License as published by the Free Software Foundation; either etisserant@0: # version 2.1 of the License, or (at your option) any later version. etisserant@0: # etisserant@0: # This library is distributed in the hope that it will be useful, etisserant@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@0: # Lesser General Public License for more details. etisserant@0: # etisserant@0: # You should have received a copy of the GNU Lesser General Public etisserant@0: # License along with this library; if not, write to the Free Software etisserant@0: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@0: # etisserant@0: etisserant@0: ########################################################################### etisserant@0: # DEFAULT CANFESTIVAL DEFINES # etisserant@0: ########################################################################### etisserant@0: etisserant@0: # Number of can bus to use greg@267: MAX_CAN_BUS_ID=1 etisserant@0: etisserant@0: # max bytes to transmit by SDO Put 4 if you only support expedited transfert. groke6@360: #For a normal transfert, (usually for a string), put the maximum string size to transfer. greg@267: SDO_MAX_LENGTH_TRANSFERT=32 etisserant@0: etisserant@0: # Number of SDO from differents nodes that the node can manage concurrently. groke6@360: #for a slave node, usually put 1. etisserant@0: SDO_MAX_SIMULTANEOUS_TRANSFERTS=4 etisserant@0: etisserant@0: # Used for NMTable[bus][nodeId] etisserant@0: # You can put less of 128 if on the netwo etisserant@0: # are connected only smaller nodeId node. greg@267: NMT_MAX_NODE_ID=128 etisserant@0: etisserant@0: #Timeout in milliseconds for SDO. etisserant@0: # Comment the #define if not used (infinite wait for SDO response message) etisserant@0: SDO_TIMEOUT_MS=3000 etisserant@0: etisserant@0: MAX_NB_TIMER=32 etisserant@0: etisserant@24: # Generic timers declaration defaults etisserant@24: US_TO_TIMEVAL_FACTOR= etisserant@24: TIMEVAL= etisserant@24: TIMEVAL_MAX= etisserant@24: etisserant@0: # Default to little-endian etisserant@0: CANOPEN_BIG_ENDIAN= etisserant@0: luis@284: # Max number of active errors managed in error_data structure. luis@284: EMCY_MAX_ERRORS=8 luis@284: groke6@360: #Timeout in milliseconds for LSS. groke6@360: LSS_TIMEOUT_MS=1000 groke6@360: #Timeout in milliseconds for LSS FastScan. groke6@360: LSS_FS_TIMEOUT_MS=100 groke6@360: etisserant@0: ########################################################################### etisserant@0: # DEFAULT BUILD OPTIONS # etisserant@0: ########################################################################### etisserant@0: etisserant@0: # Leave empty for automatic detection etisserant@0: CC= etisserant@354: CXX= etisserant@354: LD= etisserant@0: etisserant@0: #default target etisserant@0: SUB_TARGET= etisserant@0: etisserant@0: # First compiler option - we will check if it exists etisserant@0: CC1=gcc etisserant@0: # Second compiler option - we will check if it exists etisserant@0: CC2=cc etisserant@0: etisserant@0: # Install prefix etisserant@0: SUB_PREFIX= etisserant@0: etisserant@0: # Used for C compiler test/detection etisserant@0: CFLAGS= etisserant@0: test=conftest etisserant@0: rm -f $test $test.c etisserant@0: etisserant@278: if [ "$XENO_CONFIG" = "" ]; then etisserant@190: XENO_CONFIG=/usr/xenomai/bin/xeno-config etisserant@190: fi etisserant@0: etisserant@0: ########################################################################### etisserant@0: # ARGUMENTS PARSING # etisserant@0: ########################################################################### etisserant@0: while [ $# -ge 1 ]; do etisserant@0: optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` etisserant@0: etisserant@0: case $1 in etisserant@0: --cc=*) CC=$optarg;; etisserant@341: --cxx=*) CXX=$optarg;; etisserant@341: --ld=*) LD=$optarg;; etisserant@0: --arch=*) SUB_ARCH_NAME=$optarg;; etisserant@0: --os=*) SUB_OS_NAME=$optarg;; etisserant@391: --kerneldir=*) SUB_KERNELDIR=$optarg;; etisserant@0: --prefix=*) SUB_PREFIX=$optarg;; etisserant@0: --target=*) SUB_TARGET=$optarg;; etisserant@0: --can=*) SUB_CAN_DRIVER=$optarg;; etisserant@0: --timers=*) SUB_TIMERS_DRIVER=$optarg;; etisserant@398: --wx=*) SUB_WX=$optarg; etisserant@398: echo "Forced wx detection to $optarg";; etisserant@0: --disable-Ox) DISABLE_OPT=1; etisserant@0: echo "On user request: Won't optimize with \"-Ox\"";; etisserant@145: --disable-dll) DISABLE_DLL=1; etisserant@145: echo "On user request: Won't create and link to dll";; etisserant@343: --enable-lss) ENABLE_LSS=1; etisserant@343: echo "On user request: LSS services enabled";; groke6@360: --enable-lss-fs) ENABLE_LSS_FS=1; groke6@360: echo "On user request: LSS FastScan service enabled";; etisserant@195: --debug=*) DEBUG=$optarg;; etisserant@363: --MAX_CAN_BUS_ID=*) MAX_CAN_BUS_ID=$optarg;; etisserant@363: --SDO_MAX_LENGTH_TRANSFERT=*) SDO_MAX_LENGTH_TRANSFERT=$optarg;; etisserant@363: --SDO_MAX_SIMULTANEOUS_TRANSFERTS=*) SDO_MAX_SIMULTANEOUS_TRANSFERTS=$optarg;; etisserant@363: --NMT_MAX_NODE_ID=*) NMT_MAX_NODE_ID=$optarg;; etisserant@363: --SDO_TIMEOUT_MS=*) SDO_TIMEOUT_MS=$optarg;; etisserant@363: --CANOPEN_BIG_ENDIAN=*) CANOPEN_BIG_ENDIAN=$optarg;; etisserant@363: --MAX_NB_TIMER=*) MAX_NB_TIMER=$optarg;; etisserant@363: --EMCY_MAX_ERRORS=*) EMCY_MAX_ERRORS=$optarg;; groke6@360: --LSS_TIMEOUT_MS=*) LSS_TIMEOUT_MS=$optarg;; groke6@360: --LSS_FS_TIMEOUT_MS=*) LSS_FS_TIMEOUT_MS=$optarg;; etisserant@341: --help) etisserant@341: echo "Usage: ./configure [options]" etisserant@341: echo "Options:" etisserant@341: echo " --cc=foo Use C compiler 'foo' instead of defaults ${CC1} or ${CC2}." etisserant@341: echo " --cxx=foo Use C++ compiler 'foo' instead of defaults g++." etisserant@341: echo " --ld=foo Use linker 'foo' instead of ld." etisserant@145: echo " --arch=foo Use architecture 'foo' instead of trying to autodetect." etisserant@145: echo " --os=foo Use operative system 'foo' instead of trying to autodetect." etisserant@391: echo " --kerneldir=foo Use 'foo' as kernel source directory instead of default" etisserant@145: echo " --prefix=foo Use prefix 'foo' instead of default ${SUB_PREFIX}." etisserant@145: echo " --target=foo Use 'foo' as build target." etisserant@341: echo " \"unix\" for unix-like systems (Linux, Cygwin)" etisserant@341: echo " \"win32\" for win32 systems (native, mingw or VC++)" etisserant@145: echo " \"hcs12\" for HCS12 micro-controller" etisserant@145: echo " --can=foo Use 'foo' as CAN driver" etisserant@145: echo " \"peak_linux\" use Linux build host installed Peak driver and library" etisserant@341: echo " see http://www.peak-system.com/linux/" etisserant@145: echo " \"peak_win32\" use win32 PcanLight Peak driver and library with Cygwin" etisserant@341: echo " see http://www.peak-system.com/themen/download_gb.html" etisserant@145: echo " \"virtual\" use unix pipe based virtual can driver" etisserant@391: echo " \"virtual_kernel\" use kernel module virtual can driver" etisserant@145: echo " \"socket\" use socket-can " etisserant@341: echo " see http://developer.berlios.de/projects/socketcan/" etisserant@341: echo " \"lincan\" lincan driver" etisserant@341: echo " see http://www.ocera.org/download/components/WP7/lincan-0.3.3.html" groke6@364: echo " \"can4linux\" can4linux driver" groke6@364: echo " see http://www.port.de/engl/canprod/hw_can4linux.html" etisserant@391: echo " --timers=foo Use 'foo' as TIMERS driver (can be 'unix', 'xeno' or 'kernel')" etisserant@398: echo " --wx=foo force result of WxWidgets detection (0 or 1)" etisserant@145: echo " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers" etisserant@343: echo " --enable-lss Enable the LSS services" groke6@360: echo " --enable-lss-fs Enable the LSS FastScan service" etisserant@145: echo " --disable-Ox Disable gcc \"-Ox\" optimizations." greg@329: echo " --debug=foo,foo,.. Enable debug messages, ERR -> only errors, WAR)." etisserant@341: echo " \"PDO\" send errors and warnings through PDO messages" etisserant@341: echo " \"ERR\" print errors only, to stdout" etisserant@341: echo " \"WAR\" print errors and warnings, to stdout" etisserant@341: echo " \"MSG\" print messages content, to stdout" etisserant@0: echo etisserant@0: echo "Stack compilation constants" etisserant@0: echo " --MAX_CAN_BUS_ID [=1] Number of can bus to use" etisserant@0: echo " --SDO_MAX_LENGTH_TRANSFERT [=32] max bytes to transmit by SDO" etisserant@0: echo " --SDO_MAX_SIMULTANEOUS_TRANSFERTS [=4] Number of SDO that the node can manage concurrently" etisserant@0: echo " --NMT_MAX_NODE_ID [=128] can be reduced to gain memory on small network" etisserant@0: echo " --SDO_TIMEOUT_MS [=3000] Timeout in milliseconds for SDO (None to disable the feature)" luis@284: echo " --EMCY_MAX_ERRORS [=8] Max number of active errors managed in error_data structure" groke6@360: echo " --LSS_TIMEOUT_MS [=1000] Timeout in milliseconds for LSS services." groke6@360: echo " LSS must be enabled with \"--enable-lss\"" groke6@360: echo " --LSS_FS_TIMEOUT_MS [=100] Timeout in milliseconds for LSS FastScan service." groke6@360: echo " LSS FastScan must be enabled with \"--enable-lss-fs\"" etisserant@0: exit 0;; etisserant@0: *) echo "Unknown argument ${1}"; exit -1;; etisserant@0: esac etisserant@0: etisserant@0: shift etisserant@0: done etisserant@0: etisserant@0: ########################################################################### etisserant@0: # GUESS OS/ARCH # etisserant@0: ########################################################################### etisserant@0: etisserant@0: if [ "$SUB_OS_NAME" = "" ]; then etisserant@0: SUB_OS_NAME="`(uname -s | sed \"s/\//-/\" | sed \"s/_/-/\" \ etisserant@0: | sed \"s/-.*//g\") 2>&1`" etisserant@0: fi etisserant@0: etisserant@0: if [ "$SUB_ARCH_NAME" = "" ]; then etisserant@0: if [ "$CC" = "" ]; then etisserant@0: A_NAME="`(uname -m) 2>&1`" etisserant@0: else etisserant@0: A_NAME="`$CC -dumpmachine | sed 's:-.*::'`" etisserant@0: fi etisserant@0: fi etisserant@0: etisserant@0: # x86 etisserant@341: if [ "$A_NAME" = "i386" -o "$A_NAME" = "i486" -o "$A_NAME" = "i586" -o "$A_NAME" = "i686" -o "$A_NAME" = "x86" ]; then etisserant@0: SUB_ARCH_NAME=x86 etisserant@0: fi etisserant@0: etisserant@0: # x86_64 etisserant@0: if [ "$A_NAME" = "x86_64" ]; then etisserant@0: SUB_ARCH_NAME=x86_64 etisserant@0: fi etisserant@0: etisserant@0: # ppc etisserant@0: if [ "$A_NAME" = "powerpc" ]; then etisserant@0: SUB_ARCH_NAME=ppc etisserant@0: fi etisserant@0: etisserant@0: # ppc64 etisserant@0: if [ "$A_NAME" = "powerpc64" ]; then etisserant@0: SUB_ARCH_NAME=ppc64 etisserant@0: fi etisserant@0: etisserant@0: # arm etisserant@0: if [ "$A_NAME" = "arm" ]; then etisserant@0: SUB_ARCH_NAME=arm etisserant@0: fi etisserant@0: etisserant@376: # mingw32 etisserant@376: if [ "$A_NAME" = "mingw32" ]; then etisserant@376: SUB_ARCH_NAME=mingw32 etisserant@376: fi etisserant@376: etisserant@0: if [ "$SUB_ARCH_NAME" = "" ]; then etisserant@0: echo "Error: could not detect what architecture this system is running!" etisserant@0: echo "Please supply manually instead with \"--arch=foo\"" etisserant@0: exit -1 etisserant@0: fi etisserant@0: etisserant@376: echo "Host OS: ${SUB_OS_NAME}" etisserant@376: echo "Host arch: ${SUB_ARCH_NAME}" etisserant@0: etisserant@0: if [ "$SUB_ARCH_NAME" = "x86_64" -a "$CC" = "gcc" ]; then etisserant@0: # Only if we are on x86_64 and using gcc etisserant@0: # For shared library generation, it needs this etisserant@0: SUB_PROG_CFLAGS=-fPIC etisserant@0: fi etisserant@0: etisserant@200: if [ "$SUB_ARCH_NAME" = "ppc" -o "$SUB_ARCH_NAME" = "powerpc" ]; then etisserant@200: # PowerPC uses big endian format etisserant@200: CANOPEN_BIG_ENDIAN=1 etisserant@200: fi etisserant@200: etisserant@0: ########################################################################### etisserant@24: # DEFAULT TARGET/DRIVERS GUESSING # etisserant@24: ########################################################################### etisserant@400: # If target not specified, try to guess one etisserant@24: if [ "$SUB_TARGET" = "" ]; then etisserant@24: if [ "$SUB_OS_NAME" = "CYGWIN" ]; then etisserant@38: echo "Choosing unix (cygwin) target" etisserant@38: SUB_TARGET=unix greg@267: fi greg@267: if [ "$SUB_OS_NAME" = "Linux" ]; then etisserant@24: echo "Choosing unix target" etisserant@24: SUB_TARGET=unix etisserant@24: fi greg@267: if [ "$SUB_OS_NAME" = "MINGW32" ]; then greg@267: echo "Choosing windows target" greg@267: SUB_TARGET=win32 greg@267: fi etisserant@24: fi etisserant@24: etisserant@400: # Try to guess can etisserant@24: if [ "$SUB_CAN_DRIVER" = "" ]; then etisserant@24: if [ "$SUB_TARGET" = "unix" ]; then etisserant@24: if [ -e /usr/lib/libpcan.so ]; then etisserant@24: echo "Choosing installed Peak driver as CAN driver." etisserant@145: SUB_CAN_DRIVER=peak_linux etisserant@145: elif [ "$SUB_OS_NAME" = "CYGWIN" -a "PCAN_LIB" != "" ]; then etisserant@145: echo "Choosing installed Peak driver as CAN driver." etisserant@145: SUB_CAN_DRIVER=peak_win32 etisserant@400: elif [ -e /usr/lib/libcanlib.so ]; then etisserant@400: echo "Choosing installed Kvaser driver as CAN driver. (unix)" etisserant@400: SUB_CAN_DRIVER=kvaser etisserant@400: elif [ "$SUB_OS_NAME" = "CYGWIN" -a "$KVASER_DLL_PATH" != "" ]; then etisserant@400: echo "Choosing installed Kvaser driver as CAN driver. (cygwin)" etisserant@400: SUB_CAN_DRIVER=kvaser etisserant@24: else etisserant@24: echo "Choosing virtual CAN driver." etisserant@24: SUB_CAN_DRIVER=virtual etisserant@24: fi etisserant@24: fi etisserant@24: fi etisserant@24: etisserant@24: # If target is unix, default timers also etisserant@24: if [ "$SUB_TARGET" = "unix" -a "$SUB_TIMERS_DRIVER" = "" ]; then etisserant@24: echo "Choosing unix timers driver." etisserant@24: SUB_TIMERS_DRIVER=unix etisserant@24: fi etisserant@24: greg@267: # If target is windows, default timers also greg@267: if [ "$SUB_TARGET" = "win32" -a "$SUB_TIMERS_DRIVER" = "" ]; then greg@267: echo "Choosing windows timers driver." greg@267: SUB_TIMERS_DRIVER=win32 greg@267: fi greg@267: etisserant@24: # Warn for unstalled peak driver if choosen etisserant@24: if [ "$SUB_CAN_DRIVER" = "peak" ]; then etisserant@24: if [ ! -e /usr/lib/libpcan.so ]; then etisserant@24: echo "Peak driver hasn't been installed !" etisserant@24: exit -1 etisserant@24: fi etisserant@24: fi etisserant@24: etisserant@400: # Warn for unstalled kvaser driver if choosen etisserant@400: if [ "$SUB_CAN_DRIVER" = "kvaser" ]; then etisserant@400: if [ "$SUB_OS_NAME" = "CYGWIN" ]; then etisserant@400: if [ ! -e "$KVASER_DLL_PATH/canlib32.dll" ]; then etisserant@400: echo "Kvaser driver hasn't been installed (cygwin)" etisserant@400: exit -1 etisserant@400: fi etisserant@400: elif [ "$SUB_OS_NAME" = "LINUX" ]; then etisserant@400: if [ ! -e /usr/lib/libcanlib.so ]; then etisserant@400: echo "Kvaser driver hasn't been installed (unix)" etisserant@400: exit -1 etisserant@400: fi etisserant@400: fi etisserant@400: fi etisserant@400: etisserant@24: ########################################################################### etisserant@0: # TARGET/DRIVER SPECIFIC CFLAGS and OPTIONS # etisserant@0: ########################################################################### etisserant@0: if [ "$SUB_TARGET" = "hcs12" ]; then groke6@360: # Only if we want to compile for a C HCS12 frdupin@81: # it is a big endian architecture. frdupin@81: CANOPEN_BIG_ENDIAN=1 etisserant@0: # search for gcc hcs12 compiler m6811-elf-gcc or m68hc12-gcc ? etisserant@0: if [ "$CC" = "" ]; then etisserant@0: which m6811-elf-gcc >/dev/null 2>&1 etisserant@0: if (( $? )); then etisserant@0: which m68hc12-gcc >/dev/null 2>&1 etisserant@0: if (( $? )); then etisserant@0: echo "Please use --cc flag to specify compiler" etisserant@0: exit 0 etisserant@0: else etisserant@0: CC=m68hc12-gcc etisserant@0: fi etisserant@0: else etisserant@0: CC=m6811-elf-gcc etisserant@0: SUB_PROG_CFLAGS=-m68hc12 etisserant@0: fi etisserant@0: fi etisserant@0: fi etisserant@0: etisserant@0: #### CAN_DRIVER #### etisserant@0: etisserant@400: if [ "$SUB_CAN_DRIVER" = "kvaser" ]; then etisserant@400: if [ "$SUB_TARGET" = "unix" ]; then etisserant@400: if [ "$SUB_OS_NAME" = "LINUX" ]; then etisserant@400: SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lcanlib etisserant@400: elif [ "$SUB_OS_NAME" = "CYGWIN" ]; then etisserant@400: if [ "$KVASER_INCLUDE_PATH" = "" -o "$KVASER_DLL_PATH" = "" ]; then etisserant@400: echo "!!! ERROR !!! Please set KVASER_DLL_PATH and KVASER_INCLUDE_PATH to appropriate paths ! " etisserant@400: else etisserant@400: SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -L$KVASER_DLL_PATH\ -lcanlib32 etisserant@400: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -I$KVASER_INCLUDE_PATH etisserant@400: fi etisserant@400: fi etisserant@400: fi etisserant@400: fi etisserant@400: etisserant@145: if [ "$SUB_CAN_DRIVER" = "peak_linux" ]; then etisserant@145: SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lpcan etisserant@145: fi etisserant@145: etisserant@145: PW32DIR=drivers/can_peak_win32 etisserant@38: if [ "$SUB_CAN_DRIVER" = "peak_win32" ]; then etisserant@400: if [ "$PCAN_HEADER" = "" -o "$PCAN_LIB" = "" ]; then etisserant@38: echo "!!! ERROR !!! Please set PCAN_LIB PCAN_HEADER [PCAN_INCLUDE] to appropriate paths ! " etisserant@38: fi etisserant@145: SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -liberty\ \'$PCAN_LIB\' etisserant@145: echo "Converting PcanLib header files for gcc -> $PW32DIR/cancfg.h" etisserant@145: cat $PW32DIR/cancfg.h.head $PCAN_INCLUDE/$PCAN_HEADER > $PW32DIR/cancfg.h etisserant@331: echo >> $PW32DIR/cancfg.h etisserant@41: # second port handling etisserant@41: if [ "$PCAN2_HEADER" != "" ]; then etisserant@41: echo "Stripping down second Pcan Light header " etisserant@145: echo >> $PW32DIR/cancfg.h etisserant@145: echo "// Stripped PcanLight header to prevent typedef conflicts ">> $PW32DIR/cancfg.h etisserant@145: echo >> $PW32DIR/cancfg.h etisserant@145: grep __stdcall $PCAN_INCLUDE/$PCAN2_HEADER >> $PW32DIR/cancfg.h etisserant@145: echo '#define PCAN2_HEADER_' >> $PW32DIR/cancfg.h etisserant@145: SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ \'$PCAN2_LIB\' etisserant@145: fi etisserant@145: if grep -q CANHwType $PW32DIR/cancfg.h ; then etisserant@42: echo "Peak Init HwType, IO_Port and IRQ will be passed in environment :" etisserant@42: echo " PCANHwType PCANIO_Port PCANInterupt" etisserant@145: echo '#define extra_PCAN_init_params' >> $PW32DIR/cancfg.h etisserant@145: fi etisserant@331: if ! grep -q CAN_Init $PW32DIR/cancfg.h ; then etisserant@331: echo "Pcan Light header/lib is for second port of device only" etisserant@331: echo "CAN_* calls redefined to CAN2_* " etisserant@331: echo '#define CAN_Init CAN2_Init' >> $PW32DIR/cancfg.h etisserant@331: echo '#define CAN_Read CAN2_Read' >> $PW32DIR/cancfg.h etisserant@331: echo '#define CAN_Write CAN2_Write' >> $PW32DIR/cancfg.h etisserant@331: echo '#define CAN_Close CAN2_Close' >> $PW32DIR/cancfg.h etisserant@331: fi etisserant@145: cat $PW32DIR/cancfg.h.tail >> $PW32DIR/cancfg.h etisserant@38: fi etisserant@38: etisserant@24: if [ "$SUB_CAN_DRIVER" = "none" ]; then etisserant@24: SUB_CAN_DRIVER= etisserant@24: fi etisserant@24: etisserant@0: #### TIMERS_DRIVER #### etisserant@0: etisserant@0: if [ "$SUB_TIMERS_DRIVER" = "unix" ]; then etisserant@38: if [ "$SUB_OS_NAME" != "CYGWIN" ]; then etisserant@38: SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lpthread\ -lrt etisserant@38: fi etisserant@0: fi etisserant@0: etisserant@0: if [ "$SUB_TIMERS_DRIVER" = "xeno" ]; then etisserant@341: SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lnative\ -lrtdm\ -L`$XENO_CONFIG --library-dir` etisserant@0: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ `$XENO_CONFIG --xeno-cflags` etisserant@47: RTCAN_SOCKET=1 etisserant@0: fi etisserant@0: etisserant@391: if [ "$SUB_TIMERS_DRIVER" = "kernel" ]; then etisserant@391: DISABLE_DLL=1 etisserant@391: if [ "$SUB_KERNELDIR" = "" ]; then etisserant@391: # use directory of current kernel etisserant@391: SUB_KERNELDIR=/lib/modules/$(uname -r)/build etisserant@391: fi etisserant@391: fi etisserant@391: etisserant@24: if [ "$SUB_TIMERS_DRIVER" = "none" ]; then etisserant@24: SUB_TIMERS_DRIVER= etisserant@24: fi etisserant@24: etisserant@0: ########################################################################### etisserant@354: # GUESS TOOLCHAIN # etisserant@0: ########################################################################### etisserant@0: # If CC is empty, the user wanted automatic detection etisserant@0: if [ "$CC" = "" ]; then etisserant@0: # Check for second compiler, CC2 etisserant@0: cat > $test.c <&1`" = ""; then etisserant@0: DETECTCC=$CC2 etisserant@0: echo "Checking for ${CC2}... Yes." etisserant@0: else etisserant@0: echo "Checking for ${CC2}... No." etisserant@0: fi etisserant@0: rm -f $test.c $test.o etisserant@0: etisserant@0: # Check for first compiler, CC1 etisserant@0: cat > $test.c <&1`" = ""; then etisserant@0: DETECTCC=$CC1 etisserant@0: echo "Checking for ${CC1}... Yes." etisserant@0: else etisserant@0: echo "Checking for ${CC1}... No." etisserant@0: fi etisserant@0: rm -f $test.c $test.o etisserant@0: CC=$DETECTCC etisserant@0: fi etisserant@0: # Check if we decided on a compiler after all etisserant@0: if [ "$CC" = "" ]; then etisserant@0: echo "Error: Could not find a C compiler" etisserant@0: echo "Please supply the wanted compiler" etisserant@0: exit -1 etisserant@0: fi etisserant@0: etisserant@354: echo "Using ${CC} as a C compiler" etisserant@0: etisserant@0: SUB_BINUTILS_PREFIX=`echo "$CC" | sed 's/gcc$//'` etisserant@0: etisserant@354: if [ "$CXX" = "" ]; then etisserant@354: CXX=${SUB_BINUTILS_PREFIX}g++ etisserant@354: fi etisserant@354: etisserant@354: echo "Using ${CXX} as a C++ compiler" etisserant@354: etisserant@354: if [ "$SUB_TARGET" = "win32" ]; then etisserant@354: # on cygwin/mingw, choose g++ as a linker for native target etisserant@354: if [ "$LD" = "" ]; then etisserant@354: LD=$CXX etisserant@354: fi etisserant@354: if [ "$SUB_OS_NAME" = "CYGWIN" ]; then etisserant@354: SUB_PROG_CFLAGS="-mno-cygwin" etisserant@354: fi etisserant@354: fi etisserant@354: etisserant@354: if [ "$SUB_TARGET" = "unix" ]; then etisserant@354: if [ "$LD" = "" ]; then etisserant@354: LD=$CC etisserant@354: fi etisserant@354: fi etisserant@354: etisserant@354: echo "Using ${LD} as a linker" etisserant@354: etisserant@0: # Guess prefix as regard cross compiling target machine etisserant@0: if [ "$SUB_PREFIX" = "" ]; then etisserant@0: $CC -dumpspecs |grep -A 1 'cross_compile'|grep -q 1 etisserant@0: if (( $? )); then etisserant@0: SUB_PREFIX=/usr/local etisserant@0: echo "Not cross-compiling. Will install in $SUB_PREFIX"; etisserant@0: else etisserant@0: SUB_PREFIX=/usr/`$CC -dumpmachine` etisserant@0: echo "This is a cross-compiler. Will install in $SUB_PREFIX"; etisserant@0: fi etisserant@0: fi etisserant@0: etisserant@0: echo "Using prefix: ${SUB_PREFIX}" etisserant@0: etisserant@0: ########################################################################### etisserant@354: # GUESS DEPENDENCIES # etisserant@354: ########################################################################### etisserant@354: etisserant@398: if [ "$SUB_WX" = "" ]; then etisserant@398: if which wx-config >/dev/null 2>&1; then etisserant@398: echo -n "Testing wxWidgets compiles ... " etisserant@398: cat > /tmp/wx_test.cpp </dev/null 2>&1 ; then etisserant@398: SUB_WX=1 etisserant@398: echo "Yes" etisserant@398: else etisserant@398: SUB_WX=0 etisserant@398: echo "No" etisserant@398: fi etisserant@398: rm -f /tmp/wx_test* etisserant@354: else etisserant@354: SUB_WX=0 etisserant@398: echo "No wxWidgets available" etisserant@398: fi etisserant@398: fi etisserant@354: ########################################################################### etisserant@0: # CANFESTIVAL DEFINES --> config.h # etisserant@0: ########################################################################### etisserant@0: # Some CONSTANTS preparation etisserant@0: etisserant@0: # Create include/config.h with the relevant contents etisserant@0: rm -f include/config.h frdupin@77: echo "/* !!!!!!!!!! FILE GENERATED by configure. DO NOT EDIT !!!!!!!!!!*/" >> include/config.h frdupin@77: echo "" >> include/config.h frdupin@77: echo "/*"\ >> include/config.h etisserant@0: echo "This file is part of CanFestival, a library implementing CanOpen Stack." >> include/config.h etisserant@0: echo "" >> include/config.h etisserant@0: echo "Copyright (C): Edouard TISSERANT and Francis DUPIN" >> include/config.h etisserant@0: echo "See COPYING file for copyrights details." >> include/config.h etisserant@0: echo "" >> include/config.h etisserant@0: echo "This library is free software; you can redistribute it and/or" >> include/config.h etisserant@0: echo "modify it under the terms of the GNU Lesser General Public" >> include/config.h etisserant@0: echo "License as published by the Free Software Foundation; either" >> include/config.h etisserant@0: echo "version 2.1 of the License, or (at your option) any later version." >> include/config.h etisserant@0: echo "" >> include/config.h etisserant@0: echo "This library is distributed in the hope that it will be useful," >> include/config.h etisserant@0: echo "but WITHOUT ANY WARRANTY; without even the implied warranty of" >> include/config.h etisserant@0: echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU" >> include/config.h etisserant@0: echo "Lesser General Public License for more details." >> include/config.h etisserant@0: echo "" >> include/config.h etisserant@0: echo "You should have received a copy of the GNU Lesser General Public" >> include/config.h etisserant@0: echo "License along with this library; if not, write to the Free Software" >> include/config.h etisserant@0: echo "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA" >> include/config.h etisserant@0: echo "*/" >> include/config.h etisserant@0: echo "" >> include/config.h etisserant@0: echo "#ifndef _CONFIG_H_" >> include/config.h etisserant@0: echo "#define _CONFIG_H_" >> include/config.h etisserant@0: echo "" >> include/config.h etisserant@0: for i in \ etisserant@0: MAX_CAN_BUS_ID\ etisserant@0: SDO_MAX_LENGTH_TRANSFERT\ etisserant@0: SDO_MAX_SIMULTANEOUS_TRANSFERTS\ etisserant@0: NMT_MAX_NODE_ID\ etisserant@0: SDO_TIMEOUT_MS\ etisserant@0: MAX_NB_TIMER\ etisserant@0: CANOPEN_BIG_ENDIAN\ etisserant@24: US_TO_TIMEVAL_FACTOR\ etisserant@24: TIMEVAL\ etisserant@47: TIMEVAL_MAX\ luis@284: RTCAN_SOCKET\ groke6@360: EMCY_MAX_ERRORS\ groke6@360: LSS_TIMEOUT_MS\ groke6@360: LSS_FS_TIMEOUT_MS; do etisserant@0: if [ "${!i}" = "" ]; then frdupin@77: echo "/* $i is not defined */" >> include/config.h etisserant@0: else etisserant@0: echo "#define $i ${!i}" >> include/config.h etisserant@0: fi etisserant@0: done etisserant@0: echo "" >> include/config.h etisserant@91: etisserant@91: for i in \ etisserant@91: SDO_MAX_SIMULTANEOUS_TRANSFERTS\ luis@284: NMT_MAX_NODE_ID\ luis@284: EMCY_MAX_ERRORS; do etisserant@91: echo "#define REPEAT_"$i"_TIMES(repeat)\\">> include/config.h etisserant@91: times=${!i} etisserant@91: result="" etisserant@91: for (( j=0; j> include/config.h etisserant@91: done etisserant@91: etisserant@0: echo "#endif /* _CONFIG_H_ */" >> include/config.h etisserant@0: etisserant@0: ########################################################################### etisserant@0: # DEBUG DEFINES/CFLAGS # etisserant@0: ########################################################################### greg@329: greg@329: save_ifs="$IFS"; IFS=',' greg@329: greg@329: for DEBUG_METHOD in $DEBUG; greg@329: do greg@329: IFS="$save_ifs" greg@329: case $DEBUG_METHOD in greg@329: ERR)ERR=1;; greg@329: WAR)WAR=1;ERR=1;; greg@329: MSG)MSG=1;; greg@329: PDO)PDO=1;WAR=1;ERR=1;; greg@329: *)echo "" greg@329: echo "$DEBUG_METHOD is not a valid debug's method" greg@329: echo "Possible Debug's methods are : \"ERR\", \"WAR\", \"MSG\", \"PDO\"" greg@329: exit -1 greg@329: ;; greg@329: esac greg@329: done greg@329: greg@329: if [ $WAR ]; then greg@329: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_WAR_CONSOLE_ON; greg@329: fi greg@329: greg@329: if [ $ERR ]; then greg@329: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_ERR_CONSOLE_ON; greg@329: fi greg@329: greg@329: if [ $MSG ]; then greg@329: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_MSG_CONSOLE_ON; greg@329: fi greg@329: greg@329: if [ $PDO ]; then greg@329: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_PDO_CONSOLE_ON; greg@329: fi greg@329: greg@329: if [ $DEBUG ]; then greg@329: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -g greg@329: fi greg@329: greg@329: IFS="$save_ifs" etisserant@0: etisserant@0: if [ "$DISABLE_OPT" = "1" ]; then etisserant@0: SUB_OPT_CFLAGS= etisserant@0: else etisserant@0: SUB_OPT_CFLAGS=\$\(OPT_CFLAGS\) etisserant@0: fi etisserant@0: etisserant@145: if [ "$DISABLE_DLL" = "1" ]; then etisserant@145: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DNOT_USE_DYNAMIC_LOADING etisserant@145: SUB_ENABLE_DLL_DRIVERS=0 etisserant@145: else etisserant@145: SUB_ENABLE_DLL_DRIVERS=1 etisserant@354: if [ "$SUB_TARGET" = "win32" ]; then greg@351: SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS greg@351: else greg@351: SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -ldl greg@351: fi greg@351: etisserant@145: fi etisserant@145: etisserant@145: etisserant@145: if [ "$DISABLE_DLL" = "1" ]; then etisserant@145: SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ $SUB_CAN_DLL_CFLAGS etisserant@145: fi etisserant@145: etisserant@343: if [ $ENABLE_LSS ]; then etisserant@343: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DCO_ENABLE_LSS; etisserant@343: SUB_ENABLE_LSS=1 groke6@360: if [ $ENABLE_LSS_FS ]; then groke6@360: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DCO_ENABLE_LSS_FS; groke6@360: fi etisserant@343: else etisserant@343: SUB_ENABLE_LSS=0 etisserant@343: fi etisserant@343: etisserant@0: ########################################################################### etisserant@0: # CREATE MAKEFILES # etisserant@0: ########################################################################### etisserant@24: # General Makefiles etisserant@0: MAKEFILES=Makefile.in\ etisserant@0: \ src/Makefile.in\ etisserant@0: \ drivers/Makefile.in\ etisserant@0: \ objdictgen/Makefile.in\ etisserant@279: \ examples/Makefile.in\ etisserant@279: \ objdictgen/canfestival_config.py.in etisserant@0: etisserant@24: # Drivers dependent Makefiles etisserant@24: if [ "$SUB_TIMERS_DRIVER" != "" ]; then etisserant@24: MAKEFILES=$MAKEFILES\ etisserant@24: \ drivers/timers_$SUB_TIMERS_DRIVER/Makefile.in etisserant@24: fi etisserant@24: etisserant@24: if [ "$SUB_CAN_DRIVER" != "" ]; then etisserant@24: MAKEFILES=$MAKEFILES\ etisserant@24: \ drivers/can_$SUB_CAN_DRIVER/Makefile.in etisserant@24: fi etisserant@24: etisserant@24: # Target dependent Makefiles etisserant@24: MAKEFILES=$MAKEFILES\ drivers/$SUB_TARGET/Makefile.in etisserant@24: etisserant@391: if [ "$SUB_TARGET" = "unix" -a "$SUB_TIMERS_DRIVER" = "kernel" ]; then etisserant@391: MAKEFILES=$MAKEFILES\ etisserant@391: \ examples/kerneltest/Makefile.in etisserant@391: etisserant@391: elif [ "$SUB_TARGET" = "unix" ]; then etisserant@24: MAKEFILES=$MAKEFILES\ groke6@381: \ examples/TestMasterSlave/Makefile.in\ etisserant@391: \ examples/TestMasterSlaveLSS/Makefile.in\ etisserant@400: \ examples/SillySlave/Makefile.in\ etisserant@166: \ examples/TestMasterMicroMod/Makefile.in etisserant@166: fi etisserant@166: greg@267: if [ "$SUB_TARGET" = "win32" ]; then greg@267: MAKEFILES=$MAKEFILES\ greg@329: \ examples/TestMasterSlave/Makefile.in\ groke6@381: \ examples/TestMasterSlaveLSS/Makefile.in\ etisserant@400: \ examples/SillySlave/Makefile.in\ etisserant@354: \ examples/TestMasterMicroMod/Makefile.in etisserant@354: fi etisserant@354: etisserant@354: if [ "$SUB_WX" = "1" ]; then etisserant@354: MAKEFILES=$MAKEFILES\ greg@329: \ examples/DS401_Master/Makefile.in\ greg@329: \ examples/DS401_Slave_Gui/Makefile.in greg@329: fi greg@267: etisserant@0: if [ "$SUB_TARGET" = "hcs12" ]; then etisserant@0: MAKEFILES=$MAKEFILES\ etisserant@0: \ examples/gene_SYNC_HCS12/Makefile.in etisserant@0: fi etisserant@0: etisserant@0: for makefile_in in $MAKEFILES; do etisserant@0: makefile=`echo $makefile_in | sed 's:.in$::'` etisserant@0: echo "Creating $makefile" etisserant@0: sed < $makefile_in " etisserant@0: s:SUB_CC:${CC}: greg@329: s:SUB_CXX:${CXX}: greg@329: s:SUB_LD:${LD}: etisserant@0: s:SUB_PROG_CFLAGS:${SUB_PROG_CFLAGS}: etisserant@0: s:SUB_EXE_CFLAGS:${SUB_EXE_CFLAGS}: etisserant@391: s:SUB_KERNELDIR:${SUB_KERNELDIR}: etisserant@0: s:SUB_PREFIX:${SUB_PREFIX}: etisserant@0: s:SUB_OS_NAME:${SUB_OS_NAME}: etisserant@0: s:SUB_ARCH_NAME:${SUB_ARCH_NAME}: etisserant@0: s:SUB_OPT_CFLAGS:${SUB_OPT_CFLAGS}: etisserant@0: s:SUB_TARGET:${SUB_TARGET}: etisserant@0: s:SUB_BINUTILS_PREFIX:${SUB_BINUTILS_PREFIX}: etisserant@0: s:SUB_TIMERS_DRIVER:timers_${SUB_TIMERS_DRIVER}: etisserant@0: s:SUB_CAN_DRIVER:can_${SUB_CAN_DRIVER}: etisserant@145: s:SUB_CAN_DLL_CFLAGS:${SUB_CAN_DLL_CFLAGS}: etisserant@145: s:SUB_ENABLE_DLL_DRIVERS:${SUB_ENABLE_DLL_DRIVERS}: etisserant@343: s:SUB_ENABLE_LSS:${SUB_ENABLE_LSS}: etisserant@354: s:SUB_WX:${SUB_WX}: etisserant@0: " > $makefile etisserant@0: done etisserant@0: etisserant@0: echo "All done."