Merge from trunk @ 138209
[official-gcc.git] / libjava / classpath / m4 / acinclude.m4
blob9f98f1c37f6c817979648ca0123bc6732b297d16
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)
58   AC_ARG_WITH([fastjar],
59               [AS_HELP_STRING([--with-fastjar=PATH], [define to use a fastjar style tool])],
60               [
61                 AC_MSG_CHECKING([for user supplied fastjar])
62                 FASTJAR=${withval}
63                 AC_MSG_RESULT([${FASTJAR}])
64               ],
65               [AC_PATH_PROGS([FASTJAR], [fastjar gjar jar])])
66 dnl We disable ZIP by default if we find fastjar.
67   if test x"${FASTJAR}" != x; then
68     ZIP=""
69   fi
70   
71   AC_ARG_WITH([glibj],
72               [AS_HELP_STRING([--with-glibj],[define what to install (zip|flat|both|none|build) [default=zip]])],
73               [
74                 if test "x${withval}" = xyes || test "x${withval}" = xzip; then
75                   install_class_files=no
76                   build_class_files=yes
77                   use_zip=yes
78                 elif test "x${withval}" = xboth; then
79                   install_class_files=yes
80                   build_class_files=yes
81                   use_zip=yes
82                 elif test "x${withval}" = xflat; then
83                   install_class_files=yes
84                   build_class_files=yes
85                   use_zip=no
86                 elif test "x${withval}" = xno || test "x${withval}" = xnone; then
87                   install_class_files=no
88                   build_class_files=no
89                   use_zip=no
90                 elif test "x${withval}" = xbuild; then
91                   install_class_files=no
92                   build_class_files=yes
93                   use_zip=no
94                 else
95                   AC_MSG_ERROR([unknown value given to --with-glibj])
96                 fi
97               ],
98               [
99                 install_class_files=no
100                 use_zip=yes
101               ])
102   AM_CONDITIONAL(INSTALL_GLIBJ_ZIP, test "x${use_zip}" = xyes)
103   AM_CONDITIONAL(INSTALL_CLASS_FILES, test "x${install_class_files}" = xyes)
104   AM_CONDITIONAL(BUILD_CLASS_FILES, test "x${build_class_files}" = xyes)
106   AC_ARG_ENABLE([examples],
107                 [AS_HELP_STRING(--enable-examples,enable build of the examples [default=yes])],
108                 [case "${enableval}" in
109                   yes) EXAMPLESDIR="examples" ;;
110                   no) EXAMPLESDIR="" ;;
111                   *) AC_MSG_ERROR(bad value ${enableval} for --enable-examples) ;;
112                 esac],
113                 [EXAMPLESDIR="examples"])
114   if test "x${use_zip}" = xno && test "x${install_class_files}" = xno; then
115     EXAMPLESDIR=""
116   fi
117   AC_SUBST(EXAMPLESDIR)
119   AC_ARG_ENABLE([tools],
120                 [AS_HELP_STRING(--enable-tools,enable build of the tools [default=yes])],
121                 [case "${enableval}" in
122                   yes) TOOLSDIR="tools" ;;
123                   no) TOOLSDIR="" ;;
124                   *) AC_MSG_ERROR(bad value ${enableval} for --enable-tools) ;;
125                 esac],
126                 [TOOLSDIR="tools"])
127   if test "x${use_zip}" = xno && test "x${install_class_files}" = xno; then
128     TOOLSDIR=""
129   fi
130   AC_SUBST(TOOLSDIR)
133 dnl -----------------------------------------------------------
134 dnl Enable generation of API documentation, with gjdoc if it
135 dnl has been compiled to an executable (or a suitable script
136 dnl is in your PATH) or using the argument as gjdoc executable.
137 dnl -----------------------------------------------------------
138 AC_DEFUN([CLASSPATH_WITH_GJDOC],
140   AC_ARG_WITH([gjdoc],
141               AS_HELP_STRING([--with-gjdoc],
142                              [generate documentation using gjdoc (default is NO)]),
143               [if test "x${withval}" = xno; then
144                  WITH_GJDOC=no;
145                elif test "x${withval}" = xyes -o "x{withval}" = x; then
146                  WITH_GJDOC=yes;
147                  AC_PATH_PROG(GJDOC, gjdoc, "no")
148                  if test "x${GJDOC}" = xno; then
149                    AC_MSG_ERROR("gjdoc executable not found");
150                  fi
151                else
152                  WITH_GJDOC=yes
153                  GJDOC="${withval}"
154                  AC_CHECK_FILE(${GJDOC}, AC_SUBST(GJDOC),
155                                AC_MSG_ERROR("Cannot use ${withval} as gjdoc executable since it doesn't exist"))
156                fi],
157               [WITH_GJDOC=no])
159   AM_CONDITIONAL(CREATE_API_DOCS, test "x${WITH_GJDOC}" = xyes)
162 dnl -----------------------------------------------------------
163 dnl Enable regeneration of parsers using jay
164 dnl http://www.informatik.uni-osnabrueck.de/alumni/bernd/jay/
165 dnl -----------------------------------------------------------
166 AC_DEFUN([REGEN_WITH_JAY],
168   AC_ARG_WITH([jay],
169               [AS_HELP_STRING(--with-jay[=DIR|PATH],Regenerate the parsers with jay)],
170   [
171     AC_MSG_CHECKING([whether to regenerate parsers with jay])
172     JAY_FOUND=no
173     JAY_DIR_PATH=
174     if test "x${withval}" = xno; then
175       AC_MSG_RESULT(no)
176     elif test "x${withval}" = xyes; then
177       AC_MSG_RESULT(yes)
178       JAY_DIR_PATH="/usr/share/jay"
179     elif test -d "${withval}"; then
180       AC_MSG_RESULT(yes)
181       JAY_DIR_PATH="${withval}"
182     elif test -f "${withval}"; then
183       AC_MSG_RESULT(yes)
184       JAY_DIR_PATH=`dirname "${withval}"`
185       JAY="${withval}"
186     else
187         AC_MSG_ERROR(jay not found at ${withval})
188     fi
190     if test "x${JAY_DIR_PATH}" != x; then
191       AC_PATH_PROG(JAY, jay, "no", ${JAY_DIR_PATH}:${PATH})
192       if test "x${JAY}" = xno; then
193         AC_MSG_ERROR(jay executable not found);
194       fi
195       JAY_SKELETON="${JAY_DIR_PATH}/skeleton"
196       AC_CHECK_FILE(${JAY_SKELETON}, AC_SUBST(JAY_SKELETON),
197           AC_MSG_ERROR(Expected skeleton file in ${JAY_DIR_PATH}))
198       JAY_FOUND=yes
199     fi
200   ],
201   [
202     AC_MSG_CHECKING([whether to regenerate parsers with jay])
203     AC_MSG_RESULT(no)
204     JAY_FOUND=no
205   ])
206   AM_CONDITIONAL(REGEN_PARSERS, test "x${JAY_FOUND}" = xyes)
209 dnl -----------------------------------------------------------
210 dnl GCJ LOCAL: Calculate toolexeclibdir
211 dnl -----------------------------------------------------------
212 AC_DEFUN([CLASSPATH_TOOLEXECLIBDIR],
214   multi_os_directory=`$CC -print-multi-os-directory`
215   case $multi_os_directory in
216     .) toolexeclibdir=${libdir} ;; # Avoid trailing /.
217     *) toolexeclibdir=${libdir}/${multi_os_directory} ;;
218   esac
219   AC_SUBST(toolexeclibdir)
222 dnl -----------------------------------------------------------
223 AC_DEFUN([CLASSPATH_JAVAC_MEM_CHECK],
225   JAVA_TEST=Test.java
226   CLASS_TEST=Test.class
227   cat << \EOF > $JAVA_TEST
228   /* [#]line __oline__ "configure" */
229   public class Test 
230   {
231     public static void main(String[] args)
232     {
233       System.out.println("Hello World");
234     }
235   }
237   AC_MSG_CHECKING([whether javac supports -J])
238   $JAVAC $JAVACFLAGS -J-Xmx768M -sourcepath '' $JAVA_TEST
239   javac_result=$?
240   if test "x$javac_result" = "x0"; then
241     AC_MSG_RESULT([yes])
242     JAVAC_MEM_OPT="-J-Xmx768M"
243   else
244     AC_MSG_RESULT([no])
245   fi
246   rm -f $JAVA_TEST $CLASS_TEST
247   AC_SUBST(JAVAC_MEM_OPT)
250 dnl ---------------------------------------------------------------
251 dnl CLASSPATH_COND_IF(COND, SHELL-CONDITION, [IF-TRUE], [IF-FALSE])
252 dnl ---------------------------------------------------------------
253 dnl Automake 1.11 can emit conditional rules for AC_CONFIG_FILES,
254 dnl using AM_COND_IF.  This wrapper uses it if it is available,
255 dnl otherwise falls back to code compatible with Automake 1.9.6.
256 AC_DEFUN([CLASSPATH_COND_IF],
257 [m4_ifdef([AM_COND_IF],
258   [AM_COND_IF([$1], [$3], [$4])],
259   [if $2; then
260      m4_default([$3], [:])
261    else
262      m4_default([$4], [:])
263    fi
264 ])])