greg@275: #!/bin/bash
etisserant@0: 
etisserant@0: #
etisserant@0: # Copyright (C) 2004 Edouard TISSERRANT, Laurent BESSARD
edouard@629: # Based on Gabriel Gerhardsson's cacheprobe configure script.
edouard@629: #
edouard@629: # This file is part of CanFestival, a library implementing CanOpen Stack.
edouard@629: #
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.
edouard@629: #
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.
edouard@629: #
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
edouard@629: #
etisserant@0: 
etisserant@0: ###########################################################################
etisserant@0: #                       DEFAULT CANFESTIVAL DEFINES                       #
etisserant@0: ###########################################################################
etisserant@0: 
edouard@629: # Number of can bus to use
greg@267: MAX_CAN_BUS_ID=1
etisserant@0: 
JaFojtik@694: # max bytes to transmit by SDO Put 4 if you only support expedited transfer.
JaFojtik@694: #For a normal transfer, (usually for a string), put the maximum string size to transfer.
JaFojtik@694: SDO_MAX_LENGTH_TRANSFER=32
JaFojtik@694: 
JaFojtik@694: # For block transfer, number of segments transmitted at once.
fbeaulier@664: # SDO_BLOCK_SIZE CAN frames must fit into the CAN Tx buffer
fbeaulier@664: SDO_BLOCK_SIZE=16
fbeaulier@664: 
edouard@629: # Number of SDO from differents nodes that the node can manage concurrently.
groke6@360: #for a slave node, usually put 1.
JaFojtik@694: SDO_MAX_SIMULTANEOUS_TRANSFERS=4
etisserant@0: 
edouard@629: # 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: #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: 
edouard@629: # 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: 
greg@454: if [ "$RTAI_CONFIG" = "" ]; then
greg@454: 	RTAI_CONFIG=/usr/realtime/bin/rtai-config
greg@454: fi
greg@454: 
etisserant@0: ###########################################################################
etisserant@0: #                          ARGUMENTS PARSING                              #
etisserant@0: ###########################################################################
etisserant@0: while [ $# -ge 1 ]; do
etisserant@0: 	optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
edouard@629: 
etisserant@0: 	case $1 in
etisserant@0: 	--cc=*)		CC=$optarg;;
etisserant@341: 	--cxx=*)	CXX=$optarg;;
etisserant@341: 	--ld=*)		LD=$optarg;;
etisserant@473: 	--binutils=*)   BINUTILS_PREFIX=$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;;
JaFojtik@694: 	--SDO_MAX_LENGTH_TRANSFER=*)	SDO_MAX_LENGTH_TRANSFER=$optarg;;
fbeaulier@664: 	--SDO_BLOCK_SIZE=*)	SDO_BLOCK_SIZE=$optarg;;
JaFojtik@694: 	--SDO_MAX_SIMULTANEOUS_TRANSFERS=*)	SDO_MAX_SIMULTANEOUS_TRANSFERS=$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"
edouard@629: 		echo	"               \"anagate_linux\" use AnaGate CAN(duo) driver for linux"
edouard@629: 		echo	"               \"anagate_win32\" use AnaGate CAN(duo) driver for win32"
etisserant@145: 		echo	"               \"peak_linux\" use Linux build host installed Peak driver and library"
etisserant@341: 		echo	"                 see http://www.peak-system.com/linux/"
edouard@629: 		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"
edouard@629: 		echo	"               \"copcican_linux\" user space driver interface for CO-PCICAN card"
edouard@629: 		echo	"                 see http://www.cosateq.com/"
edouard@629: 		echo	"               \"copcican_comedi\" COMEDI driver interface for CO-PCICAN card"
edouard@629: 		echo	"                 see http://www.cosateq.com/"
edouard@629: 		echo 	" --timers=foo  Use 'foo' as TIMERS driver (can be 'unix', 'xeno', 'rtai', 'kernel' or 'kernel_xeno')"
etisserant@473: 		echo 	" --wx=foo      Force result of WxWidgets detection (0 or 1)"
etisserant@473: 		echo 	" --binutils=path   Override binutils path detection (as regards \$CC content)"
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"
JaFojtik@694: 		echo	" --SDO_MAX_LENGTH_TRANSFER [=32] max bytes to transmit by SDO"
JaFojtik@694: 		echo	" --SDO_BLOCK_SIZE [=16] max CAN frames transmitted at once for block transfer"
JaFojtik@694: 		echo	" --SDO_MAX_SIMULTANEOUS_TRANSFERS [=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@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
edouard@629: 		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."
edouard@629: 			SUB_CAN_DRIVER=peak_win32
edouard@629: 		elif [ -e /usr/lib/libcanlib.so ]; then
etisserant@400: 			echo "Choosing installed Kvaser driver as CAN driver. (unix)"
etisserant@400: 			SUB_CAN_DRIVER=kvaser
edouard@629: 		elif [ -e /usr/local/lib/libAnaGateAPIDLL.so ]; then
greg@494: 			echo "Choosing installed AnaGate driver as CAN driver. (unix)"
greg@494: 			SUB_CAN_DRIVER=anagate_linux
edouard@629: 		elif [ -e /usr/local/lib/libcanfestival_can_copcican_linux.so ]; then
edouard@629: 			echo "Choosing installed CO-PCICAN driver as CAN driver. (unix)"
edouard@629: 			SUB_CAN_DRIVER=copcican_linux
edouard@629: 		elif [ -e /usr/local/lib/libcanfestival_can_copcican_comedi.so ]; then
edouard@629: 			echo "Choosing installed CO-PCICAN driver as CAN driver. (unix)"
edouard@629: 			SUB_CAN_DRIVER=copcican_comedi
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
edouard@629: 	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: 
greg@494: # Warn for unstalled peak driver if choosen
greg@494: if [ "$SUB_CAN_DRIVER" = "anagate_linux" ]; then
edouard@629: 	if [ ! -e /usr/local/lib/libAnaGateAPIDLL.so ]; then
greg@494: 		echo "AnaGateCAN driver hasn't been installed !"
greg@494: 		exit -1
greg@494: 	fi
greg@494: fi
greg@494: 
edouard@629: # Warn for unstalled CO-PCICAN driver if choosen
edouard@629: if [ "$SUB_CAN_DRIVER" = "copcican_linux" ]; then
edouard@629: 	if [ ! -e /usr/local/lib/libcanfestival_can_copcican_linux.so ]; then
edouard@629: 		echo "CO-PCICAN driver hasn't been installed !"
edouard@629: 		exit -1
edouard@629: 	fi
edouard@629: fi
edouard@629: 
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
edouard@629:         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
edouard@629:         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
edouard@629: 		if (( $? )); then
etisserant@0: 			which m68hc12-gcc >/dev/null 2>&1
edouard@629: 			if (( $? )); then
etisserant@0: 				echo "Please use --cc flag to specify compiler"
etisserant@0: 				exit 0
etisserant@0: 			else
edouard@629: 				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
edouard@629: 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
edouard@629:     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: 
greg@494: if [ "$SUB_CAN_DRIVER" = "anagate_linux" ]; then
greg@494:     SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lAnaGateAPIDLL
greg@494:     SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lAnaCommon
greg@494: fi
greg@494: 
greg@494: 
greg@455: if [ "$SUB_CAN_DRIVER" = "vscom" ]; then
hacking@674:     if  [ "$SUB_OS_NAME" = "Linux" ]; then
hacking@674: 	if [ "$SUB_ARCH_NAME" = "x86" ]; then
hacking@674: 	    SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -LLinux\ -lvs_can_api
hacking@674:         elif [ "$SUB_ARCH_NAME" = "x86_64" ]; then
hacking@674: 	    SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -L\'Linux\ x86-64\'\ -lvs_can_api_x86-64
hacking@674: 	else
hacking@674: 	    echo "!!! ERROR !!! Please adapt the configure script for your SUB_ARCH_NAME" $SUB_ARCH_NAME
hacking@674:         fi
hacking@674:     else
hacking@674: 	echo "!!! ERROR !!! Please adapt the configure script for your SUB_OS_NAME" $SUB_OS_NAME
hacking@674:     fi
greg@455: fi
greg@455: 
greg@494: if [ "$SUB_CAN_DRIVER" = "anagate_win32" ]; then
greg@494:     SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lAnaGateCan
greg@494: fi
greg@494: 
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
greg@564: 		echo '#define CAN_ReadEx CAN2_ReadEx' >> $PW32DIR/cancfg.h
greg@564: 		echo '#define CAN_SetRcvEvent CAN2_SetRcvEvent' >> $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
greg@403: 	RT_LIB_DIR=`$XENO_CONFIG --library-dir`\ -Wl,-rpath\ `$XENO_CONFIG --library-dir`
etisserant@412:     SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ `$XENO_CONFIG --xeno-ldflags`\ -L$RT_LIB_DIR\ -lnative\ -lrtdm
greg@454: 	SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DUSE_XENO\ `$XENO_CONFIG --xeno-cflags`
greg@454:     RTCAN_SOCKET=1
greg@454: fi
greg@454: 
greg@454: if [ "$SUB_TIMERS_DRIVER" = "rtai" ]; then
greg@454: 	RT_LIB_DIR=`$RTAI_CONFIG --library-dir`\ -Wl,-rpath\ `$RTAI_CONFIG --library-dir`
greg@454:     SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ `$RTAI_CONFIG --lxrt-ldflags`\ -L$RT_LIB_DIR\ -llxrt\ -lrtdm
greg@454: 	SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DUSE_RTAI\ `$RTAI_CONFIG --lxrt-cflags`
greg@403:     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: 
edouard@629: if [ "$SUB_TIMERS_DRIVER" = "kernel_xeno" ]; then
edouard@629: 	DISABLE_DLL=1
edouard@629: 	if [ "$SUB_KERNELDIR" = "" ]; then
edouard@629: 		# use directory of current kernel
edouard@629: 		SUB_KERNELDIR=/lib/modules/$(uname -r)/build
edouard@629: 	fi
edouard@629: 
edouard@629: 	# Also get the xenomai config
edouard@629: 	RT_LIB_DIR=`$XENO_CONFIG --library-dir`\ -Wl,-rpath\ `$XENO_CONFIG --library-dir`
edouard@629:     SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ `$XENO_CONFIG --xeno-ldflags`\ -L$RT_LIB_DIR\ -lnative\ -lrtdm
edouard@629: 	SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DUSE_XENO\ `$XENO_CONFIG --xeno-cflags`
edouard@629:     RTCAN_SOCKET=1
edouard@629: fi
edouard@629: 
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 <<EOF
etisserant@0: 	int main() { return 0; }
etisserant@0: EOF
etisserant@0: 	if test "`($CC2 -c $CFLAGS $test.c) 2>&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
edouard@629: 
etisserant@0: 	# Check for first compiler, CC1
etisserant@0: 	cat > $test.c <<EOF
etisserant@0: 	int main() { return 0; }
etisserant@0: EOF
etisserant@0: 	if test "`($CC1 -c $CFLAGS $test.c) 2>&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: 
lbessard@511: if [ "$SUB_ARCH_NAME" = "x86_64" -a "$CC" = "gcc" ]; then
lbessard@511: 	# Only if we are on x86_64 and using gcc
lbessard@511: 	# For shared library generation, it needs this
hacking@673: 	SUB_PROG_CFLAGS+=\ -fPIC
lbessard@511: fi
lbessard@511: 
etisserant@473: if [ "$BINUTILS_PREFIX" = "" ]; then
etisserant@473: 	SUB_BINUTILS_PREFIX=`echo "$CC" | sed 's/gcc$//'`
etisserant@473: else
etisserant@473: 	SUB_BINUTILS_PREFIX=$BINUTILS_PREFIX
etisserant@473: fi
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
edouard@629: fi
etisserant@354: 
etisserant@354: if [ "$SUB_TARGET" = "unix" ]; then
etisserant@354: 	if [ "$LD" = "" ]; then
Edouard@693: 		LD=$CXX
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
edouard@629: 	if (( $? )); then
etisserant@0: 		SUB_PREFIX=/usr/local
etisserant@0: 		echo "Not cross-compiling. Will install in $SUB_PREFIX";
etisserant@0: 	else
edouard@619: 		SUB_PREFIX=/usr/`$CC -dumpmachine | tr -d '\r\n'`
edouard@629: 		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 <<EOF
etisserant@354: #include "wx/wx.h"
etisserant@354: class MyApp : public wxApp
etisserant@354: {
etisserant@354: };
etisserant@354: IMPLEMENT_APP(MyApp)
etisserant@354: EOF
etisserant@398: 		if $CXX /tmp/wx_test.cpp `wx-config --cxxflags` `wx-config --libs` -o /tmp/wx_test >/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\
JaFojtik@694:  SDO_MAX_LENGTH_TRANSFER\
fbeaulier@664:  SDO_BLOCK_SIZE\
JaFojtik@694:  SDO_MAX_SIMULTANEOUS_TRANSFERS\
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
edouard@629: done
etisserant@0: echo "" >> include/config.h
etisserant@91: 
etisserant@91: for i in \
JaFojtik@694:  SDO_MAX_SIMULTANEOUS_TRANSFERS\
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<times; j++ ));do
etisserant@91: 		result="$result repeat"
etisserant@91: 	done
etisserant@91: 	echo $result >> 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: 
edouard@629: 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: 	    	  ;;
edouard@629: 	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
edouard@629: 
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
edouard@618: if [ "$SUB_TARGET" != "none" ]; then
edouard@618:     MAKEFILES=$MAKEFILES\ drivers/$SUB_TARGET/Makefile.in
edouard@618: fi
etisserant@24: 
etisserant@391: if [ "$SUB_TARGET" = "unix" -a "$SUB_TIMERS_DRIVER" = "kernel" ]; then
etisserant@391: 	MAKEFILES=$MAKEFILES\
edouard@629: \	examples/kerneltest/Makefile.in\
edouard@629: \	examples/test_copcican_comedi/Makefile.in
edouard@629: 
edouard@629: elif [ "$SUB_TARGET" = "unix" -a "$SUB_TIMERS_DRIVER" = "kernel_xeno" ]; then
edouard@629: 	MAKEFILES=$MAKEFILES\
edouard@629: \	examples/kerneltest/Makefile.in\
edouard@629: \	examples/test_copcican_comedi/Makefile.in
etisserant@391: 
etisserant@391: elif [ "$SUB_TARGET" = "unix" ]; then
etisserant@24: 	MAKEFILES=$MAKEFILES\
greg@555: \	examples/CANOpenShell/Makefile.in\
groke6@381: \	examples/TestMasterSlave/Makefile.in\
etisserant@391: \	examples/TestMasterSlaveLSS/Makefile.in\
etisserant@400: \	examples/SillySlave/Makefile.in\
edouard@629: \	examples/TestMasterMicroMod/Makefile.in\
edouard@629: \	examples/test_copcican_linux/Makefile.in
etisserant@166: fi
etisserant@166: 
greg@267: if [ "$SUB_TARGET" = "win32" ]; then
greg@267: 	MAKEFILES=$MAKEFILES\
greg@555: \	examples/CANOpenShell/Makefile.in\
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."