From b3bb6acce9ca6ce65a991c6453205307f089640e Mon Sep 17 00:00:00 2001 From: dtb Date: Sun, 26 Jun 2022 16:34:29 -0400 Subject: [PATCH] make clean better --- Makefile | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 9b2f657..128cd2e 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,25 @@ # System utilities CC=cc -CFLAGS=-Iinclude/ -Ilib/ -g -Wall +CFLAGS=-Iinclude/ -Ilib/ -g -Wall -Wextra -Wpedantic RM=rm -f all: libraries programs -cleanall: clean cleanlibraries cleanprograms +cleanall: clean cleanprograms clean: - $(RM) src/*.o - -cleanlibraries: - $(RM) lib/libshell.o - $(RM) lib/libstr.o + $(RM) build/* cleanprograms: $(RM) bin/add + $(RM) bin/calculate $(RM) bin/cut $(RM) bin/echo $(RM) bin/eq $(RM) bin/false $(RM) bin/fdivide $(RM) bin/gt + $(RM) bin/id $(RM) bin/lowercase $(RM) bin/lt $(RM) bin/mm @@ -32,6 +30,10 @@ cleanprograms: $(RM) bin/streq $(RM) bin/str $(RM) bin/substitute + $(RM) bin/sysexits + $(RM) bin/rldecode + $(RM) bin/rlencode + $(RM) bin/roll $(RM) bin/tail libraries: libio libshell stdbool sysexits @@ -48,7 +50,8 @@ libstr: lib/libstr.c lib/libstr.h stdbool: include/stdbool.h sysexits_bin: src/sysexits.c - $(CC) $(CFLAGS) -o bin/sysexits src/sysexits.c + $(CC) $(CFLAGS) -c -o build/sysexits.o src/sysexits.c + $(CC) $(CFLAGS) -o bin/sysexits build/sysexits.o sysexits: sysexits_bin bin/sysexits >include/sysexits.h @@ -59,8 +62,11 @@ calculate: libstr sysexits src/calculate.c $(CC) $(CFLAGS) -o src/calculate.o -c src/calculate.c $(CC) $(CFLAGS) -o bin/calculate lib/libstr.o src/calculate.o -echo: sysexits src/echo.c - $(CC) $(CFLAGS) -o bin/echo src/echo.c +echo.o: libio sysexits src/echo.c + $(CC) $(CFLAGS) -c -o build/echo.o src/echo.c + +echo: libio echo.o + $(CC) $(CFLAGS) -o bin/echo build/echo.o build/libio.o false: src/false.c $(CC) $(CFLAGS) -o bin/false src/false.c @@ -124,6 +130,12 @@ substitute: stdbool src/substitute.c $(CC) $(CFLAGS) -c -o src/substitute.o src/substitute.c $(CC) $(CFLAGS) -o bin/substitute src/substitute.o +tail.o: libio src/tail.c + $(CC) $(CFLAGS) -c -o build/tail.o src/tail.c + +tail: libio tail.o + $(CC) $(CFLAGS) -o bin/tail build/libio.o build/tail.o + usefulmacros: include/usefulmacros.h which: libshell src/which.c