Index: lowlevel.py
===================================================================
--- lowlevel.py	(revision 473104)
+++ lowlevel.py	(working copy)
@@ -95,7 +95,7 @@
 	cachefile=env['CACHEDIR']+'lowlevel.cache.py'
 	opts = Options(cachefile)
 	opts.AddOptions(
-	        ('LOWLEVEL_ISCONFIGURED', ''),
+		('LOWLEVEL_ISCONFIGURED', ''),
 	)
 	opts.Update(env)
 
@@ -109,51 +109,51 @@
 		
 		## The platform-independent checks
 		dest=open(env.join(env['_BUILDDIR_'], 'config-lowlevel.h'), 'w')
-		dest.write('/* lowlevel configuration */\n')
+		dest.write('/* lowlevel configuration created by bksys */\n')
 
 		conf = env.Configure( custom_tests = { 'CheckFuncWithKdefakeImpl' : CheckFuncWithKdefakeImpl } )
 		## TODO let the caller specify which checks they want? Hopefully not turning this into one-file-per-check though...
-        	conf.CheckFuncWithKdefakeImpl(dest, 'setenv', '#include <stdlib.h>',
-					      'setenv("VAR", "VALUE", 1);',
-					      'int setenv (const char *, const char *, int)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'unsetenv', '#include <stdlib.h>',
-					      'unsetenv("VAR");',
-					      'void unsetenv (const char *)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'getdomainname', '#include <stdlib.h>\n#include <unistd.h>\n#include <netdb.h>',
-					      'char buffer[200]; getdomainname(buffer, 200);',
-					      '#include <sys/types.h>\nint getdomainname (char *, size_t)')
-        	# TODO: does not work yet on mingw
-        	if not (env['WINDOWS'] and env['CC'] == 'gcc'):
-        	        conf.CheckFuncWithKdefakeImpl(dest, 'gethostname', '#include <stdlib.h>\n#include <unistd.h>',
-					      'char buffer[200]; gethostname(buffer, 200);',
-					      'int gethostname (char *, unsigned int)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'usleep', '#include <unistd.h>',
-					      'sleep (200);',
-					      'int usleep (unsigned int)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'random', '#include <stdlib.h>',
-					      'random();',
-					      'long int random(void)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'srandom', '#include <stdlib.h>',
-					      'srandom(27);',
-					      'void srandom(unsigned int)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'initgroups', '#include <sys/types.h>\n#include <unistd.h>\n#include <grp.h>',
-					      'char buffer[200]; initgroups(buffer, 27);',
-					      'int initgroups(const char *, gid_t)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'mkstemps', '#include <stdlib.h>\n#include <unistd.h>',
-					      'mkstemps("/tmp/aaaXXXXXX", 6);',
-					      'int mkstemps(char *, int)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'mkstemp', '#include <stdlib.h>\n#include <unistd.h>',
-					      'mkstemp("/tmp/aaaXXXXXX");',
-					      'int mkstemp(char *)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'mkdtemp', '#include <stdlib.h>\n#include <unistd.h>',
-					      'mkdtemp("/tmp/aaaXXXXXX");',
-					      'char* mkdtemp(char *)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'strlcpy', '#include <string.h>',
-					      'char buf[20]; strlcpy(buf, "KDE function test", sizeof(buf));',
-					      'unsigned long strlcpy(char*, const char*, unsigned long)')
-        	conf.CheckFuncWithKdefakeImpl(dest, 'strlcat', '#include <string.h>',
-					      'char buf[20]; buf[0]=0; strlcat(buf, "KDE function test", sizeof(buf));',
-					      'unsigned long strlcat(char*, const char*, unsigned long)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'setenv', '#include <stdlib.h>',
+			'setenv("VAR", "VALUE", 1);',
+			'int setenv (const char *, const char *, int)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'unsetenv', '#include <stdlib.h>',
+			'unsetenv("VAR");',
+			'void unsetenv (const char *)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'getdomainname', '#include <stdlib.h>\n#include <unistd.h>\n#include <netdb.h>',
+			'char buffer[200]; getdomainname(buffer, 200);',
+			'#include <sys/types.h>\nint getdomainname (char *, size_t)')
+		# TODO: does not work yet on mingw
+		if not env['WINDOWS']:
+			conf.CheckFuncWithKdefakeImpl(dest, 'gethostname', '#include <stdlib.h>\n#include <unistd.h>',
+				'char buffer[200]; gethostname(buffer, 200);',
+				'int gethostname (char *, unsigned int)')
+			conf.CheckFuncWithKdefakeImpl(dest, 'usleep', '#include <unistd.h>',
+				'sleep (200);',
+				'int usleep (unsigned int)')
+			conf.CheckFuncWithKdefakeImpl(dest, 'random', '#include <stdlib.h>',
+				'random();',
+				'long int random(void)')
+			conf.CheckFuncWithKdefakeImpl(dest, 'srandom', '#include <stdlib.h>',
+				'srandom(27);',
+				'void srandom(unsigned int)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'initgroups', '#include <sys/types.h>\n#include <unistd.h>\n#include <grp.h>',
+			'char buffer[200]; initgroups(buffer, 27);',
+			'int initgroups(const char *, gid_t)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'mkstemps', '#include <stdlib.h>\n#include <unistd.h>',
+			'mkstemps("/tmp/aaaXXXXXX", 6);',
+			'int mkstemps(char *, int)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'mkstemp', '#include <stdlib.h>\n#include <unistd.h>',
+			'mkstemp("/tmp/aaaXXXXXX");',
+			'int mkstemp(char *)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'mkdtemp', '#include <stdlib.h>\n#include <unistd.h>',
+			'mkdtemp("/tmp/aaaXXXXXX");',
+			'char* mkdtemp(char *)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'strlcpy', '#include <string.h>',
+			'char buf[20]; strlcpy(buf, "KDE function test", sizeof(buf));',
+			'unsigned long strlcpy(char*, const char*, unsigned long)')
+		conf.CheckFuncWithKdefakeImpl(dest, 'strlcat', '#include <string.h>',
+			'char buf[20]; buf[0]=0; strlcat(buf, "KDE function test", sizeof(buf));',
+			'unsigned long strlcat(char*, const char*, unsigned long)')
 		# TODO finish (AC_CHECK_RES_QUERY and AC_CHECK_DN_SKIPNAME)
 		# TODO AC_CHECK_RES_INIT is a bit more complicated
 
