]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
build both 32 and 64-bit versions of the JNI code so as to support both
authoridgay <idgay>
Wed, 6 Jun 2007 22:40:17 +0000 (22:40 +0000)
committeridgay <idgay>
Wed, 6 Jun 2007 22:40:17 +0000 (22:40 +0000)
32 and 64-bit JDKs
install the appropriate JNI version depending on whether the JDK is 32 or 64-bit

all this is for Linux only for now

tools/configure.ac
tools/release/tinyos-tools.spec
tools/tinyos/java/env/Makefile.am
tools/tinyos/java/serial/Makefile.am
tools/tinyos/misc/tos-install-jni.in

index debc3de254939f5e19b5e649c12c7095cef8ac67..60ec10cb308d7e8867fc184bb93419f8fce53748 100644 (file)
@@ -73,12 +73,14 @@ case $host in
     AC_MSG_RESULT(yes)
     JNIPREFIX=
     JNISUFFIX=dll
+    JNIVERSIONS=.
     INSTALLJNI="install --group=SYSTEM"
     CYGWIN=yes
     ;;
   *)
     JNIPREFIX=lib
     JNISUFFIX=so
+    JNIVERSIONS="-32. -64."
     INSTALLJNI="install"
     AC_MSG_RESULT(no)
 esac
@@ -93,8 +95,14 @@ fi
 JDK=`dirname "$JAVAC_DIR"`
 AC_MSG_RESULT($JDK)
 
-GETENVLIB=${JNIPREFIX}getenv.$JNISUFFIX
-TOSCOMMLIB=${JNIPREFIX}toscomm.$JNISUFFIX
+function jnimap {
+  for v in $JNIVERSIONS; do
+    echo -n "${JNIPREFIX}$1$v$JNISUFFIX "
+  done
+}
+
+GETENVLIB=`jnimap getenv`
+TOSCOMMLIB=`jnimap toscomm`
 
 AC_SUBST(GETENVLIB)
 AC_SUBST(TOSCOMMLIB)
index 0b60a83c531129f2e2a69eedf9e25004619ce3eb..52b78c968d4fdecfff80a7e2ad71c82c9905dac7 100644 (file)
@@ -58,12 +58,21 @@ if [ $? -ne 0 ]; then
   echo "Java not found, not installing JNI code"
   exit 0
 fi
-echo "Installing Java JNI code in $jni ... "
 %ifos linux
