numeric

C++ library with numerical algorithms
git clone git://src.adamsgaard.dk/numeric # fast
git clone https://src.adamsgaard.dk/numeric.git # slow
Log | Files | Refs | README | LICENSE Back to index

Makefile (1237B)


      1 # Define compiler
      2 CC=g++
      3 
      4 # Define compiler flags (show all warnings)
      5 CCFLAGS=-Wall
      6 
      7 # Define linker
      8 LD=g++
      9 
     10 # Define linker flags
     11 LDFLAGS=
     12 
     13 # Filenames of source code
     14 ASRC=$(shell ls *.A.cpp)
     15 BSRC=$(shell ls *.B.cpp)
     16 
     17 # Filenames of object files
     18 BOBJ=$(BSRC:.cpp=.o)
     19 
     20 # Remove file type extension for binary filename
     21 ABIN=$(ASRC:.cpp=)
     22 BBIN=hello_user.B
     23 
     24 # The default "all" depends on A and B
     25 
     26 all:	A B 
     27 
     28 correct: 
     29 	# Cenerating correct answer
     30 	@echo "Hello, $(USER)" > correct.txt
     31 
     32 A:
     33 	# Compile source code
     34 	$(CC) $(CCFLAGS) $(ASRC) -o $(ABIN)
     35 	# Execute program and redirect stdout to file
     36 	./$(ABIN) > out.A.txt
     37 
     38 B:	$(BOBJ)
     39 	# Link object files together
     40 	$(LD) $(LDFLAGS) $(BOBJ) -o $(BBIN)
     41 	# Execute program and redirect stdout to file
     42 	./$(BBIN) > out.B.txt
     43 	
     44 # Object files for B require B source code files
     45 .B.o:	$(BSRC)
     46 	$(CC) $(CCFLAGS) -c $< -o $@
     47 
     48 clean-A:
     49 	# Remove binary
     50 	rm -f $(ABIN)
     51 
     52 clean-B: 
     53 	# Remove object files
     54 	rm -f $(BOBJ)
     55 	# Remove binary
     56 	rm -f $(BBIN)
     57 
     58 clean:	clean-A clean-B
     59 	rm -f correct.txt
     60 
     61 test-A:	correct A
     62 	@echo "Checking A... "
     63 	@diff --brief correct.txt out.A.txt
     64 	@echo "done"
     65 
     66 test-B:	correct B
     67 	@echo "Checking B... "
     68 	@diff --brief correct.txt out.B.txt
     69 	@echo "done"
     70 
     71 test:	test-A test-B