Search code examples
makefilejavaopenwrtjamvmopenhab

Installing JamVM 2.0 on OpenWrt : how to change the Makefile so it uses OpenJDK library?


I currently want to install OpenHAB in an OpenWrt environment (for now its on a virtual machine with x86 architecture), and it needs to have a Java runtime with at least version 1.6.

So I've used the OpenWrt 14.07 (Breaking Barrier) SDK cross compiler, and its include a compact Java machine called JamVM. For version 1.x, JamVM is using the GNU classpath which provides Java 1.5, but since JamVM 2.0, this program allows to use OpenJDK which provide Java 1.6 to 1.9. All I want is to generate the JamVM package that include this OpenJDK library, but I'm not familiarized with the Makefile configurations. Here is the current Makefile with the GNU classpath library setted :


#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=jamvm
PKG_VERSION:=2.0.0
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0+
PKG_MAINTAINER:=Dana H. Myers <[email protected]>

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
PKG_MD5SUM:=a6e3321ef4b3cfb4afc20bd75452e11e

PKG_USE_MIPS16:=0

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/jamvm
  SUBMENU:=Java
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=A compact Java Virtual Machine
  URL:=http://sourceforge.net/projects/jamvm
  DEPENDS:=+zlib +libpthread +librt +classpath @!avr32
endef

define Package/jamvm/description
 JamVM is a new Java Virtual Machine which conforms to the JVM
 specification version (blue book). In comparison to most other VM's (free
 and commercial) it is extremely small.However, unlike other small VMs
 (e.g. KVM) it is designed to support the full specification, and includes
 support for object finalisation, Soft/Weak/Phantom References, the Java
 Native Interface (JNI) and the Reflection API.
endef

CONFIGURE_ARGS += \
    --with-java-runtime-library=gnuclasspath \
    --with-classpath-install-dir=/usr \
    --disable-int-inlining \
    --disable-shared \
    --without-pic

MAKE_FLAGS += \
    GLIBJ_ZIP=$(STAGING_DIR)/usr/share/classpath/glibj.zip

define Package/jamvm/install
    $(INSTALL_DIR) $(1)/usr
    $(CP) \
        $(PKG_INSTALL_DIR)/usr/bin \
        $(PKG_INSTALL_DIR)/usr/share \
        $(1)/usr/
endef

define Build/InstallDev
    $(CP) $(PKG_INSTALL_DIR)/* $(1)/
endef

$(eval $(call BuildPackage,jamvm))

I know that in CONFIGURE_ARGS, I can change the line

--with-java-runtime-library=gnuclasspath \

to this

--with-java-runtime-library=openjdk7 \

but with this single change, my package isn't able to compile when I do

make /packages/lang/jamvm

Is there someone that knows what to do?

Thank you all


Solution

  • It is not that easy. There are a bunch of patches from Waldemar Brodkorb on the OpenWRT mailing list for OpenJDK 7 and some older ones for OpenJDK 6. But to my understanding they will only enable you to build a x86 version.

    I think it is easier to remove the java version contraints from the OpenHAB bundles than cross building OpenJDK with JamVM - no joke!