Re: enhancement request for gmake
Rob Walker <[email protected]>
| Newsgroups | gmane.comp.gnu.make.windows |
|---|---|
| Message-ID | <[email protected]> |
BrewMP ships with a make function that can be relied upon to get the
correct shortened name:
##########################################################################
# CMD_MODE
# set to yes if the shell from make is actually cmd.exe
##########################################################################
CMD_MODE:=$(if $(strip $(shell echo)),yes)
##########################################################################
# shortPath, equivalent to "cygpath -mas $1" under WinNT
shortPath=$(strip $(subst \,/,$(firstword $(subst \:cmdbug:, ,\
$(if $(CMD_MODE),\
$(shell for %%g in ( "$1\:cmdbug:" ) do echo. %%~fsg),\
$(shell cmd /Q /C for %g in \( "$1\:cmdbug:" \) do
echo. %~fsg))))))
Pardon the extra line wraps... If it's not valid make, remove a line feed.
-Rob
On 5/9/2011 9:51 AM, Rob Juergens wrote:
> 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},
>
>
> _______________________________________________
> Make-w32 mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/make-w32