hacks to build jni added by mario-goulart on Fri Feb 8 00:34:30 2013
diff --git a/jni.setup b/jni.setup index debd25c..9e33870 100644 --- a/jni.setup +++ b/jni.setup @@ -1,42 +1,48 @@ ;; -*- scheme -*- -(let ((java-path (get-environment-variable "JAVA_HOME"))) - (unless java-path - (with-output-to-port (current-error-port) - (lambda () - (print "\n\n=== Please, set the JAVA_HOME environment variable. ==="))) - (exit 1)) - (let* ((java-include-path (string-append java-path "/include/")) - (libjvm-path - (cond-expand - (x86-64 - (let* ((server-jvm-path (string-append java-path "/jre/lib/amd64/server/")) - (server-jvm-path (if (file-exists? server-jvm-path) server-jvm-path - (string-append java-path "/jre/lib/x64/server/"))) - (client-jvm-path (string-append java-path "/jre/lib/amd64/client/")) - (client-jvm-path (if (file-exists? client-jvm-path) client-jvm-path - (string-append java-path "/jre/lib/x64/client/")))) - (if (file-exists? server-jvm-path) - server-jvm-path - (if (file-exists? client-jvm-path) - client-jvm-path - (error 'jni "could not find libjvm :("))))) - (x86 - (let* ((server-jvm-path (string-append java-path "/jre/lib/i386/client/")) - (client-jvm-path (string-append java-path "/jre/lib/i386/client/"))) - (if (file-exists? server-jvm-path) - server-jvm-path - (if (file-exists? client-jvm-path) - client-jvm-path - (error 'jni "could not find libjvm :(")))))))) +(define (require-envvar var) + (let ((val (get-environment-variable var))) + (or val + (with-output-to-port (current-error-port) + (lambda () + (printf "\n\n=== Please, set the ~a environment variable. ===\n\n" var))) + (exit 1)))) - (cond-expand - (android - (compile -s jni.scm -J) - (compile -s jni.import.scm)) - (else - (compile ,(string-append "-L" libjvm-path) -ljvm -s ,(string-append "-I" java-include-path) jni.scm -J) - (compile ,(string-append "-L" libjvm-path) -ljvm -s ,(string-append "-I" java-include-path) jni.import.scm))))) +(let* ((java-path (require-envvar "JAVA_HOME")) + (ndk-libdir (require-envvar "NDK_LIBDIR")) + (java-include-path (string-append java-path "/include/")) + (libjvm-path + (if (host-extension) + (cond-expand + (x86-64 + (let* ((server-jvm-path (string-append java-path "/jre/lib/amd64/server/")) + (server-jvm-path (if (file-exists? server-jvm-path) server-jvm-path + (string-append java-path "/jre/lib/x64/server/"))) + (client-jvm-path (string-append java-path "/jre/lib/amd64/client/")) + (client-jvm-path (if (file-exists? client-jvm-path) client-jvm-path + (string-append java-path "/jre/lib/x64/client/")))) + (if (file-exists? server-jvm-path) + server-jvm-path + (if (file-exists? client-jvm-path) + client-jvm-path + (error 'jni "could not find libjvm :("))))) + (x86 + (let* ((server-jvm-path (string-append java-path "/jre/lib/i386/client/")) + (client-jvm-path (string-append java-path "/jre/lib/i386/client/"))) + (if (file-exists? server-jvm-path) + server-jvm-path + (if (file-exists? client-jvm-path) + client-jvm-path + (error 'jni "could not find libjvm :(")))))) + ndk-libdir))) + + (cond-expand + (android + (compile -s jni.scm -J) + (compile -s jni.import.scm)) + (else + (compile ,(string-append "-L" libjvm-path) ,@(if (host-extension) '(-ljvm) '()) -s ,(string-append "-I" java-include-path) jni.scm -J) + (compile ,(string-append "-L" libjvm-path) ,@(if (host-extension) '(-ljvm) '()) -s ,(string-append "-I" java-include-path) jni.import.scm)))) (install-extension 'jni '("jni.so" "jni.import.so")