questions

Torbjorn Tornkvist <>
Tue Aug 3 02:47:57 CEST 1999


> Is there any way to find out whether a specific VM is installed on a 
> node, or it is safe to assume both JAM and BEAM are present? (the 
> latter restricts the possible use of other VMs)

One way of doing this is to compile a module with:

 erl -compile <MOD>

and then test if the resulting file suffix is beam or jam.

I've done this in combination with autoconf. 
So in the configure.in I have:

  dnl find out the type of Erlang machine which is used
  AC_MSG_CHECKING([checking for Erlang machine type])
  rm -f rootdir.{jam,beam}
  $ac_cv_erl -compile rootdir
  EDDIE_ROOTDIR_FILES=`echo rootdir.*`
  case "rootdir_FILES"in
  *jam*)
          EMULATOR=jam
          AC_SUBST(EMULATOR)
          AC_MSG_RESULT([jam])
          ;;
  *beam*) 
          EMULATOR=beam
          AC_SUBST(EMULATOR)
          AC_MSG_RESULT([beam])
          ;;
  *)
          AC_MSG_RESULT([no])
          AC_MSG_ERROR("Unable to determine Erlang machine type: jam/beam")
          ;;
  esac

I also uses the module 'rootdir' to get hold of where
the Erlang root directory is, so:

  -module(rootdir).
  -author('').
  %%% --------------------------------------------------------------------
  %%% Created : 26 Mar 1999 by 
  %%% Function: Write the Erlang root dir to the file: root_dir.result
  %%% --------------------------------------------------------------------
  -vc('$Id: eddie_rootdir.erl,v 1.3 1999/05/13 02:36:03 ttey Exp $ ').
  -export([start/1]).
  
  start([ResultFile]) when atom(ResultFile) ->
      case file:open(atom_to_list(ResultFile),[write,raw]) of
          {ok,Fd} ->
              file:write(Fd,code:root_dir()),
              file:sync(Fd),
              file:close(Fd);
          _ ->
              false
      end,
      halt().

In the configure.in this is used as:

  dnl find out where the Erlang root dir is located
  AC_MSG_CHECKING([checking for the Erlang root dir])
  ROOTDIR_RESULT=rootdir.result
  rm -f ROOTDIR_RESULT
  $ac_cv_erl +B -noshell -s rootdir start rootdir_result
  ERLDIR=`cat $ROOTDIR_RESULT`
  AC_SUBST(ERLDIR)
  AC_MSG_RESULT([$ERLDIR])


Cheers /Tobbe






More information about the erlang-questions mailing list