Separate out mpy core and unix version.
diff --git a/py/.gitignore b/py/.gitignore
deleted file mode 100644
index e7f3545..0000000
--- a/py/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.o
-py
-*.py
-.*.swp
diff --git a/py/Makefile b/py/Makefile
deleted file mode 100644
index 0f4483d..0000000
--- a/py/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-CC = gcc
-CFLAGS = -Wall -ansi -std=gnu99 -Os -DEMIT_ENABLE_CPY -DEMIT_ENABLE_THUMB #-DNDEBUG
-LDFLAGS =
-
-SRC = \
-	malloc.c \
-	misc.c \
-	qstr.c \
-	lexer.c \
-	lexerfile.c \
-	parse.c \
-	scope.c \
-	compile.c \
-	emitcommon.c \
-	emitpass1.c \
-	emitcpy.c \
-	emitbc.c \
-	asmx64.c \
-	asmthumb.c \
-	emitinlinethumb.c \
-	runtime.c \
-	vm.c \
-	main.c \
-
-SRC_ASM = \
-
-OBJ = $(SRC:.c=.o) $(SRC_ASM:.s=.o) emitnx64.o emitnthumb.o
-LIB =
-PROG = py
-
-$(PROG): $(OBJ)
-	$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS)
-
-runtime.o: runtime.c
-	$(CC) $(CFLAGS) -O3 -c -o $@ $<
-
-vm.o: vm.c
-	$(CC) $(CFLAGS) -O3 -c -o $@ $<
-
-parse.o: grammar.h
-compile.o: grammar.h
-emitcpy.o: emit.h
-emitbc.o: emit.h
-
-emitnx64.o: emitnative.c emit.h
-	$(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
-
-emitnthumb.o: emitnative.c emit.h
-	$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
-
-clean:
-	/bin/rm $(OBJ)
diff --git a/py/asmthumb.c b/py/asmthumb.c
index ba61c31..a6b9576 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -4,7 +4,7 @@
 #include <string.h>
 
 #include "misc.h"
-#include "machine.h"
+#include "mpyconfig.h"
 #include "asmthumb.h"
 
 #define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0)
diff --git a/py/compile.c b/py/compile.c
index 3d5a29a..8104461 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -6,8 +6,8 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "scope.h"
 #include "compile.h"
@@ -768,8 +768,10 @@
         *emit_options = EMIT_OPT_NATIVE_PYTHON;
     } else if (attr == comp->qstr_viper) {
         *emit_options = EMIT_OPT_VIPER;
+#if defined(MICROPY_EMIT_ENABLE_INLINE_THUMB)
     } else if (attr == comp->qstr_asm_thumb) {
         *emit_options = EMIT_OPT_ASM_THUMB;
+#endif
     } else {
         printf("SyntaxError: invalid micropython decorator\n");
     }
