--- a/configure Fri Dec 07 18:22:41 2007 +0100
+++ b/configure Sat Dec 08 15:01:14 2007 +0100
@@ -64,6 +64,8 @@
# Leave empty for automatic detection
CC=
+CXX=g++
+LD=ld
#default target
SUB_TARGET=
@@ -136,10 +138,11 @@
echo " --timers=foo Use 'foo' as TIMERS driver (can be either 'unix' or 'xeno')"
echo " --disable-dll Disable run-time dynamic linking of can, led and nvram drivers"
echo " --disable-Ox Disable gcc \"-Ox\" optimizations."
- echo " --debug=foo Enable debug messages, ERR -> only errors, WAR)."
+ echo " --debug=foo,foo,.. Enable debug messages, ERR -> only errors, WAR)."
echo " \"PDO\" send errors and warnings through PDO messages"
- echo " \"ERR\" errors only, to stdout"
- echo " \"WAR\" errors and warnings, to stdout"
+ echo " \"ERR\" print errors only, to stdout"
+ echo " \"WAR\" print errors and warnings, to stdout"
+ echo " \"MSG\" print messages content, to stdout"
echo
echo "Stack compilation constants"
echo " --MAX_CAN_BUS_ID [=1] Number of can bus to use"
@@ -421,6 +424,11 @@
fi
fi
+if [ "$SUB_TARGET" = "win32" ]; then
+ LD=g++
+ SUB_PROG_CFLAGS="-mno-cygwin"
+fi
+
#### CAN_DRIVER ####
if [ "$SUB_CAN_DRIVER" = "peak_linux" ]; then
@@ -607,17 +615,46 @@
###########################################################################
# DEBUG DEFINES/CFLAGS #
###########################################################################
-if [ "$DEBUG" = "WAR" ]; then
- SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_WAR_CONSOLE_ON\ -DDEBUG_ERR_CONSOLE_ON\ -g
-fi
-
-if [ "$DEBUG" = "ERR" ]; then
- SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_ERR_CONSOLE_ON\ -g
-fi
-
-if [ "$DEBUG" = "PDO" ]; then
- SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_WAR_CONSOLE_ON\ -DDEBUG_ERR_CONSOLE_ON\ -g\ -DPDO_ERROR
-fi
+
+save_ifs="$IFS"; IFS=','
+
+for DEBUG_METHOD in $DEBUG;
+ do
+ IFS="$save_ifs"
+ case $DEBUG_METHOD in
+ ERR)ERR=1;;
+ WAR)WAR=1;ERR=1;;
+ MSG)MSG=1;;
+ PDO)PDO=1;WAR=1;ERR=1;;
+ *)echo ""
+ echo "$DEBUG_METHOD is not a valid debug's method"
+ echo "Possible Debug's methods are : \"ERR\", \"WAR\", \"MSG\", \"PDO\""
+ exit -1
+ ;;
+ esac
+done
+
+if [ $WAR ]; then
+ SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_WAR_CONSOLE_ON;
+fi
+
+if [ $ERR ]; then
+ SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_ERR_CONSOLE_ON;
+fi
+
+if [ $MSG ]; then
+ SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_MSG_CONSOLE_ON;
+fi
+
+if [ $PDO ]; then
+ SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -DDEBUG_PDO_CONSOLE_ON;
+fi
+
+if [ $DEBUG ]; then
+ SUB_PROG_CFLAGS=$SUB_PROG_CFLAGS\ -g
+fi
+
+IFS="$save_ifs"
if [ "$DISABLE_OPT" = "1" ]; then
SUB_OPT_CFLAGS=
@@ -670,27 +707,18 @@
if [ "$SUB_TARGET" = "unix" ]; then
MAKEFILES=$MAKEFILES\
-\ examples/DS401_Master/Makefile.in
-fi
-if [ "$SUB_TARGET" = "unix" ]; then
- MAKEFILES=$MAKEFILES\
-\ examples/DS401_Slave_Gui/Makefile.in
-fi
-if [ "$SUB_TARGET" = "unix" ]; then
- MAKEFILES=$MAKEFILES\
+\ examples/DS401_Master/Makefile.in\
+\ examples/DS401_Slave_Gui/Makefile.in\
\ examples/TestMasterMicroMod/Makefile.in
fi
if [ "$SUB_TARGET" = "win32" ]; then
MAKEFILES=$MAKEFILES\
-\ examples/TestMasterSlave/Makefile.in
-fi
-
-if [ "$SUB_TARGET" = "win32" ]; then
- MAKEFILES=$MAKEFILES\
-\ examples/TestMasterMicroMod/Makefile.in
-fi
-
+\ examples/TestMasterSlave/Makefile.in\
+\ examples/TestMasterMicroMod/Makefile.in\
+\ examples/DS401_Master/Makefile.in\
+\ examples/DS401_Slave_Gui/Makefile.in
+fi
if [ "$SUB_TARGET" = "hcs12" ]; then
MAKEFILES=$MAKEFILES\
@@ -702,6 +730,8 @@
echo "Creating $makefile"
sed < $makefile_in "
s:SUB_CC:${CC}:
+ s:SUB_CXX:${CXX}:
+ s:SUB_LD:${LD}:
s:SUB_PROG_CFLAGS:${SUB_PROG_CFLAGS}:
s:SUB_EXE_CFLAGS:${SUB_EXE_CFLAGS}:
s:SUB_PREFIX:${SUB_PREFIX}:
--- a/drivers/can_peak_win32/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/drivers/can_peak_win32/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -22,6 +22,8 @@
#
CC = SUB_CC
+CXX = SUB_CXX
+LD = SUB_LD
OPT_CFLAGS = -O2
CFLAGS = SUB_OPT_CFLAGS
PROG_CFLAGS = SUB_PROG_CFLAGS
@@ -53,7 +55,7 @@
$(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
cyg$(CAN_DRIVER).dll: $(OBJS)
- $(CC) -shared -o $@ \
+ $(LD) $(PROG_CFLAGS) -shared -o $@ \
-Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--whole-archive $< \
--- a/drivers/can_peak_win32/can_peak_win32.c Fri Dec 07 18:22:41 2007 +0100
+++ b/drivers/can_peak_win32/can_peak_win32.c Sat Dec 08 15:01:14 2007 +0100
@@ -71,13 +71,13 @@
{
int baudrate;
-//#ifdef PCAN2_HEADER_
+#ifdef PCAN2_HEADER_
// if not the first handler
if(second_board == (s_BOARD *)board)
if(baudrate = TranslateBaudeRate(board->baudrate))
CAN2_Init (baudrate,
CAN_INIT_TYPE_ST extra_PCAN_init_params);
-//#endif
+#endif
if(first_board == (s_BOARD *)board)
if(baudrate = TranslateBaudeRate(board->baudrate))
CAN_Init (baudrate,
@@ -209,21 +209,25 @@
{
char busname[64];
char* pEnd;
-
+
//printf ("Board Busname=%d.\n",strtol(board->busname, &pEnd,0));
if (strtol(board->busname, &pEnd,0) == 0)
{
first_board = board;
printf ("First Board selected\n");
+ canInit(board);
+ return (CAN_HANDLE)board;
}
+ #ifdef PCAN2_HEADER_
if (strtol(board->busname, &pEnd,0) == 1)
{
- second_board = board;
- printf ("Second Board selected\n");
+ second_board = board;
+ printf ("Second Board selected\n");
+ canInit(board);
+ return (CAN_HANDLE)board;
}
- canInit(board);
-
- return (CAN_HANDLE)board;
+ #endif
+ return NULL;
}
/***************************************************************************/
--- a/drivers/timers_win32/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/drivers/timers_win32/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -21,7 +21,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-CC = mingw32-g++
+CC = SUB_CC
+CXX = SUB_CXX
+LD = SUB_LD
OPT_CFLAGS = -O2
CFLAGS = SUB_OPT_CFLAGS
PROG_CFLAGS = SUB_PROG_CFLAGS
@@ -45,7 +47,7 @@
driver: $(OBJS)
%o: %cpp
- $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
+ $(CXX) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
install:
mkdir -p $(PREFIX)/include/canfestival
--- a/drivers/win32/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/drivers/win32/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -21,7 +21,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-CC = mingw32-g++
+CC = SUB_CC
+CXX = SUB_CXX
+LD = SUB_LD
OPT_CFLAGS = -O2
CFLAGS = SUB_OPT_CFLAGS
PROG_CFLAGS = SUB_PROG_CFLAGS
@@ -52,7 +54,7 @@
%o: %cpp
- $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
+ $(CXX) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
#../$(TIMERS_DRIVER)/$(TIMERS_DRIVER).o:
# $(MAKE) -C ../$(TIMERS_DRIVER) driver
--- a/examples/DS401_Master/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/DS401_Master/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -22,6 +22,8 @@
#
CC = SUB_CC
+CXX = SUB_CXX
+LD = SUB_LD
OPT_CFLAGS = -O2
CFLAGS = SUB_OPT_CFLAGS
PROG_CFLAGS = SUB_PROG_CFLAGS
@@ -50,7 +52,7 @@
DS401_Master: TestMaster.c $(OBJS)
- $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) $(EXE_CFLAGS)
+ $(LD) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) $(EXE_CFLAGS)
TestMaster.c: TestMaster.od
--- a/examples/DS401_Slave_Gui/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/DS401_Slave_Gui/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -22,6 +22,8 @@
#
CC = SUB_CC
+CXX = SUB_CXX
+LD = SUB_LD
OPT_CFLAGS = -O2
CFLAGS = SUB_OPT_CFLAGS
PROG_CFLAGS = SUB_PROG_CFLAGS
@@ -33,15 +35,9 @@
CAN_DRIVER = SUB_CAN_DRIVER
TIMERS_DRIVER = SUB_TIMERS_DRIVER
-
-# Détermine le nom du fichier exécutable.
EXEC = main
-# Détermine la liste des fichiers sources.
SRCS = $(wildcard *.cpp)
-# Détermine le nom du fichier qui contiendra les dépendances.
DEPFILE = .depend
-# Construit la liste des fichiers temporaires à partir de la liste des fichiers
-# sources.
CPP_OBJS = $(SRCS:%.cpp=%.o)
@@ -61,8 +57,7 @@
DS401_Slave_Gui: ObjDict.c $(OBJS) $(CPP_OBJS)
- $(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) `wx-config --libs` $(OBJS) $(CPP_OBJS) $(EXE_CFLAGS) -o $@
-
+ $(LD) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) $(OBJS) $(CPP_OBJS) $(EXE_CFLAGS) `wx-config --libs` -o $@
%o: %c
$(CC) -c $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) $< -o $@
@@ -71,7 +66,7 @@
python ../../objdictgen/objdictgen.py ObjDict.od ObjDict.c
.cpp.o:
- g++ -c $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) `wx-config --cxxflags` $< -o $@
+ $(CXX) -c $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) `wx-config --cxxflags` $< -o $@
clean:
rm -f $(MASTER_OBJS)
@@ -91,7 +86,7 @@
rm -f $(PREFIX)/bin/DS401_Slave_Gui
$(EXEC): $(OBJS)
- g++ $(OBJS) `wx-config --libs` -o $(EXEC)
+ $(LD) $(OBJS) `wx-config --libs` -o $(EXEC)
-include $(DEPFILE)
--- a/examples/DS401_Slave_Gui/TestSlaveGui.cpp Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/DS401_Slave_Gui/TestSlaveGui.cpp Sat Dec 08 15:01:14 2007 +0100
@@ -28,15 +28,6 @@
#if defined(WIN32) && !defined(__CYGWIN__)
#include <windows.h>
-
- extern "C" {
- #include "getopt.h"
- }
-
- void pause(void)
- {
- system("PAUSE");
- }
#else
#include <stdio.h>
#include <string.h>
--- a/examples/DS401_Slave_Gui/TestSlaveGui.h Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/DS401_Slave_Gui/TestSlaveGui.h Sat Dec 08 15:01:14 2007 +0100
@@ -1,9 +1,12 @@
#ifndef TESTSLAVEGUI_H_
#define TESTSLAVEGUI_H_
+extern "C"
+ {
#include "canfestival.h"
+ }
- int main_can(s_BOARD SlaveBoard, char* LibraryPath);
- void stop_slave();
+int main_can(s_BOARD SlaveBoard, char* LibraryPath);
+void stop_slave();
#endif /*TESTSLAVEGUI_H_*/
--- a/examples/DS401_Slave_Gui/getopt.h Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/DS401_Slave_Gui/getopt.h Sat Dec 08 15:01:14 2007 +0100
@@ -147,7 +147,7 @@
`getopt'. */
#if (defined __STDC__ && __STDC__) || defined __cplusplus
-# ifdef __GNU_LIBRARY__
+# if (defined __GNU_LIBRARY__ || __CYGWIN__ || __MINGW32__)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
--- a/examples/DS401_Slave_Gui/main.cpp Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/DS401_Slave_Gui/main.cpp Sat Dec 08 15:01:14 2007 +0100
@@ -16,6 +16,13 @@
//#include "monicone.xpm"
+#if defined(WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+extern "C" {
+ #include "getopt.h"
+}
+#endif
+
#include "main.h"
#include "TestSlaveGui.h"
extern "C" {
--- a/examples/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -30,15 +30,15 @@
ifeq ($(TARGET),unix)
$(MAKE) -C TestMasterSlave $@
-# $(MAKE) -C DS401_Master $@
-# $(MAKE) -C DS401_Slave_Gui $@
+ $(MAKE) -C DS401_Master $@
+ $(MAKE) -C DS401_Slave_Gui $@
$(MAKE) -C TestMasterMicroMod $@
endif
ifeq ($(TARGET),win32)
$(MAKE) -C TestMasterSlave $@
-# $(MAKE) -C DS401_Master $@
-# $(MAKE) -C DS401_Slave_Gui $@
+ $(MAKE) -C DS401_Master $@
+ $(MAKE) -C DS401_Slave_Gui $@
$(MAKE) -C TestMasterMicroMod $@
endif
@@ -49,15 +49,15 @@
ifeq ($(TARGET),unix)
$(MAKE) -C TestMasterSlave $@
-# $(MAKE) -C DS401_Master $@
-# $(MAKE) -C DS401_Slave_Gui $@
+ $(MAKE) -C DS401_Master $@
+ $(MAKE) -C DS401_Slave_Gui $@
$(MAKE) -C TestMasterMicroMod $@
endif
ifeq ($(TARGET),win32)
$(MAKE) -C TestMasterSlave $@
-# $(MAKE) -C DS401_Master $@
-# $(MAKE) -C DS401_Slave_Gui $@
+ $(MAKE) -C DS401_Master $@
+ $(MAKE) -C DS401_Slave_Gui $@
$(MAKE) -C TestMasterMicroMod $@
endif
@@ -70,15 +70,15 @@
install:
ifeq ($(TARGET),unix)
$(MAKE) -C TestMasterSlave $@
-# $(MAKE) -C DS401_Master $@
-# $(MAKE) -C DS401_Slave_Gui $@
+ $(MAKE) -C DS401_Master $@
+ $(MAKE) -C DS401_Slave_Gui $@
$(MAKE) -C TestMasterMicroMod $@
endif
uninstall:
ifeq ($(TARGET),unix)
$(MAKE) -C TestMasterSlave $@
-# $(MAKE) -C DS401_Master $@
-# $(MAKE) -C DS401_Slave_Gui $@
+ $(MAKE) -C DS401_Master $@
+ $(MAKE) -C DS401_Slave_Gui $@
$(MAKE) -C TestMasterMicroMod $@
endif
--- a/examples/TestMasterMicroMod/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/TestMasterMicroMod/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -22,6 +22,8 @@
#
CC = SUB_CC
+CXX = SUB_CXX
+LD = SUB_LD
OPT_CFLAGS = -O2
CFLAGS = SUB_OPT_CFLAGS
PROG_CFLAGS = SUB_PROG_CFLAGS
@@ -51,14 +53,14 @@
PROGDEFINES = -DUSE_XENO
endif
-all: TestMasterMicroMod
+all: $(TESTMASTERMICROMOD)
../../drivers/$(TARGET)/libcanfestival_$(TARGET).a:
$(MAKE) -C ../../drivers/$(TARGET) libcanfestival_$(TARGET).a
-TestMasterMicroMod: TestMaster.c $(OBJS)
- g++ $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) $(EXE_CFLAGS)
+$(TESTMASTERMICROMOD): $(OBJS)
+ $(LD) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) $(EXE_CFLAGS)
TestMaster.c: TestMaster.od
--- a/examples/TestMasterSlave/Makefile.in Fri Dec 07 18:22:41 2007 +0100
+++ b/examples/TestMasterSlave/Makefile.in Sat Dec 08 15:01:14 2007 +0100
@@ -22,6 +22,8 @@
#
CC = SUB_CC
+CXX = SUB_CXX
+LD = SUB_LD
OPT_CFLAGS = -O2
CFLAGS = SUB_OPT_CFLAGS
PROG_CFLAGS = SUB_PROG_CFLAGS
@@ -52,14 +54,14 @@
PROGDEFINES = -DUSE_XENO
endif
-all: TestMasterSlave
+all: $(TESTMASTERSLAVE)
../../drivers/$(TARGET)/libcanfestival_$(TARGET).a:
$(MAKE) -C ../../drivers/$(TARGET) libcanfestival_$(TARGET).a
-TestMasterSlave: TestSlave.c TestMaster.c $(OBJS)
- g++ $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) $(EXE_CFLAGS)
+$(TESTMASTERSLAVE): $(OBJS)
+ $(LD) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) $(EXE_CFLAGS)
TestSlave.c: TestSlave.od
$(MAKE) -C ../../objdictgen gnosis
--- a/include/unix/canfestival.h Fri Dec 07 18:22:41 2007 +0100
+++ b/include/unix/canfestival.h Sat Dec 08 15:01:14 2007 +0100
@@ -9,13 +9,9 @@
#include "can_driver.h"
#include "data.h"
#include "timers_driver.h"
-#ifdef WIN32
-#include <windows.h>
-typedef HINSTANCE LIB_HANDLE;
-#else
+
#include <dlfcn.h>
typedef void* LIB_HANDLE;
-#endif
UNS8 UnLoadCanDriver(LIB_HANDLE handle);
LIB_HANDLE LoadCanDriver(char* driver_name);
--- a/include/win32/canfestival.h Fri Dec 07 18:22:41 2007 +0100
+++ b/include/win32/canfestival.h Sat Dec 08 15:01:14 2007 +0100
@@ -26,6 +26,7 @@
#include "timerscfg.h"
#include "can_driver.h"
#include "data.h"
+#include "timers_driver.h"
#include <windows.h>
typedef HINSTANCE LIB_HANDLE;