-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
73 lines (61 loc) · 2.37 KB
/
makefile
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
CC = g++
CFLAGS = -std=c++17 -lstdc++fs -lcryptopp -Wall -lsystemd -O3
BLFLAGS = -shared -O3
IDIR = ./include/
SDIR = ./src/
ODIR = ./obj/
LDIR = ./lib/
BLAKE = ./external/blake3/
BLIB = ./lib/libblake3.so
LIBDIR=$(abspath $(LDIR))
LD = -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) -I$(BLAKE)
arch := $(shell uname -m)
main:$(SDIR)fsCheckDaemon.cpp $(IDIR)fsCheckDaemon.hpp $(ODIR)mnode.o $(ODIR)mtree.o $(IDIR)mtree.hpp $(ODIR)utils.o $(IDIR)utils.hpp
@echo Compiling fsCheckDaemon...
@g++ $(LD) -o fsCheckDaemon $(SDIR)fsCheckDaemon.cpp $(ODIR)mtree.o $(ODIR)mnode.o $(ODIR)utils.o -lblake3 $(CFLAGS) -lpthread
@echo Done
$(ODIR)utils.o: $(SDIR)utils.cpp $(IDIR)utils.hpp
@echo Compiling utils...
@g++ -c $(SDIR)utils.cpp -o $(ODIR)utils.o -std=c++17 -lstdc++fs -Wall
$(ODIR)mnode.o: $(SDIR)mnode.cpp $(IDIR)mnode.hpp
@mkdir -p $(ODIR) $(LDIR)
@echo Compiling mnode...
@g++ $(LD) -c $(SDIR)mnode.cpp -o $(ODIR)mnode.o -lblake3 $(CFLAGS)
$(ODIR)mtree.o: $(SDIR)mtree.cpp $(IDIR)mtree.hpp $(IDIR)mnode.hpp
@echo Compiling mtree...
@g++ -c $(SDIR)mtree.cpp -o $(ODIR)mtree.o $(CFLAGS)
@/bin/bash -c "if [ ! -f ./lib/libblake3.so ]; then \
make blake; \
fi"
blake:
@echo 'Blake lib not detected...';
ifeq ($(arch),x86_64)
@echo "Target x86_64 detected for blake3..."
@echo "Compiling blake for x86_64..."
@gcc $(BLFLAGS) -o $(LDIR)libblake3.so $(BLAKE)blake3.c $(BLAKE)blake3_dispatch.c $(BLAKE)blake3_portable.c $(BLAKE)blake3_sse2_x86-64_unix.S $(BLAKE)blake3_sse41_x86-64_unix.S $(BLAKE)blake3_avx2_x86-64_unix.S $(BLAKE)blake3_avx512_x86-64_unix.S -lm
endif
ifneq ($(filter $(arch), arm64 aarch64),)
@echo "Target arm detected for blake3..."
@echo "Compiling blake for arm..."
@gcc -shared -O3 -o $(LDIR)libblake3.so -DBLAKE3_USE_NEON $(BLAKE)blake3.c $(BLAKE)blake3_dispatch.c $(BLAKE)blake3_portable.c $(BLAKE)blake3_neon.c
endif
@echo Done
blake-portable:
@echo "Compiling the generic version of blake3:"
@gcc -shared -O3 -o $(LDIR)libblake3.so $(BLAKE)blake3.c $(BLAKE)blake3_dispatch.c $(BLAKE)blake3_portable.c
@echo "Done."
.PHONY : clean, all, clean-all, fresh, generic
all: blake main
fresh: clean-all all
generic: blake-portable main
clean :
@echo Cleaning object files and the executable...
@rm -f $(ODIR)*
@rm -f fsCheckDaemon
@echo Done
clean-all:
@echo Cleaning object files, the executable and blake3 lib...
@rm -f $(LDIR)*
@rm -f $(ODIR)*
@rm -f fsCheckDaemon
@echo Done