#! gmake

#
# Copyright (C) 2006 Laurent Bessard
# 
# This file is part of canfestival, a library implementing the canopen
# stack
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# 

CC = SUB_CC
CFLAGS = 
PROG_CFLAGS = SUB_PROG_CFLAGS
OS_NAME = SUB_OS_NAME
ARCH_NAME = SUB_ARCH_NAME
PREFIX = SUB_PREFIX
TARGET = SUB_TARGET
INCLUDES = -I../../include -I../../include/hcs12

OPT_CFLAGS = -Os
PROGDEFINES = -mnoshort -Wall -Wmissing-prototypes -fno-strict-aliasing
PROGDEFINES_ASM = -mnoshort -Wall -Wmissing-prototypes 

OBJS = canOpenDriver.o interrupt.o ports.o 

all: driver

driver: $(OBJS)

libcandriver.a: $(OBJS)
	@echo " "
	@echo "*********************************************"
	@echo "**Building [libcandriver]"
	@echo "*********************************************"
	ar rc $@ $(OBJS)
	ranlib $@

%.o: %.c
	@echo " "
	@echo "*********************************************"
	@echo "**Compiling $< -> $@"
	@echo "*********************************************"
	$(CC) $(OPT_CFLAGS) $(CFLAGS) $(PROG_CFLAGS) ${PROGDEFINES} $(INCLUDES) -c -o $@ $<

%o: %s
	@echo " "
	@echo "*********************************************"
	@echo "**Compiling $< -> $@"
	@echo "*********************************************"
	$(CC)  -c -x assembler-with-cpp $(PROG_CFLAGS) ${PROGDEFINES_ASM} -o $@ $<

install: libcandriver.a
	mkdir -p ../../lib/hc12
	mv libcandriver.a ../../lib/hc12

uninstall:
	rm -f ../../lib/hc12/libcandriver.a

clean:
	rm -f $(OBJS)

mrproper: clean
	rm -f ../../lib/hc12/libcandriver.a