-for lib in $RPM_INSTALL_PREFIX/lib/tinyos/*.so; do 
-  install $lib "$jni" || exit 0
+java=`$RPM_INSTALL_PREFIX/bin/tos-locate-jre --java`
+bits=32
+if [ $? -ne 0 ]; then
+  echo "java command not found - assuming 32 bits"
+elif file -L $java/java | grep -q 64-bit; then
+  bits=64
+fi
+echo "Installing $bits-bit Java JNI code in $jni ... "
+for lib in $tinyoslibdir/*-$bits.so; do 
+  realname=`basename $lib | sed -e s/-$bits\.so/.so/`
+  install $lib "$jni/$realname" || exit 1
 done
 %else
+echo "Installing Java JNI code in $jni ... "
 for lib in $RPM_INSTALL_PREFIX/lib/tinyos/*.dll; do 
   install --group=SYSTEM $lib "$jni" || exit 0
 done
index ab66da62456a3e48dd25089a68d1a0c2cc65e4b8..32383bee779e70a9e3621c0e7f20a13883365389 100644 (file)
@@ -6,12 +6,20 @@ tinyoslibdir=$(libdir)/tinyos
 
 tinyoslib_PROGRAMS = @GETENVLIB@
 
-EXTRA_PROGRAMS = libgetenv.so getenv.dll
+EXTRA_PROGRAMS = libgetenv-32.so libgetenv-64.so getenv.dll
 
-libgetenv_so_SOURCES = net_tinyos_util_Env.h net_tinyos_util_Env.c
+SOFLAGS = "-I$(JDK)/include/linux" "-I$(JDK)/include" -shared -fpic
 
-libgetenv.so : net_tinyos_util_Env.h net_tinyos_util_Env.c
-       gcc "-I$(JDK)/include/linux" "-I$(JDK)/include" -shared -fpic -m32 net_tinyos_util_Env.c -o$@
+libgetenv_32_so_SOURCES = net_tinyos_util_Env.h net_tinyos_util_Env.c
+libgetenv_64_so_SOURCES = $(libgetenv_32_so_SOURCES)
+
+libgetenv-32.so : net_tinyos_util_Env.h net_tinyos_util_Env.c
+       $(CC) $(SOFLAGS) -m32 net_tinyos_util_Env.c -o$@
+
+libgetenv-64.so : net_tinyos_util_Env.h net_tinyos_util_Env.c
+       @echo $(CC) $(SOFLAGS) -m64 net_tinyos_util_Env.c -o$@
+       @$(CC) $(SOFLAGS) -m64 net_tinyos_util_Env.c -o$@ || \
+       (echo 64-bit libgetenv.so NOT GENERATED - DO NOT USE THIS RUN TO BUILD AN RPM; echo Press return to continue; read; rm -f libtoscomm-64.so)
 
 getenv.dll: net_tinyos_util_Env.h net_tinyos_util_Env.c
        gcc -shared -o$@ -mno-cygwin "-I$(JDK)/include" "-I$(JDK)/include/win32" -D_JNI_IMPLEMENTATION -Wl,--kill-at net_tinyos_util_Env.c
index 2db55771746e7f0b1bb1db97071ad182678e325b..315d1f345768917c70053bcef91072eb577cd28d 100644 (file)
@@ -6,21 +6,31 @@ tinyoslibdir=$(libdir)/tinyos
 
 tinyoslib_PROGRAMS = @TOSCOMMLIB@
 
-EXTRA_PROGRAMS = libtoscomm.so toscomm.dll
+EXTRA_PROGRAMS = libtoscomm-32.so libtoscomm-64.so toscomm.dll
 
-libtoscomm_so_SOURCES = \
+# Compiling libtoscomm.so with -O2 generates bad code with gcc 4.1.x on x86_64
+# (the -O1 code is slightly weird, but works at least ;-))
+SOFLAGS = -O1 -shared -fPIC "-I$(JDK)/include" "-I$(JDK)/include/linux"
+
+libtoscomm_32_so_SOURCES = \
   NativeSerialEnums.h \
   NativeSerial_linux.cpp \
   TOSComm_wrap.cxx
 
+libtoscomm_64_so_SOURCES = $(libtoscomm_32_so_SOURCES)
+
 toscomm_dll_SOURCES = \
   NativeSerialEnums.h \
   NativeSerial_win32.cpp \
   TOSComm_wrap.cxx
 
-libtoscomm.so: $(libtoscomm_so_SOURCES)
-       $(CXX) -m32 -O2 -shared -fPIC "-I$(JDK)/include" "-I$(JDK)/include/linux" \
-         -o $@ NativeSerial_linux.cpp
+libtoscomm-32.so: $(libtoscomm_so_SOURCES)
+       $(CXX) -m32 $(SOFLAGS) -o $@ NativeSerial_linux.cpp
+
+libtoscomm-64.so: $(libtoscomm_so_SOURCES)
+       @echo $(CXX) -m64 $(SOFLAGS) -o $@ NativeSerial_linux.cpp
+       @$(CXX) -m64 $(SOFLAGS) -o $@ NativeSerial_linux.cpp || \
+       (echo 64-bit libtoscomm.so NOT GENERATED - DO NOT USE THIS RUN TO BUILD AN RPM; echo Press return to continue; read; rm -f libtoscomm-64.so)
 
 toscomm.dll: $(toscomm_dll_SOURCES)
        $(CXX) -O2 -s -mno-cygwin -shared "-I$(JDK)/include" "-I$(JDK)/include/win32" -D_JNI_IMPLEMENTATION -Wl,--kill-at \
index 505f5157dc4d437ddda5afe3c500ed1824b716fc..bfb7b5ab5ba0ec0119229065fccc587001552c71 100644 (file)
@@ -9,8 +9,24 @@ if [ $? -ne 0 ]; then
   echo "Java not found, not installing JNI code"
   exit 1
 fi
-echo "Installing Java JNI code in $jni ... "
-for lib in $tinyoslibdir/*.@JNISUFFIX@; do 
-  @INSTALLJNI@ $lib "$jni" || exit 1
-done
+
+if cygpath -w / >/dev/null 2>/dev/null; then
+  echo "Installing Java JNI code in $jni ... "
+  for lib in $tinyoslibdir/*.@JNISUFFIX@; do 
+    @INSTALLJNI@ $lib "$jni" || exit 1
+  done
+else
+  java=`tos-locate-jre --java`
+  bits=32
+  if [ $? -ne 0 ]; then
+    echo "java command not found - assuming 32 bits"
+  elif file -L $java/java | grep -q 64-bit; then
+    bits=64
+  fi
+  echo "Installing $bits-bit Java JNI code in $jni ... "
+  for lib in $tinyoslibdir/*-$bits.@JNISUFFIX@; do 
+    realname=`basename $lib | sed -e s/-$bits\.@JNISUFFIX@/.@JNISUFFIX@/`
+    @INSTALLJNI@ $lib "$jni/$realname" || exit 1
+  done
+fi
 echo "done."