From a58f720cc16bdb5063833e2a6e6c07f92df4feaa Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 15 Sep 2023 01:32:57 -0300 Subject: [PATCH] Add `make example` Compiles and runs the examples in `share/isinetaddr/examples/`. --- Makefile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 481decf..71b4725 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ SRCDIR = src SRCFILES = $(SRCDIR)/isinetaddr4.c $(SRCDIR)/iscidraddr4.c $(SRCDIR)/isinetaddr6.c INCDIR = include TESTDIR = test +EXAMPLEDIR = share/isinetaddr/examples/ +EXAMPLEBIN = example CC = cc CFLAGS = -fstack-protector-all -I$(INCDIR) -Wall -Wextra -pedantic @@ -23,4 +25,15 @@ test6: @echo -n test/isinetaddr6: '' @$(TESTDIR)/isinetaddr6 -.PHONY: test +example: + @for file in isinetaddr4.c iscidraddr4.c isinetaddr6.c ; do \ + echo Example: $$file; \ + $(CC) $(CFLAGS) $(SRCFILES) $(EXAMPLEDIR)/$$file -o $(EXAMPLEBIN); \ + ./$(EXAMPLEBIN); \ + rm $(EXAMPLEBIN); \ + if [ $$file != isinetaddr6.c ]; then \ + echo; \ + fi; \ + done + +.PHONY: test example