This repository was archived by the owner on Aug 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (55 loc) · 2.14 KB
/
Makefile
File metadata and controls
73 lines (55 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#
# Copyright 2025 Nick Brown <njbrown4@buffalo.edu>
#
# This file is part of nickdb.
#
# nickdb is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# nickdb is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
CC := gcc
CFLAGS := -O2 -Wall -Werror -Wextra -std=c99 -D_DEFAULT_SOURCE -D_GNU_SOURCE
CDEBUGFLAGS := -O0 -g -Wall -Werror -Wextra -fsanitize=address -fsanitize=leak -std=c99 -D_DEFAULT_SOURCE -D_GNU_SOURCE -DDEBUG
LDFLAGS :=
LDASNFLAGS := -static-libubsan
TESTS := fileiotest pageiotest
SRCDIR := src/
LIBDIR := src/lib/
DATASTRUCTURESDIR := src/lib/datastructures/
SOURCES := $(SRCDIR)nickdb.c
OBJS := $(patsubst %.c,%.o,$(SOURCES))
LIBS := $(LIBDIR)constants.c $(LIBDIR)fileio.c $(LIBDIR)buffer_manager.c
LIBOBJS := $(patsubst %.c,%.o,$(LIBS))
DATASTRUCTURES := $(DATASTRUCTURESDIR)btree.c
DATASTRUCTUREOBJS := $(patsubst %.c,%.o,$(DATASTRUCTURES))
GLIBH := $(shell pkg-config --cflags glib-2.0)
GLIBL := $(shell pkg-config --libs glib-2.0)
nickdb: $(SOURCES) $(LIBS) $(DATASTRUCTURES)
$(CC) $(CFLAGS) $(LDFLAGS) $(GLIBH) -o $@ $^ $(GLIBL)
debug: $(SOURCES) $(LIBS) $(DATASTRUCTURES)
$(CC) $(CDEBUGFLAGS) $(LDASNFLAGS) $(GLIBH) -o $@ $^ $(GLIBL)
test: $(TESTS)
@echo
@for test in $^; do \
printf "Running %-20s: " "$$test"; \
(./$$test && echo "passed\n") || echo "failed\n"; \
done
@echo
%: tests/%.c $(LIBS) $(DATASTRUCTURES)
$(CC) $(CDEBUGFLAGS) $(LDASNFLAGS) $(GLIBH) -o $@ $^ $(GLIBL)
clean:
rm -f src/*~ src/lib/*~ src/lib/*/*~ tests/*~ $(OBJS) $(LIBOBJS) $(DATASTRUCTUREOBJS)
rm -f $(TESTS)
rm -f *~nickdb
rm -f *~debug
rm -f *.store
rm -f nickdb debug
.PHONY: all clean