[storage] Set 'object.id' in 'session.save'
[abstract.git] / config / xpcom.m4
blob47ff345edcf128e2d0a6d70ab2fc41a2c40a8bf9
1 dnl Copyright (C) 2006 Sergey Yanovich
2 dnl
3 dnl This program is free software; you can redistribute it and/or modify it
4 dnl under the terms of the GNU General Public License as published by the
5 dnl Free Software Foundation; either version 2 of the License, or (at your
6 dnl option) any later version.
7 dnl
8 dnl This program is distributed in the hope that it will be useful, but
9 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU General Public License along
14 dnl with this program; if not, write to the Free Software Foundation, Inc.,
15 dnl 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
17 dnl AA_INIT_XPCOM()
19 AC_DEFUN([AA_INIT_XPCOM],[
21 AC_MSG_CHECKING([how to run xpcom])
22         AA_RUNNER=xulrunner
23         AA_RUNNER_BIN="\$(pkglibdir)/\$(PACKAGE)"
24         AA_RUNNER_PARAM=""
25 AC_MSG_RESULT([$AA_RUNNER])
27 AC_MSG_CHECKING([where to find xpcom])
28 AC_ARG_WITH([sdk],
29             [AC_HELP_STRING([--with-sdk[=/path/to/sdk]],
30                             [build using sdk (default use installed gecko)])],
31             [if test x$withval = xyes; then
32              AA_GECKO_SDK=$(pwd)/../mozilla/dist/sdk
33              elif test x$withval != xno; then
34                      AA_GECKO_SDK=$withval
35              fi])
36 if test x$AA_GECKO_SDK = x; then
37         AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
38         if test x$prefix = xNONE; then
39                 aa_prefix=$ac_default_prefix
40         else
41                 aa_prefix=$prefix
42         fi
43         if test x$exec_prefix = xNONE; then
44                 aa_exec_prefix=$aa_prefix
45         else
46                 aa_exec_prefix=$exec_prefix
47         fi
48         if test x$libdir = x\$\{exec_prefix\}\/lib; then
49                 aa_libdir=$aa_exec_prefix/lib
50         else
51                 aa_libdir=$libdir 
52         fi
53         export PKG_CONFIG_PATH=${aa_libdir}/pkgconfig:$PKG_CONFIG_PATH
54         PKG_CHECK_EXISTS([libxul],
55                 [AA_MOZ_INCLUDE="-I$($PKG_CONFIG --variable=includedir libxul)"
56                  AA_MOZ_BIN="$($PKG_CONFIG --variable=sdkdir libxul)/bin"
57                  AA_MOZ_LIB="$($PKG_CONFIG --variable=sdkdir libxul)/lib"
58                  AA_MOZ_IDL=$($PKG_CONFIG --variable=idldir libxul)
59                  AA_MOZ_IDLFLAGS="-I$AA_MOZ_IDL/stable -I$AA_MOZ_IDL/unstable"
60                  AA_MOZ_LDFLAGS=-L$AA_MOZ_LIB],
61                 [AC_MSG_ERROR([[LIBXUL is missing.
62         You may need to install a $AA_RUNNER-devel package at $aa_prefix,
63         correct your \$PKG_CONFIG_PATH=$PKG_CONFIG_PATH
64         or install SDK and use --with-sdk configure option]])])
65         PKG_CHECK_EXISTS([mozilla-js],
66                 [AA_MOZ_INCLUDE="$AA_MOZ_INCLUDE $($PKG_CONFIG --cflags mozilla-js)"],
67                 [AC_MSG_ERROR([[MOZILLA-JS is missing.
68         You may need to install a $AA_RUNNER-devel package at $aa_prefix,
69         correct your \$PKG_CONFIG_PATH=$PKG_CONFIG_PATH
70         or install SDK and use --with-sdk configure option]])])
71         AA_MOZ_LDFLAGS="$AA_MOZ_LDFLAGS -Wl,-rpath-link,$AA_MOZ_LIB"
72         aa_xpcom_source=$AA_RUNNER-devel
73 else
74         AA_MOZ_INCLUDE=$AA_GECKO_SDK/include
75         AA_MOZ_BIN=$AA_GECKO_SDK/bin
76         AA_MOZ_IDLFLAGS=-I$AA_GECKO_SDK/idl
77         AA_MOZ_LDFLAGS="-L$AA_GECKO_SDK/lib -Wl,-rpath-link,$AA_MOZ_BIN"
78         aa_xpcom_source=sdk
80 AC_MSG_RESULT([$aa_xpcom_source])
82 dnl C++ options
84 AC_ARG_ENABLE([rtti],
85         AS_HELP_STRING([--enable-rtti],[enable C++ RTTI (disabled by default)]),
86         [aa_cv_rtti=$enableval],[aa_cv_rtti=no])
87 if test x$aa_cv_rtti = xno; then
88         AA_CXXFLAGS="-fno-rtti $AA_CXXFLAGS"
91 AC_ARG_ENABLE([exceptions],
92         AS_HELP_STRING([--enable-exceptions],
93                        [enable C++ exceptions (disabled by default)]),
94         [aa_cv_exceptions=$enableval],[aa_cv_exceptions=no])
95 if test x$aa_cv_exceptions = xno; then
96         AA_CXXFLAGS="-fno-exceptions $AA_CXXFLAGS"
99 dnl Check for wchar_t
101 AC_LANG_PUSH(C++)
102 TMP_CXXFLAGS=$CXXFLAGS
103 CXXFLAGS="$AA_MOZ_INCLUDE $AA_CXXFLAGS $TMP_CXXFLAGS"
104 AC_CACHE_CHECK([for wchar_t in xpcom],
105         ac_cv_wchar_xpcom,
106         [AC_TRY_RUN([#include "xpcom-config.h"
107                      int main() {
108                      #ifndef HAVE_CPP_2BYTE_WCHAR_T
109                      return 1;
110                      #else
111                      return 0;
112                      #endif
113                      } ],
114                      ac_cv_wchar_xpcom="yes",
115                      ac_cv_wchar_xpcom="no",
116                      ac_cv_wchar_xpcom="maybe")])
117 if test x$ac_cv_wchar_xpcom = xyes; then
118     AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
119         ac_cv_have_usable_wchar,
120         [AC_TRY_RUN([#include <stddef.h>
121                      int main () {
122                        return (sizeof(wchar_t) != 2) ||
123                               (wchar_t)-1 < (wchar_t) 0 ; } ],
124                     ac_cv_have_usable_wchar="yes",
125                     ac_cv_have_usable_wchar="no",
126                     ac_cv_have_usable_wchar="maybe")])
127     if test x$ac_cv_have_usable_wchar != xyes; then
128         CXXFLAGS="$AA_MOZ_INCLUDE $AA_CXXFLAGS -fshort-wchar $TMP_CXXFLAGS"
129         AC_CACHE_CHECK(for compiler -fshort-wchar option,
130             ac_cv_have_usable_wchar_option,
131             [AC_TRY_RUN([#include <stddef.h>
132                          int main () {
133                            return (sizeof(wchar_t) != 2) ||
134                                   (wchar_t)-1 < (wchar_t) 0 ; } ],
135                         ac_cv_have_usable_wchar_option="yes",
136                         ac_cv_have_usable_wchar_option="no",
137                         ac_cv_have_usable_wchar_option="maybe")])
138         if test x$ac_cv_have_usable_wchar_option = xyes; then
139             AA_CXXFLAGS="$AA_CXXFLAGS -fshort-wchar"
140         else
141             AC_MSG_ERROR(["cannot obtain usable wchar_t"])
142         fi
143     fi
145 CXXFLAGS=$TMP_CXXFLAGS
147 dnl __TODO__  XPCOM integrity verification
148 dnl Programs:
149 dnl - xpidl
150 AC_PATH_PROG([XPIDL],[xpidl],[],$AA_MOZ_BIN)
151 if test x$XPIDL = x; then
152         AC_MSG_ERROR([xpidl not found in $AA_MOZ_BIN])
154 dnl - xpt_link
155 AC_PATH_PROG([XPTLINK],[xpt_link],[],$AA_MOZ_BIN)
156 if test x$XPTLINK = x; then
157         AC_MSG_ERROR([xpt_link not found])
159 dnl - regxpcom
160 dnl - xulrunner-stub
161 if test x$AA_RUNNER = xxulrunner; then
162 AC_PATH_PROG([XULSTUB],[xulrunner-stub],[],$AA_MOZ_BIN)
163 if test x$XULSTUB = x; then
164         AC_MSG_ERROR([xulrunner-stub not found])
168 dnl Libraries:
169 dnl -libxpcomglue
170 dnl 
171 dnl Headers:
172 dnl nsIGenericFactory.h
174 dnl Output
176 AC_SUBST(AA_RUNNER)
177 AC_SUBST(AA_RUNNER_BIN)
178 AC_SUBST(AA_RUNNER_PARAM)
179 AC_SUBST(AA_MOZ_BIN)
180 AC_SUBST(AA_MOZ_IDLFLAGS)
181 AC_SUBST(AA_MOZ_INCLUDE)
182 AC_SUBST(AA_MOZ_LDFLAGS)
183 AC_SUBST(AA_CXXFLAGS)