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