1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 19:29:37 +00:00

Try reading from /proc/self first on linux, this is needed to make the edgy "make avail" work

This commit is contained in:
Bob Andrews 2022-04-30 15:01:58 +02:00 committed by mrdudz
parent 6f74a2e9c7
commit 546e82965d

View File

@ -296,10 +296,23 @@ void AddSubSearchPathFromBin (SearchPaths* P, const char* SubDir)
}
*Ptr = '\0';
#elif defined(__linux__)
/* reading from proc will return the real location, excluding symlinked
pathes - which is needed for certain edgy cases */
if (readlink("/proc/self/exe", Dir, sizeof(Dir) - 1) < 0) {
GetProgPath(Dir, ArgVec[0]);
} else {
/* Remove binary name */
Ptr = strrchr (Dir, PATHSEP[0]);
if (Ptr == 0) {
return;
}
*Ptr = '\0';
}
#else
GetProgPath(Dir, ArgVec[0]);
#endif
/* Check for 'bin' directory */