From 4627d6994af5e9eff77003fd0d125ec03db50a58 Mon Sep 17 00:00:00 2001 From: romanschenk37 Date: Wed, 23 Mar 2022 16:28:20 +0100 Subject: [PATCH] Update Makefile Andrin --- .../work/show-dependencies/Makefile Andrin | 70 +++++++++++++++---- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/P04_Modularisieren_von_C_Code/work/show-dependencies/Makefile Andrin b/P04_Modularisieren_von_C_Code/work/show-dependencies/Makefile Andrin index 174a96a..f3952c6 100644 --- a/P04_Modularisieren_von_C_Code/work/show-dependencies/Makefile Andrin +++ b/P04_Modularisieren_von_C_Code/work/show-dependencies/Makefile Andrin @@ -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)