* as/doc/asmlnk.doc, as/doc/asxhtm.html: updated link-xx and aslink
[fw/sdcc] / as / link / z80 / lkmain.c
index cbfa64df8ce7543eda711bd443808c4459371ac7..da4719ae34c698a8d28b5d7ab223202cde5b3506 100644 (file)
@@ -7,6 +7,7 @@
  * Alan R. Baldwin
  * 721 Berkeley St.
  * Kent, Ohio  44240
+ * 31-Feb-2008 AD added -y to create cdb file for non gameboy
  */
 
 /*
@@ -320,6 +321,14 @@ main(int argc, char *argv[])
 #endif /* GAMEBOY */
 
         syminit();
+
+        if (dflag){
+            SaveLinkedFilePath(linkp->f_idp); //Must be the first one...
+            dfp = afile(linkp->f_idp,"cdb",1);
+            if (dfp == NULL)
+                lkexit(1);
+        }
+
         for (pass=0; pass<2; ++pass) {
                 cfp = NULL;
                 sfp = NULL;
@@ -449,6 +458,7 @@ lkexit(int i)
         if (rfp != NULL) fclose(rfp);
         if (sfp != NULL) fclose(sfp);
         if (tfp != NULL) fclose(tfp);
+        if (dfp != NULL) fclose(dfp);
         exit(i);
 }
 
@@ -976,11 +986,15 @@ parse()
                                 case 'J':
                                         ++symflag;
                                         break;
-                                case 'z':
                                 case 'Z':
                                         oflag = 3;
                                         break;
 #endif /* SDK */
+#ifndef GAMEBOY
+                                case 'z':
+                                        dflag = 1;
+                                        return(0);
+#endif
                                 case 'm':
                                 case 'M':
                                         ++mflag;
@@ -1039,7 +1053,6 @@ parse()
                                 case 'L':
                                         addlib();
                                         return(0);
-
                                 default:
                                         fprintf(stderr, "Invalid option\n");
                                         lkexit(1);
@@ -1404,8 +1417,11 @@ afile(char *fn, char *ft, int wf)
 #else /* SDK */
         if ((fp = fopen(fb, wf?"w":"r")) == NULL) {
 #endif /* SDK */
+            if (strcmp(ft,"adb"))/*Do not complaint for optional adb files*/
+            {
                 fprintf(stderr, "%s: cannot %s.\n", fb, wf?"create":"open");
                 lkerr++;
+            }
         }
         return (fp);
 }
@@ -1420,18 +1436,17 @@ char *usetxt[] = {
         "\n",
 #endif
         "Startup:",
-#ifdef SDK
-        "  --   [Commands]              Non-interactive command line input",
-#endif /* SDK */
         "  -c                           Command line input",
         "  -f   file[LNK]               File input",
         "  -p   Prompt and echo of file[LNK] to stdout (default)",
         "  -n   No echo of file[LNK] to stdout",
+/*
 #ifdef SDK
         "Usage: [-Options] outfile file [file ...]",
 #else /* SDK */
         "Usage: [-Options] file [file ...]",
 #endif /* SDK */
+*/
         "Libraries:",
         "  -k   Library path specification, one per -k",
         "  -l   Library file specification, one per -l",
@@ -1454,11 +1469,14 @@ char *usetxt[] = {
         "Output:",
         "  -i   Intel Hex as file[IHX]",
         "  -s   Motorola S19 as file[S19]",
+#ifndef GAMEBOY
+        "  -z   Produce SDCdb debug as file[cdb]",
+#endif
 #ifdef SDK
 #ifdef GAMEGEAR
-        "  -z   Gamegear image as file[GG]",
+        "  -Z   Gamegear image as file[GG]",
 #else
-        "  -z   Gameboy image as file[GB]",
+        "  -Z   Gameboy image as file[GB]",
 #endif /* GAMEGEAR */
 #endif /* SDK */
         "List:",
@@ -1498,3 +1516,28 @@ usage()
                 fprintf(stderr, "%s\n", *dp);
         lkexit(1);
 }
+
+/*)Function VOID    copyfile()
+ *
+ *      FILE    *dest           destination file
+ *      FILE    *src            source file
+ *
+ *      function will copy source file to destination file
+ *
+ *
+ *  functions called:
+ *      int     fgetc()         c_library
+ *      int     fputc()         c_library
+ *
+ *  side effects:
+ *      none
+ */
+VOID copyfile (dest,src)
+FILE *src,*dest ;
+{
+    int ch;
+
+    while ((ch = fgetc(src)) != EOF) {
+        fputc(ch,dest);
+    }
+}