public static void cppOutputSystemMakefile() {
    { String makefile = Stella.makeFileName("Makefile", Stella.KWD_STELLA, true);
      String templatefile = Stella.fileNameWithoutExtension(makefile) + ".in";
      SystemDefinition system = ((SystemDefinition)(Stella.$CURRENTSYSTEMDEFINITION$.get()));

      if (!(Stella.probeFileP(templatefile))) {
        { Object old$Currentsystemdefinition$000 = Stella.$CURRENTSYSTEMDEFINITION$.get();
          Object old$Currentsystemdefinitionsubdirectory$000 = Stella.$CURRENTSYSTEMDEFINITIONSUBDIRECTORY$.get();

          try {
            Native.setSpecial(Stella.$CURRENTSYSTEMDEFINITION$, Stella.getSystemDefinition("STELLA"));
            Native.setSpecial(Stella.$CURRENTSYSTEMDEFINITIONSUBDIRECTORY$, ((((SystemDefinition)(Stella.$CURRENTSYSTEMDEFINITION$.get())) != null) ? ((SystemDefinition)(Stella.$CURRENTSYSTEMDEFINITION$.get())).directory : null));
            if (((SystemDefinition)(Stella.$CURRENTSYSTEMDEFINITION$.get())) != null) {
              {
                makefile = Stella.makeFileName("Makefile-default", Stella.KWD_STELLA, true);
                templatefile = Stella.fileNameWithoutExtension(makefile) + ".in";
              }
            }
            else {
              {
                Stella.STANDARD_WARNING.nativeStream.println("Warning: Can't find a system named STELLA");
                Stella.STANDARD_WARNING.nativeStream.println();
              }
;
            }

          } finally {
            Stella.$CURRENTSYSTEMDEFINITIONSUBDIRECTORY$.set(old$Currentsystemdefinitionsubdirectory$000);
            Stella.$CURRENTSYSTEMDEFINITION$.set(old$Currentsystemdefinition$000);
          }
        }
      }
      { KeyValueList variables = KeyValueList.newKeyValueList();
        OutputStringStream systemfiles = OutputStringStream.newOutputStringStream();
        OutputStringStream requiredsystems = OutputStringStream.newOutputStringStream();
        OutputStringStream requiredsystemdirs = OutputStringStream.newOutputStringStream();
        OutputStringStream allrequiredsystems = OutputStringStream.newOutputStringStream();
        String nativesystemroot = Stella.fileNameDirectory(Stella.makeFileName("foo", Stella.KWD_CPP_CODE, true));

        variables.insertAt(StringWrapper.wrapString("SYSTEM-NAME"), StringWrapper.wrapString(system.name));
        variables.insertAt(StringWrapper.wrapString("PROGRAM-NAME"), StringWrapper.wrapString(system.name));
        variables.insertAt(StringWrapper.wrapString("MAIN-NAME"), StringWrapper.wrapString(Stella.fileNameWithoutDirectory(Stella.cppYieldMainFileName())));
        variables.insertAt(StringWrapper.wrapString("SYSTEMS-ROOT"), StringWrapper.wrapString(Stella.cppYieldSystemsRootDirectory()));
        variables.insertAt(StringWrapper.wrapString("STELLA-ROOT"), StringWrapper.wrapString(Stella.cppYieldStellaRootDirectory()));
        { StringWrapper file = null;
          Cons iter000 = Cons.filesPlusSystemStartup(SystemDefinition.systemDefinitionSourceFiles(system));

          for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
            file = ((StringWrapper)(iter000.value));
            systemfiles.nativeStream.print(Stella.relativizeFileName(Stella.makeFileName(file.wrapperValue, Stella.KWD_CPP_CODE, true), nativesystemroot) + " ");
          }
        }
        variables.insertAt(StringWrapper.wrapString("SYSTEM-FILES"), StringWrapper.wrapString(systemfiles.theStringReader()));
        if (system.requiredSystems != null) {
          { StringWrapper reqsys = null;
            Cons iter001 = system.requiredSystems;

            for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
              reqsys = ((StringWrapper)(iter001.value));
              requiredsystems.nativeStream.print(reqsys.wrapperValue + " ");
              requiredsystemdirs.nativeStream.print(Stella.getSystemDefinition(reqsys.wrapperValue).directory + " ");
            }
          }
          { StringWrapper reqsys = null;
            Cons iter002 = Stella.allRequiredSystems(system.name);

            for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
              reqsys = ((StringWrapper)(iter002.value));
              allrequiredsystems.nativeStream.print(reqsys.wrapperValue + " ");
            }
          }
        }
        variables.insertAt(StringWrapper.wrapString("REQUIRED-SYSTEMS"), StringWrapper.wrapString(requiredsystems.theStringReader()));
        variables.insertAt(StringWrapper.wrapString("REQUIRED-SYSTEM-DIRS"), StringWrapper.wrapString(requiredsystemdirs.theStringReader()));
        variables.insertAt(StringWrapper.wrapString("ALL-REQUIRED-SYSTEMS"), StringWrapper.wrapString(allrequiredsystems.theStringReader()));
        makefile = Stella.fileNameWithoutExtension(Stella.makeFileName("Makefile", Stella.KWD_CPP_CODE, true));
        Stella.substituteTemplateVariablesToMakefile(templatefile, makefile, variables);
      }
    }
  }