- setMainValue ("z80libspec", "-k{libdir}{sep}{port} -l{port}.lib");
- setMainValue ("z80crt0", "{libdir}{sep}{port}{sep}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);
+ }