Import GNU Classpath (20121202).
[official-gcc.git] / libjava / classpath / m4 / acinclude.m4
blobb5fa999bb5e7d826934927f7ea1e6ab12155e529
1 dnl Used by aclocal to generate configure
3 dnl -----------------------------------------------------------
4 AC_DEFUN([CLASSPATH_WITH_JAVAH],
6   AC_ARG_WITH([javah],
7               [AS_HELP_STRING(--with-javah,specify path or name of a javah-like program)],
8   [
9     if test "x${withval}" != x && test "x${withval}" != xyes && test "x${withval}" != xno; then
10       CLASSPATH_CHECK_JAVAH(${withval})
11     else
12       CLASSPATH_CHECK_JAVAH
13     fi
14   ],
15   [ 
16     CLASSPATH_CHECK_JAVAH
17   ])
18   AC_SUBST(USER_JAVAH)
21 dnl -----------------------------------------------------------
22 dnl Checking for a javah like program 
23 dnl -----------------------------------------------------------
24 AC_DEFUN([CLASSPATH_CHECK_JAVAH],
26   if test "x$1" != x; then
27     if test -f "$1"; then
28       USER_JAVAH="$1"
29     else
30       AC_PATH_PROG(USER_JAVAH, "$1")
31     fi
32   else
33     AC_PATH_PROGS([USER_JAVAH],[gjavah gjavah-4.3 gjavah-4.2 gjavah-4.1 gcjh-wrapper-4.1 gcjh-4.1 javah])
34   fi
35   
36   if test "x${USER_JAVAH}" = x; then
37     AC_MSG_ERROR([can not find javah])
38   fi
41 dnl -----------------------------------------------------------
42 dnl CLASSPATH_WITH_CLASSLIB - checks for user specified classpath additions
43 dnl -----------------------------------------------------------
44 AC_DEFUN([CLASSPATH_WITH_CLASSLIB],
46   AC_ARG_WITH([vm-classes],
47               [AS_HELP_STRING(--with-vm-classes,specify path to VM override source files)], [vm_classes="$with_vm_classes"],
48               [vm_classes='${top_srcdir}/vm/reference'])
49   AC_SUBST(vm_classes)
52 dnl -----------------------------------------------------------
53 dnl CLASSPATH_WITH_GLIBJ - specify what to install
54 dnl -----------------------------------------------------------
55 AC_DEFUN([CLASSPATH_WITH_GLIBJ],
57   AC_PATH_PROG(ZIP, zip)
59   AC_MSG_CHECKING(for a jar-like tool)
60   AC_ARG_WITH([jar],
61               [AS_HELP_STRING([--with-jar=PATH], [define to use a jar style tool])],
62               [
63                 case "${withval}" in
64                   yes)
65                     JAR=yes
66                     ;;
67                   no)
68                     JAR=no
69                     AC_MSG_RESULT(${JAR})
70                     ;;
71                   *)
72                     if test -f "${withval}"; then
73                       JAR="${withval}"
74                       AC_MSG_RESULT(${JAR})
75                     else
76                       AC_MSG_RESULT([not found])
77                       AC_MSG_ERROR([The jar tool ${withval} was not found.])
78                     fi
79                     ;;
80                 esac
81               ],
82               [
83                 JAR=yes
84               ])
85   if test x"${JAR}" = "xyes"; then
86     AC_MSG_RESULT([trying fastjar, gjar and jar])
87     AC_PATH_PROGS([JAR], [fastjar gjar jar])
88     if test x"${RHINO_JAR}" = "xyes"; then
89       AC_MSG_RESULT([not found])
90     fi
91   fi
92   if test x"${JAR}" = "xno" && test x"${ZIP}" = ""; then
93     AC_MSG_ERROR([No zip or jar tool found.])
94   fi
95   AM_CONDITIONAL(WITH_JAR, test x"${JAR}" != "xno" && test x"${JAR}" != "xyes")
96   AC_SUBST(JAR)
97   
98   AC_ARG_WITH([glibj],
99               [AS_HELP_STRING([--with-glibj],[define what to install (zip|flat|both|none|build) [default=zip]])],
100               [
101                 if test "x${withval}" = xyes || test "x${withval}" = xzip; then
102                   install_class_files=no
103                   build_class_files=yes
104                   use_zip=yes
105                 elif test "x${withval}" = xboth; then
106                   install_class_files=yes
107                   build_class_files=yes
108                   use_zip=yes
109                 elif test "x${withval}" = xflat; then
110                   install_class_files=yes
111                   build_class_files=yes
112                   use_zip=no
113                 elif test "x${withval}" = xno || test "x${withval}" = xnone; then
114                   install_class_files=no
115                   build_class_files=no
116                   use_zip=no
117                 elif test "x${withval}" = xbuild; then
118                   install_class_files=no
119                   build_class_files=yes
120                   use_zip=no
121                 else
122                   AC_MSG_ERROR([unknown value given to --with-glibj])
123                 fi
124               ],
125               [
126                 install_class_files=no
127                 use_zip=yes
128               ])
129   AM_CONDITIONAL(INSTALL_GLIBJ_ZIP, test "x${use_zip}" = xyes)
130   AM_CONDITIONAL(INSTALL_CLASS_FILES, test "x${install_class_files}" = xyes)
131   AM_CONDITIONAL(BUILD_CLASS_FILES, test "x${build_class_files}" = xyes)
133   AC_ARG_ENABLE([examples],
134                 [AS_HELP_STRING(--enable-examples,enable build of the examples [default=yes])],
135                 [case "${enableval}" in
136                   yes) EXAMPLESDIR="examples" ;;
137                   no) EXAMPLESDIR="" ;;
138                   *) AC_MSG_ERROR(bad value ${enableval} for --enable-examples) ;;
139                 esac],
140                 [EXAMPLESDIR="examples"])
141   if test "x${build_class_files}" = xno; then
142     EXAMPLESDIR=""
143   fi
144   AC_SUBST(EXAMPLESDIR)
146   AC_ARG_ENABLE([tools],
147                 [AS_HELP_STRING(--enable-tools,enable build of the tools [default=yes])],
148                 [case "${enableval}" in
149                   yes) TOOLSDIR="tools" ;;
150                   no) TOOLSDIR="" ;;
151                   *) AC_MSG_ERROR(bad value ${enableval} for --enable-tools) ;;
152                 esac],
153                 [TOOLSDIR="tools"])
154   if test "x${build_class_files}" = xno; then
155     TOOLSDIR=""
156   fi
157   AC_SUBST(TOOLSDIR)
160 dnl -----------------------------------------------------------
161 dnl Enable generation of API documentation, with gjdoc if it
162 dnl has been compiled to an executable (or a suitable script
163 dnl is in your PATH) or using the argument as gjdoc executable.
164 dnl -----------------------------------------------------------
165 AC_DEFUN([CLASSPATH_WITH_GJDOC],
167   AC_ARG_WITH([gjdoc],
168               AS_HELP_STRING([--with-gjdoc],
169                              [generate documentation using gjdoc (default is NO)]),
170               [if test "x${withval}" = xno; then
171                  WITH_GJDOC=no;
172                elif test "x${withval}" = xyes -o "x{withval}" = x; then
173                  WITH_GJDOC=yes;
174                  AC_PATH_PROG(GJDOC, gjdoc, "no")
175                  if test "x${GJDOC}" = xno; then
176                    AC_MSG_ERROR("gjdoc executable not found");
177                  fi
178                else
179                  WITH_GJDOC=yes
180                  GJDOC="${withval}"
181                  AC_CHECK_FILE(${GJDOC}, AC_SUBST(GJDOC),
182                                AC_MSG_ERROR("Cannot use ${withval} as gjdoc executable since it doesn't exist"))
183                fi],
184               [WITH_GJDOC=no])
185   AM_CONDITIONAL(CREATE_API_DOCS, test "x${WITH_GJDOC}" = xyes)
186   if test "x${WITH_GJDOC}" = xyes; then
187     AC_MSG_CHECKING([version of GJDoc])
188     gjdoc_version=$(${GJDOC} --version|cut -d ' ' -f2)
189     AC_MSG_RESULT(${gjdoc_version})
190     case ${gjdoc_version} in
191       0.7.9) ;;
192       0.8*) ;;
193       0.9*) ;;
194       1*) ;;
195       *) AC_MSG_ERROR([Building documentation requires GJDoc >= 0.7.9, ${gjdoc_version} found.]) ;;
196     esac
197   fi
200 dnl -----------------------------------------------------------
201 dnl Enable regeneration of parsers using jay
202 dnl http://www.informatik.uni-osnabrueck.de/alumni/bernd/jay/
203 dnl -----------------------------------------------------------
204 AC_DEFUN([REGEN_WITH_JAY],
206   AC_ARG_WITH([jay],
207               [AS_HELP_STRING(--with-jay[=DIR|PATH],Regenerate the parsers with jay)],
208   [
209     AC_MSG_CHECKING([whether to regenerate parsers with jay])
210     JAY_FOUND=no
211     JAY_DIR_PATH=
212     if test "x${withval}" = xno; then
213       AC_MSG_RESULT(no)
214     elif test "x${withval}" = xyes; then
215       AC_MSG_RESULT(yes)
216       JAY_DIR_PATH="/usr/share/jay"
217     elif test -d "${withval}"; then
218       AC_MSG_RESULT(yes)
219       JAY_DIR_PATH="${withval}"
220     elif test -f "${withval}"; then
221       AC_MSG_RESULT(yes)
222       JAY_DIR_PATH=`dirname "${withval}"`
223       JAY="${withval}"
224     else
225         AC_MSG_ERROR(jay not found at ${withval})
226     fi
228     if test "x${JAY_DIR_PATH}" != x; then
229       AC_PATH_PROG(JAY, jay, "no", ${JAY_DIR_PATH}:${PATH})
230       if test "x${JAY}" = xno; then
231         AC_MSG_ERROR(jay executable not found);
232       fi
233       JAY_SKELETON="${JAY_DIR_PATH}/skeleton"
234       AC_CHECK_FILE(${JAY_SKELETON}, AC_SUBST(JAY_SKELETON),
235           AC_MSG_ERROR(Expected skeleton file in ${JAY_DIR_PATH}))
236       JAY_FOUND=yes
237     fi
238   ],
239   [
240     AC_MSG_CHECKING([whether to regenerate parsers with jay])
241     AC_MSG_RESULT(no)
242     JAY_FOUND=no
243   ])
244   AM_CONDITIONAL(REGEN_PARSERS, test "x${JAY_FOUND}" = xyes)
247 dnl -----------------------------------------------------------
248 dnl GCJ LOCAL: Calculate toolexeclibdir
249 dnl -----------------------------------------------------------
250 AC_DEFUN([CLASSPATH_TOOLEXECLIBDIR],
252   multi_os_directory=`$CC -print-multi-os-directory`
253   case $multi_os_directory in
254     .) toolexeclibdir=${libdir} ;; # Avoid trailing /.
255     *) toolexeclibdir=${libdir}/${multi_os_directory} ;;
256   esac
257   AC_SUBST(toolexeclibdir)
260 dnl -----------------------------------------------------------
261 AC_DEFUN([CLASSPATH_JAVAC_MEM_CHECK],
263   JAVA_TEST=Test.java
264   CLASS_TEST=Test.class
265   cat << \EOF > $JAVA_TEST
266   /* [#]line __oline__ "configure" */
267   public class Test 
268   {
269     public static void main(String[] args)
270     {
271       System.out.println("Hello World");
272     }
273   }
275   if test x$JAVAC_IS_GCJ != xyes; then
276     AC_MSG_CHECKING([whether javac supports -J])
277     $JAVAC $JAVACFLAGS -J-Xmx768M -sourcepath '' $JAVA_TEST
278     javac_result=$?
279     if test "x$javac_result" = "x0"; then
280       AC_MSG_RESULT([yes])
281       JAVAC_MEM_OPT="-J-Xmx768M"
282     else
283       AC_MSG_RESULT([no])
284     fi
285   fi
286   rm -f $JAVA_TEST $CLASS_TEST
287   AC_SUBST(JAVAC_MEM_OPT)
290 dnl ---------------------------------------------------------------
291 dnl CLASSPATH_COND_IF(COND, SHELL-CONDITION, [IF-TRUE], [IF-FALSE])
292 dnl ---------------------------------------------------------------
293 dnl Automake 1.11 can emit conditional rules for AC_CONFIG_FILES,
294 dnl using AM_COND_IF.  This wrapper uses it if it is available,
295 dnl otherwise falls back to code compatible with Automake 1.9.6.
296 AC_DEFUN([CLASSPATH_COND_IF],
297 [m4_ifdef([AM_COND_IF],
298   [AM_COND_IF([$1], [$3], [$4])],
299   [if $2; then
300      m4_default([$3], [:])
301    else
302      m4_default([$4], [:])
303    fi
304 ])])