Update Makefile Andrin
This commit is contained in:
		
							parent
							
								
									04b3b86afb
								
							
						
					
					
						commit
						4627d6994a
					
				| 
						 | 
				
			
			@ -1,25 +1,67 @@
 | 
			
		|||
SNP_SHARED_MAKEFILE := $(if $(SNP_SHARED_MAKEFILE),$(SNP_SHARED_MAKEFILE),"~/snp/shared.mk")
 | 
			
		||||
 | 
			
		||||
TARGET := bin/triangle
 | 
			
		||||
SOURCES := src/triangle.c src/read.c src/rectang.c
 | 
			
		||||
TARGET := bin/dep2dot
 | 
			
		||||
# Add all additional c-files to the SOURCES variable
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
SOURCES := src/main.c src/data.c src/output.c
 | 
			
		||||
# END-STUDENTS-TO-ADD-CODE
 | 
			
		||||
TSTSOURCES := tests/tests.c
 | 
			
		||||
LIBS := -lm
 | 
			
		||||
 | 
			
		||||
include $(SNP_SHARED_MAKEFILE)
 | 
			
		||||
 | 
			
		||||
all: modul
 | 
			
		||||
 | 
			
		||||
modul: triangle.o read.o rectang.o
 | 
			
		||||
gcc -o modul src/triangle.o src/read.o src/rectang.o
 | 
			
		||||
# DEPFILES := ... define a list of png file names: %.c -> %.c.png
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
DEPFILES := $(SOURCES:%.c=%.c.png)
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
rm -f *.o modul
 | 
			
		||||
# END-STUDENTS-TO-ADD-CODE
 | 
			
		||||
 | 
			
		||||
triangle.o: src/triangle.c Makefile
 | 
			
		||||
gcc -c src/triangle.c
 | 
			
		||||
 | 
			
		||||
read.o: src/read.c src/read.h Makefile
 | 
			
		||||
gcc -c src/read.c
 | 
			
		||||
 | 
			
		||||
rectang.o: src/rectang.c src/rectang.h Makefile
 | 
			
		||||
gcc -c src/rectang.c
 | 
			
		||||
# define dep target as .PHONEY
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
.PHONEY: dep
 | 
			
		||||
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# define dep target depending on FULLTARGET and DEPFILES above
 | 
			
		||||
# action: echo some text telling that the target is done using $@ - the echo command shall not be echoed before execution
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
dep: $(DEPFILES) $(FULLTARGET)
 | 
			
		||||
echo $@
 | 
			
		||||
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# define new suffix rule for %.png depending on %.dot
 | 
			
		||||
# action: dot -Tpng $< >$@ || $(RM) $@
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
%.png: %.dot
 | 
			
		||||
dot -Tpng $< >$@ || $(RM) $@
 | 
			
		||||
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# define new suffix rule for %.dot depending on %.dep
 | 
			
		||||
# action: call $(TARGET) $(@:.dot=) <$< >$@ || $(RM) $@
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
%.dot: %.dep
 | 
			
		||||
call $(TARGET) $(@:.dot=) <$< >$@ || $(RM) $@
 | 
			
		||||
 | 
			
		||||
# BEGIN-STUDENTS-TO-ADD-CODE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# converts any .c file into a .c.dep file by means of GCC -H switch
 | 
			
		||||
# note: it removes intermediate files which were created as side effect
 | 
			
		||||
%.c.dep: %.c
 | 
			
		||||
$(COMPILE.c) -H -o $@.x $< 2>$@ && $(RM) $@.x $@.d
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# cleanup all results, including the ones od creating the dependencies
 | 
			
		||||
dep-clean: clean
 | 
			
		||||
$(RM) $(DEPFILES) $(wildcard src/*.dep src/*.dot)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue