From 09579599764fce8dd5afc49927c29e5b69956209 Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 29 May 2003 09:35:11 +0000 Subject: [PATCH] Add file search path capability (still unused) git-svn-id: svn://svn.cc65.org/cc65/trunk@2178 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ld65/filepath.c | 79 ++++++++++++++++++++++++++++++++++++++++ src/ld65/filepath.h | 73 +++++++++++++++++++++++++++++++++++++ src/ld65/main.c | 39 ++++++++++++++++++-- src/ld65/make/gcc.mak | 1 + src/ld65/make/watcom.mak | 1 + 5 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 src/ld65/filepath.c create mode 100644 src/ld65/filepath.h diff --git a/src/ld65/filepath.c b/src/ld65/filepath.c new file mode 100644 index 000000000..cdf176534 --- /dev/null +++ b/src/ld65/filepath.c @@ -0,0 +1,79 @@ +/*****************************************************************************/ +/* */ +/* filepath.c */ +/* */ +/* File search path handling for ld65 */ +/* */ +/* */ +/* */ +/* (C) 2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* 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. */ +/* */ +/*****************************************************************************/ + + + +/* common */ +#include "searchpath.h" + +/* ld65 */ +#include "filepath.h" + + + +/*****************************************************************************/ +/* 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 + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void InitSearchPaths (void) +/* Initialize the path search list */ +{ + /* Always search all stuff in the current directory */ + AddSearchPath ("", SEARCH_LIB | SEARCH_OBJ | SEARCH_CFG); + + /* Add a standard path for the libraries and objects */ + AddSearchPath (CC65_LIB, SEARCH_LIB | SEARCH_OBJ); + + /* Add paths from the environment */ + AddSearchPathFromEnv ("LD65_LIB", SEARCH_LIB); + AddSearchPathFromEnv ("LD65_OBJ", SEARCH_OBJ); + AddSearchPathFromEnv ("LD65_CFG", SEARCH_CFG); +} + + + diff --git a/src/ld65/filepath.h b/src/ld65/filepath.h new file mode 100644 index 000000000..f1a501c1a --- /dev/null +++ b/src/ld65/filepath.h @@ -0,0 +1,73 @@ +/*****************************************************************************/ +/* */ +/* filepath.h */ +/* */ +/* File search path handling for ld65 */ +/* */ +/* */ +/* */ +/* (C) 2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* 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. */ +/* */ +/*****************************************************************************/ + + + +#ifndef FILEPATH_H +#define FILEPATH_H + + + +/* common */ +#include "searchpath.h" + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + +#define SEARCH_LIB 0x0001U /* Library path */ +#define SEARCH_OBJ 0x0002U /* Object file path */ +#define SEARCH_CFG 0x0004U /* Config file path */ + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void InitSearchPaths (void); +/* Initialize the path search list */ + + + +/* End of filepath.h */ +#endif + + + diff --git a/src/ld65/main.c b/src/ld65/main.c index 489ac5cb9..f6073c8ff 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -54,6 +54,7 @@ #include "error.h" #include "exports.h" #include "fileio.h" +#include "filepath.h" #include "global.h" #include "library.h" #include "mapfile.h" @@ -90,6 +91,7 @@ static void Usage (void) "Usage: %s [options] module ...\n" "Short options:\n" " -C name\t\tUse linker config file\n" + " -L path\t\tSpecify a library search path\n" " -Ln name\t\tCreate a VICE label file\n" " -Lp\t\t\tMark write protected segments as such (VICE)\n" " -S addr\t\tSet the default start address\n" @@ -102,11 +104,14 @@ static void Usage (void) " -vm\t\t\tVerbose map file\n" "\n" "Long options:\n" + " --cfg-path path\tSpecify a config file search path\n" " --config name\t\tUse linker config file\n" " --dump-config name\tDump a builtin configuration\n" " --help\t\tHelp (this text)\n" + " --lib-path path\tSpecify a library search path\n" " --mapfile name\tCreate a map file\n" " --module-id id\tSpecify a module id\n" + " --obj-path path\tSpecify an object file search path\n" " --start-addr addr\tSet the default start address\n" " --target sys\t\tSet the target system\n" " --version\t\tPrint the linker version\n", @@ -218,6 +223,14 @@ static void LinkFile (const char* Name) +static void OptCfgPath (const char* Opt attribute ((unused)), const char* Arg) +/* Specify a config file search path */ +{ + AddSearchPath (Arg, SEARCH_CFG); +} + + + static void OptConfig (const char* Opt attribute ((unused)), const char* Arg) /* Define the config file */ { @@ -262,6 +275,14 @@ static void OptHelp (const char* Opt attribute ((unused)), +static void OptLibPath (const char* Opt attribute ((unused)), const char* Arg) +/* Specify a library file search path */ +{ + AddSearchPath (Arg, SEARCH_LIB); +} + + + static void OptMapFile (const char* Opt attribute ((unused)), const char* Arg) /* Give the name of the map file */ { @@ -282,6 +303,14 @@ static void OptModuleId (const char* Opt, const char* Arg) +static void OptObjPath (const char* Opt attribute ((unused)), const char* Arg) +/* Specify an object file search path */ +{ + AddSearchPath (Arg, SEARCH_OBJ); +} + + + static void OptStartAddr (const char* Opt, const char* Arg) /* Set the default start address */ { @@ -328,12 +357,15 @@ int main (int argc, char* argv []) { /* Program long options */ static const LongOpt OptTab[] = { + { "--cfg-path", 1, OptCfgPath }, { "--config", 1, OptConfig }, { "--dbgfile", 1, OptDbgFile }, { "--dump-config", 1, OptDumpConfig }, { "--help", 0, OptHelp }, + { "--lib-path", 1, OptLibPath }, { "--mapfile", 1, OptMapFile }, { "--module-id", 1, OptModuleId }, + { "--obj-path", 1, OptObjPath }, { "--start-addr", 1, OptStartAddr }, { "--target", 1, OptTarget }, { "--version", 0, OptVersion }, @@ -407,9 +439,10 @@ int main (int argc, char* argv []) case 'L': switch (Arg [2]) { - case 'n': LabelFileName = GetArg (&I, 3); break; - case 'p': WProtSegs = 1; break; - default: UnknownOption (Arg); break; + /* ## The first two are obsolete and will go */ + case 'n': LabelFileName = GetArg (&I, 3); break; + case 'p': WProtSegs = 1; break; + default: OptLibPath (Arg, GetArg (&I, 2)); break; } break; diff --git a/src/ld65/make/gcc.mak b/src/ld65/make/gcc.mak index e20b7fcc9..913a8f179 100644 --- a/src/ld65/make/gcc.mak +++ b/src/ld65/make/gcc.mak @@ -30,6 +30,7 @@ OBJS = bin.o \ extsyms.o \ fileinfo.o \ fileio.o \ + filepath.o \ fragment.o \ global.o \ library.o \ diff --git a/src/ld65/make/watcom.mak b/src/ld65/make/watcom.mak index b14fd45a2..c4b0981e4 100644 --- a/src/ld65/make/watcom.mak +++ b/src/ld65/make/watcom.mak @@ -55,6 +55,7 @@ OBJS = bin.obj \ extsyms.obj \ fileinfo.obj \ fileio.obj \ + filepath.obj \ fragment.obj \ global.obj \ library.obj \ -- 2.39.5