Makefile (1118B)
1 # Define compiler 2 CC=g++ 3 4 # Define compiler flags (show all warnings) 5 CPPFLAGS=-Wall 6 7 # Define linker flags 8 LDFLAGS= 9 10 # Define extra libraries to be dynamically linked 11 LDLIBS+=-larmadillo 12 13 # Compile optimized code 14 #CPPFLAGS+=-O2 15 16 # Compile debuggable code 17 #CPPFLAGS+=-g 18 19 # Compile profilable code 20 #CPPFLAGS+=-pg 21 #LDFLAGS+=-pg 22 23 # Define linker 24 LD=g++ 25 26 # Filenames of source code 27 SRC=$(shell ls *.cpp) 28 29 # Filenames of object files 30 OBJ=$(SRC:.cpp=.o) 31 32 # Remove file type extension for binary filename 33 BIN=eigen 34 35 # The default "all" depends on A and B 36 37 #all: A B 38 A: 39 ./eigen 11 40 41 #A: plot.A.png 42 43 #B: plot.B.png 44 45 #plot.%.png: fit.A.dat fit.B.dat data.A.txt data.B.txt 46 # gnuplot plotall.gp 47 48 #fit.A.dat: $(BIN) 49 # ./$(BIN) data.A.txt fit.A.dat 50 51 #fit.B.dat: $(BIN) 52 # ./$(BIN) data.B.txt fit.B.dat 53 54 $(BIN): $(OBJ) 55 @# Link object files together 56 $(LD) $(LDFLAGS) $(OBJ) -o $(BIN) $(LDLIBS) 57 @# Execute program and redirect stdout to file 58 @#./$(BIN) > out.txt 59 60 clean: 61 @# Remove object files 62 rm -f $(OBJ) 63 @# Remove binary 64 rm -f $(BIN) 65 @# Remove datafiles and plot 66 #rm -f *.dat *.png 67 edit: 68 vim -p Makefile *.cpp *.h *.gp 69