alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (mkLibNatives.sh)

This example Scala source code file (mkLibNatives.sh) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

cc, cc, cc_includes, cc_options, full_lib_name, java_home, java_home, javah, javah_options, lib_name, lnk_options, lnk_options, obj_name, obj_name

The Scala mkLibNatives.sh source code

#!/bin/sh

##############################################################################
# Author  : Stephane Micheloud
##############################################################################

##############################################################################
# variables

# set any value to enable debugging output
debug=

cygwin=false;
darwin=false;
case "`uname`" in
    CYGWIN*) cygwin=true ;;
    Darwin*) darwin=true ;;
esac

CLASS_NAME=Test\$
CLASS_DIR=natives-jvm.obj

OBJ_NAME=natives
LIB_NAME=libnatives

if [ -z "${JAVA_HOME}" ]; then
  echo "environment variable JAVA_HOME is undefined."
  exit
elif $cygwin; then
  echo "Cygwin not supported (use 'mkLibNatives.bat')."
  exit
fi

JAVAH=${JAVA_HOME}/bin/javah
JAVAH_OPTIONS="-jni -force -classpath ${CLASS_DIR} -o ${OBJ_NAME}.h"

CC=gcc

if $darwin; then
  CC_OPTIONS="-c -arch ppc -arch i386 -arch x86_64"
  CC_INCLUDES="-I/System/Library/Frameworks/JavaVM.framework/Headers"
  LNK_OPTIONS="-dynamiclib -framework JavaVM"
  FULL_LIB_NAME=${LIB_NAME}.jnilib
else
  CC_OPTIONS=-c
  CC_INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/${OSTYPE}"
  LNK_OPTIONS="-shared -Wl,-soname,${LIB_NAME}"
  FULL_LIB_NAME=${LIB_NAME}.so
fi

##############################################################################
# commands

[ $debug ] && echo ${JAVAH} ${JAVAH_OPTIONS} ${CLASS_NAME}
${JAVAH} ${JAVAH_OPTIONS} ${CLASS_NAME}

[ $debug ] && echo ${CC} ${CC_OPTIONS} ${CC_INCLUDES} -o ${OBJ_NAME}.o natives.c
${CC} ${CC_OPTIONS} ${CC_INCLUDES} -o ${OBJ_NAME}.o natives.c

[ $debug ] && echo ${CC} ${LNK_OPTIONS} -o ${FULL_LIB_NAME} ${OBJ_NAME}.o
${CC} ${LNK_OPTIONS} -o ${FULL_LIB_NAME} ${OBJ_NAME}.o

Other Scala examples (source code examples)

Here is a short list of links related to this Scala mkLibNatives.sh source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.