Mercurial > hg > index.cgi
changeset 188:b6685a7ec2bd
Add stub for lwcc
author | lost@l-w.ca |
---|---|
date | Wed, 11 Jan 2012 20:18:10 -0700 |
parents | 4e12d881df85 |
children | 8a84141ea6dd |
files | Makefile lwcc/lwcc.c |
diffstat | 2 files changed, 117 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sat Dec 24 12:20:43 2011 -0700 +++ b/Makefile Wed Jan 11 20:18:10 2012 -0700 @@ -33,23 +33,31 @@ -include $(subdirs:=/rules.make) +lwcc_srcs := lwcc.c + +lwcc_srcs := $(addprefix lwcc/,$(lwcc_srcs)) + + lwasm_objs := $(lwasm_srcs:.c=.o) lwlink_objs := $(lwlink_srcs:.c=.o) lwar_objs := $(lwar_srcs:.c=.o) lwlib_objs := $(lwlib_srcs:.c=.o) lwobjdump_objs := $(lwobjdump_srcs:.c=.o) +lwcc_objs := $(lwcc_srcs:.c=.o) lwasm_deps := $(lwasm_srcs:.c=.d) lwlink_deps := $(lwlink_srcs:.c=.d) lwar_deps := $(lwar_srcs:.c=.d) lwlib_deps := $(lwlib_srcs:.c=.d) lwobjdump_deps := $(lwobjdump_srcs:.c=.d) +lwcc_deps := $(lwcc_srcs:.c=.d) -.PHONY: lwlink lwasm lwar lwobjdump +.PHONY: lwlink lwasm lwar lwobjdump lwcc lwlink: lwlink/lwlink$(PROGSUFFIX) lwasm: lwasm/lwasm$(PROGSUFFIX) lwar: lwar/lwar$(PROGSUFFIX) lwobjdump: lwlink/lwobjdump$(PROGSUFFIX) +lwcc: lwcc/lwcc$(PROGSUFFIX) .PHONY: lwbasic lwbasic: lwbasic/lwbasic$(PROGSUFFIX) @@ -70,6 +78,10 @@ @echo Linking $@ @$(CC) -o $@ $(lwar_objs) $(LDFLAGS) +lwcc/lwcc$(PROGSUFFIX): $(lwcc_objs) lwlib + @echo Linking $@ + @$(CC) -o $@ $(lwcc_objs) $(LDFLAGS) + #.PHONY: lwlib .INTERMEDIATE: lwlib lwlib: lwlib/liblw.a @@ -79,7 +91,7 @@ @$(AR) rc $@ $(lwlib_objs) @$(RANLIB) $@ -alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps) +alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps) $(lwcc_deps) -include $(alldeps) @@ -99,8 +111,8 @@ .PHONY: clean clean: $(cleantargs) @echo "Cleaning up" - @rm -f lwlib/liblw.a lwasm/lwasm$(PROGSUFFIX) lwlink/lwlink$(PROGSUFFIX) lwlink/lwobjdump$(PROGSUFFIX) lwar/lwar$(PROGSUFFIX) - @rm -f $(lwasm_objs) $(lwlink_objs) $(lwar_objs) $(lwlib_objs) $(lwobjdump_objs) + @rm -f lwlib/liblw.a lwasm/lwasm$(PROGSUFFIX) lwlink/lwlink$(PROGSUFFIX) lwlink/lwobjdump$(PROGSUFFIX) lwar/lwar$(PROGSUFFIX) lwcc/lwcc$(PROGSUFFIX) + @rm -f $(lwasm_objs) $(lwlink_objs) $(lwar_objs) $(lwlib_objs) $(lwobjdump_objs) $(lwcc_objs) @rm -f $(extra_clean) @rm -f */*.exe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwcc/lwcc.c Wed Jan 11 20:18:10 2012 -0700 @@ -0,0 +1,101 @@ +/* + +This is the front-end program for the C compiler. + +Copyright © 2011 William Astle + +This file is part of LWTOOLS. + +LWTOOLS 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 <http://www.gnu.org/licenses/>. + +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <lw_alloc.h> +#include <lw_string.h> +#include <lw_cmdline.h> + +/* command line option handling */ +#define PROGVER "lwcc from " PACKAGE_STRING +char *program_name; + +/* global state */ +char *output_file = NULL; +int debug_level = 0; + + +static struct lw_cmdline_options options[] = +{ + { "output", 'o', "FILE", 0, "Output to FILE"}, + { "debug", 'd', "LEVEL", lw_cmdline_opt_optional, "Set debug mode"}, + { 0 } +}; + + +static int parse_opts(int key, char *arg, void *state) +{ + switch (key) + { + case 'o': + if (output_file) + lw_free(output_file); + output_file = lw_strdup(arg); + break; + + case 'd': + if (!arg) + debug_level = 50; + else + debug_level = atoi(arg); + break; + + case lw_cmdline_key_end: + break; + + case lw_cmdline_key_arg: + printf("Input file: %s\n", arg); + break; + + default: + return lw_cmdline_err_unknown; + } + return 0; +} + +static struct lw_cmdline_parser cmdline_parser = +{ + options, + parse_opts, + "INPUTFILE", + "lwcc, a HD6309 and MC6809 cross-compiler\vPlease report bugs to lost@l-w.ca.", + PROGVER +}; + +int main(int argc, char **argv) +{ + program_name = argv[0]; + + /* parse command line arguments */ + lw_cmdline_parse(&cmdline_parser, argc, argv, 0, 0, NULL); + + if (!output_file) + { + output_file = lw_strdup("a.out"); + } + + exit(0); +}