X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fld65%2Ffilepath.c;h=aa7d547e275f50f441e2020ff40acbe5f088a3af;hb=35e1184901ca38bdb2e56d154ed3b71f6096eacc;hp=cdf176534422612390a553df45b42c5668d8b669;hpb=09579599764fce8dd5afc49927c29e5b69956209;p=cc65 diff --git a/src/ld65/filepath.c b/src/ld65/filepath.c index cdf176534..aa7d547e2 100644 --- a/src/ld65/filepath.c +++ b/src/ld65/filepath.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 2003-2010, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -33,29 +33,25 @@ -/* common */ -#include "searchpath.h" - /* ld65 */ #include "filepath.h" /*****************************************************************************/ -/* Data */ +/* Data */ /*****************************************************************************/ -/* If the standard library search path is not given, use a hardcoded one */ -#ifndef CC65_LIB -#define CC65_LIB "/usr/lib/cc65/lib/"; -#endif +SearchPath* LibSearchPath; /* Library path */ +SearchPath* ObjSearchPath; /* Object file path */ +SearchPath* CfgSearchPath; /* Config file path */ /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ @@ -63,16 +59,36 @@ void InitSearchPaths (void) /* Initialize the path search list */ { + /* Create the search path lists */ + LibSearchPath = NewSearchPath (); + ObjSearchPath = NewSearchPath (); + CfgSearchPath = NewSearchPath (); + /* Always search all stuff in the current directory */ - AddSearchPath ("", SEARCH_LIB | SEARCH_OBJ | SEARCH_CFG); + AddSearchPath (LibSearchPath, ""); + AddSearchPath (ObjSearchPath, ""); + AddSearchPath (CfgSearchPath, ""); + + /* Add some compiled in search paths if defined at compile time */ +#if defined(LD65_LIB) + AddSearchPath (LibSearchPath, LD65_LIB); +#endif +#if defined(LD65_OBJ) + AddSearchPath (ObjSearchPath, LD65_OBJ); +#endif +#if defined(LD65_CFG) + AddSearchPath (CfgSearchPath, LD65_CFG); +#endif - /* Add a standard path for the libraries and objects */ - AddSearchPath (CC65_LIB, SEARCH_LIB | SEARCH_OBJ); + /* Add specific paths from the environment */ + AddSearchPathFromEnv (LibSearchPath, "LD65_LIB"); + AddSearchPathFromEnv (ObjSearchPath, "LD65_OBJ"); + AddSearchPathFromEnv (CfgSearchPath, "LD65_CFG"); - /* Add paths from the environment */ - AddSearchPathFromEnv ("LD65_LIB", SEARCH_LIB); - AddSearchPathFromEnv ("LD65_OBJ", SEARCH_OBJ); - AddSearchPathFromEnv ("LD65_CFG", SEARCH_CFG); + /* Add paths relative to a main directory defined in an env var */ + AddSubSearchPathFromEnv (LibSearchPath, "CC65_HOME", "lib"); + AddSubSearchPathFromEnv (ObjSearchPath, "CC65_HOME", "obj"); + AddSubSearchPathFromEnv (CfgSearchPath, "CC65_HOME", "cfg"); }