diff options
| -rw-r--r-- | .Makefile.common | 10 | ||||
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | set1/Makefile | 30 | ||||
| -rw-r--r-- | set2/Makefile | 26 | ||||
| -rw-r--r-- | set3/Makefile | 21 |
5 files changed, 42 insertions, 59 deletions
diff --git a/.Makefile.common b/.Makefile.common new file mode 100644 index 0000000..b4c5ab3 --- /dev/null +++ b/.Makefile.common @@ -0,0 +1,10 @@ +## define variables used in all makefiles +LIB=../lib/lib2.c ../lib/lib.c ../lib/lib3.c +CC=gcc +CFLAGS := -g $(CFLAGS) +CLIBS=`pkg-config --cflags --libs libcrypto` + +%: %.c + @echo -e "\tCC\t $<" + @$(CC) $(CFLAGS) $< $(LIB) $(CLIBS) -o $* + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..68cf09c --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +# call all makefiles in sudirs +DIRS = set1 set2 set3 + +compile: + @for i in $(DIRS); do \ + echo "Compiling $$i:"; \ + make -s -C $$i ;\ + done + +clean: + @for i in $(DIRS); do \ + echo "Cleaning $$i:"; \ + make -s -C $$i clean;\ + done diff --git a/set1/Makefile b/set1/Makefile index 0d08451..8b0ffbd 100644 --- a/set1/Makefile +++ b/set1/Makefile @@ -1,27 +1,9 @@ -LIB=../lib/lib.c -CC=gcc -CFLAGS := -g -Wall $(CFLAGS) +include ../.Makefile.common +COBJS=$(shell find . -type f -name "task*.c" | sed "s/\(.*\)\.c/\1.o/g") +TARGETS=$(shell find . -type f -name "task*.c" | sed "s/\(.*\)\.c/\1/g") -all: task1 task2 task4 task5 task6 task7 task8 +all: $(TARGETS) -task1: - $(CC) $(CFLAGS) task1.c $(LIB) -o task1 - -task2: - $(CC) $(CFLAGS) task2.c $(LIB) -o task2 - -task4: - $(CC) $(CFLAGS) task4.c $(LIB) -o task4 - -task5: - $(CC) $(CFLAGS) task5.c $(LIB) -o task5 - -task6: - $(CC) $(CFLAGS) task6.c $(LIB) -o task6 - -task7: - $(CC) $(CFLAGS) task7.c `pkg-config --cflags --libs libcrypto` -o task7 -task8: - $(CC) $(CFLAGS) task8.c $(LIB) -o task8 clean: - rm task1 task2 task4 task5 task6 task7 task8 + @echo -e "\tDEL\t$(TARGETS)" + @rm $(TARGETS) diff --git a/set2/Makefile b/set2/Makefile index 914471a..8b0ffbd 100644 --- a/set2/Makefile +++ b/set2/Makefile @@ -1,23 +1,9 @@ -LIB=../lib/lib2.c ../lib/lib.c -CC=gcc -CFLAGS := -g $(CFLAGS) -CLIBS=`pkg-config --cflags --libs libcrypto` +include ../.Makefile.common +COBJS=$(shell find . -type f -name "task*.c" | sed "s/\(.*\)\.c/\1.o/g") +TARGETS=$(shell find . -type f -name "task*.c" | sed "s/\(.*\)\.c/\1/g") -all: task9 task10 task11 task12 task13 task15 task16 +all: $(TARGETS) -task9: - $(CC) $(CFLAGS) task9.c $(LIB) $(CLIBS) -o task9 -task10: - $(CC) $(CFLAGS) task10.c $(LIB) $(CLIBS) -o task10 -task11: - $(CC) $(CFLAGS) task11.c $(LIB) $(CLIBS) -o task11 -task12: - $(CC) $(CFLAGS) task12.c $(LIB) $(CLIBS) -o task12 -task13: - $(CC) $(CFLAGS) task13.c $(LIB) $(CLIBS) -o task13 -task15: - $(CC) $(CFLAGS) task15.c $(LIB) $(CLIBS) -o task15 -task16: - $(CC) $(CFLAGS) task16.c $(LIB) $(CLIBS) -o task16 clean: - rm task9 task10 task11 task12 task13 task15 task16 + @echo -e "\tDEL\t$(TARGETS)" + @rm $(TARGETS) diff --git a/set3/Makefile b/set3/Makefile index a6ed5fc..8b0ffbd 100644 --- a/set3/Makefile +++ b/set3/Makefile @@ -1,18 +1,9 @@ -LIB=../lib/lib2.c ../lib/lib.c ../lib/lib3.c -CC=gcc -CFLAGS := -g $(CFLAGS) -CLIBS=`pkg-config --cflags --libs libcrypto` +include ../.Makefile.common +COBJS=$(shell find . -type f -name "task*.c" | sed "s/\(.*\)\.c/\1.o/g") +TARGETS=$(shell find . -type f -name "task*.c" | sed "s/\(.*\)\.c/\1/g") -all: task17 task18 task19 task20 +all: $(TARGETS) -task17: - $(CC) $(CFLAGS) task17.c $(LIB) $(CLIBS) -o task17 - -task18: - $(CC) $(CFLAGS) task18.c $(LIB) $(CLIBS) -o task18 -task19: - $(CC) $(CFLAGS) task19.c $(LIB) $(CLIBS) -o task19 -task20: - $(CC) $(CFLAGS) task20.c $(LIB) $(CLIBS) -o task20 clean: - rm task17 task18 task19 task20 + @echo -e "\tDEL\t$(TARGETS)" + @rm $(TARGETS) |
