Avoid overriding the check-local rule, hushing automake warning
[gnash.git] / macros / xpcom.m4
blobab5a16ee0cf553feefe8420a285ab3159349bd44
1 dnl  
2 dnl    Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
3 dnl  
4 dnl  This program is free software; you can redistribute it and/or modify
5 dnl  it under the terms of the GNU General Public License as published by
6 dnl  the Free Software Foundation; either version 3 of the License, or
7 dnl  (at your option) any later version.
8 dnl  
9 dnl  This program is distributed in the hope that it will be useful,
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl  GNU General Public License for more details.
13 dnl  You should have received a copy of the GNU General Public License
14 dnl  along with this program; if not, write to the Free Software
15 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 dnl Configure paths for Firefox. We used to run firefox-config, but that
18 dnl got too messy. Then with a little experimentation we determined
19 dnl most of the options weren't actually needed... so now the handful
20 dnl of critical headers are part of the plugin/mozilla-sdk sources
21 dnl copied out of a current Firefox release. This greatly simplified
22 dnl both the configuration and compilation processes.
23 AC_DEFUN([GNASH_PATH_XPCOM],
24 [dnl 
26   has_xpcom=no
27   AC_ARG_ENABLE(xpcom,
28     AC_HELP_STRING([--enable-xpcom],[Enable xpcom support in NPAPI plugin]),
29   [case "${enableval}" in
30     yes) xpcom=yes ;;
31     no)  xpcom=no ;;
32     *)   AC_MSG_ERROR([bad value ${enableval} for --enable-xpcom option]) ;;
33    esac],xpcom=no)
35   dnl Look for the header
36   AC_ARG_WITH(xpcom-incl, AC_HELP_STRING([--with-xpcom-incl], [directory where XPCOM headers are]), with_xpcom_incl=${withval})
37   AC_CACHE_VAL(ac_cv_path_xpcom_incl, [
38     if test x"${with_xpcom_incl}" != x ; then
39       if test -f ${with_xpcom_incl}/mozilla-config.h ; then
40         ac_cv_path_xpcom_incl="-I`(cd ${with_xpcom_incl}; pwd)`"
41       else
42         AC_MSG_ERROR([${with_xpcom_incl} directory doesn't contain mozilla-config.h!])
43       fi
44     fi
45   ])
47     dnl Look for the library
48   AC_ARG_WITH(xpcom-sdk-dir, AC_HELP_STRING([--with-xpcom-sdk-dir], [directory where XPCOM SDK is]), with_xpcom_sdk_dir=${withval})
49     AC_CACHE_VAL(ac_cv_path_xpcom_sdk_dir, [
50       if test x"${with_xpcom_sdk_dir}" != x ; then
51         if test -f ${with_xpcom_sdk_dir}/libxpcomglue_s.a; then
52           ac_cv_path_xpcom_sdk_dir="-L`(cd ${with_xpcom_sdk_dir}; pwd)` -lxpcomglue_s -lnspr4 -lplds4"
53         else
54           AC_MSG_ERROR([${with_xpcom_sdk_dir} directory doesn't contain libxpcomglue_s.a!])
55         fi
56       fi
57     ])
59   if test x$xpcom = xyes; then
60     if test x$cross_compiling = xno; then
62       # Look for libxpcomglue_s.a (version 1.8 !!) if not explicitly given
63       if test x$ac_cv_path_xpcom_sdk_dir = x; then
64         for i in /usr/lib/iceape; do
65           # TODO: check version ! we do NOT want to use 1.9 here !!!
66           # TODO: check availability of nspr4 and plds4 (may be in /usr/lib too)
67           if test -e "${i}/libxpcomglue_s.a"; then
68             ac_cv_path_xpcom_sdk_dir="-L${i} -lxpcomglue_s -lnspr4 -lplds4"
69             break
70           fi
71         done
72       fi
74       # Look for xpcom headers (version 1.8 !!) if not explicitly given
75       if test x$ac_cv_path_xpcom_incl = x; then
76         # Prefer libxul-unstable for cflags.
77         if $PKG_CONFIG --exists libxul-unstable; then
78               ac_cv_path_xpcom_incl="`$PKG_CONFIG --cflags-only-I libxul-unstable`"
79         else
80               if $PKG_CONFIG --exists libxul; then
81                 ac_cv_path_xpcom_incl="`$PKG_CONFIG --cflags-only-I libxul`"
82               fi
83         fi
84       fi
86       # hack, hack, broken .pc files in F9's xulrunner-devel
87       # they fail to include the include subdirectories
88       if test x"${ac_cv_path_xpcom_incl}" = x"-I/usr/include/xulrunner-sdk-1.9/stable -I/usr/include/nspr4  "; then
89         ac_cv_path_xpcom_incl="-I/usr/include/xulrunner-sdk-1.9/stable -I/usr/include/xulrunner-sdk-1.9/extensions -I/usr/include/xulrunner-sdk-1.9/necko -I/usr/include/nspr4"
90       fi
92       # Look for libxul. TODO: needed at all ?
93       if $PKG_CONFIG --exists libxul; then
94         if test x$ac_cv_path_xpcom_sdk_dir = x; then
95           ac_cv_path_xpcom_sdk_dir="`$PKG_CONFIG --libs libxul`"
96         fi
97         ac_cv_path_xpidl="`$PKG_CONFIG --libs-only-L libxul`"
98       fi
100     fi
101   fi
103   if test x"${ac_cv_path_xpcom_incl}" != x; then
104     XPCOM_CFLAGS="${ac_cv_path_xpcom_incl}"
105     XPCOM_IDL_CFLAGS=`echo $XPCOM_CFLAGS | sed -e 's:include:share/idl:'`
106     XPIDL=`echo ${ac_cv_path_xpidl} | sed -e 's:-L::' -e 's:sdk-::' -e 's:sdk/lib::' -e 's:-devel::' -e 's:lib$::'`
107     XPIDL="${XPIDL}xpidl"
108     AC_DEFINE([HAVE_XPCOM], [1], [Use XPCOM in the NPAPI plugin])
109   else
110     XPCOM_CFLAGS=""
111     XPIDL=""
112   fi
114   if test x"${ac_cv_path_xpcom_sdk_dir}" != x ; then
115     XPCOM_LIBS="${ac_cv_path_xpcom_sdk_dir}"
116     has_xpcom=yes
117   else
118     XPCOM_LIBS=""
119     has_xpcom=no
120   fi
122   AC_SUBST(XPCOM_CFLAGS)
123   AC_SUBST(XPCOM_IDL_CFLAGS)
124   AC_SUBST(XPCOM_LIBS)
125   AC_SUBST(XPIDL)
127 dnl end of GNASH_PATH_XPCOM
128 # Local Variables:
129 # c-basic-offset: 2
130 # tab-width: 2
131 # indent-tabs-mode: nil
132 # End: