From a8405576412e0993efae4e0a0b24d79954228ec2 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Sat, 11 Jan 2003 13:56:08 +0000 Subject: [PATCH] * src/SDCCmain.c (assemble, linkEdit): preparations for -o * src/port.h: typo * src/pic/main.c (_asmCmd): gpasm supports -o * device/lib/Makefile.in: remove intermediate files git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2148 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 8 ++++++ device/lib/Makefile.in | 7 ++++-- src/SDCCmain.c | 57 ++++++++++++++++++++++++++++++++++++------ src/pic/main.c | 2 +- src/port.h | 2 +- 5 files changed, 64 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 877ab712..74b2092a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-01-11 Bernhard Held + + * src/SDCCmain.c (assemble, linkEdit): preparations for -o + * src/port.h: typo + * src/pic/main.c (_asmCmd): gpasm supports -o + * src/z80/main.c: more general macros + * device/lib/Makefile.in: remove intermediate files + 2003-01-11 Bernhard Held * .version: Bumped version number to 2.3.3 diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index b4b868ef..4cac93c3 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -124,7 +124,7 @@ include incl.mk # ------------------------------------------ all: checkconf models model-ds390 model-z80 model-gbz80 -objects: build-dir $(OBJECTS) port-specific-objects lib-files +objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate models: if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \ @@ -156,7 +156,7 @@ model-gbz80: $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \ fi -objects-z80: build-dir $(Z80OBJECTS) port-specific-objects +objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib build-dir: $(PORTDIR) @@ -173,6 +173,9 @@ port-specific-objects: lib-files: cp *.lib $(PORTDIR) +clean_intermediate: + rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym + # Compiling and installing everything and runing test # --------------------------------------------------- install: all installdirs diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 19e9e7cf..a0733f71 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -1341,10 +1341,33 @@ linkEdit (char **envp) if (options.verbose) printf ("sdcc: Calling linker...\n"); + /* build linker output filename */ + + /* -o option overrides default name? */ + if (fullDstFileName) + { + strcpy (scratchFileName, fullDstFileName); + } + else + { + /* the linked file gets the name of the first modul */ + if (fullSrcFileName) + { + strcpy (scratchFileName, dstFileName); + } + else + { + strcpy (scratchFileName, relFiles[0]); + /* strip ".rel" extension */ + *strrchr (scratchFileName, '.') = '\0'; + } + strcat (scratchFileName, options.out_fmt ? ".S19" : ".ihx"); + } + if (port->linker.cmd) { char buffer2[PATH_MAX]; - buildCmdLine (buffer2, port->linker.cmd, dstFileName, NULL, NULL, NULL); + buildCmdLine (buffer2, port->linker.cmd, dstFileName, scratchFileName, NULL, NULL); buildCmdLine2 (buffer, buffer2); } else @@ -1356,6 +1379,7 @@ linkEdit (char **envp) { exit (1); } + /* TODO: most linker don't have a -o parameter */ /* -o option overrides default name? */ if (fullDstFileName) { @@ -1381,11 +1405,22 @@ linkEdit (char **envp) static void assemble (char **envp) { + /* build assembler output filename */ + + /* -o option overrides default name? */ + if (options.cc_only && fullDstFileName) { + strcpy (scratchFileName, fullDstFileName); + } else { + /* the assembled file gets the name of the first modul */ + strcpy (scratchFileName, dstFileName); + strcat (scratchFileName, port->linker.rel_ext); + } + if (port->assembler.do_assemble) { port->assembler.do_assemble(asmOptions); return ; } else if (port->assembler.cmd) { - buildCmdLine (buffer, port->assembler.cmd, dstFileName, NULL, + buildCmdLine (buffer, port->assembler.cmd, dstFileName, scratchFileName, options.debug ? port->assembler.debug_opts : port->assembler.plain_opts, asmOptions); } else { @@ -1398,10 +1433,11 @@ assemble (char **envp) */ exit (1); } + /* TODO: most assembler don't have a -o parameter */ /* -o option overrides default name? */ if (options.cc_only && fullDstFileName) { strcpy (scratchFileName, dstFileName); - strcat (scratchFileName, ".rel"); + strcat (scratchFileName, port->linker.rel_ext); rename (scratchFileName, fullDstFileName); } } @@ -1469,7 +1505,12 @@ preProcess (char **envp) setMainValue ("cppextraopts", join(preArgv)); - if (!preProcOnly) + if (preProcOnly) + { + if (fullDstFileName) + preOutName = Safe_strdup (fullDstFileName); + } + else preOutName = Safe_strdup (tempfilename ()); /* Have to set cppoutfilename to something, even if just pre-processing. */ @@ -1655,20 +1696,20 @@ initValues (void) if (options.cc_only && fullDstFileName) /* compile + assemble and -o given: -o specifies name of object file */ { - setMainValue ("z80objdstfilename", fullDstFileName); + setMainValue ("objdstfilename", fullDstFileName); } else { - setMainValue ("z80objdstfilename", "{z80stdobjdstfilename}"); + setMainValue ("objdstfilename", "{stdobjdstfilename}"); } if (fullDstFileName) /* if we're linking, -o gives the final file name */ { - setMainValue ("z80linkdstfilename", fullDstFileName); + setMainValue ("linkdstfilename", fullDstFileName); } else { - setMainValue ("z80linkdstfilename", "{z80stdlinkdstfilename}"); + setMainValue ("linkdstfilename", "{stdlinkdstfilename}"); } } diff --git a/src/pic/main.c b/src/pic/main.c index 56948434..5f7511cf 100644 --- a/src/pic/main.c +++ b/src/pic/main.c @@ -337,7 +337,7 @@ static const char *_linkCmd[] = */ static const char *_asmCmd[] = { - "gpasm", "-c -I /usr/local/share/gpasm/header", "$1.asm", NULL + "gpasm", "-c -I /usr/local/share/gpasm/header -o $2", "$1.asm", NULL }; diff --git a/src/port.h b/src/port.h index 5f2643ec..8a21c5d8 100644 --- a/src/port.h +++ b/src/port.h @@ -94,7 +94,7 @@ typedef struct const char *mcmd; /** If non-null will be used to execute the link. */ void (*do_link) (void); - /** Extention for object files (.rel, .obj, ...) */ + /** Extension for object files (.rel, .obj, ...) */ const char *rel_ext; } linker; -- 2.39.5