summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/cgen.nim8
-rwxr-xr-xcompiler/platform.nim14
2 files changed, 17 insertions, 5 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index e9d7673bb..d85d3fe53 100755
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -778,6 +778,9 @@ proc genMainProc(m: BModule) =
     PosixCMain = "int main(int argc, char** args, char** env) {$n" &
         "  cmdLine = args;$n" & "  cmdCount = argc;$n" & "  gEnv = env;$n" &
         "  NimMain();$n" & "  return nim_program_result;$n" & "}$n"
+    StandaloneCMain = "int main(void) {$n" &
+        "  NimMain();$n" & 
+        "  return 0;$n" & "}$n"
     WinNimMain = "N_CDECL(void, NimMain)(void) {$n" &
         CommonMainBody & "}$n"
     WinCMain = "N_STDCALL(int, WinMain)(HINSTANCE hCurInstance, $n" &
@@ -807,7 +810,10 @@ proc genMainProc(m: BModule) =
   elif optGenDynLib in gGlobalOptions:
     nimMain = posixNimDllMain
     otherMain = posixCDllMain
-  else: 
+  elif platform.targetOS == osStandalone:
+    nimMain = PosixNimMain
+    otherMain = StandaloneCMain
+  else:
     nimMain = PosixNimMain
     otherMain = PosixCMain
   if gBreakpoints != nil: discard cgsym(m, "dbgRegisterBreakpoint")
diff --git a/compiler/platform.nim b/compiler/platform.nim
index 01190c9c9..f4cf3b882 100755
--- a/compiler/platform.nim
+++ b/compiler/platform.nim
@@ -21,7 +21,8 @@ type
                     # conditionals to condsyms (end of module).
     osNone, osDos, osWindows, osOs2, osLinux, osMorphos, osSkyos, osSolaris, 
     osIrix, osNetbsd, osFreebsd, osOpenbsd, osAix, osPalmos, osQnx, osAmiga, 
-    osAtari, osNetware, osMacos, osMacosx, osEcmaScript, osNimrodVM
+    osAtari, osNetware, osMacos, osMacosx, osEcmaScript, osNimrodVM, 
+    osStandalone
 
 type 
   TInfoOSProp* = enum 
@@ -139,14 +140,18 @@ const
       exeExt: "", extSep: ".", props: {}), 
      (name: "NimrodVM", parDir: "..", dllFrmt: "lib$1.so", altDirSep: "/", 
       objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/", 
-      scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".", props: {})]
+      scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".", props: {}),
+     (name: "Standalone", parDir: "..", dllFrmt: "lib$1.so", altDirSep: "/",
+      objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/",
+      scriptExt: ".sh", curDir: ".", exeExt: ".elf", extSep: ".", 
+      props: {})]
 
 type 
   TSystemCPU* = enum # Also add CPU for in initialization section and 
                      # alias conditionals to condsyms (end of module).
     cpuNone, cpuI386, cpuM68k, cpuAlpha, cpuPowerpc, cpuPowerpc64,
     cpuSparc, cpuVm, cpuIa64, cpuAmd64, cpuMips, cpuArm, 
-    cpuEcmaScript, cpuNimrodVM
+    cpuEcmaScript, cpuNimrodVM, cpuAVR
 
 type 
   TEndian* = enum 
@@ -169,7 +174,8 @@ const
     (name: "mips", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32), 
     (name: "arm", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32), 
     (name: "ecmascript", intSize: 32, endian: bigEndian,floatSize: 64,bit: 32), 
-    (name: "nimrodvm", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32)]
+    (name: "nimrodvm", intSize: 32, endian: bigEndian, floatSize: 64, bit: 32),
+    (name: "avr", intSize: 16, endian: littleEndian, floatSize: 32, bit: 16)]
 
 var 
   targetCPU*, hostCPU*: TSystemCPU