-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (73 loc) · 2.24 KB
/
Makefile
File metadata and controls
98 lines (73 loc) · 2.24 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
CC = g++
# Set this next flag to enable fractional powers for Units
# This needs a compiler with C++20 support AND MAY INCREASE compilation time
# If you don't need fractional powers but want other c++20 support, set to 0
# but set DEFAULT_STD to c++20
USE_FRACTIONAL_POWERS = 1
DEFAULT_STD = c++17
#Set this for compilers which dont support templating friendship, such as GCC pre 13
#NO_SUPPORT_TEMPLATE_FRIENDSHIP = 1
INCLUDE = -I ./include/
SRCDIR = src
OBJDIR = obj
LFLAGS =
CFLAGS = -g -c $(INCLUDE) -O3
CFLAGS += -DNO_NARROWING_CONVERSIONS
ifeq ($(strip $(USE_FRACTIONAL_POWERS)),1)
CFLAGS += -std=c++20 -DUSE_FRACTIONAL_POWERS
$(info *****Enabled fractional powers*****)
else
CFLAGS += -std=$(DEFAULT_STD)
$(info *****Disabled fractional powers*****)
endif
ifeq ($(strip $(NO_SUPPORT_TEMPLATE_FRIENDSHIP)),1)
CFLAGS += -DNO_SUPPORT_TEMPLATE_FRIENDSHIP
endif
DEBUG = -W -Wall -O0 -pedantic -D_GLIBCXX_DEBUG
#DEBUG+= -Wno-sign-compare
DEBUG+= -Wno-unused-parameter
EXENAME = Test
DEPS = -MM
ifeq ($(strip $(MODE)),debug)
CFLAGS += $(DEBUG) -DDEBUG
endif
ifeq ($(strip $(TIMER)),true)
CFLAGS += -DRUN_TIMER_TEST
endif
ifeq ($(strip $(FAIL)), true)
CFLAGS += -DFAIL_DEMO
endif
#list of all header and cpp pairs. Add new files here.....
INCLS =
#make lists of source and object files, all headers plus main
SOURCE := $(INCLS:.h=.cpp)
SOURCE += test.cpp
OBJS := $(SOURCE:.cpp=.o)
#header files only (no .cpp)
INCLS += helper.hpp SimpleFrac.hpp UnitCheckedType.hpp StorageTypes.hpp
#add directory prefixes
SOURCE := $(addprefix $(SRCDIR)/, $(SOURCE))
OBJS := $(addprefix $(OBJDIR)/, $(OBJS))
INCLS := $(addprefix include/, $(INCLS))
VPATH = include/
default : $(OBJS)
$(CC) $(OBJS) $(LFLAGS) -o $(EXENAME)
.PHONY: deps
deps: clean
$(CC) $(CFLAGS) $(DEPS) $(SOURCE)
#Create the object directory before it is used, no error if not exists (order-only prereqs, will not rebuild objects if directory timestamp changes)
$(OBJS): | $(OBJDIR)
$(OBJDIR):
@mkdir -p $(OBJDIR)
obj/%.o:./src/%.cpp
$(CC) $(CFLAGS) $< -o $@
#Dependencies
$(OBJDIR)/test.o : $(SRCDIR)/test.cpp $(INCLS)
.PHONY : tar clean veryclean
clean:
$(RM) $(EXENAME) $(OBJS)
veryclean:
$(RM) $(EXENAME) $(OBJS)
$(RM) -r $(OBJDIR)
tar:
tar -cvf $(EXENAME).tar $(SOURCE) $(INCLS) Makefile