/*                                                                          */
 /*                                                                          */
 /*                                                                          */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                          */
 /*                                                                          */
 /* This software is provided 'as-is', without any expressed or implied      */
 
            case 'V':
                fprintf (stderr,
-                                "ar65 V%u.%u.%u - (C) Copyright 1998-2003 Ullrich von Bassewitz\n",
-                        VER_MAJOR, VER_MINOR, VER_PATCH);
+                                "ar65 V%s - (C) Copyright 1998-2009 Ullrich von Bassewitz\n",
+                        GetVersionAsString ());
                break;
 
            default:
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2008 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
            break;
 
         case TOK_VERSION:
-            N = GenLiteralExpr (VERSION);
+            N = GenLiteralExpr (GetVersionAsNumber ());
             NextTok ();
             break;
 
 
 
     /* Print the header on the new page */
     fprintf (F,
-            "ca65 V%u.%u.%u - %s\n"
+                    "ca65 V%s - %s\n"
             "Main file   : %s\n"
             "Current file: %.*s\n"
             "\n",
-            VER_MAJOR, VER_MINOR, VER_PATCH,
-             Copyright,
+            GetVersionAsString (), Copyright,
             InFile,
             (int) SB_GetLen (CurFile), SB_GetConstBuf (CurFile));
 
 
     StrBuf Buf = STATIC_STRBUF_INITIALIZER;
 
     /* Set the translator */
-    SB_Printf (&Buf, "ca65 V%u.%u.%u", VER_MAJOR, VER_MINOR, VER_PATCH);
+    SB_Printf (&Buf, "ca65 V%s", GetVersionAsString ());
     OptTranslator (&Buf);
 
     /* Set date and time */
                        const char* Arg attribute ((unused)))
 /* Print the assembler version */
 {
-    fprintf (stderr,
-                    "ca65 V%u.%u.%u - %s\n",
-                    VER_MAJOR, VER_MINOR, VER_PATCH, Copyright);
+    fprintf (stderr, "ca65 V%s - %s\n", GetVersionAsString (), Copyright);
 }
 
 
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2009 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
     /* Identify the compiler version */
     AddTextLine (";");
-    AddTextLine ("; File generated by cc65 v %u.%u.%u",
-                VER_MAJOR, VER_MINOR, VER_PATCH);
+    AddTextLine ("; File generated by cc65 v %s", GetVersionAsString ());
     AddTextLine (";");
 
     /* Insert some object file options */
-    AddTextLine ("\t.fopt\t\tcompiler,\"cc65 v %u.%u.%u\"",
-                   VER_MAJOR, VER_MINOR, VER_PATCH);
+    AddTextLine ("\t.fopt\t\tcompiler,\"cc65 v %s\"",
+                GetVersionAsString ());
 
     /* If we're producing code for some other CPU, switch the command set */
     switch (CPU) {
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2009 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2000-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
     };
 
     /* Add macros that are always defined */
-    DefineNumericMacro ("__CC65__", VERSION);
+    DefineNumericMacro ("__CC65__", GetVersionAsNumber ());
 
     /* Language standard that is supported */
     DefineNumericMacro ("__CC65_STD_C89__", STD_C89);
 
 /* Print the compiler version */
 {
     fprintf (stderr,
-                    "cc65 V%u.%u.%u\n"
-            "SVN version: %s\n",
-                    VER_MAJOR, VER_MINOR, VER_PATCH, SVNVersion);
+                    "cc65 V%s\nSVN version: %s\n",
+                    GetVersionAsString (), SVNVersion);
     exit (EXIT_SUCCESS);
 }
 
 
 /* Print version number */
 {
     fprintf (stderr,
-            "cl65 V%u.%u.%u - (C) Copyright 1998-2005 Ullrich von Bassewitz\n",
-            VER_MAJOR, VER_MINOR, VER_PATCH);
+            "cl65 V%s - (C) Copyright 1998-2009 Ullrich von Bassewitz\n",
+            GetVersionAsString ());
 }
 
 
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2003      Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2003-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
     }
 
     /* Create a header */
-    fprintf (F, ";\n; File generated by co65 v %u.%u.%u using model `%s'\n;\n",
-             VER_MAJOR, VER_MINOR, VER_PATCH, GetModelName (Model));
+    fprintf (F, ";\n; File generated by co65 v %s using model `%s'\n;\n",
+             GetVersionAsString (), GetModelName (Model));
 
     /* Select the CPU */
     if ((D->Header.mode & O65_CPU_MASK) == O65_CPU_65816) {
     }
 
     /* Object file options */
-    fprintf (F, ".fopt\t\tcompiler,\"co65 v %u.%u.%u\"\n",
-             VER_MAJOR, VER_MINOR, VER_PATCH);
+    fprintf (F, ".fopt\t\tcompiler,\"co65 v %s\"\n", GetVersionAsString ());
     if (Author) {
         fprintf (F, ".fopt\t\tauthor, \"%s\"\n", Author);
         xfree (Author);
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2003      Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2003-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* Print the assembler version */
 {
     fprintf (stderr,
-                    "co65 V%u.%u.%u - (C) Copyright 1998-2003 Ullrich von Bassewitz\n",
-                    VER_MAJOR, VER_MINOR, VER_PATCH);
+                    "co65 V%s - (C) Copyright 1998-2009 Ullrich von Bassewitz\n",
+                    GetVersionAsString ());
 }
 
 
 
        strutil.o       \
        target.o        \
        tgttrans.o      \
