greg@555: #! gmake
greg@555: 
greg@555: #
greg@555: # Copyright (C) 2006 Laurent Bessard
greg@555: # 
greg@555: # This file is part of canfestival, a library implementing the canopen
greg@555: # stack
greg@555: # 
greg@555: # This library is free software; you can redistribute it and/or
greg@555: # modify it under the terms of the GNU Lesser General Public
greg@555: # License as published by the Free Software Foundation; either
greg@555: # version 2.1 of the License, or (at your option) any later version.
greg@555: # 
greg@555: # This library is distributed in the hope that it will be useful,
greg@555: # but WITHOUT ANY WARRANTY; without even the implied warranty of
greg@555: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
greg@555: # Lesser General Public License for more details.
greg@555: # 
greg@555: # You should have received a copy of the GNU Lesser General Public
greg@555: # License along with this library; if not, write to the Free Software
greg@555: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
greg@555: # 
greg@555: 
greg@555: CC = SUB_CC
greg@555: CXX = SUB_CXX
greg@555: LD = SUB_LD
greg@555: OPT_CFLAGS = -O2
greg@555: CFLAGS = SUB_OPT_CFLAGS
greg@555: PROG_CFLAGS = SUB_PROG_CFLAGS
greg@555: EXE_CFLAGS = SUB_EXE_CFLAGS
greg@555: OS_NAME = SUB_OS_NAME
greg@555: ARCH_NAME = SUB_ARCH_NAME
greg@555: PREFIX = SUB_PREFIX
greg@555: TARGET = SUB_TARGET
greg@555: CAN_DRIVER = SUB_CAN_DRIVER
greg@555: TIMERS_DRIVER = SUB_TIMERS_DRIVER
greg@555: CANOPENSHELL = CANOpenShell
greg@555: 
greg@555: INCLUDES = -I../../include -I../../include/$(TARGET) -I../../include/$(CAN_DRIVER) -I../../include/$(TIMERS_DRIVER)
greg@555: 
greg@555: MASTER_OBJS = CANOpenShellMasterOD.o CANOpenShellSlaveOD.o CANOpenShell.o
greg@555: 
greg@555: OBJS = $(MASTER_OBJS) ../../src/libcanfestival.a ../../drivers/$(TARGET)/libcanfestival_$(TARGET).a
greg@555: 
greg@555: ifeq ($(TARGET),win32)
greg@555: 	CANOPENSHELL = CANOpenShell.exe
greg@555: endif
greg@555: 
greg@555: ifeq ($(TIMERS_DRIVER),timers_win32)
greg@555: 	EXE_CFLAGS =
greg@555: endif
greg@555: 
greg@555: ifeq ($(TIMERS_DRIVER),timers_xeno)
greg@555: 	PROGDEFINES = -DUSE_XENO
greg@555: endif
greg@555: 
greg@555: ifeq ($(TIMERS_DRIVER),timers_rtai)
greg@555: 	PROGDEFINES = -DUSE_RTAI
greg@555: endif
greg@555: 
greg@555: all: $(CANOPENSHELL)
greg@555: 
greg@555: ../../drivers/$(TARGET)/libcanfestival_$(TARGET).a:
greg@555: 	$(MAKE) -C ../../drivers/$(TARGET) libcanfestival_$(TARGET).a
greg@555: 
greg@555: $(CANOPENSHELL): $(OBJS)
greg@555: 	$(LD) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ $(OBJS) $(EXE_CFLAGS)
greg@555: 	mkdir -p Debug; cp $(CANOPENSHELL) Debug
greg@555: 	
greg@555: CANOpenShellOD.c: CANOpenShellOD.od
greg@555: 	$(MAKE) -C ../../objdictgen gnosis
greg@555: 	python ../../objdictgen/objdictgen.py CANOpenShellMasterOD.od CANOpenShellMasterOD.c
greg@555: 	python ../../objdictgen/objdictgen.py CANOpenShellSlaveOD.od CANOpenShellSlaveOD.c
greg@555: 
greg@555: %o: %c
greg@555: 	$(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
greg@555: 
greg@555: clean:
greg@555: 	rm -f $(MASTER_OBJS)
greg@555: 	rm -f $(CANOPENSHELL)
greg@555: 		
greg@555: mrproper: clean
greg@555: 	rm -f CANOpenShellMasterOD.c
greg@555: 	rm -f CANOpenShellSlaveOD.c
greg@555: