what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
+#include <sys/stat.h>
#include "z80.h"
#include "MySystem.h"
#include "BuildCmd.h"
#include "SDCCutil.h"
+#include "dbuf.h"
static char _z80_defaultRules[] =
{
if (options.nostdlib == FALSE)
{
- setMainValue ("z80libspec", "-l\"{port}.lib\"");
- setMainValue ("z80crt0", "\"crt0{objext}\"");
+ const char *s;
+ char path[PATH_MAX];
+ struct dbuf_s dbuf;
+
+ dbuf_init(&dbuf, PATH_MAX);
+
+ for (s = setFirstItem(libDirsSet); s != NULL; s = setNextItem(libDirsSet))
+ {
+ buildCmdLine2(path, sizeof path, "-k\"%s" DIR_SEPARATOR_STRING "{port}\" ", s);
+ dbuf_append(&dbuf, path, strlen(path));
+ }
+ buildCmdLine2(path, sizeof path, "-l\"{port}.lib\"", s);
+ dbuf_append(&dbuf, path, strlen(path));
+
+ setMainValue ("z80libspec", dbuf_c_str(&dbuf));
+ dbuf_destroy(&dbuf);
+
+ 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
{
NULL,
1
},
+ { NULL, NULL },
{
-1, 0, 0, 4, 0, 2
},
NULL,
1
},
+ { NULL, NULL },
{
-1, 0, 0, 2, 0, 4
},