Skip to content

Commit

Permalink
Makefiles with own, less verbose output.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsm-lisper committed May 16, 2024
1 parent f12b69c commit 63ef9d6
Show file tree
Hide file tree
Showing 25 changed files with 353 additions and 77 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ SUBDIRS=$(wildcard chapter_*/)

TOPTARGETS=all check clean

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "

MAKEFLAGS+=--silent

$(TOPTARGETS): $(SUBDIRS)

$(SUBDIRS):
echo "* Directory "$(ANSIBOLD)$@$(ANSIRST)":"
$(MAKE) -C $@ $(MAKECMDGOALS)
echo $(ANSIBOLD)$@$(ANSIRST)" done."

.PHONY: $(TOPTARGETS) $(SUBDIRS)
.PHONY: $(TOPTARGETS) $(SUBDIRS)
22 changes: 19 additions & 3 deletions chapter_2.types_operators_expressions/2_01.ranges/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
BINARY=ranges

CFILES=$(wildcard *.c)
TESTDIR=./tests/
TESTDIR=tests/
TESTS=$(wildcard $(TESTDIR)*.tin)
TEST_RESULTS=$(patsubst %.tin,%.res,$(TESTS))

CC=gcc
CFLAGS=-Wall -Wextra -Werror -ggdb -std=c89

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "
ANSIYBIN=$(ANSIYELLOW)$(BINARY)$(ANSIRST)

MAKEFLAGS+=--silent

all: $(BINARY)

$(BINARY): $(CFILES)
echo -n "** Building "$(ANSIYBIN)":"
$(CC) $(CFLAGS) -o $@ $^
echo $(ANSIGOK)

check: $(TEST_RESULTS)
echo "** "$(ANSIBOLD)$(ANSIYBIN)" test results:"$(ANSIBOLD)$(ANSIGOK)

%.res: %.tin
@./$(BINARY) <$? >$@ult
@diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo -n "- Testing "$(ANSIBOLD)$(BINARY)$(ANSIRST)":" \
$(ANSIYELLOW)$(patsubst $(TESTDIR)%.tin,%,$?)$(ANSIRST)
./$(BINARY) <$? >$@ult
diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo $(ANSIGOK)

clean:
echo -n "** Cleaning "$(ANSIYBIN)":"
rm -f $(BINARY)
rm -f $(TESTDIR)*.result
echo $(ANSIGOK)
22 changes: 19 additions & 3 deletions chapter_2.types_operators_expressions/2_02.loop/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
BINARY=loop

CFILES=$(wildcard *.c)
TESTDIR=./tests/
TESTDIR=tests/
TESTS=$(wildcard $(TESTDIR)*.tin)
TEST_RESULTS=$(patsubst %.tin,%.res,$(TESTS))

CC=gcc
CFLAGS=-Wall -Wextra -Werror -ggdb -std=c89

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "
ANSIYBIN=$(ANSIYELLOW)$(BINARY)$(ANSIRST)

MAKEFLAGS+=--silent

all: $(BINARY)

$(BINARY): $(CFILES)
echo -n "** Building "$(ANSIYBIN)":"
$(CC) $(CFLAGS) -o $@ $^
echo $(ANSIGOK)

check: $(TEST_RESULTS)
echo "** "$(ANSIBOLD)$(ANSIYBIN)" test results:"$(ANSIBOLD)$(ANSIGOK)

%.res: %.tin
@./$(BINARY) <$? >$@ult
@diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo -n "- Testing "$(ANSIBOLD)$(BINARY)$(ANSIRST)":" \
$(ANSIYELLOW)$(patsubst $(TESTDIR)%.tin,%,$?)$(ANSIRST)
./$(BINARY) <$? >$@ult
diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo $(ANSIGOK)

clean:
echo -n "** Cleaning "$(ANSIYBIN)":"
rm -f $(BINARY)
rm -f $(TESTDIR)*.result
echo $(ANSIGOK)
22 changes: 19 additions & 3 deletions chapter_2.types_operators_expressions/2_03.htoi/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
BINARY=htoi

