PHP_ARG_ENABLE(wrenchboard_api_root,
    [Whether to enable the "wrenchboard_api_root" extension],
    [  --enable-wrenchboard_api_root      Enable "wrenchboard_api_root" extension support])

# *** Mac:
# brew install rapidjson boost
# c++ -DRAPIDJSON_HAS_STDSTRING=1 -I./include -I/usr/include -I/opt/homebrew/include -std=gnu++14 -o main.cpp.o -c main.cpp
# c++ main.cpp.o -o main -L/opt/homebrew/lib -lboost_system-mt -lboost_iostreams-mt -lpthread

# *** Linux:
# dnf install rapidjson-devel boost boost-devel # centos
# apt install rapidjson-dev libboost-all-dev # ubuntu
# c++ -DRAPIDJSON_HAS_STDSTRING=1 -I./include -I/usr/include -std=gnu++14 -o main.cpp.o -c main.cpp
# c++ main.cpp.o -o main -lboost_system -lboost_iostreams -lpthread


if test $PHP_WRENCHBOARD_API_ROOT != "no"; then
    PHP_REQUIRE_CXX()
    PHP_SUBST(WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_INCLUDE(/usr/include/pgsql)
    PHP_ADD_INCLUDE(/usr/include/postgresql)
    PHP_ADD_LIBRARY_WITH_PATH(pq, /usr/lib64,  WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(stdc++, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(curl, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(config++, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(json-c, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(ssl, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(z, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(pcrecpp, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(gcc_s, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(boost_system, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(boost_iostreams, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)
    PHP_ADD_LIBRARY(pthread, 1, WRENCHBOARD_API_ROOT_SHARED_LIBADD)

    #LIBCFG_DIR="`pwd`/libconfig-1.3.1"

    #PHP_ADD_LIBRARY_WITH_PATH(config++, "$LIBCFG_DIR/.libs/")

    PHP_NEW_EXTENSION(
	wrenchboard_api_root, 
	core/*.cc shared_tool/*.cc, 
	$ext_shared,
	,-I@ext_srcdir@/include/gelfcpp -std=gnu++14 -DRAPIDJSON_HAS_STDSTRING=1)
    PHP_DEFINE([WRENCHBOARD_API_ROOT_NS],[\"wrenchboard_api_root\"],[])
    PHP_DEFINE([WRENCHBOARD_CONFIG],[\"`pwd|sed s/src//`etc/\"],[])
    PHP_DEFINE([WRENCHBOARD_LOG],[\"`pwd|sed s/src//`logs/wrenchboard_api_root.log\"],[])
    PHP_DEFINE([TMPL_PREFIX],[\"`pwd|sed s/src//`email/\"],[])
    PHP_DEFINE([FILELOG_MAX_LEVEL],[9],[])
fi
