zeus/src/m3zume.tmpl


% Copyright (C) 1993, Digital Equipment Corporation
% All rights reserved.
% See the file COPYRIGHT for a full description.
%
% Last modified on Fri Feb 10 08:05:06 PST 1995 by kalsow
%      modified on Fri Jun  3 09:57:46 PDT 1994 by heydon
%      modified on Thu Jun  2 00:12:29 PDT 1994 by mhb
%      modified on Mon Jan 24 13:14:09 PST 1994 by najork
%      modified on Thu Jul  8 11:26:51 PDT 1993 by steveg
%      modified on Wed Jul  7 15:11:23 PDT 1993 by harrison

if defined ("M3ZUME")
  % take the version of m3zume specified by the user
  _ZUME_EXEC = M3ZUME
else
  _ZUME_EXEC = format ("%s%s%s", BIN_USE, SL, "m3zume")  %% - full path
  %% _ZUME_EXEC = "m3zume"
end

%
% Allow native I386_NT (NT386) cm3 to run I386_CYGWIN (NT386GNU) m3zume.
% This is a fairly real scenario in my workflow that I was ignoring.
% I386_CYGWIN does not like commands like:
%   m3zume ..\foo\bar => invalid extension, it probably
%   thinks \foo\bar is the extension.
% This is a more general problem, not fully solved here.
% For this to be OK on native Win32 depends on that / are now accepted on Win32.
% (Which I question from time to time, if it was a good idea.)
%
%
% A problem is that on "biarch" systems, such as NT386 + NT386GNU, or
% LINUXLIBC6 + AMD64_LINUX, /cm3/bin/cm3 can bounce back and forth between the two,
% leading to the two worlds to come together somewhat, and perhaps interop.
%
% Probably there should be /cm3/bin/target/cm3, and a "portable" /cm3/bin/cm3 that
% figures out which one to call. On Posix it would be an extensionless sh
% that ends with "exec". It could sniff host platform with uname, like sysinfo.sh does,
% though sysinfo.sh would also compute it, allowing skipping running the sniffing repeatedly.
% On NT it would be nice if it could be .cmd, but more likely an NT386 binary.
% On uniarch systems, just link the two.
%
% This way the systems don't have to interop, nor would the general problem of differing
% slashes have to be dealt with. Though, it is a dilemna beyond Modula-3 as to interop
% of Cygwin binaries with Win32 binaries.
%

readonly proc PathOf(a) is
    a = path_of(a)
    if defined("HOST")
        if equal (HOST, "NT386")
            if defined("subst_chars")
                a = subst_chars(a, "\\", "/")
            end
        end
    end
    return a
end

%------------------------------------------------------------- vanilla zume ---

readonly _ZUME_FV_FILES = [ "EventData", "TranscriptView" ]
readonly _ZUME_M3_FILES = [ "AlgClass", "ViewClass", "IE",
                            "DataView", "TranscriptView" ]

readonly proc zume(x) is
  local any_stale = ""
  local evt_file = PathOf(x & ".evt")

  foreach p in _ZUME_M3_FILES
    local fn = x & p

    if not any_stale
      any_stale = stale(fn & ".i3", evt_file) or stale(fn & ".m3", evt_file)
    end
    derived_interface(fn, VISIBLE)
    derived_implementation(fn)
  end

  if defined("_all") and any_stale
    exec(_ZUME_EXEC, PathOf(x))
  end

  foreach r in _ZUME_FV_FILES
    derived_resource(format ("%s%s.fv", x, r))
  end
end

%------------------------------------------------------------- 3D zume --------

readonly _ZUME3D_M3_FILES = [ "AlgClass", "ViewClass", "3DViewClass", "IE",
                            "DataView", "TranscriptView" ]

readonly proc zume3D(x) is
  local any_stale = ""
  local evt_file = PathOf(x & ".evt")

  foreach p in _ZUME3D_M3_FILES
    local fn = x & p

    if not any_stale
      any_stale = stale(fn & ".i3", evt_file) or stale(fn & ".m3", evt_file)
    end
    derived_interface(fn, VISIBLE)
    derived_implementation(fn)
  end

  if defined("_all") and any_stale
    exec(_ZUME_EXEC, "-3D", PathOf(x))
  end

  foreach r in _ZUME_FV_FILES
    derived_resource(format ("%s%s.fv", x, r))
  end
end

%------------------------------------------------------------------ Obliq -----

readonly _OBLUME_FILES = ["ObliqView"]

readonly proc oblume(x, obl) is
  local any_stale = ""
  local evt_file = PathOf(x & ".evt")

  import ("obliqparse")
  import ("obliqlibm3")
  import ("obliqlibanim")

  foreach p in _OBLUME_FILES
    local fn = format("%s%s%s", x, obl, p)

    if not any_stale
      any_stale = stale(fn & ".i3", evt_file) or stale(fn & ".m3", evt_file)
    end
    derived_interface(fn, VISIBLE)
    derived_implementation(fn)
  end

  if defined ("_all") and any_stale
    exec(_ZUME_EXEC, "-Obliq", PathOf(obl), PathOf(x))
  end

  resource(obl & ".obl")
end

%---------------------------------------------------------------- Obliq3D -----

readonly _OBLUME3D_FILES = ["Obliq3DView"]

readonly proc oblume3D(x, obl) is
  local any_stale = ""
  local evt_file = PathOf(x & ".evt")

  import ("obliqparse")
  import ("obliqlibm3")
  import ("obliqlib3D")

  foreach p in _OBLUME3D_FILES
    local fn = format("%s%s%s", x, obl, p)

    if not any_stale
      any_stale = stale(fn & ".i3", evt_file) or stale(fn & ".m3", evt_file)
    end
    derived_interface(fn, VISIBLE)
    derived_implementation(fn)
  end

  if defined ("_all") and any_stale
    exec(_ZUME_EXEC, "-Obliq3D", PathOf(obl), PathOf(x))
  end

  resource(obl & ".obl")
end

%------------------------------------------------------------------ Juno -----

readonly _JUNOZUME_FILES = ["JunoView"]

readonly proc junozume(x, viewName) is
  local any_stale = ""
  local evt_file = PathOf(x & ".evt")

  foreach p in _JUNOZUME_FILES
    local fn = format("%s%s%s", x, viewName, p)

    if not any_stale
      any_stale = stale(fn & ".i3", evt_file) or stale(fn & ".m3", evt_file)
    end
    derived_interface(fn, VISIBLE)
    derived_implementation(fn)
  end

  if defined ("_all") and any_stale
    exec(_ZUME_EXEC, "-Juno", viewName, PathOf(x))
  end
end

%---------------------------------------------------------------------- gef ---
%
%  readonly _GEFLUME_FILES = ["GEFView"]
%
%  readonly proc geflume(x, gef) is
%    local any_stale = ""
%    local evt_file = PathOf(x & ".evt")
%
%    import ("gef")
%
%    foreach p in _GEFLUME_FILES
%      local fn = format("%s%s%s", x, gef, p)
%
%      if not any_stale
%        any_stale = stale(fn & ".i3", evt_file) or stale(fn & ".m3", evt_file)
%      end
%      derived_interface(fn, VISIBLE)
%      derived_implementation(fn)
%    end
%
%    if defined ("_all") and any_stale
%      exec(_ZUME_EXEC, "-GEF", PathOf(gef), PathOf(x))
%    end
%
%    resource(gef & ".gef")
%  end