]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - configure
fixed the DCF-LSS conflict
[CanFestival-3.git] / configure
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2004 Edouard TISSERRANT, Laurent BESSARD
5 # Based on Gabriel Gerhardsson's cacheprobe configure script. 
6
7 # This file is part of CanFestival, a library implementing CanOpen Stack. 
8
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
13
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
18
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
23
24 ###########################################################################
25 #                       DEFAULT CANFESTIVAL DEFINES                       #
26 ###########################################################################
27
28 # Number of can bus to use 
29 MAX_CAN_BUS_ID=1
30
31 # max bytes to transmit by SDO Put 4 if you only support expedited transfert.
32 # For a normal transfert, (usually for a string), put the maximum string size to transfer.
33 SDO_MAX_LENGTH_TRANSFERT=32
34
35 # Number of SDO from differents nodes that the node can manage concurrently.   
36 # for a slave node, usually put 1.
37 SDO_MAX_SIMULTANEOUS_TRANSFERTS=4
38
39 # Used for NMTable[bus][nodeId]   
40 # You can put less of 128 if on the netwo
41 # are connected only smaller nodeId node.
42 NMT_MAX_NODE_ID=128
43
44 #Timeout in milliseconds for SDO.
45 #    Comment the #define if not used (infinite wait for SDO response message)
46 SDO_TIMEOUT_MS=3000
47
48 MAX_NB_TIMER=32
49
50 # Generic timers declaration defaults
51 US_TO_TIMEVAL_FACTOR=
52 TIMEVAL=
53 TIMEVAL_MAX=
54
55 # Default to little-endian
56 CANOPEN_BIG_ENDIAN=
57
58 # Max number of active errors managed in error_data structure.
59 EMCY_MAX_ERRORS=8
60
61 ###########################################################################
62 #                             DEFAULT BUILD OPTIONS                       #
63 ###########################################################################
64
65 # Leave empty for automatic detection
66 CC=
67 CXX=g++
68 LD=ld
69
70 #default target
71 SUB_TARGET=
72
73 # First compiler option - we will check if it exists
74 CC1=gcc
75 # Second compiler option - we will check if it exists
76 CC2=cc
77
78 # Install prefix
79 SUB_PREFIX=
80
81 # Used for C compiler test/detection 
82 CFLAGS=
83 test=conftest
84 rm -f $test $test.c
85
86 if [ "$XENO_CONFIG" = "" ]; then
87         XENO_CONFIG=/usr/xenomai/bin/xeno-config
88 fi
89
90 ###########################################################################
91 #                          ARGUMENTS PARSING                              #
92 ###########################################################################
93 while [ $# -ge 1 ]; do
94         optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
95         
96         case $1 in
97         --cc=*)         CC=$optarg;;
98         --cxx=*)        CXX=$optarg;;
99         --ld=*)         LD=$optarg;;
100         --arch=*)       SUB_ARCH_NAME=$optarg;;
101         --os=*)         SUB_OS_NAME=$optarg;;
102         --prefix=*)     SUB_PREFIX=$optarg;;
103         --target=*)     SUB_TARGET=$optarg;;
104         --can=*)        SUB_CAN_DRIVER=$optarg;;
105         --timers=*)     SUB_TIMERS_DRIVER=$optarg;;
106         --disable-Ox)   DISABLE_OPT=1;
107                         echo "On user request: Won't optimize with \"-Ox\"";;
108         --disable-dll)  DISABLE_DLL=1;
109                         echo "On user request: Won't create and link to dll";;
110         --enable-lss)   ENABLE_LSS=1;
111                         echo "On user request: LSS services enabled";;
112         --debug=*)      DEBUG=$optarg;;
113         --MAX_CAN_BUS_ID=*)     MAX_CAN_BUS_ID=$1;;
114         --SDO_MAX_LENGTH_TRANSFERT=*)   SDO_MAX_LENGTH_TRANSFERT=$1;;
115         --SDO_MAX_SIMULTANEOUS_TRANSFERTS=*)    SDO_MAX_SIMULTANEOUS_TRANSFERTS=$1;;
116         --NMT_MAX_NODE_ID=*)    NMT_MAX_NODE_ID=$1;;
117         --SDO_TIMEOUT_MS=*)     SDO_TIMEOUT_MS=$1;;
118         --CANOPEN_BIG_ENDIAN=*) CANOPEN_BIG_ENDIAN=$1;;
119         --MAX_NB_TIMER=*) MAX_NB_TIMER=$1;;
120         --EMCY_MAX_ERRORS=*) EMCY_MAX_ERRORS=$1;;
121         --help)
122                 echo    "Usage: ./configure [options]"
123                 echo    "Options:"
124                 echo    " --cc=foo      Use C compiler 'foo' instead of defaults ${CC1} or ${CC2}."
125                 echo    " --cxx=foo     Use C++ compiler 'foo' instead of defaults g++."
126                 echo    " --ld=foo      Use linker 'foo' instead of ld."
127                 echo    " --arch=foo    Use architecture 'foo' instead of trying to autodetect."
128                 echo    " --os=foo      Use operative system 'foo' instead of trying to autodetect."
129                 echo    " --prefix=foo  Use prefix 'foo' instead of default ${SUB_PREFIX}."
130                 echo    " --target=foo  Use 'foo' as build target."
131                 echo    "               \"unix\" for unix-like systems (Linux, Cygwin)"
132                 echo    "               \"win32\" for win32 systems (native, mingw or VC++)"
133                 echo    "               \"hcs12\" for HCS12 micro-controller"
134                 echo    " --can=foo     Use 'foo' as CAN driver"
135                 echo    "               \"peak_linux\" use Linux build host installed Peak driver and library"
136                 echo    "                 see http://www.peak-system.com/linux/"
137                 echo    "               \"peak_win32\" use win32 PcanLight Peak driver and library with Cygwin" 
138                 echo    "                 see http://www.peak-system.com/themen/download_gb.html"
139                 echo    "               \"virtual\" use unix pipe based virtual can driver"
140                 echo    "               \"socket\" use socket-can  "
141                 echo    "                 see http://developer.berlios.de/projects/socketcan/"
142                 echo    "               \"lincan\" lincan driver"
143                 echo    "                 see http://www.ocera.org/download/components/WP7/lincan-0.3.3.html"
144                 echo    " --timers=foo  Use 'foo' as TIMERS driver (can be either 'unix' or 'xeno')"
145                 echo    " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers"
146                 echo    " --enable-lss  Enable the LSS services"
147                 echo    " --disable-Ox  Disable gcc \"-Ox\" optimizations."
148                 echo    " --debug=foo,foo,..   Enable debug messages, ERR -> only errors, WAR)."
149                 echo    "               \"PDO\" send errors and warnings through PDO messages"
150                 echo    "               \"ERR\" print errors only, to stdout"
151                 echo    "               \"WAR\" print errors and warnings, to stdout"
152                 echo    "               \"MSG\" print messages content, to stdout"
153                 echo
154                 echo    "Stack compilation constants"
155                 echo    " --MAX_CAN_BUS_ID [=1] Number of can bus to use"
156                 echo    " --SDO_MAX_LENGTH_TRANSFERT [=32] max bytes to transmit by SDO"
157                 echo    " --SDO_MAX_SIMULTANEOUS_TRANSFERTS [=4] Number of SDO that the node can manage concurrently"
158                 echo    " --NMT_MAX_NODE_ID [=128] can be reduced to gain memory on small network"
159                 echo    " --SDO_TIMEOUT_MS [=3000] Timeout in milliseconds for SDO (None to disable the feature)"
160                 echo    " --EMCY_MAX_ERRORS [=8] Max number of active errors managed in error_data structure"
161                 exit 0;;
162         *)              echo "Unknown argument ${1}"; exit -1;;
163         esac
164
165         shift
166 done
167
168 ###########################################################################
169 #                              GUESS OS/ARCH                              #
170 ###########################################################################
171
172 if [ "$SUB_OS_NAME" = "" ]; then
173         SUB_OS_NAME="`(uname -s | sed \"s/\//-/\" | sed \"s/_/-/\" \
174                         | sed \"s/-.*//g\") 2>&1`"
175 fi
176
177 if [ "$SUB_ARCH_NAME" = "" ]; then
178         if [ "$CC" = "" ]; then
179                 A_NAME="`(uname -m) 2>&1`"
180         else
181                 A_NAME="`$CC -dumpmachine | sed 's:-.*::'`"
182         fi
183 fi
184
185 # x86
186 if [ "$A_NAME" = "i386" -o "$A_NAME" = "i486" -o "$A_NAME" = "i586" -o "$A_NAME" = "i686" -o "$A_NAME" = "x86" ]; then
187         SUB_ARCH_NAME=x86
188 fi
189
190 # x86_64
191 if [ "$A_NAME" = "x86_64" ]; then
192         SUB_ARCH_NAME=x86_64
193 fi
194
195 # ppc
196 if [ "$A_NAME" = "powerpc" ]; then
197         SUB_ARCH_NAME=ppc
198 fi
199
200 # ppc64
201 if [ "$A_NAME" = "powerpc64" ]; then
202         SUB_ARCH_NAME=ppc64
203 fi
204
205 # arm
206 if [ "$A_NAME" = "arm" ]; then
207         SUB_ARCH_NAME=arm
208 fi
209
210 if [ "$SUB_ARCH_NAME" = "" ]; then
211         echo "Error: could not detect what architecture this system is running!"
212         echo "Please supply manually instead with \"--arch=foo\""
213         exit -1
214 fi
215
216 echo "Using OS: ${SUB_OS_NAME}"
217 echo "Using architecture: ${SUB_ARCH_NAME}"
218
219 if [ "$SUB_ARCH_NAME" = "x86_64" -a "$CC" = "gcc" ]; then
220         # Only if we are on x86_64 and using gcc
221         # For shared library generation, it needs this
222         SUB_PROG_CFLAGS=-fPIC
223 fi
224
225 if [ "$SUB_ARCH_NAME" = "ppc" -o "$SUB_ARCH_NAME" = "powerpc" ]; then
226         # PowerPC uses big endian format
227         CANOPEN_BIG_ENDIAN=1
228 fi
229
230 ###########################################################################
231 #                      DEFAULT TARGET/DRIVERS GUESSING                    #
232 ###########################################################################
233 # If target not specified, try to gess one
234 if [ "$SUB_TARGET" = "" ]; then
235         if [ "$SUB_OS_NAME" = "CYGWIN" ]; then
236                 echo "Choosing unix (cygwin) target"
237                 SUB_TARGET=unix
238         fi
239         if [ "$SUB_OS_NAME" = "Linux" ]; then
240                 echo "Choosing unix target"
241                 SUB_TARGET=unix
242         fi
243         if [ "$SUB_OS_NAME" = "MINGW32" ]; then
244                 echo "Choosing windows target"
245                 SUB_TARGET=win32
246         fi
247 fi
248
249 # Try to gess can
250 if [ "$SUB_CAN_DRIVER" = "" ]; then
251         if [ "$SUB_TARGET" = "unix" ]; then
252                 if [ -e /usr/lib/libpcan.so ]; then 
253                         echo "Choosing installed Peak driver as CAN driver."
254                         SUB_CAN_DRIVER=peak_linux
255                 elif [ "$SUB_OS_NAME" = "CYGWIN" -a "PCAN_LIB" != "" ]; then
256                         echo "Choosing installed Peak driver as CAN driver."
257                         SUB_CAN_DRIVER=peak_win32               
258                 else
259                         echo "Choosing virtual CAN driver."
260                         SUB_CAN_DRIVER=virtual
261                 fi
262         fi
263 fi
264
265 # If target is unix, default timers also
266 if [ "$SUB_TARGET" = "unix" -a "$SUB_TIMERS_DRIVER" = "" ]; then
267         echo "Choosing unix timers driver."
268         SUB_TIMERS_DRIVER=unix
269 fi
270
271 # If target is windows, default timers also
272 if [ "$SUB_TARGET" = "win32" -a "$SUB_TIMERS_DRIVER" = "" ]; then
273         echo "Choosing windows timers driver."
274         SUB_TIMERS_DRIVER=win32
275 fi
276
277 # Warn for unstalled peak driver if choosen
278 if [ "$SUB_CAN_DRIVER" = "peak" ]; then
279         if [ ! -e /usr/lib/libpcan.so ]; then 
280                 echo "Peak driver hasn't been installed !"
281                 exit -1
282         fi
283 fi
284
285 ###########################################################################
286 #              TARGET/DRIVER SPECIFIC CFLAGS and OPTIONS                  #
287 ###########################################################################
288 if [ "$SUB_TARGET" = "hcs12" ]; then
289         # Only if we want to compile for a µC HCS12
290        # it is a big endian architecture.
291        CANOPEN_BIG_ENDIAN=1
292         # search for gcc hcs12 compiler m6811-elf-gcc or m68hc12-gcc ?
293         if [ "$CC" = "" ]; then
294                 which m6811-elf-gcc >/dev/null 2>&1
295                 if (( $? )); then 
296                         which m68hc12-gcc >/dev/null 2>&1
297                         if (( $? )); then 
298                                 echo "Please use --cc flag to specify compiler"
299                                 exit 0
300                         else
301                                 CC=m68hc12-gcc 
302                         fi
303                 else
304                         CC=m6811-elf-gcc
305                         SUB_PROG_CFLAGS=-m68hc12
306                 fi
307         fi
308 fi      
309
310 if [ "$SUB_TARGET" = "win32" ]; then
311                 LD=g++
312                 SUB_PROG_CFLAGS="-mno-cygwin"
313 fi      
314
315 if [ "$SUB_TARGET" = "unix" ]; then
316                 LD=gcc
317 fi
318         
319 #### CAN_DRIVER ####
320
321 if [ "$SUB_CAN_DRIVER" = "peak_linux" ]; then
322     SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -lpcan
323 fi
324
325 PW32DIR=drivers/can_peak_win32
326 if [ "$SUB_CAN_DRIVER" = "peak_win32" ]; then
327         if [ "$PCAN_HEADER" = "" -o "PCAN_LIB" = "" ]; then
328                 echo "!!! ERROR !!! Please set PCAN_LIB PCAN_HEADER [PCAN_INCLUDE] to appropriate paths ! "
329         fi
330         SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ -liberty\ \'$PCAN_LIB\'
331         echo "Converting PcanLib header files for gcc -> $PW32DIR/cancfg.h"
332         cat $PW32DIR/cancfg.h.head $PCAN_INCLUDE/$PCAN_HEADER > $PW32DIR/cancfg.h
333         echo >> $PW32DIR/cancfg.h
334         # second port handling
335         if [ "$PCAN2_HEADER" != "" ]; then
336                 echo "Stripping down second Pcan Light header "
337                 echo >> $PW32DIR/cancfg.h
338                 echo "// Stripped PcanLight header to prevent typedef conflicts ">> $PW32DIR/cancfg.h
339                 echo >> $PW32DIR/cancfg.h
340                 grep __stdcall $PCAN_INCLUDE/$PCAN2_HEADER >> $PW32DIR/cancfg.h
341                 echo '#define PCAN2_HEADER_' >> $PW32DIR/cancfg.h
342                 SUB_CAN_DLL_CFLAGS=$SUB_CAN_DLL_CFLAGS\ \'$PCAN2_LIB\'
343         fi
344         if grep -q CANHwType $PW32DIR/cancfg.h ; then
345                 echo "Peak Init HwType, IO_Port and IRQ will be passed in environment :"
346                 echo "  PCANHwType PCANIO_Port PCANInterupt"
347                 echo '#define extra_PCAN_init_params' >> $PW32DIR/cancfg.h
348         fi
349         if ! grep -q CAN_Init $PW32DIR/cancfg.h ; then
350                 echo "Pcan Light header/lib is for second port of device only"
351                 echo "CAN_* calls redefined to CAN2_* "
352                 echo '#define CAN_Init CAN2_Init' >> $PW32DIR/cancfg.h
353                 echo '#define CAN_Read CAN2_Read' >> $PW32DIR/cancfg.h
354                 echo '#define CAN_Write CAN2_Write' >> $PW32DIR/cancfg.h
355                 echo '#define CAN_Close CAN2_Close' >> $PW32DIR/cancfg.h
356         fi
357         cat $PW32DIR/cancfg.h.tail >> $PW32DIR/cancfg.h
358 fi
359
360 if [ "$SUB_CAN_DRIVER" = "none" ]; then
361         SUB_CAN_DRIVER=
362 fi
363
364 #### TIMERS_DRIVER ####
365
366 if [ "$SUB_TIMERS_DRIVER" = "unix" ]; then
367         if [ "$SUB_OS_NAME" != "CYGWIN" ]; then
368            SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lpthread\ -lrt
369         fi
370 fi
371
372 if [ "$SUB_TIMERS_DRIVER" = "xeno" ]; then
373         SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -lnative\ -lrtdm\ -L`$XENO_CONFIG --library-dir`
374         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ `$XENO_CONFIG --xeno-cflags`
375         RTCAN_SOCKET=1
376 fi
377
378 if [ "$SUB_TIMERS_DRIVER" = "none" ]; then
379         SUB_TIMERS_DRIVER=
380 fi
381
382 ###########################################################################
383 #                              GUESS COMPILER                             #
384 ###########################################################################
385 # If CC is empty, the user wanted automatic detection
386 if [ "$CC" = "" ]; then
387         # Check for second compiler, CC2
388         cat > $test.c <<EOF
389         int main() { return 0; }
390 EOF
391         if test "`($CC2 -c $CFLAGS $test.c) 2>&1`" = ""; then
392                 DETECTCC=$CC2
393                 echo "Checking for ${CC2}... Yes."
394         else
395                 echo "Checking for ${CC2}... No."
396         fi
397         rm -f $test.c $test.o
398         
399         # Check for first compiler, CC1
400         cat > $test.c <<EOF
401         int main() { return 0; }
402 EOF
403         if test "`($CC1 -c $CFLAGS $test.c) 2>&1`" = ""; then
404                 DETECTCC=$CC1
405                 echo "Checking for ${CC1}... Yes."
406         else
407                 echo "Checking for ${CC1}... No."
408         fi
409         rm -f $test.c $test.o
410         CC=$DETECTCC
411 fi
412 # Check if we decided on a compiler after all
413 if [ "$CC" = "" ]; then
414         echo "Error: Could not find a C compiler"
415         echo "Please supply the wanted compiler"
416         exit -1
417 fi
418
419 echo "Using ${CC}"
420
421 ###########################################################################
422 #                              GUESS PREFIX's                             #
423 ###########################################################################
424
425 SUB_BINUTILS_PREFIX=`echo "$CC" | sed 's/gcc$//'`
426
427 # Guess prefix as regard cross compiling target machine
428 if [ "$SUB_PREFIX" = "" ]; then
429         $CC -dumpspecs |grep -A 1 'cross_compile'|grep -q 1
430         if (( $? )); then 
431                 SUB_PREFIX=/usr/local
432                 echo "Not cross-compiling. Will install in $SUB_PREFIX";
433         else
434                 SUB_PREFIX=/usr/`$CC -dumpmachine`
435                 echo "This is a cross-compiler. Will install in $SUB_PREFIX";                   
436         fi
437 fi
438
439 echo "Using prefix: ${SUB_PREFIX}"
440
441 ###########################################################################
442 #                   CANFESTIVAL DEFINES --> config.h                      #
443 ###########################################################################
444 # Some CONSTANTS preparation
445
446 # Create include/config.h with the relevant contents
447 rm -f include/config.h
448 echo "/* !!!!!!!!!! FILE GENERATED by configure. DO NOT EDIT !!!!!!!!!!*/" >>  include/config.h
449 echo "" >>  include/config.h
450 echo "/*"\ >>  include/config.h
451 echo "This file is part of CanFestival, a library implementing CanOpen Stack." >> include/config.h
452 echo "" >> include/config.h
453 echo "Copyright (C): Edouard TISSERANT and Francis DUPIN" >> include/config.h
454 echo "See COPYING file for copyrights details." >> include/config.h
455 echo "" >> include/config.h
456 echo "This library is free software; you can redistribute it and/or" >> include/config.h
457 echo "modify it under the terms of the GNU Lesser General Public" >> include/config.h
458 echo "License as published by the Free Software Foundation; either" >> include/config.h
459 echo "version 2.1 of the License, or (at your option) any later version." >> include/config.h
460 echo "" >> include/config.h
461 echo "This library is distributed in the hope that it will be useful," >> include/config.h
462 echo "but WITHOUT ANY WARRANTY; without even the implied warranty of" >> include/config.h
463 echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU" >> include/config.h
464 echo "Lesser General Public License for more details." >> include/config.h
465 echo "" >> include/config.h
466 echo "You should have received a copy of the GNU Lesser General Public" >> include/config.h
467 echo "License along with this library; if not, write to the Free Software" >> include/config.h
468 echo "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA" >> include/config.h
469 echo "*/" >> include/config.h
470 echo "" >> include/config.h
471 echo "#ifndef _CONFIG_H_" >> include/config.h
472 echo "#define _CONFIG_H_" >> include/config.h
473 echo "" >> include/config.h
474 for i in \
475  MAX_CAN_BUS_ID\
476  SDO_MAX_LENGTH_TRANSFERT\
477  SDO_MAX_SIMULTANEOUS_TRANSFERTS\
478  NMT_MAX_NODE_ID\
479  SDO_TIMEOUT_MS\
480  MAX_NB_TIMER\
481  CANOPEN_BIG_ENDIAN\
482  US_TO_TIMEVAL_FACTOR\
483  TIMEVAL\
484  TIMEVAL_MAX\
485  RTCAN_SOCKET\
486  EMCY_MAX_ERRORS; do
487 if [ "${!i}" = "" ]; then
488 echo "/* $i is not defined */" >> include/config.h
489 else
490 echo "#define $i ${!i}" >> include/config.h
491 fi
492 done    
493 echo "" >> include/config.h
494
495 for i in \
496  SDO_MAX_SIMULTANEOUS_TRANSFERTS\
497  NMT_MAX_NODE_ID\
498  EMCY_MAX_ERRORS; do
499         echo "#define REPEAT_"$i"_TIMES(repeat)\\">> include/config.h
500         times=${!i}
501         result=""
502         for (( j=0; j<times; j++ ));do
503                 result="$result repeat"
504         done
505         echo $result >> include/config.h
506 done
507
508 echo "#endif /* _CONFIG_H_ */" >> include/config.h
509
510 ###########################################################################
511 #                           DEBUG DEFINES/CFLAGS                          #
512 ###########################################################################
513
514 save_ifs="$IFS"; IFS=','
515
516 for DEBUG_METHOD in $DEBUG; 
517         do
518             IFS="$save_ifs"
519             case $DEBUG_METHOD in
520                 ERR)ERR=1;;
521                 WAR)WAR=1;ERR=1;;
522                 MSG)MSG=1;;
523                 PDO)PDO=1;WAR=1;ERR=1;;
524                 *)echo ""
525                   echo "$DEBUG_METHOD is not a valid debug's method"
526                   echo "Possible Debug's methods are : \"ERR\", \"WAR\", \"MSG\", \"PDO\""
527                   exit -1
528                   ;;
529         esac    
530 done
531
532 if [ $WAR ]; then
533         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_WAR_CONSOLE_ON;
534 fi
535
536 if [ $ERR ]; then
537         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_ERR_CONSOLE_ON;
538 fi
539
540 if [ $MSG ]; then
541         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_MSG_CONSOLE_ON;
542 fi
543
544 if [ $PDO ]; then
545         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_PDO_CONSOLE_ON;
546 fi
547
548 if [ $DEBUG ]; then
549         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -g
550 fi
551
552 IFS="$save_ifs"
553
554 if [ "$DISABLE_OPT" = "1" ]; then
555         SUB_OPT_CFLAGS=
556 else
557         SUB_OPT_CFLAGS=\$\(OPT_CFLAGS\)
558 fi
559
560 if [ "$DISABLE_DLL" = "1" ]; then
561         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DNOT_USE_DYNAMIC_LOADING
562         SUB_ENABLE_DLL_DRIVERS=0
563 else
564         SUB_ENABLE_DLL_DRIVERS=1
565         SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ -ldl
566 fi
567
568
569 if [ "$DISABLE_DLL" = "1" ]; then
570         SUB_EXE_CFLAGS=$SUB_EXE_CFLAGS\ $SUB_CAN_DLL_CFLAGS
571 fi
572
573 if [ $ENABLE_LSS ]; then
574         SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DCO_ENABLE_LSS;
575         SUB_ENABLE_LSS=1
576 else
577         SUB_ENABLE_LSS=0
578 fi
579
580 ###########################################################################
581 #                              CREATE MAKEFILES                           #
582 ###########################################################################
583 # General Makefiles
584 MAKEFILES=Makefile.in\
585 \ src/Makefile.in\
586 \ drivers/Makefile.in\
587 \ objdictgen/Makefile.in\
588 \ examples/Makefile.in\
589 \ objdictgen/canfestival_config.py.in
590
591 # Drivers dependent Makefiles
592 if [ "$SUB_TIMERS_DRIVER" != "" ]; then
593         MAKEFILES=$MAKEFILES\
594 \       drivers/timers_$SUB_TIMERS_DRIVER/Makefile.in
595 fi
596
597 if [ "$SUB_CAN_DRIVER" != "" ]; then
598         MAKEFILES=$MAKEFILES\
599 \       drivers/can_$SUB_CAN_DRIVER/Makefile.in
600 fi
601
602 # Target dependent Makefiles
603 MAKEFILES=$MAKEFILES\ drivers/$SUB_TARGET/Makefile.in
604
605 if [ "$SUB_TARGET" = "unix" ]; then
606         MAKEFILES=$MAKEFILES\
607 \       examples/TestMasterSlave/Makefile.in
608 fi
609
610 if [ "$SUB_TARGET" = "unix" ]; then
611         MAKEFILES=$MAKEFILES\
612 \       examples/DS401_Master/Makefile.in\
613 \       examples/DS401_Slave_Gui/Makefile.in\
614 \       examples/TestMasterMicroMod/Makefile.in
615 fi
616
617 if [ "$SUB_TARGET" = "win32" ]; then
618         MAKEFILES=$MAKEFILES\
619 \       examples/TestMasterSlave/Makefile.in\
620 \       examples/TestMasterMicroMod/Makefile.in\
621 \       examples/DS401_Master/Makefile.in\
622 \       examples/DS401_Slave_Gui/Makefile.in
623 fi
624
625 if [ "$SUB_TARGET" = "hcs12" ]; then
626         MAKEFILES=$MAKEFILES\
627 \       examples/gene_SYNC_HCS12/Makefile.in
628 fi
629
630 for makefile_in in $MAKEFILES; do
631         makefile=`echo $makefile_in | sed 's:.in$::'`
632         echo "Creating $makefile"
633         sed < $makefile_in "
634         s:SUB_CC:${CC}:
635         s:SUB_CXX:${CXX}:
636         s:SUB_LD:${LD}:
637         s:SUB_PROG_CFLAGS:${SUB_PROG_CFLAGS}:
638         s:SUB_EXE_CFLAGS:${SUB_EXE_CFLAGS}:
639         s:SUB_PREFIX:${SUB_PREFIX}:
640         s:SUB_OS_NAME:${SUB_OS_NAME}:
641         s:SUB_ARCH_NAME:${SUB_ARCH_NAME}:
642         s:SUB_OPT_CFLAGS:${SUB_OPT_CFLAGS}:
643         s:SUB_TARGET:${SUB_TARGET}:
644         s:SUB_BINUTILS_PREFIX:${SUB_BINUTILS_PREFIX}:
645         s:SUB_TIMERS_DRIVER:timers_${SUB_TIMERS_DRIVER}:
646         s:SUB_CAN_DRIVER:can_${SUB_CAN_DRIVER}:
647         s:SUB_CAN_DLL_CFLAGS:${SUB_CAN_DLL_CFLAGS}:
648         s:SUB_ENABLE_DLL_DRIVERS:${SUB_ENABLE_DLL_DRIVERS}:
649         s:SUB_ENABLE_LSS:${SUB_ENABLE_LSS}:
650         " > $makefile
651 done
652
653 echo "All done."