--debug Debug mode
--debug-info Add debug info to object file
--debug-opt name Debug optimization steps
+ --dep-target target Use this dependency target
--disable-opt name Disable an optimization step
--enable-opt name Enable an optimization step
--forget-inc-paths Forget include search paths
mortals:-)
+ <label id="option-dep-target">
+ <tag><tt>--dep-target target</tt></tag>
+
+ When generating a dependency file, don't use the actual output file as the
+ target of the dependency, but the file specified with this option. The
+ option has no effect if neither <tt/<ref id="option-create-dep"
+ name="--create-dep">/ nor <tt/<ref id="option-create-full-dep"
+ name="--create-full-dep">/ is specified.
+
+
<tag><tt>-D sym[=definition]</tt></tag>
Define a macro on the command line. If no definition is given, the macro
/* File names */
StrBuf DepName = STATIC_STRBUF_INITIALIZER; /* Name of dependencies file */
StrBuf FullDepName = STATIC_STRBUF_INITIALIZER; /* Name of full dependencies file */
+StrBuf DepTarget = STATIC_STRBUF_INITIALIZER; /* Name of dependency target */
/* File names */
extern StrBuf DepName; /* Name of dependencies file */
extern StrBuf FullDepName; /* Name of full dependencies file */
+extern StrBuf DepTarget; /* Name of dependency target */
/* Create a dependency file with the given name and place dependencies for
* all files with the given types there.
*/
-{
+{
+ const char* Target;
+
/* Open the file */
FILE* F = fopen (Name, "w");
if (F == 0) {
- Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno));
+ Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno));
}
- /* Print the output file followed by a tab char */
- fprintf (F, "%s:\t", OutputFilename);
+ /* If a dependency target was given, use it, otherwise use the output
+ * file name as target, followed by a tab character.
+ */
+ if (SB_IsEmpty (&DepTarget)) {
+ Target = OutputFilename;
+ } else {
+ Target = SB_GetConstBuf (&DepTarget);
+ }
+ fprintf (F, "%s:\t", Target);
/* Write out the dependencies for the output file */
WriteDep (F, Types);
" --debug\t\t\tDebug mode\n"
" --debug-info\t\t\tAdd debug info to object file\n"
" --debug-opt name\t\tDebug optimization steps\n"
+ " --dep-target target\t\tUse this dependency target\n"
" --disable-opt name\t\tDisable an optimization step\n"
" --enable-opt name\t\tEnable an optimization step\n"
" --forget-inc-paths\t\tForget include search paths\n"
+static void OptDepTarget (const char* Opt attribute ((unused)), const char* Arg)
+/* Handle the --dep-target option */
+{
+ FileNameOption (Opt, Arg, &DepTarget);
+}
+
+
+
static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg)
/* Disable an optimization step */
{
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--debug-opt", 1, OptDebugOpt },
+ { "--dep-target", 1, OptDepTarget },
{ "--disable-opt", 1, OptDisableOpt },
{ "--enable-opt", 1, OptEnableOpt },
{ "--forget-inc-paths", 0, OptForgetIncPaths },
/* Set the target system */
CmdSetTarget (&CC65, Target);
- /* If we won't assemble, this is the final step. In this case, set the
- * output name.
- */
- if (!DoAssemble && OutputName) {
- CmdSetOutput (&CC65, OutputName);
+ /* Check if this is the final step */
+ if (DoAssemble) {
+ /* We will assemble this file later. If a dependency file is to be
+ * generated, set the dependency target to be the final object file,
+ * not the intermediate assembler file. But beware: There may be an
+ * output name specified for the assembler.
+ */
+ if (DepName || FullDepName) {
+ /* Was an output name for the assembler specified? */
+ if (!DoLink && OutputName) {
+ /* Use this name as the dependency target */
+ CmdAddArg2 (&CC65, "--dep-target", OutputName);
+ } else {
+ /* Use the object file name as the dependency target */
+ char* ObjName = MakeFilename (File, ".o");
+ CmdAddArg2 (&CC65, "--dep-target", ObjName);
+ xfree (ObjName);
+ }
+ }
+ } else {
+ /* If we won't assemble, this is the final step. In this case, set
+ * the output name if it was given.
+ */
+ if (OutputName) {
+ CmdSetOutput (&CC65, OutputName);
+ }
}
/* Add the file as argument for the compiler */