1 # SPDX-License-Identifier: FSFAP
3 # ===========================================================================
4 # https://www.gnu.org/software/autoconf-archive/ax_prog_javah.html
5 # ===========================================================================
13 # AX_PROG_JAVAH tests the availability of the javah header generator and
14 # looks for the jni.h header file. If available, JAVAH is set to the full
15 # path of javah and CPPFLAGS is updated accordingly.
19 # Copyright (c) 2008 Luc Maisonobe <luc@spaceroots.org>
21 # Copying and distribution of this file, with or without modification, are
22 # permitted in any medium without royalty provided the copyright notice
23 # and this notice are preserved. This file is offered as-is, without any
28 AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH])
29 AC_DEFUN([AX_PROG_JAVAH],[
30 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
31 AC_REQUIRE([AC_PROG_CPP])dnl
32 AC_PATH_PROG(JAVAH,javah)
33 AS_IF([test -n "$ac_cv_path_JAVAH"],
35 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])],[],[
36 ac_save_CPPFLAGS="$CPPFLAGS"
37 _ACJAVAH_FOLLOW_SYMLINKS("$ac_cv_path_JAVAH")
38 ax_prog_javah_bin_dir=`AS_DIRNAME([$_ACJAVAH_FOLLOWED])`
39 ac_dir="`AS_DIRNAME([$ax_prog_javah_bin_dir])`/include"
43 [ac_machdep=`AS_ECHO($build_os) | sed 's,[[-0-9]].*,,'`])
44 CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep"
45 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])],
46 [ac_save_CPPFLAGS="$CPPFLAGS"],
47 [AC_MSG_WARN([unable to include <jni.h>])])
48 CPPFLAGS="$ac_save_CPPFLAGS"])
52 AC_DEFUN([_ACJAVAH_FOLLOW_SYMLINKS],[
53 # find the include directory relative to the javac executable
55 while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
56 AC_MSG_CHECKING([symlink for $_cur])
57 _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
60 # 'X' avoids triggering unwanted echo options.
61 *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
63 AC_MSG_RESULT([$_cur])
65 _ACJAVAH_FOLLOWED="$_cur"