#
# Description:  Makefile for c792Lib.o
#   This driver is specific to VxWorks BSPs and must be compiled
#   with access to vxWorks headers.
#

#Check Operating system we are using
ifndef OSNAME
  OSNAME := $(subst -,_,$(shell uname))
endif


ifndef WIND_BASE
  WIND_BASE = /site/vxworks/5.5/ppc
endif


ifeq ($(OSNAME),SunOS)
ARCH = VXWORKSPPC
CFLAGS = -O $(DEFS)
endif

ifeq ($(OSNAME),Linux)
CC = cc
LD = ld
ARCH = Linux
CFLAGS = -O $(DEFS)
DEFS = -mcpu=604 -DCPU=PPC604 -D_GNU_TOOL
INCS = -fno-builtin -fvolatile -fstrength-reduce -mlongcall -I.

all: echoarch ppcTimer.o libppcTimer.so timer_test

endif

ifeq ($(ARCH),VXWORKSPPC)
INCDIR=$(WIND_BASE)/target/h
CC = ccppc
LD = ldppc
DEFS = -mcpu=604 -DCPU=PPC604 -DVXWORKS -D_GNU_TOOL -DVXWORKSPPC
INCS = -fno-for-scope -fno-builtin -fvolatile -fstrength-reduce -mlongcall -I. -I$(INCDIR)

all: echoarch ppcTimer.o

endif


ppcTimer.o: ppcTimer.c ppcTimer.h
	$(CC) -c $(CFLAGS) $(INCS) -o $@ ppcTimer.c

timer_test: timer_test.c libppcTimer.so
	$(CC) -L. -lppcTimer $(CFLAGS) $(INCS) -o $@ timer_test.c

libppcTimer.so: ppcTimer.o
	ld -r -L. -o libppcTimer.so ppcTimer.o

clean:
	rm -f ppcTimer.o libppcTimer.so timer_test

echoarch:
	echo "Make for $(ARCH)"
