Skip to content
Snippets Groups Projects
Makefile 1.42 KiB
Newer Older
  • Learn to ignore specific revisions
  • Ronald Charles Moore's avatar
    Ronald Charles Moore committed
    # This Makefile made available to his students by 
    # Prof. Ronald Moore  
    #     https://fbi.h-da.de/personen/ronald-moore/  
    #     mailto:ronald.moore@h-da.de
    # with no warranties whatsoever
    
    
    PROGS := interpreter
    
    TESTINPUT := goodTest.input badTest.input
    
    
    Ronald Charles Moore's avatar
    Ronald Charles Moore committed
    # Uncomment only one of the next two lines (choose your c++ compiler)
    # CC=g++
    CC := clang++
    
    ## Add your own CFLAGS if you find them necessary... such as -O3 or so... 
    
    CFLAGS :=   -g -std=c++20 -Wall 
    
    Ronald Charles Moore's avatar
    Ronald Charles Moore committed
    
    
    # By the way, it should also work with -std=c++17
    # (there's nothing here that requires c++20.
    
    Ronald Charles Moore's avatar
    Ronald Charles Moore committed
    
    ## More preliminaries
    # See https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
    # In this makefile, we want to keep going even if we find errors
    .IGNORE :
    
    # Tell make that the following "targets" are "phony"
    # Cf. https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets
    
    .PHONY : all clean test
    
    Ronald Charles Moore's avatar
    Ronald Charles Moore committed
    
    ##  Now, the targets -- the things that will get made!
    
    all: $(PROGS)
    
    $(PROGS): %: %.cpp
    	$(CC) -g $< $(CFLAGS) -o $@
    
    clean: 
    
    	$(RM) -v *~ *.o $(PROGS) tmp.txt
    
    test: $(PROGS) $(TESTFILES)
    
    	# Running interpreter in test mode
    
    	-./interpreter goodTest.input >tmp.txt  2>&1 
    	# Checking output -- no news is good news!
    	@diff -qs goodTest.reference tmp.txt
    	-$(RM) tmp.txt
    	# Running interpreter in test mode
    	-./interpreter badTest.input 2>&1 >tmp.txt
    
    	# Checking output -- no news is good news!
    
    	@diff -qs badTest.reference tmp.txt
    	-$(RM) tmp.txt
    	
    
    Ronald Charles Moore's avatar
    Ronald Charles Moore committed