windowsResources/src/winRes.tmpl


/* winRes.tmpl template, R. C. Coleburn */

/*****************************************************************************/
/* The purpose of this template is to permit adding Microsoft Windows        */
/* resources, such as icons, to a compiled program.  If the target platform  */
/* is not Windows, no action is taken.  So, you can simply put the following */
/* lines in your program's m3makefile:                                       */
/*   if equal (OS_TYPE, "WIN32")                                             */
/*      import ("windowsResources")                                          */
/*      WindowsResource("MyProgramIconResourceFile")                         */
/*   end                                                                     */
/*****************************************************************************/

readonly proc WindowsResource (file) is
   local src = path_of (file & ".rc")
   local res = file & ".res"

   %
   % if backend mode is not 0, that hints at NT386MINGNU, which
   % doesn't have rc.exe, but does have windres.exe.
   %
   if equal (OS_TYPE, "WIN32")
      if defined ("_all")
         if stale (res, src)
            if equal (M3_BACKEND_MODE, "0")
              exec ("rc -DWIN32 -i", path_of(""), "-fo", res, src)
            else
              exec ("windres -DWIN32 -I", path_of(""), "-o", res, "-i", src)
            end
         end
      end
      pgm_source (res)
      deriveds ("", [res])
   end
end