-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (74 loc) · 2.5 KB
/
Copy pathMakefile
File metadata and controls
98 lines (74 loc) · 2.5 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
CXX = g++
CC = gcc
# -MMD genera file .d per il tracking automatico delle dipendenze degli header
# -D_FILE_OFFSET_BITS=64 dovrebbe essere superfluo dato il limite di 1GiB
CXXFLAGS = -std=c++20 -Wall -Wextra -O3 -march=native -D_FILE_OFFSET_BITS=64 -DNDEBUG -MMD -Wno-interference-size
CFLAGS = -Wall -Wextra -O3 -march=native -D_FILE_OFFSET_BITS=64 -MMD
INCLUDES = -Iinclude -Iexternal
LDFLAGS =
PTHREAD = -pthread
OMPFLAGS = -fopenmp
ifeq ($(TSAN), 1)
CXXFLAGS := $(filter-out -O3 -march=native -DNDEBUG,$(CXXFLAGS))
CFLAGS := $(filter-out -O3 -march=native,$(CFLAGS))
CXXFLAGS += -O1 -g -fsanitize=thread
CFLAGS += -O1 -g -fsanitize=thread
LDFLAGS += -fsanitize=thread
# export TSAN_OPTIONS=ignore_noninstrumented_modules=1
endif
ifeq ($(INSTRUMENT), 1)
CXXFLAGS += -DENABLE_INSTRUMENTATION
endif
# Directory
SRCDIR = src
BINDIR = bin
OBJDIR = obj
EXTDIR = external/miniz
INCDIR = include
# Target principali
TARGETS = $(BINDIR)/seq_miniz $(BINDIR)/par_miniz $(BINDIR)/omp_miniz
# sorgenti e oggetti
SRC_SEQ = $(SRCDIR)/seq_miniz.cpp
SRC_PAR = $(SRCDIR)/par_miniz.cpp
SRC_OMP = $(SRCDIR)/omp_miniz.cpp
OBJ_SEQ = $(OBJDIR)/seq_miniz.o
OBJ_PAR = $(OBJDIR)/par_miniz.o
OBJ_OMP = $(OBJDIR)/omp_miniz.o
MINIZ_OBJ = $(OBJDIR)/miniz.o
# regole principali
.PHONY: all clean cleanall folders tsan
all: folders $(TARGETS)
# target per test di correttezza (ThreadSanitizer con Clang)
tsan:
$(MAKE) clean
$(MAKE) TSAN=1 CXX=clang++ CC=clang
tsan-gcc:
$(MAKE) clean
$(MAKE) TSAN=1
folders:
@mkdir -p $(BINDIR)
@mkdir -p $(OBJDIR)
$(OBJDIR)/miniz.o: $(EXTDIR)/miniz.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# regola per la compilazione dei file oggetto .o dai sorgenti .cpp
$(OBJDIR)/seq_miniz.o: $(SRCDIR)/seq_miniz.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(OBJDIR)/par_miniz.o: $(SRCDIR)/par_miniz.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(OBJDIR)/omp_miniz.o: $(SRCDIR)/omp_miniz.cpp
$(CXX) $(CXXFLAGS) $(OMPFLAGS) $(INCLUDES) -c $< -o $@
# regole compilazione eseguibili tramite file oggetto .o
$(BINDIR)/seq_miniz: $(OBJ_SEQ) $(MINIZ_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
$(BINDIR)/par_miniz: $(OBJ_PAR) $(MINIZ_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(PTHREAD)
$(BINDIR)/omp_miniz: $(OBJ_OMP) $(MINIZ_OBJ)
$(CXX) $(CXXFLAGS) $(OMPFLAGS) -o $@ $^ $(LDFLAGS) $(PTHREAD)
# inclusione delle dipendenze generate automaticamente
# alla prima compilazione invece di fallire li crea
-include $(OBJDIR)/*.d
# pulizia
clean:
rm -rf $(OBJDIR) $(TARGETS)
cleanall: clean
rm -rf $(BINDIR) $(OBJDIR)