Make javac and jni.h optional in ./configure

This commit is contained in:
Andrew Bettison 2012-04-23 12:05:00 +09:30
parent 44e9449988
commit 551f22092f
4 changed files with 44 additions and 8 deletions

15
aclocal.m4 vendored
View File

@ -263,8 +263,23 @@ else
AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
echo "configure: failed program was:" >&AC_FD_CC echo "configure: failed program was:" >&AC_FD_CC
cat $JAVA_TEST >&AC_FD_CC cat $JAVA_TEST >&AC_FD_CC
ac_cv_prog_javac_works=no
fi fi
rm -f $JAVA_TEST $CLASS_TEST rm -f $JAVA_TEST $CLASS_TEST
]) ])
AC_PROVIDE([$0])dnl AC_PROVIDE([$0])dnl
]) ])
The Autoconf macros in this directory were copied from the GNU Autoconf Archive
http://www.gnu.org/software/autoconf-archive/
To use them, simply concatenate them all into the aclocal.m4 file in the
project root directory:
cd batphone/jni/servald
cat m4/* >aclocal.m4
Then you can run autoconf with no special arguments:
autoconf
./configure
make

View File

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_JNI_H #ifdef HAVE_JNI_H
@ -91,6 +92,7 @@ int cli_usage() {
#ifdef HAVE_JNI_H #ifdef HAVE_JNI_H
/* JNI entry point to command line. See org.servalproject.servald.ServalD class for the Java side. /* JNI entry point to command line. See org.servalproject.servald.ServalD class for the Java side.
JNI method descriptor: "([Ljava/lang/String;)Lorg/servalproject/servald/ServalDResult;" JNI method descriptor: "([Ljava/lang/String;)Lorg/servalproject/servald/ServalDResult;"
*/ */
@ -122,7 +124,8 @@ JNIEXPORT jobject JNICALL Java_org_servalproject_servald_ServalD_command(JNIEnv
} }
return (*env)->NewObject(env, resultClass, resultConstructorId, status, outv); return (*env)->NewObject(env, resultClass, resultConstructorId, status, outv);
} }
#endif
#endif /* HAVE_JNI_H */
/* args[] excludes command name (unless hardlinks are used to use first words /* args[] excludes command name (unless hardlinks are used to use first words
of command sequences as alternate names of the command. */ of command sequences as alternate names of the command. */
@ -218,6 +221,16 @@ int cli_arg(int argc, char **argv, command_line_option *o, char *argname, char *
return 1; return 1;
} }
int cli_printf(const char *fmt, ...)
{
va_list ap,ap2;
va_start(ap,fmt);
va_copy(ap2,ap);
//vsnprintf(msg,8192,fmt,ap2);
va_end(ap);
return 0;
}
int app_dna_lookup(int argc,char **argv,struct command_line_option *o) int app_dna_lookup(int argc,char **argv,struct command_line_option *o)
{ {
/* Create the instance directory if it does not yet exist */ /* Create the instance directory if it does not yet exist */

View File

@ -1,18 +1,25 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_INIT(dna.c) AC_INIT(dna.c)
dnl Checks for programs. dnl Check for programs.
AC_PROG_CC AC_PROG_CC
dnl Check for a working Java compiler, keep going if unsuccessful.
pushdef([AC_MSG_ERROR], defn([AC_MSG_WARN]))
AC_PROG_JAVAC AC_PROG_JAVAC
popdef([AC_MSG_ERROR])
dnl Check for JNI includes, keep going if not present.
pushdef([AC_MSG_ERROR], defn([AC_MSG_WARN]))
AC_JNI_INCLUDE_DIR
for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do
CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR"
done
popdef([AC_MSG_ERROR])
AC_CHECK_LIB(c,srandomdev) AC_CHECK_LIB(c,srandomdev)
AC_CHECK_HEADERS(stdio.h errno.h stdlib.h strings.h unistd.h string.h arpa/inet.h sys/socket.h sys/mman.h sys/time.h poll.h netdb.h linux/if.h linux/netlink.h linux/rtnetlink.h net/if.h netinet/in.h ifaddrs.h net/route.h signal.h portaudio.h) AC_CHECK_HEADERS(stdio.h errno.h stdlib.h strings.h unistd.h string.h arpa/inet.h sys/socket.h sys/mman.h sys/time.h poll.h netdb.h linux/if.h linux/netlink.h linux/rtnetlink.h net/if.h netinet/in.h ifaddrs.h net/route.h signal.h jni.h)
dnl AC_JNI_INCLUDE_DIR
dnl for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do
dnl CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR"
dnl done
echo "Fetching and building NaCl if required." echo "Fetching and building NaCl if required."
echo "(this can take HOURS to build depending on your architecture," echo "(this can take HOURS to build depending on your architecture,"

View File

@ -65,6 +65,7 @@ else
AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
echo "configure: failed program was:" >&AC_FD_CC echo "configure: failed program was:" >&AC_FD_CC
cat $JAVA_TEST >&AC_FD_CC cat $JAVA_TEST >&AC_FD_CC
ac_cv_prog_javac_works=no
fi fi
rm -f $JAVA_TEST $CLASS_TEST rm -f $JAVA_TEST $CLASS_TEST
]) ])