@@ -161,6 +161,10 @@
 
 		## The platform-dependent checks
 
+		if not env['WINDOWS']:
+			dest.write("\n/* What OS used for compilation */\n#define KDE_COMPILING_OS \"%s %s %s\"\n" 
+				% (os.uname()[0], os.uname()[2], os.uname()[4]))
+
 		if sys.platform == 'darwin':
 			sys.path.insert(0,'bksys'+os.sep+'osx')
 			from detect_lowlevel import detect
Index: unix/detect_lowlevel.py
===================================================================
--- unix/detect_lowlevel.py	(revision 473104)
+++ unix/detect_lowlevel.py	(working copy)
@@ -568,9 +568,6 @@
 /* The compiled in system configuration prefix */
 #define KDESYSCONFDIR "/usr/etc"
 
-/* what OS used for compilation */
-#define KDE_COMPILING_OS "Linux 2.6.12-1.1398_FC4 i686"
-
 /* Distribution Text to append to OS */
 #define KDE_DISTRIBUTION_TEXT "compiled sources"
 
Index: libidn.py
===================================================================
--- libidn.py	(revision 473104)
+++ libidn.py	(working copy)
@@ -18,7 +18,7 @@
 		have_idn  = env.pkgConfig_findPackage('LIBIDN', 'libidn', '0.5.0')
 
     		dest=open(env.join(env['_BUILDDIR_'], 'config-libidn.h'), 'w')
