* src/SDCCmain.c (assemble, linkEdit): preparations for -o
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 11 Jan 2003 13:56:08 +0000 (13:56 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 11 Jan 2003 13:56:08 +0000 (13:56 +0000)
* 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
device/lib/Makefile.in
src/SDCCmain.c
src/pic/main.c
src/port.h

index 877ab712e3fa4da5bf2e018d899206392db2d6d0..74b2092a148e51fe04d83c458f81481016bce910 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-01-11  Bernhard Held <bernhard@bernhardheld.de>
+
+       * 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 <bernhard@bernhardheld.de>
 
        * .version: Bumped version number to 2.3.3
index b4b868ef27925abd7cdf500aef92130ec9d80ffd..4cac93c3e91b2f6da462a85d8ba6c81d4ad4c17d 100644 (file)
@@ -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
index 19e9e7cf2d3b0dd7feb951ddbb9c32c15b61557e..a0733f71bb6cfbe97558ae6f539cb2589150dd99 100644 (file)
@@ -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}");
     }
 
 }
index 56948434aa84d9781a1602472fba7593fc97ada0..5f7511cf856802dfbcd0dccc91168fe4ee73d308 100644 (file)
@@ -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
 
 };
 
index 5f2643ec22f31d4aa2998ed275fd36665751cfee..8a21c5d841a341cd632853c026de78761fcf1cc1 100644 (file)
@@ -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;