summaryrefslogtreecommitdiff
path: root/ext/json/config.m4
blob: a937b1f91b66c00dc21c7d2a57ad8d478a7f1d1f (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
dnl
dnl $Id$
dnl

AC_DEFUN([PHP_JSON_ADD_SOURCES], [
  PHP_JSON_SOURCES="$PHP_JSON_SOURCES $1"
])

AC_DEFUN([PHP_JSON_ADD_BASE_SOURCES], [
  PHP_JSON_BASE_SOURCES="$PHP_JSON_BASE_SOURCES $1"
])

AC_DEFUN([PHP_JSON_ADD_BUILD_DIR], [
  PHP_JSON_EXTRA_BUILD_DIRS="$PHP_JSON_EXTRA_BUILD_DIRS $1"
])

AC_DEFUN([PHP_JSON_ADD_INCLUDE], [
  PHP_JSON_EXTRA_INCLUDES="$PHP_JSON_EXTRA_INCLUDES $1"
])

AC_DEFUN([PHP_JSON_ADD_CONFIG_HEADER], [
  PHP_JSON_EXTRA_CONFIG_HEADERS="$PHP_JSON_EXTRA_CONFIG_HEADERS $1"
])

AC_DEFUN([PHP_JSON_ADD_CFLAG], [
  PHP_JSON_CFLAGS="$PHP_JSON_CFLAGS $1"
])

AC_DEFUN([PHP_JSON_EXTENSION], [
  PHP_NEW_EXTENSION(json, $PHP_JSON_SOURCES, $ext_shared,, $PHP_JSON_CFLAGS)
  PHP_SUBST(JSON_SHARED_LIBADD)

  for dir in $PHP_JSON_EXTRA_BUILD_DIRS; do
    PHP_ADD_BUILD_DIR([$ext_builddir/$dir], 1)
  done
  
  for dir in $PHP_JSON_EXTRA_INCLUDES; do
    PHP_ADD_INCLUDE([$ext_srcdir/$dir])
    PHP_ADD_INCLUDE([$ext_builddir/$dir])
  done

  if test "$ext_shared" = "no"; then
    PHP_ADD_SOURCES(PHP_EXT_DIR(json), $PHP_JSON_BASE_SOURCES,$PHP_JSON_CFLAGS)
    out="php_config.h"
  else
    PHP_ADD_SOURCES_X(PHP_EXT_DIR(json),$PHP_JSON_BASE_SOURCES,$PHP_JSON_CFLAGS,shared_objects_json,yes)
    if test -f "$ext_builddir/config.h.in"; then
      out="$abs_builddir/config.h"
    else
      out="php_config.h"
    fi
  fi
  
  for cfg in $PHP_JSON_EXTRA_CONFIG_HEADERS; do
    cat > $ext_builddir/$cfg <<EOF
#include "$out"
EOF
  done
])

AC_DEFUN([PHP_JSON_SETUP_JSON_CHECKER], [
  PHP_JSON_ADD_SOURCES([
    utf8_to_utf16.c
    utf8_decode.c
    JSON_parser.c
  ])
])

dnl
dnl Main config
dnl

PHP_ARG_WITH(json, whether to enable JavaScript Object Serialization support,
[  --with-json       Enable JavaScript Object Serialization support])

if test "$PHP_JSON" != "no"; then  
  AC_DEFINE([HAVE_JSON],1,[whether to have JavaScript Object Serialization support])
  AC_HEADER_STDC

  PHP_JSON_ADD_BASE_SOURCES([json.c])

  dnl json_c is required
  PHP_JSON_SETUP_JSON_CHECKER
  PHP_JSON_EXTENSION
  dnl PHP_INSTALL_HEADERS([ext/json], [json_c])
fi

# vim600: sts=2 sw=2 et