Skip to content

Commit

Permalink
Merge pull request #49 from mouse07410/master
Browse files Browse the repository at this point in the history
Fix linking, running tests, etc.
  • Loading branch information
jakinyele authored Oct 5, 2020
2 parents 3bffe3e + a8f4b3a commit f44844d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifndef ZROOT
$(error ZROOT is undefined. Need to source env file: . ./env)
endif

INSTALL_PREFIX := /usr/local
INSTALL_PREFIX = /usr/local

docs:
$(MAKE) -C docs
Expand Down Expand Up @@ -60,6 +60,7 @@ clean:
$(MAKE) -C cli clean
$(MAKE) -C examples clean
$(RM) -rf $(ZROOT)/deps/root
$(RM) -rf $(ZROOT)/root/lib/* $(ZROOT)/root/include/*

distclean: clean
$(MAKE) -C deps distclean
24 changes: 10 additions & 14 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# Shared Makefile for
# Shared Makefile for openabe build from the source

CC ?= g++
CXX ?= g++
ifndef LDLIBS
LDLIBS := -lgtest -lpthread
endif

LDLIBS ?= -lgtest -lpthread

DEPS_INSTALL_ZROOT = $(ZROOT)/deps/root
OABE_LIB_ROOT = $(ZROOT)/root/lib
INCLUDE_ROOT = $(ZROOT)/root/include
ifndef LOCAL_LIB_ROOT
LOCAL_LIB_ROOT = /usr/local/lib
endif
ifndef LOCAL_INCLUDE
LOCAL_INCLUDE = /usr/local/include
endif
LOCAL_INSTALL_BIN = /usr/local/bin
LOCAL_LIB_ROOT ?= /usr/local/lib
LOCAL_INCLUDE ?= /usr/local/include
LOCAL_INSTALL_BIN ?= /usr/local/bin

# Include locations
# Dependencies (C/C++)
Expand All @@ -28,6 +23,7 @@ CCFLAGS += -I$(INCLUDE_ROOT) -I$(LOCAL_INCLUDE)
CXXFLAGS += -I$(INCLUDE_ROOT) -I$(LOCAL_INCLUDE)

RELIC_LIB = -lrelic -lrelic_ec
RELIC_LIB_STATIC = -lrelic_s -lrelic_s_ec
GMP_LIB = -lgmp
SSL_LIB = -lssl
CRYPTO_LIB = -lcrypto
Expand Down Expand Up @@ -141,12 +137,12 @@ else
# relic-only build for math ops
CXXFLAGS += $(OPENSSL_ZML)
CCFLAGS += -g -O2 $(OPENSSL_ZML) $(ADD_CFLAGS)
OABELDLIBS = $(RELIC_LIB)
OABELDLIBS = $(RELIC_LIB_STATIC)
OABELDSHLIBS = $(RELIC_LIB)
endif
# remaining deps
OABELDLIBS += $(SSL_LIB) $(CRYPTO_LIB)
OABELDSHLIBS += $(SSL_LIB) $(CRYPTO_LIB)
OABELDLIBS += $(SSL_LIB) $(CRYPTO_LIB) $(GMP_LIB)
OABELDSHLIBS += $(SSL_LIB) $(CRYPTO_LIB) $(GMP_LIB)

SHLIB_PATH = $(LDFLAGS)

Expand Down
8 changes: 4 additions & 4 deletions cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ install: $(BINOBJS)
# NOTE: order of library matters: libztk first, then relic, then gmp
# if relic goes before ztk, then you'll see a bunch of undefined references to relic symbols!
oabe_setup: $(OBJS)
$(CXX) -o oabe_setup $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/setup.cpp $(OABE_LIB) $(OABELDLIBS)
$(CXX) -o oabe_setup $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/setup.cpp $(OABE_LIB) $(OABELDSHLIBS)

oabe_keygen: $(OBJS)
$(CXX) -o oabe_keygen $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/keygen.cpp $(OABE_LIB) $(OABELDLIBS)
$(CXX) -o oabe_keygen $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/keygen.cpp $(OABE_LIB) $(OABELDSHLIBS)

oabe_enc: $(OBJS)
$(CXX) -o oabe_enc $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/encrypt.cpp $(OABE_LIB) $(OABELDLIBS)
$(CXX) -o oabe_enc $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/encrypt.cpp $(OABE_LIB) $(OABELDSHLIBS)

oabe_dec: $(OBJS)
$(CXX) -o oabe_dec $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/decrypt.cpp $(OABE_LIB) $(OABELDLIBS)
$(CXX) -o oabe_dec $(OBJS) -I../src/ $(CXXFLAGS) $(LDFLAGS) $(CUR_DIR)/decrypt.cpp $(OABE_LIB) $(OABELDSHLIBS)

%.o: %.c
$(CC) $(CCFLAGS) -c $<
Expand Down
6 changes: 3 additions & 3 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ ifdef LOCAL_LIB_ROOT
LOC_LIB="-L$(LOCAL_LIB_ROOT)"
endif

CXXFLAGS := $(CXX11FLAGS) $(OS_CXXFLAGS) -pthread -Wall -g -O2 -DSSL_LIB_INIT -I${ZROOT}/deps/root/include -I${ZROOT}/root/include $(LOC_INC)
LDFLAGS := -L${ZROOT}/deps/root/lib -L${ZROOT}/root/lib $(LOC_LIB)
LIBS := -lcrypto -lrelic -lrelic_ec -lopenabe
CXXFLAGS = $(CXX11FLAGS) $(OS_CXXFLAGS) -pthread -Wall -g -O2 -DSSL_LIB_INIT -I${ZROOT}/deps/root/include -I${ZROOT}/root/include $(LOC_INC)
LDFLAGS = -L${ZROOT}/deps/root/lib -L${ZROOT}/root/lib $(LOC_LIB)
LIBS = -lcrypto -lrelic -lrelic_ec -lopenabe

all: test_kp test_cp test_pk test_km

Expand Down
27 changes: 24 additions & 3 deletions macport.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,38 @@
# $ source macport.emv
# $ make && make test
#
# To install, do (after making sure "LOCAL_INSTALL_BIN" points where ypu want it to):
#
# $ sudo -EH make install
#
source ./env
export ADD_CFLAGS="-I/opt/local/include -march=native"
# For the case when "bison" in on the PATH
export BISON="bison"
# What dependencies to pull and build within this process. Options are
# "relic, openssl, gtest" or any subset thereof.
export USE_DEPS="relic"
#
# Where to find dependencies and extra header files/libraries
# The following points at those installed by Macports
export ADD_CFLAGS="-I/opt/local/include -march=native"
export LDFLAGS="-L/opt/local/lib -lgtest"
export LOCAL_LIB_ROOT="/opt/local/lib"
export LOCAL_INCLUDE="/opt/local/include"
export OS_CXXFLAGS="-I/opt/local/include -march=native"
#
# Point at the installed OpenSSL library
export ZSYM_DEP_LIBS="-L/opt/local/lib -lcrypto"
#
# Uncomment the following *only* if you already have RELIC, OpenSSL, and GTest
# installed where this build can find them
#export NO_DEPS="none"
unset NO_DEPS
export OS_CXXFLAGS="-I/opt/local/include -march=native"
# Note: uncomment the following *only* if you will use Zeutro fork of
# the OpenSSL package!
#export ZML_LIB="with_openssl"
unset ZML_LIB
export ZSYM_DEP_LIBS="-L/opt/local/lib -lcrypto"
export ZROOT="${PWD}"
#
# Where to install "openabe" (following sets it to where Macports
# installs binaries):
export INSTALL_PREFIX="/opt/local"
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CC ?= gcc
OABE_INCLUDE_DIR := $(INCLUDE_ROOT)/openabe
CXX11FLAGS += $(CXXFLAGS)

$(info CXX11FLAGS: $(CXX11FLAGS) )
RELICLIBS = -lrelic_s
#$(DEPS_INSTALL_ROOT)/lib/librelic_s.a

Expand Down Expand Up @@ -133,6 +132,7 @@ test_zsym: $(ZSYMLIB)

clean:
-rm -rf *.o *.dSYM a.out zparser.output $(PROGRAMS) $(OABELIB) $(OABE_SHLIB) $(ZSYMLIB) $(GENFILES)
-rm -f librelic*.$(SHLIB) libcrypto.$(SHLIB) libsl.$(SHLIB) libgtest*.$(SHLIB)

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $<
Expand Down

0 comments on commit f44844d

Please sign in to comment.