make-w32
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

enhancement request for gmake


From: Rob Juergens
Subject: enhancement request for gmake
Date: Mon, 9 May 2011 09:51:17 -0700

In most Unix environments, the "cc" program has a switch to build either a 
32-bit or a 64-bit environment,
For example "gcc -m32 ..." or "gcc -m64 ...".

However, in Windoze, there are separate programs that must be invoked:

        32 bit: C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe
        64 bit: C:\Program Files\Microsoft Visual Studio 
9.0\VC\bin\x86_amd64\cl.exe

The result of this is that rather than depending on finding "cl.exe" in the 
path, you have to specify the full path in your command line.  The problem here 
is that the full path contains spaces, which really messes up gmake.

Now, Windoze has the ability to "shorten" a path, thus "Program Files" becomes 
"Micros~1" or something similar, which has no spaces in it.  Unfortunately, you 
cannot hard-code this short path in a makefile, since how the actual short name 
is created depends on what other files/directories are in that directory.

My suggestion:

Add a new function "shortname", which in Windoze creates a short name of the 
given name, and in all other environments just copies the name.  Thus, I can 
then do the following:

        VSINSTALLDIR := $(strip $(shortname C:/Program Files/Microsoft Visual 
Studio 9.0/VC/bin))

And then just invoke the command "$(VSINSTALLDIR)/cl.exe".

The only changes would be in function.c.  Here is the code:

#if _WIN32
#include <windows.h>
#endif

.....

static char *
func_shortname (char *o, char **argv, const char *funcname)
{
  /* Expand the argument.  */
  const char *p3 = argv[0];
  const char *p2;
  PATH_VAR(path);
  int doneany=0;
  unsigned int len=0;

  while ((p2 = find_next_token (&p3, &len)) != 0)
    {
#if _WIN32
       len = GetShortPathName(p2, path, PATH_MAX);
#else
       strcpy(buf, p2);
       len = strlen(buf);
#endif
      o = variable_buffer_output (o, path, len);
      o = variable_buffer_output (o, " ", 1);
      doneany = 1;
    }

  if (doneany)
    /* Kill last space.  */
    --o;

  return o;
}

.....

static struct function_table_entry function_table_init[] =
{
 /* Name/size */                    /* MIN MAX EXP? Function */
  ...
  { STRING_SIZE_TUPLE("shortname"),     0,  1,  1,  func_shortname},




reply via email to

[Prev in Thread] Current Thread [Next in Thread]