1%YAML 1.2
2--- |
3  PHP_ARG_ENABLE(grpc, whether to enable grpc support,
4  [  --enable-grpc           Enable grpc support])
5
6  if test "$PHP_GRPC" != "no"; then
7    dnl Write more examples of tests here...
8
9    dnl # --with-grpc -> add include path
10    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include)
11    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc)
12    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include)
13    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include)
14    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/nanopb)
15
16    LIBS="-lpthread $LIBS"
17
18    CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2 -D PB_FIELD_32BIT=1"
19    CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2 -D PB_FIELD_32BIT=1"
20    GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD"
21    PHP_REQUIRE_CXX()
22    PHP_ADD_LIBRARY(pthread)
23    PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD)
24    PHP_ADD_LIBRARY(dl)
25
26    case $host in
27      *darwin*)
28        ;;
29      *)
30        PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
31        PHP_ADD_LIBRARY(rt)
32        ;;
33    esac
34
35    PHP_NEW_EXTENSION(grpc,
36      % for source in php_config_m4.src:
37      ${source} ${"\\"}
38      % endfor
39      % for lib in libs:
40      % if lib.name in php_config_m4.get('deps', []) and lib.name != 'z':
41      % for source in lib.src:
42      ${source} ${"\\"}
43      % endfor
44      % endif
45      % endfor
46      , $ext_shared, , -fvisibility=hidden ${"\\"}
47      -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN ${"\\"}
48      -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0)
49
50    PHP_ADD_BUILD_DIR($ext_builddir/src/php/ext/grpc)
51  <%
52    dirs = {}
53    for lib in libs:
54      if lib.name in php_config_m4.get('deps', []) and lib.name != 'z':
55        for source in lib.src:
56          dirs[source[:source.rfind('/')]] = 1
57    dirs = dirs.keys()
58    dirs.sort()
59  %>
60    % for dir in dirs:
61    PHP_ADD_BUILD_DIR($ext_builddir/${dir})
62    % endfor
63  fi
64