+        version.o       \
        xmalloc.o       \
        xsprintf.o
 
 
        strutil.obj     \
        target.obj      \
        tgttrans.obj    \
+        version.obj     \
         wildargv.obj    \
        xmalloc.obj     \
        xsprintf.obj
 
--- /dev/null
+/*****************************************************************************/
+/*                                                                          */
+/*                                version.c                                 */
+/*                                                                          */
+/*            Version information for the cc65 compiler package             */
+/*                                                                          */
+/*                                                                          */
+/*                                                                          */
+/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 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.                                                         */
+/*                                                                          */
+/*****************************************************************************/
+
+
+
+#include "version.h"
+#include "xsprintf.h"
+
+
+
+/*****************************************************************************/
+/*                                  Data                                    */
+/*****************************************************************************/
+
+
+
+#define VER_MAJOR      2U
+#define VER_MINOR              13U
+#define VER_PATCH       0U
+#define VER_RC          0U
+
+
+
+
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+const char* GetVersionAsString (void)
+/* Returns the version number as a string in a static buffer */
+{
+    static char Buf[20];
+#if defined(VER_RC) && (VER_RC > 0U)
+    xsnprintf (Buf, sizeof (Buf), "%u.%u.%u-rc%u", VER_MAJOR, VER_MINOR, VER_PATCH, VER_RC);
+#else
+    xsnprintf (Buf, sizeof (Buf), "%u.%u.%u", VER_MAJOR, VER_MINOR, VER_PATCH);
+#endif
+    return Buf;
+}
+
+
+
+unsigned GetVersionAsNumber (void)
+/* Returns the version number as a combined unsigned for use in a #define */
+{
+    return ((VER_MAJOR * 0x100) + (VER_MINOR * 0x10) + VER_PATCH);
+}
+
+
+
 
 /*                                                                          */
 /*                                                                          */
 /*                                                                          */
-/* (C) 1998-2008, Ullrich von Bassewitz                                      */
+/* (C) 1998-2009, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
 
-#define VER_MAJOR      2U
-#define VER_MINOR      12U
-#define VER_PATCH       9U
+const char* GetVersionAsString (void);
+/* Returns the version number as a string in a static buffer */
 
-#define VERSION         ((VER_MAJOR * 0x100) + (VER_MINOR * 0x10) + VER_PATCH)
+unsigned GetVersionAsNumber (void);
+/* Returns the version number as a combined unsigned for use in a #define */
 
 
 
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2007 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2009, Ullrich von Bassewitz                                       */
+/*                Roemerstrasse 52                                            */
+/*                D-70794 Filderstadt                                         */
+/* EMail:         uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* Print the disassembler version */
 {
     fprintf (stderr,
-                    "da65 V%u.%u.%u - (C) Copyright 2000-2006, Ullrich von Bassewitz\n",
-                    VER_MAJOR, VER_MINOR, VER_PATCH);
+                    "da65 V%s - (C) Copyright 2000-2009, Ullrich von Bassewitz\n",
+                    GetVersionAsString ());  
 }
 
 
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2007 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2000-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* Print a page header */
 {
     fprintf (F,
-                    "; da65 V%u.%u.%u - (C) Copyright 2000-2005,  Ullrich von Bassewitz\n"
+                    "; da65 V%s - (C) Copyright 2000-2009,  Ullrich von Bassewitz\n"
              "; Created:    %s\n"
             "; Input file: %s\n"
             "; Page:       %u\n\n",
-                    VER_MAJOR, VER_MINOR, VER_PATCH,
+                    GetVersionAsString (),
              Now,
             InFile,
             Page);
             LineFeed ();
         }
 
-        /* Output the forward definition */ 
+        /* Output the forward definition */
         Output ("%s", Name);
         Indent (ACol);
         if (UseHexOffs) {
 
 /* Print the assembler version */
 {
     fprintf (stderr,
-                    "ld65 V%u.%u.%u - (C) Copyright 1998-2005 Ullrich von Bassewitz\n",
-            VER_MAJOR, VER_MINOR, VER_PATCH);
+                    "ld65 V%s - (C) Copyright 1998-2009, Ullrich von Bassewitz\n",
+            GetVersionAsString ());
 }
 
 
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1999-2007 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1999-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
     }
     OptBuf[OptLen] = '\0';
     O65SetOption (D, O65OPT_TIMESTAMP, OptBuf, OptLen + 1);
-    sprintf (OptBuf, "ld65 V%u.%u.%u", VER_MAJOR, VER_MINOR, VER_PATCH);
+    sprintf (OptBuf, "ld65 V%s", GetVersionAsString ());
     O65SetOption (D, O65OPT_ASM, OptBuf, strlen (OptBuf) + 1);
 
     /* Write the header */
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2002 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2000-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* Print the assembler version */
 {
     fprintf (stderr,
-                    "%s V%u.%u.%u - (C) Copyright 2000-2002 Ullrich von Bassewitz\n",
-                    ProgName, VER_MAJOR, VER_MINOR, VER_PATCH);
+                    "%s V%s - (C) Copyright 2000-2009, Ullrich von Bassewitz\n",
+                    ProgName, GetVersionAsString ());
 }
 
 
 
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2002-2005 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2002-2009, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
                        const char* Arg attribute ((unused)))
 /* Print the assembler version */
 {
-    fprintf (stderr,
-                    "sim65 V%u.%u.%u\n",
-                    VER_MAJOR, VER_MINOR, VER_PATCH);
+    fprintf (stderr, "sim65 V%s\n", GetVersionAsString ());
 }