Makefile.benchmark 4.64 KB
Newer Older
Gerard Ryan's avatar
Gerard Ryan committed
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
#
#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.
#

Gerard Ryan's avatar
Gerard Ryan committed
26 27 28 29 30
# this defines the source, build (obj) and binary directories
BMARK_SRC := benchmark/src
BMARK_BIN := $(BINDIR)/benchmark
BMARK_BUILD := $(BINDIR)/build/benchmark

31 32 33
BMLIB_SRCDIR := google/benchmark-master/src
BMLIB_IFLAG := -I$(BMLIB_SRCDIR)/../include
BMLIB_SRC := $(wildcard $(BMLIB_SRCDIR)/*.cc)
Gerard Ryan's avatar
Gerard Ryan committed
34
BMLIB_OBJ := $(patsubst $(BMLIB_SRCDIR)/%,$(BMARK_BUILD)/%,$(BMLIB_SRC:.cc=.o)) 
Gerard Ryan's avatar
Gerard Ryan committed
35 36

#this defines the benchmark library archive
Gerard Ryan's avatar
Gerard Ryan committed
37
BMLIB_LIB := $(BMARK_BIN)/libbenchmark.a
Gerard Ryan's avatar
Gerard Ryan committed
38 39 40 41 42 43 44 45 46 47

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

48
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
Gerard Ryan's avatar
Gerard Ryan committed
49

50 51
#define list of source files (all files with .cc in the BMARK_SRC
BM_SOURCES :=  $(wildcard $(BMARK_SRC)/*.cpp) 
Gerard Ryan's avatar
Gerard Ryan committed
52

53
BM_OBJS :=  $(BM_SOURCES:$(BMARK_SRC)%.cpp=$(BMARK_BUILD)%.o)
Gerard Ryan's avatar
Gerard Ryan committed
54

55
-include $(BM_OBJS:.o=.d)
Gerard Ryan's avatar
Gerard Ryan committed
56

57
BMARKS :=  $(BM_SOURCES:$(BMARK_SRC)%.cpp=$(BMARK_BIN)%$(EXESUFFIX))
Gerard Ryan's avatar
Gerard Ryan committed
58

59
benchmark: $(BMLIB_LIB) $(BMARKS)
Gerard Ryan's avatar
Gerard Ryan committed
60

61 62
# this builds objects from sources for benchmark library
.PRECIOUS: $(BMLIB_SRCDIR)/%.o
Gerard Ryan's avatar
Gerard Ryan committed
63 64
$(BMARK_BUILD)/%.o: $(BMLIB_SRCDIR)/%.cc
	@mkdir -p $(BMARK_BUILD)
65
	$(CC) $(CPPFLAGS) $(LIBBENCHMARK_FLAGS) $(BMLIB_IFLAG) -o $@ -c $<
Gerard Ryan's avatar
Gerard Ryan committed
66

67 68
.PRECIOUS: $(BMLIB_LIB)
$(BMLIB_LIB): $(BMLIB_OBJ)
Gerard Ryan's avatar
Gerard Ryan committed
69
	@mkdir -p $(BMARK_BIN)
70 71
	ar cr $(BMLIB_LIB) $(BMLIB_OBJ)
	ranlib $(BMLIB_LIB) 
Gerard Ryan's avatar
Gerard Ryan committed
72

73 74
# this is where the benchmark library code lives
BMLIB_LIBSRCDIR := google/benchmark-master/include
Gerard Ryan's avatar
Gerard Ryan committed
75

76
########### PALISADE BENCHMARKS BUILD HERE
Gerard Ryan's avatar
Gerard Ryan committed
77 78

#this is is the Include directive for the palisade code being benchmarked
Gerard Ryan's avatar
Gerard Ryan committed
79
BM_IFLAG := -Isrc -Isrc/core/lib -Isrc/pke/lib $(BMLIB_IFLAG) $(THIRDPARTYINCLUDE)
Gerard Ryan's avatar
Gerard Ryan committed
80

Gerard Ryan's avatar
Gerard Ryan committed
81
PLIBS := $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
82 83

# this builds executables from objects for benchmarks
Gerard Ryan's avatar
Gerard Ryan committed
84
$(BMARK_BIN)/%$(EXESUFFIX): $(BMARK_BUILD)/%.o $(BMLIB_LIB) $(PLIBS)
85
	@mkdir -p $(BMARK_BIN)
Gerard Ryan's avatar
Gerard Ryan committed
86 87
	$(CC) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS)  $(BMLIB_IFLAG) $< -o $@ $(LOADTHREADFLAG) $(RDYNAMIC) $(BMLIB_LIB) -L$(EXTLIBDIR) -lPALISADEpke -lPALISADEcore $(NTLLIB) $(GMPLIB) -lpthread $(LOADTHREADFLAG) -fopenmp -lgomp $(SHLWAPI)

Gerard Ryan's avatar
Gerard Ryan committed
88 89

# this builds objects from sources for benchmarks
Gerard Ryan's avatar
Gerard Ryan committed
90 91 92
.PRECIOUS: $(BMARK_BUILD)/%.o
$(BMARK_BUILD)/%.o: $(BMARK_SRC)/%.cpp
	@mkdir -p $(BMARK_BUILD)
93
	@$(CC) -MM $(CPPFLAGS) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS)  $(BM_IFLAG) $(patsubst $(BMARK_BUILD)/%,$(BMARK_SRC)/%,$(patsubst %.o,%.cpp,$@))  > $(patsubst %.o,%.d,$@)
Gerard Ryan's avatar
Gerard Ryan committed
94 95 96
	@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,$@)
97
	$(CC) $(CPPFLAGS) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS)  $(BM_IFLAG) -c -o $@ $(patsubst $(BMARK_BUILD)/%,$(BMARK_SRC)/%,$(patsubst %.o,%.cpp,$@))
Gerard Ryan's avatar
Gerard Ryan committed
98 99

#this target is usesd to cleanup, it is called from the top Makefile
Gerard Ryan's avatar
Gerard Ryan committed
100
.PHONY: cleanbenchmark
Gerard Ryan's avatar
Gerard Ryan committed
101 102
cleanbenchmark:
	@echo " Cleaning Benchmarks...";
103
	$(RM) -r $(BMARK_BIN) $(BMARK_BUILD) $(BMLIB_OBJ) $(BMLIB_LIB)
Gerard Ryan's avatar
Gerard Ryan committed
104

105
bstrings:
Gerard Ryan's avatar
Gerard Ryan committed
106 107 108 109 110
	@echo BMARKS is $(BMARKS)
	@echo BMLIB_SRC is $(BMLIB_SRC)
	@echo BMLIB_OBJ is $(BMLIB_OBJ)
	@echo  $(BMLIB_SRC:.cc=.o)
	@echo $(BMLIB_SRCDIR)