tmpScript:="Modelica.tmp.mos";

for pack in {"Complex","Modelica","ModelicaServices","ModelicaTest"} loop
  suffix := if pack=="Complex" then ".mo" else "/package.mo";
  if not loadFile(pack+suffix) then
  print("Failed to load "+pack+"\n");
    print(getErrorString());
    exit(1);
  end if;
end for;
getErrorString();

fundamentalWaveFile := getSourceFile(Modelica.Magnetic.QuasiStatic.FundamentalWave);
fileStrFundamentalWave := readFile(fundamentalWaveFile);
addClassAnnotation(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_YD, __OpenModelica_simulationFlags(nls = "newton"));
addClassAnnotation(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_Transformer, __OpenModelica_simulationFlags(nls = "newton"));
listing := listFile(Modelica.Magnetic.QuasiStatic.FundamentalWave);
fileStrFundamentalWave := diffModelicaFileListings(fileStrFundamentalWave, listing, OpenModelica.Scripting.DiffFormat.plain);
writeFile(fundamentalWaveFile, fileStrFundamentalWave);getErrorString();

echo(false);mathFile:=getSourceFile(Modelica.Math);mathFileStr:=readFile(mathFile);echo(true);
getErrorString();

echo(false);
servicesFile:=getSourceFile(ModelicaServices);
servicesFileStr:=readFile(servicesFile);
setClassComment(ModelicaServices, "ModelicaServices (OpenModelica implementation) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation");
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
setComponentModifierValue(ModelicaServices, target, $Code(="OpenModelica"));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
setComponentModifierValue(ModelicaServices.Machine, Integer_inf, $Code(=OpenModelica.Internal.Architecture.integerMax()));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
addClassAnnotation(ModelicaServices.ExternalReferences.loadResource, annotate=__OpenModelica_EarlyInline(true));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if err<>"" then
  print(err);
  exit(1);
end if;
echo(true);
writeFile(servicesFile, servicesFileStr);
cmd := "sed -i '/^ *uses[(]Modelica[(]version=\"[^\"]*\"[)][)], *$/d' ModelicaServices/package.mo";
if 0 <> system(cmd) then
  print(cmd + " failed");
  exit(1);
end if;
