1dnl Used by aclocal to generate configure
2
3dnl -----------------------------------------------------------
4AC_DEFUN([CLASSPATH_WITH_JAVAH],
5[
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)
19])
20
21dnl -----------------------------------------------------------
22dnl Checking for a javah like program
23dnl -----------------------------------------------------------
24AC_DEFUN([CLASSPATH_CHECK_JAVAH],
25[
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
39])
40
41dnl -----------------------------------------------------------
42dnl CLASSPATH_WITH_CLASSLIB - checks for user specified classpath additions
43dnl -----------------------------------------------------------
44AC_DEFUN([CLASSPATH_WITH_CLASSLIB],
45[
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)
50])
51
52dnl -----------------------------------------------------------
53dnl CLASSPATH_WITH_GLIBJ - specify what to install
54dnl -----------------------------------------------------------
55AC_DEFUN([CLASSPATH_WITH_GLIBJ],
56[
57  AC_PATH_PROG(ZIP, zip)
58
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)
132
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)
145
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)
158])
159
160dnl -----------------------------------------------------------
161dnl Enable generation of API documentation, with gjdoc if it
162dnl has been compiled to an executable (or a suitable script
163dnl is in your PATH) or using the argument as gjdoc executable.
164dnl -----------------------------------------------------------
165AC_DEFUN([CLASSPATH_WITH_GJDOC],
166[
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
198])
199
200dnl -----------------------------------------------------------
201dnl Enable regeneration of parsers using jay
202dnl http://www.informatik.uni-osnabrueck.de/alumni/bernd/jay/
203dnl -----------------------------------------------------------
204AC_DEFUN([REGEN_WITH_JAY],
205[
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
227
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)
245])
246
247dnl -----------------------------------------------------------
248dnl GCJ LOCAL: Calculate toolexeclibdir
249dnl -----------------------------------------------------------
250AC_DEFUN([CLASSPATH_TOOLEXECLIBDIR],
251[
252  case ${version_specific_libs} in
253    yes)
254      # Need the gcc compiler version to know where to install libraries
255      # and header files if --enable-version-specific-runtime-libs option
256      # is selected.
257      includedir='$(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include/'
258      toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
259      toolexecmainlibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
260      toolexeclibdir=$toolexecmainlibdir
261      ;;
262    no)
263      if test -n "$with_cross_host" &&
264         test x"$with_cross_host" != x"no"; then
265        # Install a library built with a cross compiler in tooldir, not libdir.
266        toolexecdir='$(exec_prefix)/$(target_noncanonical)'
267        toolexecmainlibdir='$(toolexecdir)/lib'
268      else
269        toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
270        toolexecmainlibdir='$(libdir)'
271      fi
272      multi_os_directory=`$CC -print-multi-os-directory`
273      case $multi_os_directory in
274        .) toolexeclibdir=$toolexecmainlibdir ;; # Avoid trailing /.
275        *) toolexeclibdir=$toolexecmainlibdir/$multi_os_directory ;;
276      esac
277      ;;
278  esac
279  AC_SUBST(toolexecdir)
280  AC_SUBST(toolexecmainlibdir)
281  AC_SUBST(toolexeclibdir)
282])
283
284dnl -----------------------------------------------------------
285AC_DEFUN([CLASSPATH_JAVAC_MEM_CHECK],
286[
287  JAVA_TEST=Test.java
288  CLASS_TEST=Test.class
289  cat << \EOF > $JAVA_TEST
290  /* [#]line __oline__ "configure" */
291  public class Test
292  {
293    public static void main(String[] args)
294    {
295      System.out.println("Hello World");
296    }
297  }
298EOF
299  if test x$JAVAC_IS_GCJ != xyes; then
300    AC_MSG_CHECKING([whether javac supports -J])
301    $JAVAC $JAVACFLAGS -J-Xmx768M -sourcepath '' $JAVA_TEST
302    javac_result=$?
303    if test "x$javac_result" = "x0"; then
304      AC_MSG_RESULT([yes])
305      JAVAC_MEM_OPT="-J-Xmx768M"
306    else
307      AC_MSG_RESULT([no])
308    fi
309  fi
310  rm -f $JAVA_TEST $CLASS_TEST
311  AC_SUBST(JAVAC_MEM_OPT)
312])
313
314dnl ---------------------------------------------------------------
315dnl CLASSPATH_COND_IF(COND, SHELL-CONDITION, [IF-TRUE], [IF-FALSE])
316dnl ---------------------------------------------------------------
317dnl Automake 1.11 can emit conditional rules for AC_CONFIG_FILES,
318dnl using AM_COND_IF.  This wrapper uses it if it is available,
319dnl otherwise falls back to code compatible with Automake 1.9.6.
320AC_DEFUN([CLASSPATH_COND_IF],
321[m4_ifdef([AM_COND_IF],
322  [AM_COND_IF([$1], [$3], [$4])],
323  [if $2; then
324     m4_default([$3], [:])
325   else
326     m4_default([$4], [:])
327   fi
328])])
329