CFILES=$(wildcard *.c)
TESTDIR=./tests/
TESTDIR=tests/
TESTS=$(wildcard $(TESTDIR)*.tin)
TEST_RESULTS=$(patsubst %.tin,%.res,$(TESTS))

CC=gcc
CFLAGS=-Wall -Wextra -Werror -ggdb -std=c89

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "
ANSIYBIN=$(ANSIYELLOW)$(BINARY)$(ANSIRST)

MAKEFLAGS+=--silent

all: $(BINARY)

$(BINARY): $(CFILES)
echo -n "** Building "$(ANSIYBIN)":"
$(CC) $(CFLAGS) -o $@ $^
echo $(ANSIGOK)

check: $(TEST_RESULTS)
echo "** "$(ANSIBOLD)$(ANSIYBIN)" test results:"$(ANSIBOLD)$(ANSIGOK)

%.res: %.tin
@./$(BINARY) <$? >$@ult
@diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo -n "- Testing "$(ANSIBOLD)$(BINARY)$(ANSIRST)":" \
$(ANSIYELLOW)$(patsubst $(TESTDIR)%.tin,%,$?)$(ANSIRST)
./$(BINARY) <$? >$@ult
diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo $(ANSIGOK)

clean:
echo -n "** Cleaning "$(ANSIYBIN)":"
rm -f $(BINARY)
rm -f $(TESTDIR)*.result
echo $(ANSIGOK)
25 changes: 0 additions & 25 deletions chapter_2.types_operators_expressions/2_04.sqeeze/Makefile

This file was deleted.

41 changes: 41 additions & 0 deletions chapter_2.types_operators_expressions/2_04.squeeze/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
BINARY=squeeze

CFILES=$(wildcard *.c)
TESTDIR=tests/
TESTS=$(wildcard $(TESTDIR)*.tin)
TEST_RESULTS=$(patsubst %.tin,%.res,$(TESTS))

CC=gcc
CFLAGS=-Wall -Wextra -Werror -ggdb -std=c89

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "
ANSIYBIN=$(ANSIYELLOW)$(BINARY)$(ANSIRST)

MAKEFLAGS+=--silent

all: $(BINARY)

$(BINARY): $(CFILES)
echo -n "** Building "$(ANSIYBIN)":"
$(CC) $(CFLAGS) -o $@ $^
echo $(ANSIGOK)

check: $(TEST_RESULTS)
echo "** "$(ANSIBOLD)$(ANSIYBIN)" test results:"$(ANSIBOLD)$(ANSIGOK)

%.res: %.tin
echo -n "- Testing "$(ANSIBOLD)$(BINARY)$(ANSIRST)":" \
$(ANSIYELLOW)$(patsubst $(TESTDIR)%.tin,%,$?)$(ANSIRST)
./$(BINARY) <$? >$@ult
diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo $(ANSIGOK)

clean:
echo -n "** Cleaning "$(ANSIYBIN)":"
rm -f $(BINARY)
rm -f $(TESTDIR)*.result
echo $(ANSIGOK)
22 changes: 19 additions & 3 deletions chapter_2.types_operators_expressions/2_05.any/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
BINARY=any

CFILES=$(wildcard *.c)
TESTDIR=./tests/
TESTDIR=tests/
TESTS=$(wildcard $(TESTDIR)*.tin)
TEST_RESULTS=$(patsubst %.tin,%.res,$(TESTS))

CC=gcc
CFLAGS=-Wall -Wextra -Werror -ggdb -std=c89

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "
ANSIYBIN=$(ANSIYELLOW)$(BINARY)$(ANSIRST)

MAKEFLAGS+=--silent

all: $(BINARY)

$(BINARY): $(CFILES)
echo -n "** Building "$(ANSIYBIN)":"
$(CC) $(CFLAGS) -o $@ $^
echo $(ANSIGOK)

check: $(TEST_RESULTS)
echo "** "$(ANSIBOLD)$(ANSIYBIN)" test results:"$(ANSIBOLD)$(ANSIGOK)

