From a81ec42f1883f172d4bbc3b8f367424e5ecec5ee Mon Sep 17 00:00:00 2001 From: borutr Date: Thu, 19 Jun 2003 12:13:31 +0000 Subject: [PATCH] fixed Z80 port - crt0.o: cannot open. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2707 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/SDCCglobl.h | 1 + src/SDCCmain.c | 8 ++++---- src/SDCCutil.c | 12 ++++++++++-- src/SDCCutil.h | 2 +- src/z80/main.c | 27 ++++++++++++++++++++++++++- 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b348074..d7c61e41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-06-19 Borut Razem + + * 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 * support/Util/MySystem.c (merge_command): revert bad fix diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 42759a82..0b6d6f8e 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -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 *); diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 4dc4da94..9f86359a 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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)) { diff --git a/src/SDCCutil.c b/src/SDCCutil.c index 381d53d0..c0c317be 100644 --- a/src/SDCCutil.c +++ b/src/SDCCutil.c @@ -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 diff --git a/src/SDCCutil.h b/src/SDCCutil.h index fbfc7a04..e5f64d74 100644 --- a/src/SDCCutil.h +++ b/src/SDCCutil.h @@ -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. */ diff --git a/src/z80/main.c b/src/z80/main.c index 233574c1..6a715333 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -22,6 +22,7 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ +#include #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 { -- 2.30.2