clone url: git://git.m455.casa/utils.h
Makefile
1 | # usage: |
2 | # make check: checks for Bad Stuff™ |
3 | # make: builds the damn thing |
4 | # |
5 | SOURCE_FILE = utils.c |
6 | BIN_FILE = a.out |
7 |
|
8 | build: |
9 | $(CC) -std=c89 $(SOURCE_FILE) -o $(BIN_FILE) |
10 |
|
11 | clean: |
12 | @rm $(BIN_FILE) |
13 |
|
14 | check: clang_check gcc_check valgrind_check |
15 | # I found a lot of these from 100r's makefile, and then modified them: |
16 | # https://github.com/hundredrabbits/100r.co/blob/main/makefile |
17 | # as well as a friend from tilde.town who taught me about the fsanitize flags :) |
18 | # meanings can be found here: |
19 | # https://clang.llvm.org/docs/CommandGuide/clang.html |
20 | clang_check: |
21 | @echo "== clang check ====================" |
22 | @clang \ |
23 | -std=c89 \ |
24 | -O2 \ |
25 | -Wall \ |
26 | -Wpedantic \ |
27 | -Werror \ |
28 | -Wextra \ |
29 | -Wshadow \ |
30 | -Wuninitialized \ |
31 | -Wconversion \ |
32 | -Werror=implicit-int \ |
33 | -Werror=incompatible-pointer-types \ |
34 | -Werror=int-conversion \ |
35 | -Wvla \ |
36 | -g \ |
37 | -O0 \ |
38 | -fsanitize=address \ |
39 | -fsanitize=undefined \ |
40 | -fsanitize=leak \ |
41 | $(SOURCE_FILE) -o $(BIN_FILE) |
42 | @./$(BIN_FILE) |
43 | @rm $(BIN_FILE) |
44 | @echo "done!" |
45 |
|
46 | gcc_check: |
47 | @echo "== gcc check ====================" |
48 | @gcc \ |
49 | -std=c89 \ |
50 | -Werror \ |
51 | -Wall \ |
52 | -Wextra \ |
53 | -pedantic-errors \ |
54 | -Wstrict-prototypes \ |
55 | -Wold-style-definition \ |
56 | -Wmissing-prototypes \ |
57 | -Wmissing-declarations \ |
58 | -Wdeclaration-after-statement \ |
59 | -Wconversion \ |
60 | -Wno-unused-function \ |
61 | -Wno-unused-macros \ |
62 | -Wunused-parameter \ |
63 | -Wunused-value \ |
64 | -Wunused-variable \ |
65 | -fanalyzer \ |
66 | $(SOURCE_FILE) -o $(BIN_FILE) |
67 | @./$(BIN_FILE) |
68 | @rm $(BIN_FILE) |
69 | @echo "done!" |
70 |
|
71 | valgrind_check: |
72 | @echo "== valgrind ======================" |
73 | @gcc -g $(SOURCE_FILE) -o $(BIN_FILE) |
74 | @valgrind -s --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(BIN_FILE) |
75 | @rm $(BIN_FILE) |