#   Makefile for Monte Carlo class

#   http://www.math.nyu.edu/faculty/goodman/teaching/MonteCarlo12/ClassHomePage.php.html

#   The author gives permission for anyone to use this publicly posted 
#   code for any purpose.  The code was written for teaching, not research 
#   or commercial use.  It has not been tested thoroughly and probably has
#   serious bugs.  Results may be inaccurate, incorrect, or just wrong.

#   Week 1, direct samplers

SUFFIXES :=
%.c:
%.cpp:
%.o:
%.h:
%.py:

#        Compilers, linkers, compile options, link options 

CC      = gcc             #  C
CPP     = g++             #  C++ 

CCFLAGS = -O2       

LINKER  =  g++       # linker, use C++ linker to link C and C++ object files.

#          Lists of files

C_SOURCES   = rng.c 

CPP_SOURCES = main.cpp f.cpp pyWrite.cpp

P_SOURCES   = histogram.py 

C_OBJECTS   = $(patsubst %.c,   %.o, $(C_SOURCES) )
CPP_OBJECTS = $(patsubst %.cpp, %.o, $(CPP_SOURCES) )


#           Stuff that every single program depends on

FOR_ALL   = Makefile header.h

ALL_SOURCES = $(CPP_SOURCES) $(C_SOURCES) $(P_SOURCES) Makefile  header.h README.tex


#        compiling instructions, all manual, no implicit rules

main.o: main.cpp $(FOR_ALL)
	$(CPP) -c $(CCFLAGS) main.cpp

f.o:    f.cpp $(FOR_ALL)
	$(CPP) -c $(CCFLAGS) f.cpp

pyWrite.o: pyWrite.cpp $(FOR_ALL)
	$(CPP) -c $(CCFLAGS) pyWrite.cpp

rng.o:   rng.c $(FOR_ALL)
	$(CC) -c $(CCFLAGS) rng.c



#               Build and run executables

#      "main program" fTest

fTestExecutable: main.o f.o rng.o pyWrite.o
	$(LINKER)  -o fTestExecutable main.o f.o rng.o pyWrite.o

plotInfo.py: fTestExecutable 
	./fTestExecutable 

fTest: plotInfo.py
	python histogram.py

tarball: $( All_SOURCES)  
	tar -cvf Week2.tar $(ALL_SOURCES) 



