summaryrefslogtreecommitdiffstats
path: root/win/nmakehlp.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2006-06-14 15:21:12 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2006-06-14 15:21:12 (GMT)
commit509281cd2ab88a10a9e781f373d5e59f29f3bc79 (patch)
treeb7f93c0f3fad3eccfb16e8fcd337ce453d85e1c7 /win/nmakehlp.c
parent0c32ed9ff184245f1517edf43a56d458a73b871f (diff)
downloadtcl-509281cd2ab88a10a9e781f373d5e59f29f3bc79.zip
tcl-509281cd2ab88a10a9e781f373d5e59f29f3bc79.tar.gz
tcl-509281cd2ab88a10a9e781f373d5e59f29f3bc79.tar.bz2
Enable building Tcl with Microsoft's latest compiler offering
(VS2005). We have to handle a number of oddities as they have deprecated most of the standard C library and now generate manifest files to be linked into the binaries. SF bug #1424909
Diffstat (limited to 'win/nmakehlp.c')
-rw-r--r--win/nmakehlp.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 4906303..48b82c4 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -9,9 +9,11 @@
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* ----------------------------------------------------------------------------
- * RCS: @(#) $Id: nmakehlp.c,v 1.1 2002/03/27 21:15:43 davygrvy Exp $
+ * RCS: @(#) $Id: nmakehlp.c,v 1.1.4.1 2006/06/14 15:21:15 patthoyts Exp $
* ----------------------------------------------------------------------------
*/
+
+#define _CRT_SECURE_NO_DEPRECATE
#include <windows.h>
#pragma comment (lib, "user32.lib")
#pragma comment (lib, "kernel32.lib")
@@ -41,6 +43,19 @@ main (int argc, char *argv[])
DWORD dwWritten;
int chars;
+ /*
+ * Make sure children (cl.exe and link.exe) are kept quiet.
+ */
+
+ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+
+ /*
+ * Make sure the compiler and linker aren't affected by the outside world.
+ */
+
+ SetEnvironmentVariable("CL", "");
+ SetEnvironmentVariable("LINK", "");
+
if (argc > 1 && *argv[1] == '-') {
switch (*(argv[1]+1)) {
case 'c':
@@ -90,11 +105,11 @@ CheckForCompilerFeature (const char *option)
STARTUPINFO si;
PROCESS_INFORMATION pi;
SECURITY_ATTRIBUTES sa;
- DWORD threadID;
+ DWORD threadID, n;
char msg[300];
BOOL ok;
HANDLE hProcess, h, pipeThreads[2];
- char cmdline[100];
+ char cmdline[256];
hProcess = GetCurrentProcess();
@@ -122,11 +137,16 @@ CheckForCompilerFeature (const char *option)
0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
/* base command line */
- strcpy(cmdline, "cl.exe -nologo -c -TC -Fdtemp ");
+ n = GetEnvironmentVariable("CC", cmdline, 255);
+ cmdline[n] = 0;
+ if (n == 0)
+ strcpy(cmdline, "cl.exe");
+ strncat(cmdline, " -nologo -c -TC -Zs -X ", 255);
+
/* append our option for testing */
strcat(cmdline, option);
/* filename to compile, which exists, but is nothing and empty. */
- strcat(cmdline, " nul");
+ strcat(cmdline, " .\\nul");
ok = CreateProcess(
NULL, /* Module name. */
@@ -175,8 +195,28 @@ CheckForCompilerFeature (const char *option)
CloseHandle(pipeThreads[0]);
CloseHandle(pipeThreads[1]);
- /* look for the commandline warning code in both streams. */
- return !(strstr(Out.buffer, "D4002") != NULL || strstr(Err.buffer, "D4002") != NULL);
+#ifdef _DEBUG
+ {
+ DWORD err = 0;
+ strcat(cmdline, "\n");
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), cmdline,
+ strlen(cmdline), &err, NULL);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), Out.buffer,
+ strlen(Out.buffer), &err,NULL);
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), Err.buffer,
+ strlen(Err.buffer), &err,NULL);
+ }
+#endif
+
+ /*
+ * Look for the commandline warning code in both streams.
+ * - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002.
+ */
+
+ return !(strstr(Out.buffer, "D4002") != NULL
+ || strstr(Err.buffer, "D4002") != NULL
+ || strstr(Out.buffer, "D9002") != NULL
+ || strstr(Err.buffer, "D9002") != NULL);
}
int