%.res: %.tin
@./$(BINARY) <$? >$@ult
@diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo -n "- Testing "$(ANSIBOLD)$(BINARY)$(ANSIRST)":" \
$(ANSIYELLOW)$(patsubst $(TESTDIR)%.tin,%,$?)$(ANSIRST)
./$(BINARY) <$? >$@ult
diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo $(ANSIGOK)

clean:
echo -n "** Cleaning "$(ANSIYBIN)":"
rm -f $(BINARY)
rm -f $(TESTDIR)*.result
echo $(ANSIGOK)
22 changes: 19 additions & 3 deletions chapter_2.types_operators_expressions/2_06.setbits/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
BINARY=setbits

CFILES=$(wildcard *.c)
TESTDIR=./tests/
TESTDIR=tests/
TESTS=$(wildcard $(TESTDIR)*.tin)
TEST_RESULTS=$(patsubst %.tin,%.res,$(TESTS))

CC=gcc
CFLAGS=-Wall -Wextra -Werror -ggdb -std=c89

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "
ANSIYBIN=$(ANSIYELLOW)$(BINARY)$(ANSIRST)

MAKEFLAGS+=--silent

all: $(BINARY)

$(BINARY): $(CFILES)
echo -n "** Building "$(ANSIYBIN)":"
$(CC) $(CFLAGS) -o $@ $^
echo $(ANSIGOK)

check: $(TEST_RESULTS)
echo "** "$(ANSIBOLD)$(ANSIYBIN)" test results:"$(ANSIBOLD)$(ANSIGOK)

%.res: %.tin
@./$(BINARY) <$? >$@ult
@diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo -n "- Testing "$(ANSIBOLD)$(BINARY)$(ANSIRST)":" \
$(ANSIYELLOW)$(patsubst $(TESTDIR)%.tin,%,$?)$(ANSIRST)
./$(BINARY) <$? >$@ult
diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo $(ANSIGOK)

clean:
echo -n "** Cleaning "$(ANSIYBIN)":"
rm -f $(BINARY)
rm -f $(TESTDIR)*.result
echo $(ANSIGOK)
22 changes: 19 additions & 3 deletions chapter_2.types_operators_expressions/2_07.invert/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
BINARY=invert

CFILES=$(wildcard *.c)
TESTDIR=./tests/
TESTDIR=tests/
TESTS=$(wildcard $(TESTDIR)*.tin)
TEST_RESULTS=$(patsubst %.tin,%.res,$(TESTS))

CC=gcc
CFLAGS=-Wall -Wextra -Werror -ggdb -std=c89

ANSIGREEN="\033[32m"
ANSIYELLOW="\033[33m"
ANSIBOLD="\033[1m"
ANSIRST="\033[0m"
ANSIGOK=" ["$(ANSIGREEN)"OK"$(ANSIRST)"] "
ANSIYBIN=$(ANSIYELLOW)$(BINARY)$(ANSIRST)

MAKEFLAGS+=--silent

all: $(BINARY)

$(BINARY): $(CFILES)
echo -n "** Building "$(ANSIYBIN)":"
$(CC) $(CFLAGS) -o $@ $^
echo $(ANSIGOK)

check: $(TEST_RESULTS)
echo "** "$(ANSIBOLD)$(ANSIYBIN)" test results:"$(ANSIBOLD)$(ANSIGOK)

%.res: %.tin
@./$(BINARY) <$? >$@ult
@diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo -n "- Testing "$(ANSIBOLD)$(BINARY)$(ANSIRST)":" \
$(ANSIYELLOW)$(patsubst $(TESTDIR)%.tin,%,$?)$(ANSIRST)
./$(BINARY) <$? >$@ult
diff --color=always --text $@ult $(patsubst %.tin,%.tout,$?)
echo $(ANSIGOK)

clean:
echo -n "** Cleaning "$(ANSIYBIN)":"
rm -f $(BINARY)
rm -f $(TESTDIR)*.result
echo $(ANSIGOK)
Loading

0 comments on commit 63ef9d6

Please sign in to comment.