/*****************************************************************************/
/* */
-/* incpath.c */
+/* incpath.c */
/* */
-/* Include path handling for cc65 */
+/* Include path handling for cc65 */
/* */
/* */
/* */
-/* (C) 2000-2003 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2000-2013, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
-/* common */
-#include "searchpath.h"
-
/* cc65 */
#include "incpath.h"
/*****************************************************************************/
-/* Code */
+/* Data */
/*****************************************************************************/
-void AddIncludePath (const char* NewPath, unsigned Where)
-/* Add a new include path to the existing one */
-{
- AddSearchPath (NewPath, Where);
-}
+SearchPath* SysIncSearchPath; /* System include path */
+SearchPath* UsrIncSearchPath; /* User include path */
-char* FindInclude (const char* Name, unsigned Where)
-/* Find an include file. Return a pointer to a malloced area that contains
- * the complete path, if found, return 0 otherwise.
- */
-{
- return SearchFile (Name, Where);
-}
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
-void ForgetAllIncludePaths (void)
-/* Remove all include search paths. */
+void InitIncludePaths (void)
+/* Initialize the include path search list */
{
- ForgetAllSearchPaths (INC_SYS | INC_USER);
+ /* Create the search path lists */
+ SysIncSearchPath = NewSearchPath ();
+ UsrIncSearchPath = NewSearchPath ();
}
-void InitIncludePaths (void)
-/* Initialize the include path search list */
+void FinishIncludePaths (void)
+/* Finish creating the include path search lists. */
{
- /* Add some standard paths to the include search path */
- AddSearchPath ("", INC_USER); /* Current directory */
- AddSearchPath ("include", INC_SYS);
+ /* Add specific paths from the environment */
+ AddSearchPathFromEnv (SysIncSearchPath, "CC65_INC");
+ AddSearchPathFromEnv (UsrIncSearchPath, "CC65_INC");
+
+ /* Add paths relative to a main directory defined in an env. var. */
+ AddSubSearchPathFromEnv (SysIncSearchPath, "CC65_HOME", "include");
+
+ /* Add some compiled-in search paths if defined at compile time. */
#ifdef CC65_INC
- AddSearchPath (CC65_INC, INC_SYS);
-#else
- AddSearchPath ("/usr/lib/cc65/include", INC_SYS);
+ AddSearchPath (SysIncSearchPath, STRINGIZE (CC65_INC));
#endif
- AddSearchPathFromEnv ("CC65_INC", INC_SYS | INC_USER);
+
+ /* Add paths relative to the parent directory of the Windows binary. */
+ AddSubSearchPathFromWinBin (SysIncSearchPath, "include");
}