• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl macros to check for JavaScriptCore and WebKit/Gtk+ dependencies
2dnl
3dnl The rationale is so that we can share these macros between
4dnl WebKit and JavaScriptCore builds.
5
6# global states
7m4_define([initialized], [no])
8
9AC_DEFUN([BEFORE_AC_PROG_CXX],
10[dnl
11# If CXXFLAGS and CFLAGS are unset, default to empty.
12# This is to tell automake not to include '-g' if CXXFLAGS is not set
13# For more info - http://www.gnu.org/software/automake/manual/autoconf.html#C_002b_002b-Compiler
14if test -z "$CXXFLAGS"; then
15   CXXFLAGS=""
16fi
17if test -z "$CFLAGS"; then
18   CFLAGS=""
19fi
20])
21
22# check for pkg-config
23AC_DEFUN_ONCE([WEBKIT_INIT],
24[dnl
25dnl check if we have the required packages to have successful checks
26dnl
27# check for -fvisibility=hidden compiler support (GCC >= 4)
28saved_CFLAGS="$CFLAGS"
29CFLAGS="$CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
30AC_MSG_CHECKING([if ${CXX} supports -fvisibility=hidden -fvisibility-inlines-hidden])
31AC_COMPILE_IFELSE([char foo;],
32      [ AC_MSG_RESULT([yes])
33        SYMBOL_VISIBILITY="-fvisibility=hidden" SYMBOL_VISIBILITY_INLINES="-fvisibility-inlines-hidden" ],
34        AC_MSG_RESULT([no]))
35CFLAGS="$saved_CFLAGS"
36AC_SUBST(SYMBOL_VISIBILITY)
37AC_SUBST(SYMBOL_VISIBILITY_INLINES)
38
39AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
40if test "$PKG_CONFIG" = "no"; then
41   AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH])
42fi
43
44AC_PATH_PROG(PERL, perl)
45if test -z "$PERL"; then
46   AC_MSG_ERROR([You need 'perl' to compile WebKit])
47fi
48
49AC_PATH_PROG(BISON, bison)
50if test -z "$BISON"; then
51   AC_MSG_ERROR([You need the 'bison' parser generator to compile WebKit])
52fi
53
54AC_PATH_PROG(MV, mv)
55if test -z "$MV"; then
56   AC_MSG_ERROR([You need 'mv' to compile WebKit])
57fi
58
59AM_PROG_CC_STDC
60AM_PROG_CC_C_O
61# Make sure CXXFLAGS and CFLAGS are set before expanding AC_PROG_CXX to avoid
62# building with '-g -O2' on Release builds.
63AC_REQUIRE([BEFORE_AC_PROG_CXX])
64AC_REQUIRE([AC_PROG_CXX])
65AC_PROG_INSTALL
66AC_SYS_LARGEFILE
67
68# Check whether a C++ was found (AC_PROG_CXX sets $CXX to "g++" even when it
69# doesn't exist)
70AC_LANG_PUSH([C++])
71AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[],[AC_MSG_ERROR([No C++ compiler found])])
72AC_LANG_POP([C++])
73
74# C/C++ Language Features
75AC_C_CONST
76AC_C_INLINE
77AC_C_VOLATILE
78
79# C/C++ Headers
80AC_REQUIRE([AC_HEADER_STDC])
81AC_HEADER_STDBOOL
82
83m4_define([initialized], [yes])
84])
85
86AC_DEFUN_ONCE([WEBKIT_CHECK_DEPENDENCIES],
87[dnl
88dnl check for module dependencies
89for module in $1
90do
91    case $module in
92        glib) _WEBKIT_CHECK_GLIB ;;
93        unicode) _WEBKIT_CHECK_UNICODE ;;
94        *) AC_MSG_ERROR([I don't support that module. Sorry..]) ;;
95
96    esac
97done
98])
99
100AC_DEFUN_ONCE([_WEBKIT_CHECK_GLIB],
101[dnl
102dnl check for glib
103# Version requirements
104GLIB_REQUIRED_VERSION=2.0
105GOBJECT_REQUIRED_VERSION=2.0
106GTHREAD_REQUIRED_VERSION=2.0
107
108PKG_CHECK_MODULES([GLIB],
109                  [glib-2.0 >= $GLIB_REQUIRED_VERSION
110                  gobject-2.0 >= $GOBJECT_REQUIRED_VERSION
111                  gthread-2.0 >= $GTHREAD_REQUIRED_VERSION])
112AC_SUBST([GLIB_CFLAGS])
113AC_SUBST([GLIB_LIBS])
114
115# GTK+ port only
116# Check for glib-genmarshal and glib-mkenums
117AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
118AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
119if test -z "$GLIB_GENMARSHAL" || test -z "$GLIB_MKENUMS"; then
120   AC_MSG_ERROR([You need the GLib dev tools in your path])
121fi
122])
123
124AC_DEFUN_ONCE([_WEBKIT_CHECK_UNICODE],
125[dnl
126dnl determine the Unicode backend
127AC_MSG_CHECKING([which Unicode backend to use])
128AC_ARG_WITH(unicode_backend,
129            AC_HELP_STRING([--with-unicode-backend=@<:@icu/glib@:>@],
130                           [Select Unicode backend (WARNING: the glib-based backend is slow, and incomplete) [default=icu]]),
131            [],[with_unicode_backend="icu"])
132
133case "$with_unicode_backend" in
134     icu|glib) ;;
135     *) AC_MSG_ERROR([Invalid Unicode backend: must be icu or glib.]) ;;
136esac
137
138AC_MSG_RESULT([$with_unicode_backend])
139
140# https://bugs.webkit.org/show_bug.cgi?id=15914
141# Splitting ICU removal patch into smaller portions. We compile a hybrid version
142# with the WTF Unicode backend being based on GLib while text codecs and TextBreakIterator
143# keep the ICU dependency. That's why we temporarily add icu headers and libs for glib config case as well.
144if test "$with_unicode_backend" = "icu" -o "$with_unicode_backend" = "glib"; then
145	if test "$os_darwin" = "yes"; then
146		UNICODE_CFLAGS="-I\$(srcdir)/JavaScriptCore/icu -I\$(srcdir)/WebCore/icu"
147		UNICODE_LIBS="-licucore"
148	elif test "$os_win32" = "yes"; then
149		UNICODE_CFLAGS=""
150		UNICODE_LIBS="-licuin -licuuc"
151	else
152		AC_PATH_PROG(icu_config, icu-config, no)
153		if test "$icu_config" = "no"; then
154			AC_MSG_ERROR([Cannot find icu-config. The ICU library is needed.])
155		fi
156
157		# We don't use --cflags as this gives us a lot of things that we don't
158		# necessarily want, like debugging and optimization flags
159		# See man (1) icu-config for more info.
160		UNICODE_CFLAGS=`$icu_config --cppflags`
161		UNICODE_LIBS=`$icu_config --ldflags`
162	fi
163fi
164
165if test "$with_unicode_backend" = "glib"; then
166	# https://bugs.webkit.org/show_bug.cgi?id=15914
167	# Splitting ICU removal patch into smaller portions, that's why we
168	# temporarily retrieve flags & libs info for glib into UNICODEGLIB
169	# instead of UNICODE variable, then concatenate.
170	# Patch 3/4 of the above issue will rename the variable back to UNICODE.
171	PKG_CHECK_MODULES([UNICODEGLIB], [glib-2.0 pango >= 1.21.0])
172	UNICODE_CFLAGS="$UNICODE_CFLAGS $UNICODEGLIB_CFLAGS"
173	UNICODE_LIBS="$UNICODE_LIBS $UNICODEGLIB_LIBS"
174fi
175
176AC_SUBST([UNICODE_CFLAGS])
177AC_SUBST([UNICODE_LIBS])
178])
179