#edit-mode: -*- python -*-
#coding:utf-8

WORKROOT('../../../../')

#Preprocessor flags.
CPPFLAGS(r'-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__const__= -Dtypeof=__typeof__ -DUSE_PTHREAD')
#CPPFLAGS(r'-DVERSION=\"%s\"' % SVN_LAST_CHANGED_REV())

#C++ flags.
CXXFLAGS('-g -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-deprecated -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -std=c++11')

#link flags
LDFLAGS('-lpthread -lcrypto -lrt -lssl -ldl -lz -std=c++11')

ImportConfigsFrom('..')

INCPATHS('$INC')
INCPATHS('$INC/predictor')
INCPATHS('../')
INCPATHS('../predictor/')
INCPATHS('$OUT_ROOT/third-64/protobuf/output/include')
INCPATHS('$OUT_ROOT/baidu/third-party/gflags/output/include')
INCPATHS('$OUT_ROOT/baidu/third-party/glog/output/include')
INCPATHS('$INC/predictor/proto')

LIBS('$OUT/lib/libpdserving.a')
LIBS('$OUT/lib/libpdconfigure.a')
LIBS('$OUT_ROOT/baidu/third-party/mklml/output/so/libmklml_intel.so')
LIBS('$OUT_ROOT/baidu/third-party/mklml/output/so/libmklml_gnu.so')
LIBS('$OUT_ROOT/baidu/third-party/mklml/output/so/libiomp5.so')

cpp_source_dirs = []
cpp_source_dirs.append('op/*.cpp')
cpp_source_dirs.append('proto/*.proto')

# DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf.a')
# DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf-lite.a')
# DELETE_AUTO_LIBS('$OUT_ROOT/third-64/glog/output/lib/libglog.a')
DELETE_AUTO_LIBS('$OUT_ROOT/third-64/gflags/output/lib/libgflags.a')
DELETE_AUTO_LIBS('$OUT_ROOT/third-64/gflags/output/lib/libgflags_nothreads.a')
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/paddlepaddle/paddle/output/lib/libpaddle_fluid_noavx_openblas.a')

PROTOFLAGS(
        '--plugin=protoc-gen-pdcodegen=../pdcodegen/plugin/pdcodegen',
        '--pdcodegen_out proto --proto_path=.',
        '--proto_path=../predictor/proto')

HEADERS(GLOB_GEN_SRCS('proto/*.pb.h'), '$INC/demo-serving')

# Application
Application('serving', Sources(GLOB(' '.join(cpp_source_dirs))), WholeArchives('$OUT/lib/libinferencer-fluid-cpu.a'))

OUTPUT('conf', '$OUT/demo/serving/')
OUTPUT('data', '$OUT/demo/serving')