@@ -2673,8 +2675,11 @@
     comp->emit_inline_asm_method_table = NULL;
     uint max_num_labels = 0;
     for (scope_t *s = comp->scope_head; s != NULL; s = s->next) {
-        if (s->emit_options == EMIT_OPT_ASM_THUMB) {
+        if (false) {
+#ifdef MICROPY_EMIT_ENABLE_INLINE_THUMB
+        } else if (s->emit_options == EMIT_OPT_ASM_THUMB) {
             compile_scope_inline_asm(comp, s, PASS_1);
+#endif
         } else {
             compile_scope(comp, s, PASS_1);
         }
@@ -2694,11 +2699,20 @@
     emit_pass1_free(comp->emit);
 
     // compile pass 2 and 3
+#if !defined(MICROPY_EMIT_ENABLE_CPYTHON)
     emit_t *emit_bc = NULL;
     emit_t *emit_native = NULL;
+#endif
+#if defined(MICROPY_EMIT_ENABLE_INLINE_THUMB)
     emit_inline_asm_t *emit_inline_thumb = NULL;
+#endif
     for (scope_t *s = comp->scope_head; s != NULL; s = s->next) {
-        if (s->emit_options == EMIT_OPT_ASM_THUMB) {
+        if (false) {
+            // dummy
+
+#if defined(MICROPY_EMIT_ENABLE_INLINE_THUMB)
+        } else if (s->emit_options == EMIT_OPT_ASM_THUMB) {
+            // inline assembly for thumb
             if (emit_inline_thumb == NULL) {
                 emit_inline_thumb = emit_inline_thumb_new(max_num_labels);
             }
@@ -2708,15 +2722,31 @@
             comp->emit_inline_asm_method_table = &emit_inline_thumb_method_table;
             compile_scope_inline_asm(comp, s, PASS_2);
             compile_scope_inline_asm(comp, s, PASS_3);
+#endif
+
         } else {
+
+            // choose the emit type
+
+#if defined(MICROPY_EMIT_ENABLE_CPYTHON)
+            comp->emit = emit_cpython_new(max_num_labels);
+            comp->emit_method_table = &emit_cpython_method_table;
+#else
             switch (s->emit_options) {
                 case EMIT_OPT_NATIVE_PYTHON:
                 case EMIT_OPT_VIPER:
+#if defined(MICROPY_EMIT_ENABLE_X64)
                     if (emit_native == NULL) {
                         emit_native = emit_native_x64_new(max_num_labels);
                     }
-                    comp->emit = emit_native;
                     comp->emit_method_table = &emit_native_x64_method_table;
+#elif defined(MICROPY_EMIT_ENABLE_THUMB)
+                    if (emit_native == NULL) {
+                        emit_native = emit_native_thumb_new(max_num_labels);
+                    }
+                    comp->emit_method_table = &emit_native_thumb_method_table;
+#endif
+                    comp->emit = emit_native;
                     comp->emit_method_table->set_native_types(comp->emit, s->emit_options == EMIT_OPT_VIPER);
                     break;
 
@@ -2728,8 +2758,9 @@
                     comp->emit_method_table = &emit_bc_method_table;
                     break;
             }
-            //comp->emit = emit_cpython_new(max_num_labels);
-            //comp->emit_method_table = &emit_cpython_method_table;
+#endif
+
+            // compile pass 2 and pass 3
             compile_scope(comp, s, PASS_2);
             compile_scope(comp, s, PASS_3);
         }
diff --git a/py/emitbc.c b/py/emitbc.c
index f242828..8f28910 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -6,8 +6,8 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "compile.h"
 #include "scope.h"
diff --git a/py/emitcommon.c b/py/emitcommon.c
index 6d4c071..07eb181 100644
--- a/py/emitcommon.c
+++ b/py/emitcommon.c
@@ -5,8 +5,8 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "scope.h"
 #include "runtime.h"
diff --git a/py/emitcpy.c b/py/emitcpy.c
index 7c9615c..596e04e 100644
--- a/py/emitcpy.c
+++ b/py/emitcpy.c
@@ -6,15 +6,15 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "compile.h"
 #include "scope.h"
 #include "runtime.h"
 #include "emit.h"
 
-#ifdef EMIT_ENABLE_CPY
+#ifdef MICROPY_EMIT_ENABLE_CPYTHON
 
 struct _emit_t {
     int pass;
@@ -925,4 +925,4 @@
     emit_cpy_yield_from,
 };
 
-#endif // EMIT_ENABLE_CPY
+#endif // MICROPY_EMIT_ENABLE_CPYTHON
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index ae226b7..74bc6d1 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -6,15 +6,15 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "scope.h"
 #include "runtime.h"
 #include "emit.h"
 #include "asmthumb.h"
 
-#ifdef EMIT_ENABLE_THUMB
+#ifdef MICROPY_EMIT_ENABLE_INLINE_THUMB
 
 struct _emit_inline_asm_t {
     int pass;
@@ -204,4 +204,4 @@
     emit_inline_thumb_op,
 };
 
-#endif // EMIT_ENABLE_THUMB
+#endif // MICROPY_EMIT_ENABLE_INLINE_THUMB
diff --git a/py/emitnative.c b/py/emitnative.c
index db37518..0f09c07 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -24,22 +24,13 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "scope.h"
 #include "runtime.h"
 #include "emit.h"
 
-// select a machine architecture
-#if 0
-#if defined(EMIT_ENABLE_NATIVE_X64)
-#define N_X64
-#elif defined(EMIT_ENABLE_NATIVE_THUMB)
-#define N_THUMB
-#endif
-#endif
-
 // wrapper around everything in this file
 #if defined(N_X64) || defined(N_THUMB)
 
diff --git a/py/emitpass1.c b/py/emitpass1.c
index 661a622..f14ccc5 100644
--- a/py/emitpass1.c
+++ b/py/emitpass1.c
@@ -6,8 +6,8 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "compile.h"
 #include "scope.h"
diff --git a/py/emitthumb.c b/py/emitthumb.c
index 7bcdf9e..1866e00 100644
--- a/py/emitthumb.c
+++ b/py/emitthumb.c
@@ -6,15 +6,15 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 #include "scope.h"
 #include "runtime.h"
 #include "emit.h"
 #include "asmthumb.h"
 
-#ifdef EMIT_ENABLE_THUMB
+#ifdef MICROPY_EMIT_ENABLE_THUMB
 
 #define REG_LOCAL_1 (REG_R4)
 #define REG_LOCAL_2 (REG_R5)
@@ -775,4 +775,4 @@
     emit_thumb_yield_from,
 };
 
-#endif // EMIT_ENABLE_THUMB
+#endif // MICROPY_EMIT_ENABLE_THUMB
diff --git a/py/machine.h b/py/machine.h
deleted file mode 100644
index fa39c8f..0000000
--- a/py/machine.h
+++ /dev/null
@@ -1,4 +0,0 @@
-typedef int64_t machine_int_t; // must be pointer size
-typedef uint64_t machine_uint_t; // must be pointer size
-typedef void *machine_ptr_t; // must be of pointer size
-typedef double machine_float_t;
diff --git a/py/main.c b/py/main.c
deleted file mode 100644
index 2059a8f..0000000
--- a/py/main.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "misc.h"
-#include "lexer.h"
-#include "machine.h"
-#include "parse.h"
-#include "compile.h"
-#include "runtime.h"
-
-int main(int argc, char **argv) {
-    qstr_init();
-    rt_init();
-
-    if (argc != 2) {
-        printf("usage: py <file>\n");
-        return 1;
-    }
-    py_lexer_t *lex = py_lexer_from_file(argv[1]);
-    //const char *pysrc = "def f():\n  x=x+1\n  print(42)\n";
-    //py_lexer_t *lex = py_lexer_from_str_len("<>", pysrc, strlen(pysrc), false);
-    if (lex == NULL) {
-        return 1;
-    }
-
-    if (0) {
-        while (!py_lexer_is_kind(lex, PY_TOKEN_END)) {
-            py_token_show(py_lexer_cur(lex));
-            py_lexer_to_next(lex);
-        }
-    } else {
-        py_parse_node_t pn = py_parse(lex, 0);
-        if (pn != PY_PARSE_NODE_NULL) {
-            //printf("----------------\n");
-            //parse_node_show(pn, 0);
-            //printf("----------------\n");
-            py_compile(pn);
-            //printf("----------------\n");
-        }
-    }
-
-    py_lexer_free(lex);
-
-    if (1) {
-        // execute it
-        py_obj_t module_fun = rt_make_function_from_id(1);
-        if (module_fun != py_const_none) {
-            py_obj_t ret = rt_call_function_0(module_fun);
-            printf("done! got: ");
-            py_obj_print(ret);
-            printf("\n");
-        }
-    }
-
-    rt_deinit();
-
-    //printf("total bytes = %d\n", m_get_total_bytes_allocated());
-    return 0;
-}
diff --git a/py/parse.c b/py/parse.c
index 124d00f..541c4eb 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -7,8 +7,8 @@
 #include <assert.h>
 
 #include "misc.h"
+#include "mpyconfig.h"
 #include "lexer.h"
-#include "machine.h"
 #include "parse.h"
 
 #define RULE_ACT_KIND_MASK      (0xf0)
diff --git a/py/runtime.c b/py/runtime.c
index 9585075..ae24646 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -5,7 +5,7 @@
 #include <assert.h>
 
 #include "misc.h"
-#include "machine.h"
+#include "mpyconfig.h"
 #include "runtime.h"
 #include "bc.h"
 
@@ -19,9 +19,6 @@
 #define DEBUG_OP_printf(args...) (void)0
 #endif
 
-// enable/disable float support with this definition
-#define PY_FLOAT (1)
-
 typedef machine_int_t py_small_int_t;
 
 #define IS_O(o, k) (((((py_small_int_t)(o)) & 1) == 0) && (((py_obj_base_t*)(o))->kind == (k)))
@@ -29,14 +26,14 @@
 #define FROM_SMALL_INT(o) (((py_small_int_t)(o)) >> 1)
 #define TO_SMALL_INT(o) ((py_obj_t)(((o) << 1) | 1))
 
-#ifdef PY_FLOAT
+#ifdef MICROPY_ENABLE_FLOAT
 typedef machine_float_t float_t;
 #endif
 
 typedef enum {
     O_CONST,
     O_STR,
-#ifdef PY_FLOAT
+#ifdef MICROPY_ENABLE_FLOAT
     O_FLOAT,
 #endif
     O_FUN_0,
@@ -77,7 +74,7 @@
     union {
         const char *id;
         qstr u_str;
-#ifdef PY_FLOAT
+#ifdef MICROPY_ENABLE_FLOAT
         float_t u_flt;
 #endif
         struct { // for O_FUN_[012N]
@@ -260,7 +257,7 @@
     return (py_obj_t)o;
 }
 
-#ifdef PY_FLOAT
+#ifdef MICROPY_ENABLE_FLOAT
 py_obj_t py_obj_new_float(float_t val) {
     py_obj_base_t *o = m_new(py_obj_base_t, 1);
     o->kind = O_FLOAT;
@@ -514,7 +511,7 @@
                 }
             case O_STR:
                 return "str";
-#ifdef PY_FLOAT
+#ifdef MICROPY_ENABLE_FLOAT
             case O_FLOAT:
                 return "float";
 #endif
@@ -557,7 +554,7 @@
                 // TODO need to escape chars etc
                 printf("'%s'", qstr_str(o->u_str));
                 break;
-#ifdef PY_FLOAT
+#ifdef MICROPY_ENABLE_FLOAT
             case O_FLOAT:
                 printf("%f", o->u_flt);
                 break;
@@ -719,7 +716,7 @@
             case RT_BINARY_OP_SUBTRACT: val = FROM_SMALL_INT(lhs) - FROM_SMALL_INT(rhs); break;
             case RT_BINARY_OP_MULTIPLY: val = FROM_SMALL_INT(lhs) * FROM_SMALL_INT(rhs); break;
             case RT_BINARY_OP_FLOOR_DIVIDE: val = FROM_SMALL_INT(lhs) / FROM_SMALL_INT(rhs); break;
-#ifdef PY_FLOAT
+#ifdef MICROPY_ENABLE_FLOAT
             case RT_BINARY_OP_TRUE_DIVIDE: return py_obj_new_float((float_t)FROM_SMALL_INT(lhs) / (float_t)FROM_SMALL_INT(rhs));
 #endif
             default: printf("%d\n", op); assert(0); val = 0;
@@ -864,9 +861,11 @@
                 // pointer to the string (it's probably constant though!)
                 return (machine_uint_t)qstr_str(o->u_str);
 
+#ifdef MICROPY_ENABLE_FLOAT
             case O_FLOAT:
                 // convert float to int (could also pass in float registers)
                 return (machine_int_t)o->u_flt;
+#endif
 
             case O_LIST:
                 // pointer to start of list (could pass length, but then could use len(x) for that)
diff --git a/py/scope.c b/py/scope.c
index 640d4f7..c581687 100644
--- a/py/scope.c
+++ b/py/scope.c
@@ -4,7 +4,7 @@
 #include <assert.h>
 
 #include "misc.h"
-#include "machine.h"
+#include "mpyconfig.h"
 #include "parse.h"
 #include "scope.h"
 
diff --git a/py/vm.c b/py/vm.c
index e672ef7..d6740cf 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -5,7 +5,7 @@
 #include <assert.h>
 
 #include "misc.h"
-#include "machine.h"
+#include "mpyconfig.h"
 #include "runtime.h"
 #include "bc.h"