-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (34 loc) · 1.28 KB
/
Makefile
File metadata and controls
51 lines (34 loc) · 1.28 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
LDFLAGS = -lm -fopenmp
CFLAGS = -g -Wall -Wextra -std=c17 -O2 -fPIC -fvisibility=hidden -fopenmp
CC = gcc
OBJDIR = Objs
DEPDIR = Deps
## all shared objects to make
OBJS = $(patsubst %.h,$(OBJDIR)/%.o,$(wildcard *.h))
# default target for production: binaries and shared lib
default: $(OBJDIR) $(DEPDIR) allBins
# for development: like "default" but also build the LSP compilation database
all: $(OBJDIR) $(DEPDIR) compile_commands.json allBins
# all binaries
allBins: testAdjacency gbaCentrality.so
testAdjacency: $(OBJDIR)/testAdjacency.o $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^
gbaCentrality.so: $(OBJS)
$(CC) $(LDFLAGS) -shared -o $@ $^
# make subdirs if they don't exist yet
$(OBJDIR):
mkdir -p $(OBJDIR)
$(DEPDIR):
mkdir -p $(DEPDIR)
# use bear to make a compilation database for LSP (usable by emacs and other IDEs)
# (install bear with "sudo dnf install bear" on RHEL/Alma/Fedora if you don't have it)
compile_commands.json:
bear -- make allBins
# making each object file
$(OBJDIR)/%.o: %.c Makefile
$(CC) $(CFLAGS) -MMD -MF $(DEPDIR)/$*.d -c -o $@ $<
# deps made thanks to -MMD above, just include them
-include $(patsubst %.c,$(DEPDIR)/%.d,$(wildcard *.c))
clean:
rm -f $(OBJDIR)/*.o $(DEPDIR)/*.d compile_commands.json testAdjacency gbaCentrality.so
.PHONY: default all allBins clean