summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2023-09-16 09:57:57 -0400
committerPaul Duncan <pabs@pablotron.org>2023-09-16 09:57:57 -0400
commit6c8325139a08edf53c7097e9345d41b605a19373 (patch)
tree342c1afcf4bd8a0fd416406636899e5eb57a18ed
parent8c978325439a3d8f44c24bedc45ad895796ea94c (diff)
downloadsha3-6c8325139a08edf53c7097e9345d41b605a19373.tar.bz2
sha3-6c8325139a08edf53c7097e9345d41b605a19373.zip
Makefile: add TEST_CFLAGS with sanitizers, add comments
-rw-r--r--Makefile22
1 files changed, 15 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index b858ffc..609c0cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,28 @@
+# compiler flags used for sample application and shared library
CFLAGS=-W -Wall -Wextra -Werror -pedantic -std=c11 -O3 -march=native -mtune=native
+
+# sample application
+APP=./sha3
+APP_OBJS=sha3.o main.o
+
+# test app (test suite and sanitizers)
+TEST_CFLAGS=-g -fsanitize=address,pointer-compare,pointer-subtract,undefined,leak -W -Wall -Wextra -Werror -pedantic -std=c11
TEST_APP=./test-sha3
-EXAMPLE_APP=./sha3
-OBJS=sha3.o main.o
.PHONY=test all
-all: $(EXAMPLE_APP)
+all: $(APP)
-$(EXAMPLE_APP): $(OBJS)
- $(CC) -o $(EXAMPLE_APP) $(CFLAGS) $(OBJS)
+# build sample application
+$(APP): $(APP_OBJS)
+ $(CC) -o $(APP) $(CFLAGS) $(APP_OBJS)
%.o: %.c
$(CC) -c $(CFLAGS) $<
+# build and run test suite with sanitizers
test:
- $(CC) -o $(TEST_APP) $(CFLAGS) -DSHA3_TEST sha3.c && $(TEST_APP)
+ $(CC) -o $(TEST_APP) $(TEST_CFLAGS) -DSHA3_TEST sha3.c && $(TEST_APP)
clean:
- $(RM) -f $(TEST_APP) $(EXAMPLE_APP) $(OBJS)
+ $(RM) -f $(TEST_APP) $(APP) $(APP_OBJS)