--- /dev/null
+/*****************************************************************************/
+/* */
+/* 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);
+}
+
+
+
--- /dev/null
+/*****************************************************************************/
+/* */
+/* 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
+
+
+
#include "error.h"
#include "exports.h"
#include "fileio.h"
+#include "filepath.h"
#include "global.h"
#include "library.h"
#include "mapfile.h"
"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"
" -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",
+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 */
{
+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 */
{
+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 */
{
{
/* 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 },
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;