Also generate a Makefile.

Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
diff --git a/v2x/mux_gen.py b/v2x/mux_gen.py
index a312018..f680b64 100755
--- a/v2x/mux_gen.py
+++ b/v2x/mux_gen.py
@@ -179,6 +179,27 @@
 
 os.makedirs(outdir, exist_ok=True)
 
+# Create a makefile to regenerate files.
+output_files = ['model.xml', 'pb_type.xml', 'Makefile']
+with open(os.path.join(outdir, "Makefile"), "w") as f:
+    f.write("""
+all: %s
+
+.PHONY: all
+""" % " ".join(output_files))
+    f.write("""
+.mux_gen.stamp: %s
+\t%s
+\ttouch --reference $< $@
+""" % (repo_args[0], " ".join(repo_args)))
+
+    for name in output_files:
+        f.write("%s: .mux_gen.stamp\n\n" % name)
+
+print("Makefile", "-"*75)
+print(open("Makefile").read())
+print("-"*75)
+
 generated_with = """
 Generated with mux_gen.py, run the following to regenerate in this directory;
 %s
@@ -190,7 +211,7 @@
 %s
 """ % " ".join(a.replace("--", "~~") for a in repo_args)
 
-
+# Work out the port names
 port_names = []
 for i in args.order:
     if i == 'i':
@@ -295,7 +316,7 @@
     f.write(pb_type_str)
 
 
-import sys; sys.exit(1)
+import sys; sys.exit(0)
 
 mux_args = []
 for i in args.order: