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