fixed Z80 port - crt0.o: cannot open.
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 19 Jun 2003 12:13:31 +0000 (12:13 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 19 Jun 2003 12:13:31 +0000 (12:13 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2707 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCglobl.h
src/SDCCmain.c
src/SDCCutil.c
src/SDCCutil.h
src/z80/main.c

index 7b348074d30d106d3c0f87554f08e252a02f4dab..d7c61e410e88272a0a59dd5a779d6a52401942be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-06-19  Borut Razem <borut.razem@siol.net>
+
+       * src/SDCCutil.h, src/SDCCutil.c, src/SDCCglobl.h, src/SDCCmain.c, src/z80/main.c:
+       fixed Z80 port - crt0.o: cannot open.
+
 2003-06-19  Bernhard Held <bernhard@bernhardheld.de>
 
        * support/Util/MySystem.c (merge_command): revert bad fix
index 42759a82cf9941ea99eb90fb9c6d785a4f181136..0b6d6f8eb80668a62d6210f9d53034080717f5b1 100644 (file)
@@ -287,6 +287,7 @@ extern set *preArgvSet;
 extern set *relFilesSet;
 extern set *libFilesSet;
 extern set *libPathsSet;
+extern set *libDirsSet;         /* list of lib search directories */
 
 void setParseWithComma (set **, char *);
 
index 4dc4da94ec69828c9221ec0fa97ef2d9f9b03f97..9f86359a3dd89a8420a35758c1e0150d21aa9bb0 100644 (file)
@@ -1478,11 +1478,11 @@ linkEdit (char **envp)
        /* VR 030517 - gplink needs linker options to set the linker script,*/
        buildCmdLine (buffer2, port->linker.cmd, dstFileName, scratchFileName, NULL, linkOptionsSet);
 
-       buildCmdLine2 (buffer, buffer2, sizeof(buffer));
+       buildCmdLine2 (buffer, sizeof(buffer), buffer2);
     }
   else
     {
-      buildCmdLine2 (buffer, port->linker.mcmd, sizeof(buffer));
+      buildCmdLine2 (buffer, sizeof(buffer), port->linker.mcmd);
     }
 
 /*  if (options.verbose)fprintf(stderr, "linker command line: %s\n", buffer); */
@@ -1569,7 +1569,7 @@ assemble (char **envp)
                      options.debug ? port->assembler.debug_opts : port->assembler.plain_opts,
                      asmOptionsSet);
     } else {
-       buildCmdLine2 (buffer, port->assembler.mcmd, sizeof(buffer));
+       buildCmdLine2 (buffer, sizeof(buffer), port->assembler.mcmd);
     }
 
     if (my_system (buffer)) {
@@ -1675,7 +1675,7 @@ preProcess (char **envp)
       if (options.verbose)
        printf ("sdcc: Calling preprocessor...\n");
 
-      buildCmdLine2 (buffer, _preCmd, sizeof(buffer));
+      buildCmdLine2 (buffer, sizeof(buffer), _preCmd);
 
       if (preProcOnly) {
         if (my_system (buffer)) {
index 381d53d04380cc3d679027aa9bfa1e9206037951..c0c317bee6930677988f2e64babfec74885ed5aa 100644 (file)
@@ -179,14 +179,22 @@ setMainValue (const char *pname, const char *pvalue)
 }
 
 void
-buildCmdLine2 (char *pbuffer, const char *pcmd, size_t len)
+buildCmdLine2 (char *pbuffer, size_t len, const char *pcmd, ...)
 {
+  va_list ap;
   char *poutcmd;
+
   assert(pbuffer && pcmd);
   assert(_mainValues);
 
-  poutcmd = msprintf(_mainValues, pcmd);
+  va_start(ap, pcmd);
+
+  poutcmd = mvsprintf(_mainValues, pcmd, ap);
+
+  va_end(ap);
+
   strncpyz(pbuffer, poutcmd, len);
+  Safe_free(poutcmd);
 }
 
 void
index fbfc7a0449607ecd2f2ec0f3d116b96de5380124..e5f64d74ad35c50e3bfbcc802adb81b688731cfd 100644 (file)
@@ -62,7 +62,7 @@ void setMainValue (const char *pname, const char *pvalue);
 
 void populateMainValues (const char **ppin);
 
-void buildCmdLine2 (char *pbuffer, const char *pcmd, size_t len);
+void buildCmdLine2 (char *pbuffer, size_t len, const char *pcmd, ...);
 
 /** Returns true if sz starts with the string given in key.
  */
index 233574c1d9fcc312101d54ea2f67c654ac8db815..6a715333d0665f76223869146be526e3f0dc4fbf 100644 (file)
@@ -22,6 +22,7 @@
    what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
+#include <sys/stat.h>
 #include "z80.h"
 #include "MySystem.h"
 #include "BuildCmd.h"
@@ -285,8 +286,32 @@ _setValues(void)
 
   if (options.nostdlib == FALSE)
     {
+      const char *s;
+      char path[PATH_MAX];
+
       setMainValue ("z80libspec", "-l\"{port}.lib\"");
-      setMainValue ("z80crt0", "\"crt0{objext}\"");
+
+      for (s = setFirstItem(libDirsSet); s != NULL; s = setNextItem(libDirsSet))
+        {
+          struct stat stat_buf;
+
+          buildCmdLine2(path, sizeof path, "%s" DIR_SEPARATOR_STRING "{port}" DIR_SEPARATOR_STRING "crt0{objext}", s);
+          if (stat(path, &stat_buf) == 0)
+            break;
+        }
+
+      if (s == NULL)
+        setMainValue ("z80crt0", "\"crt0{objext}\"");
+      else
+        {
+          char *buf;
+          size_t len = strlen(path) + 3;
+
+          buf = Safe_alloc(len);
+          SNPRINTF(buf, len, "\"%s\"", path);
+          setMainValue("z80crt0", buf);
+          Safe_free(buf);
+        } 
     }
   else
     {