aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/config.m4.template
blob: cc19d98375f667d00cdc96767675834020f1a3d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
%YAML 1.2
--- |
  PHP_ARG_ENABLE(grpc, whether to enable grpc support,
  [  --enable-grpc           Enable grpc support])

  if test "$PHP_GRPC" != "no"; then
    dnl Write more examples of tests here...

    dnl # --with-grpc -> add include path
    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include)
    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc)
    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include)
    PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include)

    LIBS="-lpthread $LIBS"

    CFLAGS="-Wall -Werror -Wno-parentheses-equality -Wno-unused-value -std=c11 -g -O2 -D PB_FIELD_16BIT=1"
    CXXFLAGS="-std=c++11 -fno-exceptions -fno-rtti -g -O2 -D PB_FIELD_16BIT=1"
    GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD"
    PHP_REQUIRE_CXX()
    PHP_ADD_LIBRARY(pthread)
    PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD)
    PHP_ADD_LIBRARY(dl)

    case $host in
      *darwin*)
        ;;
      *)
        PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
        PHP_ADD_LIBRARY(rt)
        ;;
    esac

    PHP_NEW_EXTENSION(grpc,
      % for source in php_config_m4.src:
      ${source} ${"\\"}
      % endfor
      % for lib in libs:
      % if lib.name in php_config_m4.get('deps', []) and lib.name != 'z':
      % for source in lib.src:
      ${source} ${"\\"}
      % endfor
      % endif
      % endfor
      , $ext_shared, , -fvisibility=hidden ${"\\"}
      -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN ${"\\"}
      -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0)

    PHP_ADD_BUILD_DIR($ext_builddir/src/php/ext/grpc)
  <%
    dirs = {}
    for lib in libs:
      if lib.name in php_config_m4.get('deps', []) and lib.name != 'z':
        for source in lib.src:
          dirs[source[:source.rfind('/')]] = 1
    dirs = dirs.keys()
    dirs.sort()
  %>
    % for dir in dirs:
    PHP_ADD_BUILD_DIR($ext_builddir/${dir})
    % endfor
  fi