forked from holybao/PALISADE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.benchmark
110 lines (88 loc) · 4.64 KB
/
Makefile.benchmark
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
99
100
101
102
103
104
105
106
107
108
109
110
#
#Copyright (c) 2015, New Jersey Institute of Technology (NJIT)
#All rights reserved.
#Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
#met:
#1. Redistributions of source code must retain the above copyright
#notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
#notice, this list of conditions and the following disclaimer in the
#documentation and/or other materials provided with the distribution.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
#IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#PARTICULAR PURPOSE ARE DISCLAIMED.
#IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
#STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
#IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#POSSIBILITY OF SUCH DAMAGE.
#
# this defines the source, build (obj) and binary directories
BMARK_SRC := benchmark/src
BMARK_BIN := $(BINDIR)/benchmark
BMARK_BUILD := $(BINDIR)/build/benchmark
BMLIB_SRCDIR := google/benchmark-master/src
BMLIB_IFLAG := -I$(BMLIB_SRCDIR)/../include
BMLIB_SRC := $(wildcard $(BMLIB_SRCDIR)/*.cc)
BMLIB_OBJ := $(patsubst $(BMLIB_SRCDIR)/%,$(BMARK_BUILD)/%,$(BMLIB_SRC:.cc=.o))
#this defines the benchmark library archive
BMLIB_LIB := $(BMARK_BIN)/libbenchmark.a
REGEX_FLAG := -DHAVE_STD_REGEX #note does not work for g++ <version 4.9
#### this warning flag should NOT be used with clang
WARNING_FLAG := -Wno-unused-but-set-variable
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
WARNING_FLAG :=
endif
LIBBENCHMARK_FLAGS := $(REGEX_FLAG) -DHAVE_STEADY_CLOCK -DNDEBUG $(WARNING_FLAG) -Wno-unused-variable ##-Wextra -Wshadow -pedantic -pedantic-errors -Wfloat-equal -Wzero-as-null-pointer-constant -fstrict-aliasing -Wstrict-aliasing -Wno-nested-anon-types
#define list of source files (all files with .cc in the BMARK_SRC
BM_SOURCES := $(wildcard $(BMARK_SRC)/*.cpp)
BM_OBJS := $(BM_SOURCES:$(BMARK_SRC)%.cpp=$(BMARK_BUILD)%.o)
-include $(BM_OBJS:.o=.d)
BMARKS := $(BM_SOURCES:$(BMARK_SRC)%.cpp=$(BMARK_BIN)%$(EXESUFFIX))
benchmark: $(BMLIB_LIB) $(BMARKS)
# this builds objects from sources for benchmark library
.PRECIOUS: $(BMLIB_SRCDIR)/%.o
$(BMARK_BUILD)/%.o: $(BMLIB_SRCDIR)/%.cc
@mkdir -p $(BMARK_BUILD)
$(CC) $(CPPFLAGS) $(LIBBENCHMARK_FLAGS) $(BMLIB_IFLAG) -o $@ -c $<
.PRECIOUS: $(BMLIB_LIB)
$(BMLIB_LIB): $(BMLIB_OBJ)
@mkdir -p $(BMARK_BIN)
ar cr $(BMLIB_LIB) $(BMLIB_OBJ)
ranlib $(BMLIB_LIB)
# this is where the benchmark library code lives
BMLIB_LIBSRCDIR := google/benchmark-master/include
########### PALISADE BENCHMARKS BUILD HERE
#this is is the Include directive for the palisade code being benchmarked
BM_IFLAG := -Isrc -Isrc/core/lib -Isrc/pke/lib $(BMLIB_IFLAG) $(THIRDPARTYINCLUDE)
PLIBS := $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
# this builds executables from objects for benchmarks
$(BMARK_BIN)/%$(EXESUFFIX): $(BMARK_BUILD)/%.o $(BMLIB_LIB) $(PLIBS)
@mkdir -p $(BMARK_BIN)
$(CC) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS) $(BMLIB_IFLAG) $< -o $@ $(LOADTHREADFLAG) $(RDYNAMIC) $(BMLIB_LIB) -L$(EXTLIBDIR) -lPALISADEpke -lPALISADEcore $(NTLLIB) $(GMPLIB) -lpthread $(LOADTHREADFLAG) -fopenmp -lgomp $(SHLWAPI)
# this builds objects from sources for benchmarks
.PRECIOUS: $(BMARK_BUILD)/%.o
$(BMARK_BUILD)/%.o: $(BMARK_SRC)/%.cpp
@mkdir -p $(BMARK_BUILD)
@$(CC) -MM $(CPPFLAGS) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS) $(BM_IFLAG) $(patsubst $(BMARK_BUILD)/%,$(BMARK_SRC)/%,$(patsubst %.o,%.cpp,$@)) > $(patsubst %.o,%.d,$@)
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d.tmp,$@)
@sed -e 's|.*\.o:|$@:|' < $(patsubst %.o,%.d.tmp,$@) > $(patsubst %.o,%.d,$@)
@rm -f $(patsubst %.o,%.d.tmp,$@)
$(CC) $(CPPFLAGS) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS) $(BM_IFLAG) -c -o $@ $(patsubst $(BMARK_BUILD)/%,$(BMARK_SRC)/%,$(patsubst %.o,%.cpp,$@))
#this target is usesd to cleanup, it is called from the top Makefile
.PHONY: cleanbenchmark
cleanbenchmark:
@echo " Cleaning Benchmarks...";
$(RM) -r $(BMARK_BIN) $(BMARK_BUILD) $(BMLIB_OBJ) $(BMLIB_LIB)
bstrings:
@echo BMARKS is $(BMARKS)
@echo BMLIB_SRC is $(BMLIB_SRC)
@echo BMLIB_OBJ is $(BMLIB_OBJ)
@echo $(BMLIB_SRC:.cc=.o)
@echo $(BMLIB_SRCDIR)