-    		dest.write('/* libidn configuration */\n')
+    		dest.write('/* libidn configuration created by bksys */\n')
 		if have_idn: dest.write('#define HAVE_IDNA_H 1\n');
 		dest.close()
 		env['_CONFIG_H_'].append('libidn')
Index: compiler.py
===================================================================
--- compiler.py	(revision 473104)
+++ compiler.py	(working copy)
@@ -8,11 +8,19 @@
 	def get_compiler_version():
 		import re, os
 
+		if env['CC'] == 'cl':
+			syspf=os.popen4('cl')
+			verline=syspf[1].readline()
+			verstr=re.match('(.*Version )(.+)( for.+)', verline).group(2)
+			major=int(verstr[0:2])-6
+			minor=int(verstr[3:5])/10
+			return "msvc %d.%d (%s)" % (major, minor, verstr)
+
 		# TODO check this with other compilers
 		# TODO: and convert xlC and KCC code from kdelibs/configure.in.in
-		if env['CC'] != 'gcc' and env['CC'] != 'cl':
+		if env['CC'] != 'gcc':
 			return False
-	
+
 		error_regexp = re.compile('Usage|ERROR|unrecognized option|unknown option|WARNING|missing|###')
 		unused_regexp = re.compile('Reading specs|Using built|Configured with|Thread model|Copyright|###')
 	
Index: win32/detect_lowlevel.py
===================================================================
--- win32/detect_lowlevel.py	(revision 473104)
+++ win32/detect_lowlevel.py	(working copy)
@@ -17,15 +17,15 @@
 #define HAVE_STDLIB_H 1
 #define HAVE_SYS_TYPES_H 1
 
-/* what OS used for compilation */
-#define KDE_COMPILING_OS "Windows XP i686"
-
 /* Distribution Text to append to OS */
-#define KDE_DISTRIBUTION_TEXT "compiled sources"
+#define KDE_DISTRIBUTION_TEXT "KDE Libraries for MS Windows"
+"""
 
-/* which compiler in use */
-#define KDE_COMPILER_VERSION "gcc 3.4"
+	import sys
+	wver=sys.getwindowsversion()
+	content += """
+/* What OS used for compilation */
+#define KDE_COMPILING_OS \"MS Windows %d.%d %s\"
+""" % (wver[0], wver[1], wver[4])
 
-"""
-
 	dest.write(content)
Index: win32/detect_generic.py
===================================================================
--- win32/detect_generic.py	(revision 473104)
+++ win32/detect_generic.py	(working copy)
@@ -14,6 +14,7 @@
 	import SCons.Util
 	env['GENCXXFLAGS'] = []
 	env['CPPPATH'] = []
+	env['BKS_DEBUG']=0
 
 	# (rh) The flags from GENCCFLAGS seems to be added to GENCXXFLAGS, 
 	# so there is no need to duplicate settings in GENCXXGLAGS
@@ -24,11 +25,11 @@
 			env['GENCCFLAGS'] = ['-g']
 			env['GENLINKFLAGS'] = ['-g']
 		elif env['CC'] == 'cl':
-			env['GENCCFLAGS'] = ['-Od','-ZI','-MDd']
+			env['GENCCFLAGS'] = ['-Od','-ZI','-MDd','-GX','-GR']
 			env['GENLINKFLAGS'] = ['/INCREMENTAL', '/DEBUG']
 	else:
 		if env['CC'] == 'gcc':
-			env['GENCCFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG']
+			env['GENCCFLAGS'] = ['-O2', '-DNDEBUG', '-DNO_DEBUG','-GX','-GR']
 			env['GENLINKFLAGS'] = []
 		elif env['CC'] == 'cl':
 			env['GENCCFLAGS'] = ['-MD']
Index: generic.py
===================================================================
--- generic.py	(revision 473104)
+++ generic.py	(working copy)
@@ -17,12 +17,12 @@
 def write_config_h(lenv):
 	# put the files into the builddir
 	dest=open(lenv.join(lenv['_BUILDDIR_'], 'config.h'), 'w')
