greg@494: #! gmake
greg@494: 
greg@494: #
greg@494: # Copyright (C) 2006 Edouard TISSERANT
greg@494: # 
greg@494: # This file is part of canfestival, a library implementing the canopen
greg@494: # stack
greg@494: # 
greg@494: # This library is free software; you can redistribute it and/or
greg@494: # modify it under the terms of the GNU Lesser General Public
greg@494: # License as published by the Free Software Foundation; either
greg@494: # version 2.1 of the License, or (at your option) any later version.
greg@494: # 
greg@494: # This library is distributed in the hope that it will be useful,
greg@494: # but WITHOUT ANY WARRANTY; without even the implied warranty of
greg@494: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
greg@494: # Lesser General Public License for more details.
greg@494: # 
greg@494: # You should have received a copy of the GNU Lesser General Public
greg@494: # License along with this library; if not, write to the Free Software
greg@494: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
greg@494: # 
greg@494: 
greg@494: CC = SUB_CC
greg@494: CXX = SUB_CXX
greg@494: LD = SUB_LD
greg@494: OPT_CFLAGS = -O2
greg@494: CFLAGS = SUB_OPT_CFLAGS
greg@494: PROG_CFLAGS = SUB_PROG_CFLAGS
greg@494: PREFIX = SUB_PREFIX
greg@494: TARGET = SUB_TARGET
greg@494: CAN_DRIVER = SUB_CAN_DRIVER
greg@494: TIMERS_DRIVER = SUB_TIMERS_DRIVER
greg@494: ENABLE_DLL_DRIVERS=SUB_ENABLE_DLL_DRIVERS
greg@494: CAN_DLL_CFLAGS=SUB_CAN_DLL_CFLAGS
greg@494: 
greg@494: INCLUDES = -I../../include -I../../include/$(TARGET) -I../../include/$(CAN_DRIVER) -IAnaGateCAN_API
greg@494: 
greg@494: OBJS =  $(CAN_DRIVER).o
greg@494: 
greg@494: ifeq ($(ENABLE_DLL_DRIVERS),1)
greg@494: #CFLAGS += -fPIC
greg@494: DRIVER = cyg$(CAN_DRIVER).dll
greg@494: else
greg@494: DRIVER = $(OBJS)
greg@494: endif
greg@494: 
greg@494: 
greg@494: TARGET_SOFILES = $(PREFIX)/lib/$(DRIVER)
greg@494: 
greg@494: all: driver
greg@494: 
greg@494: driver: $(DRIVER)
greg@494: 
greg@494: 
greg@494: %o: %c
greg@494: 	$(CC) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
greg@494: 
greg@494: %o: %cpp
greg@494: 	$(CXX) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -o $@ -c $<
greg@494: 
greg@494: $(DRIVER): $(OBJS)
greg@494: 	$(LD) $(PROG_CFLAGS) -shared -o $@ \
greg@494: 	-Wl,--export-all-symbols \
greg@494: 	-Wl,--enable-auto-import \
greg@494: 	-Wl,--whole-archive $^ \
greg@494: 	-Wl,--no-whole-archive $(CAN_DLL_CFLAGS) \
greg@494:         AnaGateCAN_API/AnaGateCANDll.lib \
greg@494: 	-Wl,--exclude-libs,ALL -lws2_32
greg@494: 		
greg@494: install: libcanfestival_$(CAN_DRIVER).so
greg@494: 	mkdir -p $(PREFIX)/lib/
greg@494: 	cp $< $(PREFIX)/lib/
greg@494: 		
greg@494: uninstall:
greg@494: 	rm -f $(TARGET_SOFILES)
greg@494: 
greg@494: clean:
greg@494: 	rm -f $(OBJS) $(DRIVER) $(SERVER).exe
greg@494: 
greg@494: mrproper: clean