From 551f22092fd0af933fac634038ceae60d4348877 Mon Sep 17 00:00:00 2001 From: Andrew Bettison <andrewb@zip.com.au> Date: Mon, 23 Apr 2012 12:05:00 +0930 Subject: [PATCH] Make javac and jni.h optional in ./configure --- aclocal.m4 | 15 +++++++++++++++ commandline.c | 15 ++++++++++++++- configure.in | 21 ++++++++++++++------- m4/ax_prog_javac_works.m4 | 1 + 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 48eb6c04..d83526f5 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -263,8 +263,23 @@ else AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) echo "configure: failed program was:" >&AC_FD_CC cat $JAVA_TEST >&AC_FD_CC + ac_cv_prog_javac_works=no fi rm -f $JAVA_TEST $CLASS_TEST ]) 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 diff --git a/commandline.c b/commandline.c index 374d0326..21622b86 100644 --- a/commandline.c +++ b/commandline.c @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <string.h> #include <time.h> #include <unistd.h> +#include <stdarg.h> #include <stdlib.h> #include <stdio.h> #ifdef HAVE_JNI_H @@ -91,6 +92,7 @@ int cli_usage() { #ifdef HAVE_JNI_H + /* 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;" */ @@ -122,7 +124,8 @@ JNIEXPORT jobject JNICALL Java_org_servalproject_servald_ServalD_command(JNIEnv } 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 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; } +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) { /* Create the instance directory if it does not yet exist */ diff --git a/configure.in b/configure.in index 7d573cc0..dfefcaee 100644 --- a/configure.in +++ b/configure.in @@ -1,18 +1,25 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(dna.c) -dnl Checks for programs. +dnl Check for programs. 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 +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_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) - -dnl AC_JNI_INCLUDE_DIR -dnl for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do -dnl CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" -dnl done +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) echo "Fetching and building NaCl if required." echo "(this can take HOURS to build depending on your architecture," diff --git a/m4/ax_prog_javac_works.m4 b/m4/ax_prog_javac_works.m4 index 88498276..530fccb7 100644 --- a/m4/ax_prog_javac_works.m4 +++ b/m4/ax_prog_javac_works.m4 @@ -65,6 +65,7 @@ else AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) echo "configure: failed program was:" >&AC_FD_CC cat $JAVA_TEST >&AC_FD_CC + ac_cv_prog_javac_works=no fi rm -f $JAVA_TEST $CLASS_TEST ])