# HG changeset patch
# User lost
# Date 1232211353 0
# Node ID a567dbb3f1d43d75ea8a1cd7809474c71845bbb0
# Parent d92c9f230b8fb6f91f84cd705b85d5941464a8f0
command line options
diff -r d92c9f230b8f -r a567dbb3f1d4 lwlink/trunk/src/Makefile.am
--- a/lwlink/trunk/src/Makefile.am Sat Jan 17 16:38:28 2009 +0000
+++ b/lwlink/trunk/src/Makefile.am Sat Jan 17 16:55:53 2009 +0000
@@ -1,2 +1,3 @@
bin_PROGRAMS = lwlink
-lwlink_SOURCES = main.c
+lwlink_SOURCES = main.c lwlink.c
+EXTRA_DIST = lwlink.h
diff -r d92c9f230b8f -r a567dbb3f1d4 lwlink/trunk/src/lwlink.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lwlink/trunk/src/lwlink.c Sat Jan 17 16:55:53 2009 +0000
@@ -0,0 +1,40 @@
+/*
+lwlink.c
+Copyright © 2008 William Astle
+
+This file is part of LWLINK.
+
+LWLINK is free software: you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see .
+
+
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define __lwlink_c_seen__
+
+#include
+#include
+#include
+#include
+
+#include "lwlink.h"
+
+int debug_level = 0;
+int outformat = OUTPUT_DECB;
+char *outfile = NULL;
+
diff -r d92c9f230b8f -r a567dbb3f1d4 lwlink/trunk/src/lwlink.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lwlink/trunk/src/lwlink.h Sat Jan 17 16:55:53 2009 +0000
@@ -0,0 +1,38 @@
+/*
+lwlink.h
+Copyright © 2008 William Astle
+
+This file is part of LWLINK.
+
+LWLINK is free software: you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see .
+
+Contains the main defs used by the linker
+*/
+
+
+#ifndef __lwlink_h_seen__
+#define __lwlink_h_seen__
+
+#define OUTPUT_DECB 0 // DECB multirecord format
+#define OUTPUT_RAW 1 // raw sequence of bytes
+
+#ifndef __lwlink_c_seen__
+
+extern int debug_level;
+extern int outformat;
+extern char *outfile;
+
+#endif // __lwlink_c_seen__
+
+#endif //__lwlink_h_seen__
diff -r d92c9f230b8f -r a567dbb3f1d4 lwlink/trunk/src/main.c
--- a/lwlink/trunk/src/main.c Sat Jan 17 16:38:28 2009 +0000
+++ b/lwlink/trunk/src/main.c Sat Jan 17 16:55:53 2009 +0000
@@ -0,0 +1,125 @@
+/*
+main.c
+Copyright © 2008 William Astle
+
+This file is part of LWLINK.
+
+LWLINK is free software: you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see .
+
+
+Implements the program startup code
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+#include
+#include
+
+#include "lwlink.h"
+
+// command line option handling
+const char *argp_program_version = PACKAGE_STRING;
+const char *argp_program_bug_address = PACKAGE_BUGREPORT;
+
+static error_t parse_opts(int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case 'o':
+ // output
+ if (outfile)
+ {
+ }
+ outfile = arg;
+ break;
+
+ case 'd':
+ // debug
+ debug_level++;
+ break;
+
+ case 'b':
+ // decb output
+ outformat = OUTPUT_DECB;
+ break;
+
+ case 'r':
+ // raw binary output
+ outformat = OUTPUT_RAW;
+ break;
+
+ case 'f':
+ // output format
+ if (!strcasecmp(arg, "decb"))
+ outformat = OUTPUT_DECB;
+ else if (!strcasecmp(arg, "raw"))
+ outformat = OUTPUT_RAW;
+ else
+ {
+ fprintf(stderr, "Invalid output format: %s\n", arg);
+ exit(1);
+ }
+ break;
+ case ARGP_KEY_END:
+ // done; sanity check
+ if (!outfile)
+ outfile = "a.out";
+ break;
+
+ case ARGP_KEY_ARG:
+ // FIXME: input files!
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static struct argp_option options[] =
+{
+ { "output", 'o', "FILE", 0,
+ "Output to FILE"},
+ { "debug", 'd', 0, 0,
+ "Set debug mode"},
+ { "format", 'f', "TYPE", 0,
+ "Select output format: decb, raw, obj"},
+ { "decb", 'b', 0, 0,
+ "Generate DECB .bin format output, equivalent of --format=decb"},
+ { "raw", 'r', 0, 0,
+ "Generate raw binary format output, equivalent of --format=raw"},
+ { 0 }
+};
+
+static struct argp argp =
+{
+ options,
+ parse_opts,
+ " ...",
+ "LWLINK, a HD6309 and MC6809 cross-linker"
+};
+
+// main function; parse command line, set up assembler state, and run the
+// assembler on the first file
+int main(int argc, char **argv)
+{
+ argp_parse(&argp, argc, argv, 0, 0, NULL);
+
+ exit(0);
+}