/* can be NULL while c1mode or linking without compiling */
char *fullDstFileName; /* full name for the output file; */
/* only given by -o, otherwise NULL */
-size_t fullDstFileNameLen; /* size of previous string. */
char *dstFileName; /* destination file name without extension */
char *dstPath = ""; /* path for the output files; */
/* "" is equivalent with cwd */
#define OPTION_CODE_SIZE "--code-size"
#define OPTION_NO_CCODE_IN_ASM "--no-c-code-in-asm"
#define OPTION_ICODE_IN_ASM "--i-code-in-asm"
+#define OPTION_PRINT_SEARCH_DIRS "--print-search-dirs"
static const OPTION
optionsTable[] = {
{ 0, OPTION_NO_XINIT_OPT, &options.noXinitOpt, "don't memcpy initialized xram from code"},
{ 0, OPTION_NO_CCODE_IN_ASM, &options.noCcodeInAsm, "don't include c-code as comments in the asm file"},
{ 0, OPTION_ICODE_IN_ASM, &options.iCodeInAsm, "include i-code as comments in the asm file"},
+ { 0, OPTION_PRINT_SEARCH_DIRS, &options.printSearchDirs, "display the directories in the compiler's search path"},
/* End of options */
{ 0, NULL }
};
#if !OPT_DISABLE_XA51
&xa51_port,
#endif
+#if !OPT_DISABLE_DS400
+ &ds400_port,
+#endif
};
#define NUM_PORTS (sizeof(_ports)/sizeof(_ports[0]))
#ifdef __CYGWIN__
" (CYGWIN)\n"
#elif defined __MINGW32__
- " (MINGW32) \n"
+ " (MINGW32)\n"
#elif defined __DJGPP__
- " (DJGPP) \n"
+ " (DJGPP)\n"
#elif defined(_MSC_VER)
- " (MSVC) \n"
+ " (MSVC)\n"
#elif defined(__BORLANDC__)
- " (BORLANDC) \n"
+ " (BORLANDC)\n"
#else
" (UNIX) \n"
#endif
static char *
getStringArg(const char *szStart, char **argv, int *pi, int argc)
{
- if (argv[*pi][strlen(szStart)])
+ if (argv[*pi][strlen(szStart)])
{
return &argv[*pi][strlen(szStart)];
}
- else
+ else
{
++(*pi);
- if (*pi >= argc)
+ if (*pi >= argc)
{
werror (E_ARGUMENT_MISSING, szStart);
/* Die here rather than checking for errors later. */
exit(-1);
}
- else
+ else
{
return argv[*pi];
}
}
/** Gets the integer argument to this option using the same rules as
- getStringArg.
+ getStringArg.
*/
static int
getIntArg(const char *szStart, char **argv, int *pi, int argc)
else
{
fullDstFileName = Safe_strdup (buffer);
- fullDstFileNameLen = strlen(fullDstFileName) + 1;
/* get rid of the "."-extension */
/* if debug option is set then open the cdbFile */
if (options.debug && fullSrcFileName)
{
- SNPRINTF (scratchFileName, sizeof(scratchFileName),
+ SNPRINTF (scratchFileName, sizeof(scratchFileName),
"%s.adb", dstFileName); //JCF: Nov 30, 2002
if(debugFile->openFile(scratchFileName))
debugFile->writeModule(moduleName);
int i, system_ret;
/* first we need to create the <filename>.lnk file */
- SNPRINTF (scratchFileName, sizeof(scratchFileName),
+ SNPRINTF (scratchFileName, sizeof(scratchFileName),
"%s.lnk", dstFileName);
if (!(lnkfile = fopen (scratchFileName, "w")))
{
break;
case MODEL_FLAT24:
/* c = "flat24"; */
- c = "ds390";
+ if (TARGET_IS_DS390)
+ {
+ c = "ds390";
+ }
+ else if (TARGET_IS_DS400)
+ {
+ c = "ds400";
+ }
+ else
+ {
+ fprintf(stderr,
+ "Add support for your FLAT24 target in %s @ line %d\n",
+ __FILE__, __LINE__);
+ exit(-1);
+ }
break;
case MODEL_PAGE0:
c = "xa51";
#if !OPT_DISABLE_DS390
if (options.model == MODEL_FLAT24)
{
- fprintf (lnkfile, "-l %s\n", STD_DS390_LIB);
+ if (TARGET_IS_DS390)
+ {
+ fprintf (lnkfile, "-l %s\n", STD_DS390_LIB);
+ }
+ else if (TARGET_IS_DS400)
+ {
+ fprintf (lnkfile, "-l %s\n", STD_DS400_LIB);
+ }
+ else
+ {
+ fprintf(stderr,
+ "Add support for your FLAT24 target in %s @ line %d\n",
+ __FILE__, __LINE__);
+ exit(-1);
+ }
}
#endif
else
{
strncpyz (scratchFileName, relFiles[0], sizeof(scratchFileName));
- /* strip "rel" extension */
+ /* strip ".rel" extension */
p = strrchr (scratchFileName, '.');
if (p)
{
- p++;
- *p = 0;
+ *p = 0;
}
-
}
strncatz (scratchFileName,
- options.out_fmt ? "S19" : "ihx",
+ options.out_fmt ? ".S19" : ".ihx",
sizeof(scratchFileName));
rename (scratchFileName, fullDstFileName);
- q = strrchr (fullDstFileName, '.');
- if (q)
- {
- /* point after the '.' of the extension */
- q++;
- }
- else
+ strncpyz (buffer, fullDstFileName, sizeof(buffer));
+ q = strrchr (buffer, '.');
+ if (!q)
{
/* no extension: append new extensions */
- /* Don't we want to append a period here ? */
- q = strlen (fullDstFileName) + fullDstFileName;
+ q = strlen (buffer) + buffer;
}
-
- *p = 0;
- strncatz (scratchFileName, "map", sizeof(scratchFileName));
+
+ *p = 0;
+ strncatz (scratchFileName, ".map", sizeof(scratchFileName));
*q = 0;
- strncatz(fullDstFileName, "map", fullDstFileNameLen);
- rename (scratchFileName, fullDstFileName);
- *p = 0;
- strncatz (scratchFileName, "mem", sizeof(scratchFileName));
+ strncatz(buffer, ".map", sizeof(buffer));
+ rename (scratchFileName, buffer);
+ *p = 0;
+ strncatz (scratchFileName, ".mem", sizeof(scratchFileName));
*q = 0;
- strncatz(fullDstFileName, "mem", fullDstFileNameLen);
- rename (scratchFileName, fullDstFileName);
+ strncatz(buffer, ".mem", sizeof(buffer));
+ rename (scratchFileName, buffer);
}
if (system_ret)
{
*/
/* do it in reverse mode, so that addSetHead() can be used
- instaed of slower addSet() */
+ instead of slower addSet() */
if ((p = getBinPath(argv0)) != NULL)
addSetHead(&binPathSet, Safe_strdup(p));
SNPRINTF(buf, sizeof buf, "%s" PREFIX2BIN_DIR, p);
addSetHead(&binPathSet, Safe_strdup(buf));
}
+
+ if (options.printSearchDirs) {
+ printf("programs: ");
+ if (NULL != (p = (char *)setFirstItem(binPathSet))) {
+ printf("%s", p);
+ while (NULL != (p = (char *)setNextItem(binPathSet)))
+ printf(":%s", p);
+ }
+ putchar('\n');
+ }
}
/* Set system include path */
p = buf;
}
+ if (options.printSearchDirs)
+ printf("includedir: %s\n", p);
+
setMainValue ("includedir", p);
}
p = buf;
}
+ if (options.printSearchDirs)
+ printf("libdir: %s\n", p);
+
setMainValue ("libdir", p);
}
SNPRINTF(buf, sizeof buf, "%s" PREFIX2DATA_DIR, p);
p = buf;
}
- else {
- if ((p = getBinPath(argv0)) == NULL)
- p = ".";
-
+ else if ((p = getBinPath(argv0)) != NULL) {
SNPRINTF(buf, sizeof buf, "%s" BIN2DATA_DIR, p);
p = buf;
-
-#ifndef _WIN32 /* *nix paltform */
- if (!pathExists(p))
- p = DATADIR; /* last resort */
-#endif
}
+#ifdef _WIN32
+ else {
+ /* this should never happen... */
+ wassertl(0, "Can't get binary path");
+ p = ".";
+ }
+#else
+ if (!pathExists(p))
+ p = DATADIR; /* last resort */
+#endif
+
+ if (options.printSearchDirs)
+ printf("datadir: %s\n", p);
setIncludePath(p);
setLibPath(p);
if (port->init)
port->init ();
- // Create a default exe search path from the path to the sdcc command
-
-
setDefaultOptions ();
#ifdef JAMIN_DS390
if (ds390_jammed) {
#endif
parseCmdLine (argc, argv);
- /* if no input then printUsage & exit */
- if (!options.c1mode && !fullSrcFileName && !nrelFiles)
- {
- printUsage ();
- exit (0);
- }
-
initValues ();
setBinPaths(argv[0]);
setDataPaths(argv[0]);
+ /* if no input then printUsage & exit */
+ if (!options.c1mode && !fullSrcFileName && !nrelFiles) {
+ if (!options.printSearchDirs)
+ printUsage();
+
+ exit(0);
+ }
+
/* initMem() is expensive, but
initMem() must called before port->finaliseOptions ().
And the z80 port needs port->finaliseOptions(),