greg@267: #!/bin/sh 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. etisserant@0: # 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. etisserant@0: # 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: etisserant@0: ########################################################################### etisserant@0: # DEFAULT BUILD OPTIONS # etisserant@0: ########################################################################### etisserant@0: etisserant@0: # Leave empty for automatic detection etisserant@0: CC= 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@190: 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@0: --arch=*) SUB_ARCH_NAME=$optarg;; etisserant@0: --os=*) SUB_OS_NAME=$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@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@195: --debug=*) DEBUG=$optarg;; etisserant@0: --MAX_CAN_BUS_ID=*) MAX_CAN_BUS_ID=$1;; etisserant@0: --SDO_MAX_LENGTH_TRANSFERT=*) SDO_MAX_LENGTH_TRANSFERT=$1;; etisserant@0: --SDO_MAX_SIMULTANEOUS_TRANSFERTS=*) SDO_MAX_SIMULTANEOUS_TRANSFERTS=$1;; etisserant@0: --NMT_MAX_NODE_ID=*) NMT_MAX_NODE_ID=$1;; etisserant@0: --SDO_TIMEOUT_MS=*) SDO_TIMEOUT_MS=$1;; etisserant@0: --CANOPEN_BIG_ENDIAN=*) CANOPEN_BIG_ENDIAN=$1;; etisserant@0: --MAX_NB_TIMER=*) MAX_NB_TIMER=$1;; etisserant@0: --help) echo "Usage: ./configure [options]" etisserant@0: echo "Options:" etisserant@145: echo " --cc=foo Use compiler 'foo' instead of defaults ${CC1} or ${CC2}." 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@145: echo " --prefix=foo Use prefix 'foo' instead of default ${SUB_PREFIX}." etisserant@145: echo " --target=foo Use 'foo' as build target." etisserant@145: echo " \"generic\" for have independant CAN and TIMERS driver" etisserant@145: echo " \"unix\" for unix-like systems" etisserant@145: echo " \"win32\" for win32 systems" 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@145: echo " please see http://www.peak-system.com/linux/" etisserant@145: echo " \"peak_win32\" use win32 PcanLight Peak driver and library with Cygwin" etisserant@145: echo " please see http://www.peak-system.com/themen/download_gb.html" etisserant@145: echo " \"virtual\" use unix pipe based virtual can driver" etisserant@145: echo " \"socket\" use socket-can " etisserant@145: echo " please see http://developer.berlios.de/projects/socketcan/" etisserant@145: echo " \"lincan\" for HCS12 micro-controller" etisserant@145: echo " please see http://www.ocera.org/download/components/WP7/lincan-0.3.3.html" etisserant@145: echo " --timers=foo Use 'foo' as TIMERS driver (can be either 'unix' or 'xeno')" etisserant@145: echo " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers" etisserant@145: echo " --disable-Ox Disable gcc \"-Ox\" optimizations." etisserant@195: echo " --debug=foo Enable debug messages, ERR -> only errors, WAR)." etisserant@195: echo " \"PDO\" send errors and warnings through PDO messages" etisserant@195: echo " \"ERR\" errors only, to stdout" etisserant@195: echo " \"WAR\" errors and warnings, 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)" 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: if [ "$SUB_OS_NAME" = "HP" -o "$SUB_OS_NAME" = "HP-UX" ]; then etisserant@0: SUB_OS_NAME=HPUX 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@0: if [ "$A_NAME" = "i386" ]; then etisserant@0: SUB_ARCH_NAME=x86 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "i486" ]; then etisserant@0: SUB_ARCH_NAME=x86 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "i586" ]; then etisserant@0: SUB_ARCH_NAME=x86 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "i686" ]; then etisserant@0: SUB_ARCH_NAME=x86 etisserant@0: fi etisserant@0: if [ "$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: # ia64 etisserant@0: if [ "$A_NAME" = "ia64" ]; then etisserant@0: SUB_ARCH_NAME=ia64 etisserant@0: fi etisserant@0: etisserant@0: # alpha etisserant@0: if [ "$A_NAME" = "alpha" ]; then etisserant@0: SUB_ARCH_NAME=alpha etisserant@0: fi etisserant@0: etisserant@0: # parisc etisserant@0: if [ "$A_NAME" = "parisc" ]; then etisserant@0: SUB_ARCH_NAME=parisc etisserant@0: fi etisserant@0: if [ "$SUB_OS_NAME" = "HPUX" -a "$A_NAME" != "ia64" ]; then etisserant@0: # If we're on HP-UX and the architecture is *not* ia64, etisserant@0: # it's most likely parisc etisserant@0: SUB_ARCH_NAME=parisc etisserant@0: fi etisserant@0: etisserant@0: # sparc etisserant@0: if [ "$A_NAME" = "sparc" ]; then etisserant@0: SUB_ARCH_NAME=sparc etisserant@0: fi etisserant@0: if [ "$A_NAME" = "sun4u" ]; then etisserant@0: SUB_ARCH_NAME=sparc etisserant@0: fi etisserant@0: etisserant@0: # sparc64 etisserant@0: if [ "$A_NAME" = "sparc64" ]; then etisserant@0: SUB_ARCH_NAME=sparc64 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@0: # mips3 etisserant@0: if [ "$A_NAME" = "ip32" ]; then # IRIX etisserant@0: SUB_ARCH_NAME=mips3 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "ip35" ]; then # IRIX etisserant@0: SUB_ARCH_NAME=mips3 etisserant@0: fi etisserant@0: etisserant@0: # mips32 etisserant@0: if [ "$A_NAME" = "mips32" ]; then etisserant@0: SUB_ARCH_NAME=mips32 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "mips" ]; then etisserant@0: SUB_ARCH_NAME=mips32 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "MIPS" ]; then etisserant@0: SUB_ARCH_NAME=mips32 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "RISC" ]; then # MIPS Ultrix etisserant@0: SUB_ARCH_NAME=mips32 etisserant@0: fi etisserant@0: etisserant@0: # mips64 etisserant@0: if [ "$A_NAME" = "mips64" ]; then etisserant@0: SUB_ARCH_NAME=mips64 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "MIPS64" ]; then etisserant@0: SUB_ARCH_NAME=mips64 etisserant@0: fi etisserant@0: if [ "$A_NAME" = "IP64" ]; then # IRIX etisserant@0: SUB_ARCH_NAME=mips64 etisserant@0: fi etisserant@0: etisserant@0: # power etisserant@0: if [ "$A_NAME" = "power" ]; then # Manual etisserant@0: SUB_ARCH_NAME=power etisserant@0: fi etisserant@0: etisserant@0: echo "Using OS: ${SUB_OS_NAME}" etisserant@0: echo "Using architecture: ${SUB_ARCH_NAME}" etisserant@0: 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@0: if [ "$SUB_OS_NAME" = "HPUX" -a "$CC" = "gcc" ]; then etisserant@0: # Only if we are on HP-UX, ia64 and using gcc etisserant@0: SUB_PROG_CFLAGS=-mlp64 etisserant@0: fi etisserant@0: etisserant@0: if [ "$SUB_OS_NAME" = "SunOS" -a "$SUB_ARCH_NAME" = "sparc" -a "$CC" = "gcc" ]; then etisserant@0: # Only if we are on SunOS, sparc and using gcc etisserant@0: # Tells the assembler that we are dealing with a v8plusa arch sparc etisserant@0: # and -mimpure-text is needed for shared library linking etisserant@0: SUB_PROG_CFLAGS="-Wa,-xarch=v8plusa -mimpure-text" etisserant@0: fi etisserant@0: etisserant@0: if [ "$SUB_OS_NAME" = "AIX" -a "$SUB_ARCH_NAME" = "power" -a "$CC" = "gcc" ]; then etisserant@0: # Only if we are on AIX, power and using gcc etisserant@0: # The assembler may default to generating Power and PowerPC compatible etisserant@0: # code. We need to override that. etisserant@0: SUB_PROG_CFLAGS=-Wa,-mpwr etisserant@0: fi etisserant@0: etisserant@0: if [ "$SUB_OS_NAME" = "AIX" -a "$SUB_ARCH_NAME" = "ppc" -a "$CC" = "gcc" ]; then etisserant@0: # Only if we are on AIX, ppc and using gcc etisserant@0: # The assembler may default to generating Power and PowerPC compatible etisserant@0: # code. We need to override that. etisserant@0: SUB_PROG_CFLAGS=-Wa,-mppc etisserant@0: fi 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@24: # If target not specified, try to gess 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@24: # Try to gess 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@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@24: ########################################################################### etisserant@0: # TARGET/DRIVER SPECIFIC CFLAGS and OPTIONS # etisserant@0: ########################################################################### etisserant@24: if [ "$SUB_TARGET" = "generic" ]; then etisserant@24: if [ "$US_TO_TIMEVAL_FACTOR" = "" ]; then etisserant@24: US_TO_TIMEVAL_FACTOR=1 etisserant@24: fi etisserant@24: if [ "$TIMEVAL" = "" ]; then etisserant@24: TIMEVAL=UNS64 etisserant@24: fi etisserant@24: if [ "$TIMEVAL_MAX" = "" ]; then etisserant@24: TIMEVAL_MAX=0xffffffffffffffff etisserant@24: fi etisserant@24: fi etisserant@24: etisserant@0: if [ "$SUB_TARGET" = "hcs12" ]; then etisserant@0: # 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@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@41: 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@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@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@47: SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lnative\ -lrtdm\ etisserant@0: \ -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@24: if [ "$SUB_TIMERS_DRIVER" = "none" ]; then etisserant@24: SUB_TIMERS_DRIVER= etisserant@24: fi etisserant@24: etisserant@0: ########################################################################### etisserant@0: # GUESS COMPILER # 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@0: echo "Using ${CC}" etisserant@0: etisserant@0: ########################################################################### etisserant@0: # GUESS PREFIX's # etisserant@0: ########################################################################### etisserant@0: etisserant@0: SUB_BINUTILS_PREFIX=`echo "$CC" | sed 's/gcc$//'` etisserant@0: 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@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\ etisserant@47: RTCAN_SOCKET; 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\ etisserant@91: NMT_MAX_NODE_ID; 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: ########################################################################### etisserant@195: if [ "$DEBUG" = "WAR" ]; then etisserant@195: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_WAR_CONSOLE_ON\ -DDEBUG_ERR_CONSOLE_ON\ -g etisserant@195: fi etisserant@195: etisserant@195: if [ "$DEBUG" = "ERR" ]; then etisserant@195: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_ERR_CONSOLE_ON\ -g etisserant@0: fi etisserant@0: etisserant@0: if [ "$DEBUG" = "PDO" ]; then etisserant@195: SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_WAR_CONSOLE_ON\ -DDEBUG_ERR_CONSOLE_ON\ -g\ -DPDO_ERROR etisserant@0: fi 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@145: SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -ldl 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@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@0: \ examples/Makefile.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@24: if [ "$SUB_TARGET" = "unix" ]; then etisserant@24: MAKEFILES=$MAKEFILES\ etisserant@24: \ examples/TestMasterSlave/Makefile.in etisserant@24: fi etisserant@24: etisserant@166: if [ "$SUB_TARGET" = "unix" ]; then etisserant@166: MAKEFILES=$MAKEFILES\ etisserant@246: \ examples/DS401_Master/Makefile.in etisserant@246: fi etisserant@246: if [ "$SUB_TARGET" = "unix" ]; then etisserant@246: MAKEFILES=$MAKEFILES\ etisserant@246: \ examples/DS401_Slave_Gui/Makefile.in etisserant@246: fi etisserant@246: if [ "$SUB_TARGET" = "unix" ]; then etisserant@246: MAKEFILES=$MAKEFILES\ etisserant@166: \ examples/TestMasterMicroMod/Makefile.in etisserant@166: fi etisserant@166: greg@267: if [ "$SUB_TARGET" = "win32" ]; then greg@267: MAKEFILES=$MAKEFILES\ greg@267: \ examples/TestMasterSlave/Makefile.in greg@267: fi greg@267: greg@267: if [ "$SUB_TARGET" = "win32" ]; then greg@267: MAKEFILES=$MAKEFILES\ greg@267: \ examples/TestMasterMicroMod/Makefile.in greg@267: fi greg@267: 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}: etisserant@0: s:SUB_PROG_CFLAGS:${SUB_PROG_CFLAGS}: etisserant@0: s:SUB_EXE_CFLAGS:${SUB_EXE_CFLAGS}: 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@0: " > $makefile etisserant@0: done etisserant@0: etisserant@0: echo "All done."