+ for (s = setFirstItem(libFilesSet); s != NULL; s = setNextItem(libFilesSet))
+ fprintf (lnkfile, "-l %s\n", s);
+
+ /*For the z80 and gbz80 ports, try to find where crt0.o is...
+ It is very important for this file to be first on the linking proccess
+ so the areas are set in the correct order, expecially _GSINIT*/
+ if ((TARGET_IS_Z80 || TARGET_IS_GBZ80) &&
+ !options.no_std_crt0 && !options.nostdlib) /*For the z80, gbz80*/
+ {
+ char crt0path[PATH_MAX];
+ FILE * crt0fp;
+ for (s = setFirstItem(libDirsSet); s != NULL; s = setNextItem(libDirsSet))
+ {
+ sprintf (crt0path, "%s%s%s%scrt0.o",
+ s, DIR_SEPARATOR_STRING, c, DIR_SEPARATOR_STRING);
+
+ crt0fp=fopen(crt0path, "r");
+ if(crt0fp!=NULL)/*Found it!*/
+ {
+ fclose(crt0fp);
+ #ifdef __CYGWIN__
+ {
+ /*The CYGWIN version of the z80-gbz80 linker is getting confused with
+ windows paths, so convert them to the CYGWIN format*/
+ char posix_path[PATH_MAX];
+ void cygwin_conv_to_full_posix_path(char * win_path, char * posix_path);
+ cygwin_conv_to_full_posix_path(crt0path, posix_path);
+ strcpy(crt0path, posix_path);
+ }
+ #endif
+ fprintf (lnkfile, "%s\n", crt0path);
+ break;
+ }
+ }
+ if(s==NULL) fprintf (stderr, "Warning: couldn't find crt0.o\n");
+ }