2003-05-29 09:35:11 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* filepath.c */
|
2003-05-29 09:35:11 +00:00
|
|
|
/* */
|
|
|
|
/* File search path handling for ld65 */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2013-05-04 03:25:06 +00:00
|
|
|
/* (C) 2003-2013, Ullrich von Bassewitz */
|
2009-09-22 11:49:53 +00:00
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2003-05-29 09:35:11 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ld65 */
|
|
|
|
#include "filepath.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-09 10:54:15 +00:00
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Data */
|
2010-05-09 10:54:15 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-03 21:12:14 +00:00
|
|
|
SearchPaths* LibSearchPath; /* Library path */
|
|
|
|
SearchPaths* ObjSearchPath; /* Object file path */
|
|
|
|
SearchPaths* CfgSearchPath; /* Config file path */
|
2010-05-09 10:54:15 +00:00
|
|
|
|
2014-03-03 21:12:14 +00:00
|
|
|
SearchPaths* LibDefaultPath; /* Default Library path */
|
|
|
|
SearchPaths* ObjDefaultPath; /* Default Object file path */
|
|
|
|
SearchPaths* CfgDefaultPath; /* Default Config file path */
|
2013-05-04 03:25:06 +00:00
|
|
|
|
2010-05-09 10:54:15 +00:00
|
|
|
|
|
|
|
|
2003-05-29 09:35:11 +00:00
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2003-05-29 09:35:11 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InitSearchPaths (void)
|
|
|
|
/* Initialize the path search list */
|
|
|
|
{
|
2010-05-09 10:54:15 +00:00
|
|
|
/* Create the search path lists */
|
|
|
|
LibSearchPath = NewSearchPath ();
|
|
|
|
ObjSearchPath = NewSearchPath ();
|
|
|
|
CfgSearchPath = NewSearchPath ();
|
|
|
|
|
2013-05-04 03:25:06 +00:00
|
|
|
LibDefaultPath = NewSearchPath ();
|
|
|
|
ObjDefaultPath = NewSearchPath ();
|
|
|
|
CfgDefaultPath = NewSearchPath ();
|
|
|
|
|
2003-05-29 09:35:11 +00:00
|
|
|
/* Always search all stuff in the current directory */
|
2010-05-09 10:54:15 +00:00
|
|
|
AddSearchPath (LibSearchPath, "");
|
|
|
|
AddSearchPath (ObjSearchPath, "");
|
|
|
|
AddSearchPath (CfgSearchPath, "");
|
2003-05-29 09:35:11 +00:00
|
|
|
|
2013-05-04 03:25:06 +00:00
|
|
|
/* Add specific paths from the environment. */
|
|
|
|
AddSearchPathFromEnv (LibDefaultPath, "LD65_LIB");
|
|
|
|
AddSearchPathFromEnv (ObjDefaultPath, "LD65_OBJ");
|
|
|
|
AddSearchPathFromEnv (CfgDefaultPath, "LD65_CFG");
|
|
|
|
|
|
|
|
/* Add paths relative to a main directory defined in an env. var. */
|
|
|
|
AddSubSearchPathFromEnv (LibDefaultPath, "CC65_HOME", "lib");
|
2013-05-06 21:20:56 +00:00
|
|
|
AddSubSearchPathFromEnv (ObjDefaultPath, "CC65_HOME", "lib");
|
2013-05-04 03:25:06 +00:00
|
|
|
AddSubSearchPathFromEnv (CfgDefaultPath, "CC65_HOME", "cfg");
|
|
|
|
|
|
|
|
/* Add some compiled-in search paths if defined at compile time. */
|
2014-03-03 21:12:14 +00:00
|
|
|
#if defined(LD65_LIB) && !defined(_WIN32)
|
2022-04-25 16:52:46 +00:00
|
|
|
AddSearchPath (LibDefaultPath, LD65_LIB);
|
2009-09-18 19:00:24 +00:00
|
|
|
#endif
|
2014-03-03 21:12:14 +00:00
|
|
|
#if defined(LD65_OBJ) && !defined(_WIN32)
|
2022-04-25 16:52:46 +00:00
|
|
|
AddSearchPath (ObjDefaultPath, LD65_OBJ);
|
2009-09-18 19:00:24 +00:00
|
|
|
#endif
|
2014-03-03 21:12:14 +00:00
|
|
|
#if defined(LD65_CFG) && !defined(_WIN32)
|
2022-04-25 16:52:46 +00:00
|
|
|
AddSearchPath (CfgDefaultPath, LD65_CFG);
|
2009-09-18 19:00:24 +00:00
|
|
|
#endif
|
2013-05-06 21:20:56 +00:00
|
|
|
|
|
|
|
/* Add paths relative to the parent directory of the Windows binary. */
|
2022-04-27 21:11:01 +00:00
|
|
|
AddSubSearchPathFromBin (LibDefaultPath, "lib");
|
|
|
|
AddSubSearchPathFromBin (ObjDefaultPath, "lib");
|
|
|
|
AddSubSearchPathFromBin (CfgDefaultPath, "cfg");
|
2003-05-29 09:35:11 +00:00
|
|
|
}
|