% Copyright (C) 1993, Digital Equipment Corporation
% All rights reserved.
% See the file COPYRIGHT for a full description.
%
% Last modified on Tue Mar 22 13:58:09 PST 1994 by kalsow

ret = 0
cmd = []

if defined ("M3CG_HOST") and defined ("M3CG_TARGET")
  import_version ("libm3", M3CG_HOST)
  import_version ("m3cg", M3CG_HOST)

  %----------------------------------------------- machine independent code ---
  if defined("_all") and stale("pp", path_of("pp.icn"))
    cmd = [ "icont", "-o", "pp", path_of("pp.icn")]
    write (cmd, "\n")
    ret = exec(cmd)
    if not equal(ret, 0) error(cmd, "returned error code: ", err) end
  end
  deriveds("pp", no_extension)

  noweb_interface ("TreeIR", "interface", "TreeIR")
  noweb_implementation ("TreeIR", "implementation", "TreeIR")

  noweb_interface ("MI", "interface", "MI")
  noweb_implementation ("MI", "implementation", "MI")

  noweb_interface ("Burm", "interface", "Burm")
  noweb_implementation ("Burm", "implementation", "Burm")

  noweb_interface ("Register", "interface", "Register")
  noweb_implementation ("Register", "implementation", "Register")

  interface ("M3CG_Burs")
  export_interface ("M3CG_Burs")
  module ("Fmt2")

  %------------------------------------------------- machine dependent code ---
  include_dir (M3CG_TARGET)

  %---------------------------------------------------- library vs. program ---
  if defined ("ANT")
    % module ("RTObject")
    implementation ("Main")
    program ("cg")
  else
    % source ("RTObject.i3")
    % source ("RTObject.m3")
    source ("Main.m3")
    library ("cg")
  end

else
  %-- we need to run the "build" script
  local ant = ""
  if defined ("ANT")  ant = "-DANT"  end
  write("executing build\n")
  % ret = exec ([ src/build", DEFAULT_BUILD_DIR, TARGET, ant, "-O"], [], "..")
  ret = exec ([ "src/build", "DS", TARGET, ant, "-O" ], [], "..")
  if not equal(ret, 0) error ("build returned error code", ret) end
end
