#
# To build the test programs under Windows with Cygwin, you will have to change a few lines here.
# Just search for the word "Cygwin" to find them.
#
#
# These were the paths and names of the ARM cross compiling tools I tried:
# The -Bstatic option was necessary to get statically linked files needed for ARM-simulator
#
# CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc
# LD=/usr/local/arm/2.95.3/bin/arm-linux-ld -Bstatic
# LDFLAGS= -Wl,-Bstatic
##LD=ld
CFLAGS=-Wall -Winline -DLINUX -DLITTLEENDIAN
#
# The following is needed to enable workarounds for statements that do
# not work on (some?) ARM processors:
#
#CFLAGS+=-DARM_FIX 


#-static -Wl,static -lc.a -static -lpthread.a -nostdlib 
#CFLAGS=-O0 -Wall -Winline
#CFLAGS=-O0 -Wall -Winline -DCYGWIN 
PROGRAMS=testISO_TCP testMPI testPPI \
testPPIload testMPIload ibhtest7 isotest4 \
testMPI2 testISO_TCPload testIBH testMPI_IBHload
# testPPI_IBH

DYNAMIC_PROGRAMS=testMPId testPPId testISO_TCPd

LIBRARIES=libnodave.so 


#use this line for compilation under Linux. Comment it out to compile under Windows/Cygwin
all: $(PROGRAMS) $(LIBRARIES)
install:
	cp libnodave.so /usr/local/lib
	cp nodave.h /usr/local/include
	ldconfig
dynamic: $(DYNAMIC_PROGRAMS)
#use this line for compilation under Windows/Cygwin
#all: $(PROGRAMS)
nodave.o: nodave.h

testISO_TCP: nodave.o openSocket.o testISO_TCP.o
	$(CC) $(LDFLAGS) nodave.o openSocket.o testISO_TCP.o -o testISO_TCP
testISO_TCPd: nodave.o openSocket.o testISO_TCP.o
	$(CC) -lnodave testISO_TCP.o -o testISO_TCPd
readoutISO_TCP: nodave.o openSocket.o readoutISO_TCP.o
	$(CC) $(LDFLAGS) nodave.o openSocket.o readoutISO_TCP.o -o readoutISO_TCP
testPPIload: nodave.o setport.o testPPIload.o
	$(CC) $(LDFLAGS) nodave.o setport.o testPPIload.o -o testPPIload
testMPI: setport.o testMPI.o nodave.o
	$(CC) $(LDFLAGS) setport.o nodave.o testMPI.o -o testMPI
testMPId: setport.o testMPI.o nodave.o
	$(CC) -lnodave testMPI.o -o testMPId
testMPIload: nodave.o setport.o testMPIload.o
	$(CC) $(LDFLAGS) nodave.o setport.o testMPIload.o -o testMPIload
testMPI_IBHload: nodave.o openSocket.o testMPI_IBHload.o
	$(CC) $(LDFLAGS) nodave.o openSocket.o testMPI_IBHload.o -o testMPI_IBHload
testPPI: nodave.o setport.o testPPI.o 
	$(CC) $(LDFLAGS) nodave.o setport.o testPPI.o -o testPPI
testPPId: nodave.o setport.o testPPI.o 
	$(CC) -lnodave testPPI.o -o testPPId	
profiread: nodave.o setport.o profiread.o 
	$(CC) nodave.o setport.o profiread.o -o profiread
pr2: nodave.o setport.o pr2.o 
	$(CC) nodave.o setport.o pr2.o -o pr2
testMPI2: setport.o testMPI2.o nodave.o
	$(CC) $(LDFLAGS) setport.o nodave.o testMPI2.o -o testMPI2
testISO_TCPload: nodave.o openSocket.o testISO_TCPload.o
	$(CC) $(LDFLAGS) nodave.o openSocket.o testISO_TCPload.o -o testISO_TCPload
testIBH: openSocket.o testIBH.o nodave.o
	$(CC) $(LDFLAGS) openSocket.o nodave.o testIBH.o -o testIBH
testPPI_IBH: openSocket.o testPPI_IBH.o nodave.o
	$(CC) $(LDFLAGS) openSocket.o nodave.o testPPI_IBH.o -o testPPI_IBH
#testPPIload: nodave.o setport.o testPPIload.o 
#	gcc nodave.o setport.o testPPIload.o -o testPPIload
runStopISO_TCP: nodave.o openSocket.o runStopISO_TCP.o
	$(CC) nodave.o openSocket.o runStopISO_TCP.o -o runStopISO_TCP

libnodave.so: nodave.o
	$(LD) -shared nodave.o setport.o openSocket.o -o libnodave.so	

ibhtest7: ibhtest7.o nodave.h nodave.o openSocket.o openSocket.h
	$(CC) -lpthread ibhtest7.o openSocket.o nodave.o -o ibhtest7
isotest4: isotest4.o openSocket.o nodave.o nodave.h
	$(CC) $(LDFLAGS) -lpthread isotest4.o openSocket.o nodave.o $(LIB) -o isotest4

clean: 
	rm -f $(DYNAMIC_PROGRAMS)
	rm -f $(PROGRAMS)
	rm -f *.o
	rm -f *.so
#use this line for compilation under Windows/Cygwin:
#	rm -f *.exe
