Add file search path capability (still unused)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2178 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
a0d9edf5ba
commit
0957959976
5 changed files with 190 additions and 3 deletions
79
src/ld65/filepath.c
Normal file
79
src/ld65/filepath.c
Normal file
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
73
src/ld65/filepath.h
Normal file
73
src/ld65/filepath.h
Normal file
|
@ -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
|
||||
|
||||
|
||||
|
|
@ -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]) {
|
||||
/* ## The first two are obsolete and will go */
|
||||
case 'n': LabelFileName = GetArg (&I, 3); break;
|
||||
case 'p': WProtSegs = 1; break;
|
||||
default: UnknownOption (Arg); break;
|
||||
default: OptLibPath (Arg, GetArg (&I, 2)); break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ OBJS = bin.o \
|
|||
extsyms.o \
|
||||
fileinfo.o \
|
||||
fileio.o \
|
||||
filepath.o \
|
||||
fragment.o \
|
||||
global.o \
|
||||
library.o \
|
||||
|
|
|
@ -55,6 +55,7 @@ OBJS = bin.obj \
|
|||
extsyms.obj \
|
||||
fileinfo.obj \
|
||||
fileio.obj \
|
||||
filepath.obj \
|
||||
fragment.obj \
|
||||
global.obj \
|
||||
library.obj \
|
||||
|
|
Loading…
Add table
Reference in a new issue