forked from ucbrise/jedi-pairing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (62 loc) · 2.06 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
73
74
75
76
77
78
79
80
# CXX = g++
# CXXFLAGS = -std=c++17 -I./include -Ofast
# AR = ar
# AS = as
# ASFLAGS =
ifeq ($(shell uname),Darwin)
DISABLE_ASM=true
endif
ifeq ($(DISABLE_ASM),true)
EXTRA_CXXFLAGS = -DDISABLE_ASM
else
# Try to autodetect the target architecture and set ARCHDIR accordingly
ARCH = $(shell uname -m)
ARCHDIR = src/core/arch/$(ARCH)
endif
CXX = clang++
CXXFLAGS = -std=c++17 -I./include -Ofast -fno-vectorize -fPIE $(EXTRA_CXXFLAGS)
AR = ar
AS = as
ASFLAGS =
ifneq ($(CXX_OVERRIDE),)
CXX = $(CXX_OVERRIDE)
endif
ifneq ($(AR_OVERRIDE),)
AR = $(AR_OVERRIDE)
endif
ifneq ($(AS_OVERRIDE),)
AS = $(AS_OVERRIDE)
endif
# 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
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)
BIN_OS ?= $(shell uname)
BIN_ARCH ?= $(shell uname -m)
BINDIR = bin
PAIRING_OBJECTS = $(addprefix $(BINDIR)/,$(CPP_SOURCES:.cpp=.o)) $(addprefix $(BINDIR)/,$(ASM_SOURCES:.s=.o))
.PHONY: all
all: pairing.a ;
$(BINDIR)/builtfor-%:
@echo "JEDI DETECTED ARCH CHANGE, CLEANING"
@rm -rf bin
@rm -rf pairing.a
@mkdir -p $(BINDIR)
@touch $@
pairing.a: $(BINDIR)/builtfor-$(BIN_OS)-$(BIN_ARCH) $(PAIRING_OBJECTS)
$(AR) rcs pairing.a $(wordlist 2,$(words $+),$+ )
$(BINDIR)/%.o: $(BINDIR)/builtfor-$(BIN_OS)-$(BIN_ARCH) %.cpp
mkdir -p $(dir $@)
$(CXX) -c $(CXXFLAGS) $(word 2,$+) -o $@
$(BINDIR)/%.o: $(BINDIR)/builtfor-$(BIN_OS)-$(BIN_ARCH) %.s
mkdir -p $(dir $@)
$(AS) $(ASFLAGS) $(word 2,$+) -o $@
clean:
rm -rf bin pairing.a