-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
62 lines (48 loc) · 1.83 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
# CXX = g++
# CXXFLAGS = -std=c++17 -I./include -Ofast
# AR = ar
# AS = as
# ASFLAGS =
CXX = clang++
CXXFLAGS = -std=c++17 -I./include -Ofast -fno-vectorize
AR = ar
AS = as
ASFLAGS =
# Detect if on a recent version of Ubuntu with clang++, and add -fPIC if so
ifeq ($(CXX),clang++)
ifeq ($(shell lsb_release -i | cut -f 2),Ubuntu)
UBUNTU_YEAR = $(shell lsb_release -r | cut -f 2 | cut -d '.' -f 1)
ifeq ($(shell expr $(UBUNTU_YEAR) \>= 17),1)
CXXFLAGS += -fPIC
endif
endif
endif
# Try to autodetect the target architecture and set ARCHDIR accordingly
ARCH = $(shell uname -m)
ARCHDIR = src/core/arch/$(ARCH)
# Comment out the above and uncomment the below for embedded build
# CXX = arm-none-eabi-g++
# CXXFLAGS = -std=c++17 -I./include -Os -mcpu=cortex-m0plus -mlittle-endian -mthumb -mfloat-abi=soft -mno-thumb-interwork -ffunction-sections -fdata-sections -fno-builtin -fshort-enums -fno-threadsafe-statics
# AR = arm-none-eabi-ar
# AS = arm-none-eabi-as
# ASFLAGS = -mcpu=cortex-m0plus -mlittle-endian -mthumb -mfloat-abi=soft
# ARCHDIR = src/core/arch/armv6_m
# To disable assembly optimizations, uncomment the following line (which adds -DDISABLE_ASM to CXXFLAGS)
# CXXFLAGS += -DDISABLE_ASM
PAIRING_CPP_SOURCES = $(wildcard src/core/*.cpp) $(wildcard src/bls12_381/*.cpp) $(wildcard src/wkdibe/*.cpp) $(wildcard src/lqibe/*.cpp) $(wildcard $(ARCHDIR)/*.cpp)
PAIRING_ASM_SOURCES = $(wildcard $(ARCHDIR)/*.s)
CPP_SOURCES = $(PAIRING_CPP_SOURCES)
ASM_SOURCES = $(PAIRING_ASM_SOURCES)
BINDIR = bin
PAIRING_OBJECTS = $(addprefix $(BINDIR)/,$(CPP_SOURCES:.cpp=.o)) $(addprefix $(BINDIR)/,$(ASM_SOURCES:.s=.o))
all: pairing.a
pairing.a: $(PAIRING_OBJECTS)
$(AR) rcs pairing.a $+
$(BINDIR)/%.o: %.cpp
mkdir -p $(dir $@)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(BINDIR)/%.o: %.s
mkdir -p $(dir $@)
$(AS) $(ASFLAGS) $< -o $@
clean:
rm -rf bin pairing.a