2015-05-15 17:03:23 +08:00
BIN = bin
SRC = src
EXT = ${ SRC } /externals
2015-05-20 15:36:31 +08:00
2015-05-15 17:03:23 +08:00
# compiler settings
CC = g++
2016-01-20 17:17:13 +08:00
#COMPILER_OPTIONS=-O2
2016-01-28 21:59:31 +08:00
COMPILER_OPTIONS = -g3 -O2 #-fPIC -mavx -maes -mpclmul -DRDTSC -DTEST=AES128
2016-01-20 17:17:13 +08:00
2016-01-28 21:59:31 +08:00
DEBUG_OPTIONS = -g3 -ggdb #-Wall -Wextra
2016-01-20 17:17:13 +08:00
2015-05-15 17:03:23 +08:00
BATCH =
ARCHITECTURE = $( shell uname -m)
i f e q ( $ { A R C H I T E C T U R E } , x 8 6 _ 6 4 )
MIRACL_MAKE := linux64
GNU_LIB_PATH := x86_64
e l s e
MIRACL_MAKE := linux
GNU_LIB_PATH := i386
e n d i f
2015-05-20 20:20:06 +08:00
INCLUDE = -I.. -I/usr/include/glib-2.0/ -I/usr/lib/${ GNU_LIB_PATH } -linux-gnu/glib-2.0/include
2015-05-15 17:03:23 +08:00
2015-05-20 17:48:57 +08:00
LIBRARIES = -lgmp -lgmpxx -lpthread -L /usr/lib -lssl -lcrypto -lglib-2.0
2015-05-15 17:03:23 +08:00
CFLAGS =
2015-05-20 17:48:57 +08:00
# all source files and corresponding object files
2015-05-20 20:20:06 +08:00
SOURCES_CORE := $( shell find ${ CORE } -type f -name '*.cpp' -not -path '*/Miracl/*' -a -not -path '*/mains/*' )
2015-05-20 17:48:57 +08:00
OBJECTS_CORE := $( SOURCES_CORE:.cpp= .o)
2015-05-20 15:36:31 +08:00
# directory for PSI related sources
SOURCES_UTIL = ${ SRC } /util/*.cpp
OBJECTS_UTIL = ${ SRC } /util/*.o
SOURCES_OT = ${ SRC } /util/ot/*.cpp
OBJECTS_OT = ${ SRC } /util/ot/*.o
SOURCES_CRYPTO = ${ SRC } /util/crypto/*.cpp
OBJECTS_CRYPTO = ${ SRC } /util/crypto/*.o
2015-06-11 22:40:41 +08:00
SOURCES_HASHING = ${ SRC } /hashing/*.cpp
OBJECTS_HASHING = ${ SRC } /hashing/*.o
2015-05-20 15:36:31 +08:00
# naive hashing-based solution
SOURCES_NAIVE = ${ SRC } /naive-hashing/*.cpp
OBJECTS_NAIVE = ${ SRC } /naive-hashing/*.o
# public-key-based PSI
SOURCES_DHPSI = ${ SRC } /pk-based/*.cpp
OBJECTS_DHPSI = ${ SRC } /pk-based/*.o
# third-party-based PSI
2015-05-22 00:39:59 +08:00
SOURCES_SERVERAIDED = ${ SRC } /server-aided/*.cpp
OBJECTS_SERVERAIDED = ${ SRC } /server-aided/*.o
2015-05-20 15:36:31 +08:00
# OT-based PSI
SOURCES_OTPSI = ${ SRC } /ot-based/*.cpp
OBJECTS_OTPSI = ${ SRC } /ot-based/*.o
#OBJECTS_BENCH=${SRC}/bench_psi.cpp
2015-05-15 17:03:23 +08:00
# directory for the Miracl submodule and library
MIRACL_LIB_DIR = ${ EXT } /miracl_lib
SOURCES_MIRACL = ${ EXT } /Miracl/*
OBJECTS_MIRACL = ${ MIRACL_LIB_DIR } /*.o
2015-05-20 20:20:06 +08:00
MIRACL_LIB = ${ EXT } /miracl_lib/miracl.a
2015-05-15 17:03:23 +08:00
2015-05-20 15:36:31 +08:00
2016-01-20 22:18:02 +08:00
all : miracl core bench demo
2015-05-20 17:48:57 +08:00
@echo "make all done."
2015-05-20 15:36:31 +08:00
2015-05-20 17:48:57 +08:00
core : ${OBJECTS_CORE }
2015-05-20 15:36:31 +08:00
2015-05-20 17:48:57 +08:00
%.o : %.cpp %.h
2016-01-28 21:59:31 +08:00
${ CC } $< ${ COMPILER_OPTIONS } ${ DEBUG_OPTIONS } -c ${ INCLUDE } ${ LIBRARIES } ${ CFLAGS } ${ BATCH } -o $@
2015-05-20 15:36:31 +08:00
2015-05-20 20:20:06 +08:00
bench :
2015-05-22 00:39:59 +08:00
${ CC } -o psi.exe ${ SRC } /mains/bench_psi.cpp ${ OBJECTS_DHPSI } ${ OBJECTS_OTPSI } ${ OBJECTS_NAIVE } ${ OBJECTS_SERVERAIDED } ${ OBJECTS_UTIL } ${ OBJECTS_HASHING } ${ OBJECTS_CRYPTO } ${ OBJECTS_OT } ${ OBJECTS_MIRACL } ${ CFLAGS } ${ DEBUG_OPTIONS } ${ LIBRARIES } ${ MIRACL_LIB } ${ INCLUDE } ${ COMPILER_OPTIONS }
2015-05-20 20:20:06 +08:00
demo :
2015-05-22 00:39:59 +08:00
${ CC } -o demo.exe ${ SRC } /mains/psi_demo.cpp ${ OBJECTS_DHPSI } ${ OBJECTS_OTPSI } ${ OBJECTS_NAIVE } ${ OBJECTS_SERVERAIDED } ${ OBJECTS_UTIL } ${ OBJECTS_HASHING } ${ OBJECTS_CRYPTO } ${ OBJECTS_OT } ${ OBJECTS_MIRACL } ${ CFLAGS } ${ DEBUG_OPTIONS } ${ LIBRARIES } ${ MIRACL_LIB } ${ INCLUDE } ${ COMPILER_OPTIONS }
2015-05-20 15:36:31 +08:00
2015-06-09 23:46:50 +08:00
test : core
2015-06-09 23:11:57 +08:00
${ CC } -o test.exe ${ SRC } /mains/test_psi.cpp ${ OBJECTS_DHPSI } ${ OBJECTS_OTPSI } ${ OBJECTS_NAIVE } ${ OBJECTS_SERVERAIDED } ${ OBJECTS_UTIL } ${ OBJECTS_HASHING } ${ OBJECTS_CRYPTO } ${ OBJECTS_OT } ${ OBJECTS_MIRACL } ${ CFLAGS } ${ DEBUG_OPTIONS } ${ LIBRARIES } ${ MIRACL_LIB } ${ INCLUDE } ${ COMPILER_OPTIONS }
./test.exe -r 0 -t 10 &
./test.exe -r 1 -t 10
2015-06-08 19:01:13 +08:00
cuckoo :
${ CC } -o cuckoo.exe ${ SRC } /mains/cuckoo_analysis.cpp ${ OBJECTS_UTIL } ${ OBJECTS_HASHING } ${ OBJECTS_CRYPTO } ${ OBJECTS_MIRACL } ${ CFLAGS } ${ DEBUG_OPTIONS } ${ LIBRARIES } ${ MIRACL_LIB } ${ INCLUDE } ${ COMPILER_OPTIONS }
2015-05-20 15:36:31 +08:00
2015-05-15 17:03:23 +08:00
# this will create a copy of the files in ${SOURCES_MIRACL} and its sub-directories and put them into ${MIRACL_LIB_DIR} without sub-directories, then compile it
miracl : ${MIRACL_LIB_DIR }/miracl .a
# copy Miracl files to a new directory (${CORE}/util/miracl_lib/), call the build script and delete everything except the archive, header and object files.
${MIRACL_LIB_DIR}/miracl.a : ${SOURCES_MIRACL }
@find ${ EXT } /Miracl/ -type f -exec cp '{}' ${ EXT } /miracl_lib \;
@cd ${ EXT } /miracl_lib/; bash ${ MIRACL_MAKE } ; find . -type f -not -name '*.a' -not -name '*.h' -not -name '*.o' -not -name '.git*' | xargs rm
# only clean example objects, test object and binaries
clean :
2015-06-08 19:01:13 +08:00
rm -f ${ OBJECTS_EXAMPLE } ${ OBJECTS_TEST } *.exe ${ OBJECTS_DHPSI } ${ OBJECTS_OTPSI } ${ OBJECTS_HASHING } ${ OBJECTS_CRYPTO } ${ OBJECTS_NAIVE } ${ OBJECTS_SERVERAIDED } ${ OBJECTS_UTIL } ${ OBJECTS_CRYPTO } ${ OBJECTS_OT }
2015-05-15 17:03:23 +08:00
# this will clean everything: example objects, test object and binaries and the Miracl library
2015-05-20 20:20:06 +08:00
cleanall : clean
2015-05-15 17:03:23 +08:00
rm -f ${ OBJECTS_MIRACL } ${ MIRACL_LIB_DIR } /*.a