OBJDIRS	+= main

CRYPTDB_SRCS := schema.cc Translator.cc Connect.cc \
		Analysis.cc CryptoHandlers.cc rewrite_util.cc \
		rewrite_field.cc dispatcher.cc sql_handler.cc dml_handler.cc \
		ddl_handler.cc alter_sub_handler.cc rewrite_const.cc \
		rewrite_func.cc rewrite_sum.cc metadata_tables.cc \
		error.cc stored_procedures.cc rewrite_ds.cc rewrite_main.cc big_proxy.cc

CRYPTDB_PROGS:= cdb_test load_and_store test_layer test_schema change_test insert_conf_onion


CRYPTDBPROGOBJS	:= $(patsubst %,$(OBJDIR)/main/%,$(CRYPTDB_PROGS))

all: $(CRYPTDBPROGOBJS) $(OBJDIR)/libcryptdb.so

CRYPTDB_OBJS := $(patsubst %.cc,$(OBJDIR)/main/%.o,$(CRYPTDB_SRCS))

$(CRYPTDBPROGOBJS): %: %.o $(OBJDIR)/libedbparser.so \
			   $(OBJDIR)/libedbutil.so \
			   $(OBJDIR)/libcryptdb.so \
			   $(OBJDIR)/libedbcrypto.so
	$(CXX) $< -o $@ -ledbparser $(LDFLAGS) $(LDRPATH) \
			-ledbutil -ledbcrypto -lcryptdb

$(OBJDIR)/libcryptdb.so: $(CRYPTDB_OBJS) \
			 $(OBJDIR)/libedbcrypto.so \
			 $(OBJDIR)/libedbutil.so \
			 $(OBJDIR)/libedbparser.so 
	$(CXX) -shared -g -o $@ $(CRYPTDB_OBJS) $(LDFLAGS) $(LDRPATH) \
	       -ledbcrypto -ledbutil -ledbparser -lntl -lcrypto



install: install_main

.PHONY: install_main
install_main: $(OBJDIR)/libcryptdb.so
	install -m 644 $(OBJDIR)/libcryptdb.so /usr/lib

# vim: set noexpandtab:
