annotate lwar/main.c @ 171:d610b8aef91b

Added LWAR skeleton
author lost
date Sun, 01 Mar 2009 19:37:03 +0000
parents
children 47427342e41d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
171
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
1 /*
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
2 main.c
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
3 Copyright © 2009 William Astle
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
4
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
5 This file is part of LWAR.
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
6
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
7 LWAR is free software: you can redistribute it and/or modify it under the
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
10 version.
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
11
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
15 more details.
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
16
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
19
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
20
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
21 Implements the program startup code
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
22
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
23 */
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
24
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
26 #include "config.h"
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
27 #endif
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
28
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
29 #include <argp.h>
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
30 #include <errno.h>
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
31 #include <stdio.h>
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
32 #include <stdlib.h>
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
33
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
34 #include "lwar.h"
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
35
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
36 // command line option handling
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
37 const char *argp_program_version = "LWAR from " PACKAGE_STRING;
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
38 const char *argp_program_bug_address = PACKAGE_BUGREPORT;
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
39
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
40 static error_t parse_opts(int key, char *arg, struct argp_state *state)
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
41 {
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
42 switch (key)
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
43 {
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
44 case 'd':
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
45 // debug
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
46 debug_level++;
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
47 break;
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
48
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
49 // case ARGP_KEY_ARG:
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
50 //
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
51 // break;
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
52
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
53 default:
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
54 return ARGP_ERR_UNKNOWN;
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
55 }
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
56 return 0;
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
57 }
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
58
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
59 static struct argp_option options[] =
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
60 {
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
61 { "debug", 'd', 0, 0,
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
62 "Set debug mode"},
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
63 { 0 }
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
64 };
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
65
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
66 static struct argp argp =
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
67 {
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
68 options,
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
69 parse_opts,
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
70 "<input file> ...",
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
71 "LWLINK, a HD6309 and MC6809 cross-linker"
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
72 };
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
73
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
74 // main function; parse command line, set up assembler state, and run the
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
75 // assembler on the first file
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
76 int main(int argc, char **argv)
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
77 {
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
78 argp_parse(&argp, argc, argv, 0, 0, NULL);
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
79
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
80 exit(0);
d610b8aef91b Added LWAR skeleton
lost
parents:
diff changeset
81 }