-	dest.write('/* defines are added below */\n')
+	dest.write('#ifndef BKSYS_CONFIG_H\n#define BKSYS_CONFIG_H\n\n/* defines are added below */\n')
 
 	# write the config.h including all others
 	if lenv.has_key('_CONFIG_H_'):
 		for file in lenv['_CONFIG_H_']: dest.write('#include "config-%s.h"\n' % file)
-	dest.write('\n')
+	dest.write('\n\n#endif\n')
 	dest.close()
 
 	lenv.pprint('GREEN','configuration done - run scons to compile now')
@@ -113,13 +113,14 @@
 	except: mycol=''
 	print "%s%s%s %s" % (mycol, str, env['BKS_COLORS']['NORMAL'], label)
 
-## class for building binary targets like programs, shared libraries, static libs, loadable modules and convenience libraries 
+## class for building binary targets like programs, shared libraries, static libs, 
+#  loadable modules and convenience libraries 
 #
 #
 class genobj:
 	## construct a binary target 
 	#
-	# @val type of binary object "program", "shlib", staticlib", "module", "convenience"
+	# @val type of binary object "program", "shlib", "staticlib", "module", "convenience"
 	# @env used scons environment 
 	def __init__(self, val, env):
 		# NOTE: (rh) is kioslave not a kde module ? 
@@ -167,7 +168,10 @@
 		# this value will be added at the beginning of the binary object target name 
 		# on linux e.g if the target is named \b xyaz and \b libprefix is set to \b 'lib' 
 		# the real library is named libxyz 
-		self.libprefix='lib'
+		if env['WINDOWS']:
+			self.libprefix=''
+		else:
+			self.libprefix='lib'
 
 		## a directory where to install the targets (optional)
 		self.instdir=''
@@ -277,7 +281,7 @@
 		# copy the environment if a subclass has not already done it
 		if not self.env: self.env = self.orenv.Copy()
 
-		# remove libprefix is one is given to avoid repeated libprefix
+		# remove libprefix if one is given to avoid repeated libprefix
 		if self.libprefix != '' and self.target[:len(self.libprefix)] == self.libprefix:
 			self.target = self.target[len(self.libprefix):]
 
Index: osx/detect_lowlevel.py
===================================================================
--- osx/detect_lowlevel.py	(revision 473104)
+++ osx/detect_lowlevel.py	(working copy)
@@ -586,9 +586,6 @@
 /* The compiled in system configuration prefix */
 #define KDESYSCONFDIR "/sw/etc"
 
-/* what OS used for compilation */
-#define KDE_COMPILING_OS "Darwin 8.3.0 Power Macintosh"
-
 /* Distribution Text to append to OS */
 #define KDE_DISTRIBUTION_TEXT "Fink/Mac OS X"
 
Index: openssl.py
===================================================================
--- openssl.py	(revision 473104)
+++ openssl.py	(working copy)
@@ -19,7 +19,7 @@
 		have_openssl = env.pkgConfig_findPackage('OPENSSL', 'openssl', '0.9.6')
 
 		dest=open(env.join(env['_BUILDDIR_'], 'ksslconfig.h'), 'w')
-		dest.write('/* openssl configuration */\n')
+		dest.write('/* openssl configuration created by bksys */\n')
 		if have_openssl: dest.write('#define KSSL_HAVE_SSL 1\n');
 		dest.close()
 		#env['_CONFIG_H_'].append('openssl')
Index: kde4.py
===================================================================
--- kde4.py	(revision 473104)
+++ kde4.py	(working copy)
@@ -72,7 +72,7 @@
 		detect(env)
 
 		dest=open(env.join(env['_BUILDDIR_'], 'config-kde.h'), 'w')
-		dest.write('/* kde configuration */\n')
+		dest.write('/* kde configuration created by bksys */\n')
 		dest.write(('#define KDELIBSUFF "%s"\n') % env['LIBSUFFIXEXT']);
 		dest.close()
 		env['_CONFIG_H_'].append('kde')
