SIZEN =  15
SIZEM   = 1

MACHINEFILE = ./machineFile
MPIRUN      = /usr/local/mpi/bin/mpirun
MPICC       = /usr/local/mpi/bin/mpiCC

MACHINEFILE = /usr/local/mpich-1.2.5/mf
MPICC       = /usr/local/mpich-1.2.5/ch_p4/bin/mpiCC
MPIRUN      = /usr/local/mpich-1.2.5/ch_p4/bin/mpirun

PROGRAM = a.out
ARHIVA  = `date '+../seminarski%b%d_%Hh_%Mm_%Ss.tar.gz'`

seminarski: common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o matmulPthreads.o $(PROGRAM)

common.o: common.h common.c defs.h
	g++ common.c -c -O -o common.o

matrica.o: matrica.cc matrica.hh common.c common.h defs.h timetest.hh
	g++ matrica.cc -c -O -o matrica.o

gustaMatrica.o: gustaMatrica.cc gustaMatrica.hh defs.h
	g++ gustaMatrica.cc -c -O -o gustaMatrica.o

gustaKvadratnaMatrica.o: gustaKvadratnaMatrica.cc gustaKvadratnaMatrica.hh defs.h
	g++ gustaKvadratnaMatrica.cc -c -O -o gustaKvadratnaMatrica.o

gustaSimetricnaMatrica.o: gustaSimetricnaMatrica.cc gustaSimetricnaMatrica.hh defs.h
	g++ gustaSimetricnaMatrica.cc -c -O -o gustaSimetricnaMatrica.o
	
retkaMatrica.o: retkaMatrica.cc retkaMatrica.hh defs.h
	g++ retkaMatrica.cc -c -O -o retkaMatrica.o

funkcije.o: funkcije.cc funkcije.hh
	g++ funkcije.cc -c -O -o funkcije.o

latexExport.o: latexExport.cc latexExport.hh
	g++ latexExport.cc -c -O -o latexExport.o

slj.o: slj.cc slj.hh
	g++ slj.cc -c -O -o slj.o

jacobiPthreads.o: jacobiPthreads.cc jacobiPthreads.hh
	g++ jacobiPthreads.cc -c -pthread -O -o jacobiPthreads.o

matmulPthreads.o:  matmulPthreads.cc  matmulPthreads.hh
	g++  matmulPthreads.cc -c -pthread -O -o  matmulPthreads.o

clean:
	-rm *~ *.o *.aux *.dvi *.log *.toc l w DEADJOE *.pdf primer01 primer02 primer03 primer04 primer05 primer06 $(PROGRAM) gen
	chmod 600 *
	chmod 700 mpiPrimeri  ltx slike finalno

dist: clean
	-tar -czv -C .. -f $(ARHIVA) seminarski

generate: generateSYS.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o defs.h
	g++ -lm -O common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o generateSYS.c -pthread -o gen

a.out: c.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o defs.h
	$(MPICC) -lm -O common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o c.c -pthread

primer01: primer01.c
	g++ -lm -O primer01.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o -o primer01

primer02: primer02.c
	g++ -lm -O primer02.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o -o primer02

primer03: primer03.c
	g++ -lm -O primer03.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o -o primer03

primer04: primer04.c
	g++ -lm -O primer04.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o -o primer04

primer05: primer05.c
	g++ -lm -O primer05.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o -pthread -o primer05

primer06: primer06.c
	g++ -lm -O primer06.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o matmulPthreads.o -pthread -o primer06

interpol: interpol.c
	g++ -lm -lMagick++ -O interpol.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o 

funkcional: funkcional.c
	g++ -lm -lMagick++ -O funkcional.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o 


test: test.c matrica.cc matrica.hh
	g++ -lm -O test.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o matmulPthreads.o -pthread -o test

kramer: kramer-MPI.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o defs.h
	$(MPICC) -lm -O common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o kramer-MPI.c -pthread

jacobi: jacobi-MPI.c common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o defs.h
	$(MPICC) -lm -O common.o matrica.o gustaMatrica.o gustaKvadratnaMatrica.o gustaSimetricnaMatrica.o retkaMatrica.o funkcije.o latexExport.o slj.o jacobiPthreads.o  matmulPthreads.o jacobi-MPI.c -pthread

run1:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 1 ./a.out $(SIZEN) $(SIZEM)
run2:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 2 ./a.out $(SIZEN) $(SIZEM) 
run3:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 3 ./a.out $(SIZEN) $(SIZEM) 
run4:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 4 ./a.out $(SIZEN) $(SIZEM) 
run5:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 5 ./a.out $(SIZEN) $(SIZEM) 
run6:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 6 ./a.out $(SIZEN) $(SIZEM) 
run7:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 7 ./a.out $(SIZEN) $(SIZEM) 
run8:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 8 ./a.out $(SIZEN) $(SIZEM) 
run9:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 9 ./a.out $(SIZEN) $(SIZEM) 
run10:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 10 ./a.out $(SIZEN) $(SIZEM) 
run11:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 11 ./a.out $(SIZEN) $(SIZEM) 
run12:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 12 ./a.out $(SIZEN) $(SIZEM) 
run13:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 13 ./a.out $(SIZEN) $(SIZEM) 
run14:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 14 ./a.out $(SIZEN) $(SIZEM) 
run15:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 15 ./a.out $(SIZEN) $(SIZEM) 


run21:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 21 ./a.out $(SIZEN) $(SIZEM) 
run28:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 28 ./a.out $(SIZEN) $(SIZEM) 
run35:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 35 ./a.out $(SIZEN) $(SIZEM) 
run42:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 42 ./a.out $(SIZEN) $(SIZEM) 
run49:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 49 ./a.out $(SIZEN) $(SIZEM) 
run56:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 56 ./a.out $(SIZEN) $(SIZEM) 
run63:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 63 ./a.out $(SIZEN) $(SIZEM) 

KSIZE=30
kt:
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 2  ./a.out $(KSIZE) >  l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 3  ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 4  ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 5  ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 6  ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 7  ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 8  ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 9  ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 10 ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 11 ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 12 ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 13 ./a.out $(KSIZE) >> l_kramer-$(KSIZE)
	$(MPIRUN) -machinefile $(MACHINEFILE) -np 14 ./a.out $(KSIZE) >> l_kramer-$(KSIZE)


