diff --git a/src/ca65/incpath.c b/src/ca65/incpath.c index ab0db8443..a5968cb57 100644 --- a/src/ca65/incpath.c +++ b/src/ca65/incpath.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000-2010, Ullrich von Bassewitz */ +/* (C) 2000-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -70,17 +70,23 @@ void InitIncludePaths (void) /* Create the search path lists */ IncSearchPath = NewSearchPath (); BinSearchPath = NewSearchPath (); - - /* Add some compiled in search paths if defined at compile time */ -#ifdef CA65_INC - AddSearchPath (IncSearchPath, STRINGIZE (CA65_INC)); -#endif - - /* Add specific paths from the environment */ - AddSearchPathFromEnv (IncSearchPath, "CA65_INC"); - - /* Add paths relative to a main directory defined in an env var */ - AddSubSearchPathFromEnv (IncSearchPath, "CC65_HOME", "asminc"); +} + + + +void FinishIncludePaths (void) +/* Finish creating the include path search list. */ +{ + /* Add specific paths from the environment */ + AddSearchPathFromEnv (IncSearchPath, "CA65_INC"); + + /* Add paths relative to a main directory defined in an env. var. */ + AddSubSearchPathFromEnv (IncSearchPath, "CC65_HOME", "asminc"); + + /* Add some compiled-in search paths if defined at compile time. */ +#ifdef CA65_INC + AddSearchPath (IncSearchPath, STRINGIZE (CA65_INC)); +#endif } diff --git a/src/ca65/incpath.h b/src/ca65/incpath.h index b2484cc96..96992a697 100644 --- a/src/ca65/incpath.h +++ b/src/ca65/incpath.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000-2010, Ullrich von Bassewitz */ +/* (C) 2000-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -66,6 +66,9 @@ void ForgetAllIncludePaths (void); void InitIncludePaths (void); /* Initialize the include path search list */ +void FinishIncludePaths (void); +/* Finish creating the include path search list. */ + /* End of incpath.h */ diff --git a/src/ca65/main.c b/src/ca65/main.c index f05cd3415..6e9e1e494 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -5,7 +5,7 @@ /* */ /* */ /* */ -/* (C) 1998-2012, Ullrich von Bassewitz */ +/* (C) 1998-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -1016,6 +1016,9 @@ int main (int argc, char* argv []) exit (EXIT_FAILURE); } + /* Add the default include search paths. */ + FinishIncludePaths (); + /* If no CPU given, use the default CPU for the target */ if (GetCPU () == CPU_UNKNOWN) { if (Target != TGT_UNKNOWN) { diff --git a/src/cc65/incpath.c b/src/cc65/incpath.c index 275fc844d..6e07f8f77 100644 --- a/src/cc65/incpath.c +++ b/src/cc65/incpath.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000-2012, Ullrich von Bassewitz */ +/* (C) 2000-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -70,18 +70,24 @@ void InitIncludePaths (void) /* Create the search path lists */ SysIncSearchPath = NewSearchPath (); UsrIncSearchPath = NewSearchPath (); - - /* Add some compiled in search paths if defined at compile time */ -#ifdef CC65_INC - AddSearchPath (SysIncSearchPath, STRINGIZE (CC65_INC)); -#endif - - /* 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"); +} + + + +void FinishIncludePaths (void) +/* Finish creating the include path search lists. */ +{ + /* 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 (SysIncSearchPath, STRINGIZE (CC65_INC)); +#endif } diff --git a/src/cc65/incpath.h b/src/cc65/incpath.h index dba920f6d..99096b8ae 100644 --- a/src/cc65/incpath.h +++ b/src/cc65/incpath.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000-2010, Ullrich von Bassewitz */ +/* (C) 2000-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -66,6 +66,9 @@ void ForgetAllIncludePaths (void); void InitIncludePaths (void); /* Initialize the include path search list */ +void FinishIncludePaths (void); +/* Finish creating the include path search lists. */ + /* End of incpath.h */ diff --git a/src/cc65/main.c b/src/cc65/main.c index 461d8b95a..d2996e1b5 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000-2012, Ullrich von Bassewitz */ +/* (C) 2000-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -957,6 +957,9 @@ int main (int argc, char* argv[]) AbEnd ("No input files"); } + /* Add the default include search paths. */ + FinishIncludePaths (); + /* Create the output file name if it was not explicitly given */ MakeDefaultOutputName (InputFile); diff --git a/src/ld65/filepath.c b/src/ld65/filepath.c index efed463ee..d112c0733 100644 --- a/src/ld65/filepath.c +++ b/src/ld65/filepath.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2003-2010, Ullrich von Bassewitz */ +/* (C) 2003-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -48,6 +48,10 @@ SearchPath* LibSearchPath; /* Library path */ SearchPath* ObjSearchPath; /* Object file path */ SearchPath* CfgSearchPath; /* Config file path */ +SearchPath* LibDefaultPath; /* Default Library path */ +SearchPath* ObjDefaultPath; /* Default Object file path */ +SearchPath* CfgDefaultPath; /* Default Config file path */ + /*****************************************************************************/ @@ -64,31 +68,35 @@ void InitSearchPaths (void) ObjSearchPath = NewSearchPath (); CfgSearchPath = NewSearchPath (); + LibDefaultPath = NewSearchPath (); + ObjDefaultPath = NewSearchPath (); + CfgDefaultPath = NewSearchPath (); + /* Always search all stuff in the current directory */ AddSearchPath (LibSearchPath, ""); AddSearchPath (ObjSearchPath, ""); AddSearchPath (CfgSearchPath, ""); - /* Add some compiled in search paths if defined at compile time */ + /* 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"); + AddSubSearchPathFromEnv (ObjDefaultPath, "CC65_HOME", "obj"); + AddSubSearchPathFromEnv (CfgDefaultPath, "CC65_HOME", "cfg"); + + /* Add some compiled-in search paths if defined at compile time. */ #if defined(LD65_LIB) - AddSearchPath (LibSearchPath, STRINGIZE (LD65_LIB)); + AddSearchPath (LibDefaultPath, STRINGIZE (LD65_LIB)); #endif #if defined(LD65_OBJ) - AddSearchPath (ObjSearchPath, STRINGIZE (LD65_OBJ)); + AddSearchPath (ObjDefaultPath, STRINGIZE (LD65_OBJ)); #endif #if defined(LD65_CFG) - AddSearchPath (CfgSearchPath, STRINGIZE (LD65_CFG)); + AddSearchPath (CfgDefaultPath, STRINGIZE (LD65_CFG)); #endif - - /* Add specific paths from the environment */ - AddSearchPathFromEnv (LibSearchPath, "LD65_LIB"); - AddSearchPathFromEnv (ObjSearchPath, "LD65_OBJ"); - AddSearchPathFromEnv (CfgSearchPath, "LD65_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"); } diff --git a/src/ld65/filepath.h b/src/ld65/filepath.h index 45d9a90c7..4d267b156 100644 --- a/src/ld65/filepath.h +++ b/src/ld65/filepath.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2003-2010, Ullrich von Bassewitz */ +/* (C) 2003-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -53,6 +53,10 @@ extern SearchPath* LibSearchPath; /* Library path */ extern SearchPath* ObjSearchPath; /* Object file path */ extern SearchPath* CfgSearchPath; /* Config file path */ +extern SearchPath* LibDefaultPath; /* Default Library path */ +extern SearchPath* ObjDefaultPath; /* Default Object file path */ +extern SearchPath* CfgDefaultPath; /* Default Config file path */ + /*****************************************************************************/ diff --git a/src/ld65/main.c b/src/ld65/main.c index 675970523..0f7eaa07f 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2010, Ullrich von Bassewitz */ +/* (C) 1998-2013, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -178,10 +178,16 @@ static void LinkFile (const char* Name, FILETYPE Type) case FILETYPE_LIB: PathName = SearchFile (LibSearchPath, Name); + if (PathName == 0) { + PathName = SearchFile (LibDefaultPath, Name); + } break; case FILETYPE_OBJ: PathName = SearchFile (ObjSearchPath, Name); + if (PathName == 0) { + PathName = SearchFile (ObjDefaultPath, Name); + } break; default: @@ -295,13 +301,15 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg) } /* Search for the file */ PathName = SearchFile (CfgSearchPath, Arg); + if (PathName == 0) { + PathName = SearchFile (CfgDefaultPath, Arg); + } if (PathName == 0) { Error ("Cannot find config file `%s'", Arg); - } else { - CfgSetName (PathName); } /* Read the config */ + CfgSetName (PathName); CfgRead (); } @@ -487,6 +495,9 @@ static void OptTarget (const char* Opt attribute ((unused)), const char* Arg) /* Search for the file */ PathName = SearchFile (CfgSearchPath, SB_GetBuf (&FileName)); + if (PathName == 0) { + PathName = SearchFile (CfgDefaultPath, SB_GetBuf (&FileName)); + } if (PathName == 0) { Error ("Cannot find config file `%s'", SB_GetBuf (&FileName)); } @@ -715,4 +726,3 @@ int main (int argc, char* argv []) -