Index: waflib/Tools/c_config.py
===================================================================
--- waflib/Tools/c_config.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/c_config.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -600,5 +600,5 @@
 		if out.find('__INTEL_COMPILER')>=0:
 			conf.fatal('The intel compiler pretends to be gcc')
-		if out.find('__GNUC__')<0:
+		if out.find('__GNUC__')<0 and out.find('__clang__')<0:
 			conf.fatal('Could not determine the compiler type')
 	if icc and out.find('__INTEL_COMPILER')<0:
@@ -630,7 +630,7 @@
 		if isD('__ELF__'):
 			conf.env.DEST_BINFMT='elf'
-		elif isD('__WINNT__')or isD('__CYGWIN__'):
+		elif isD('__WINNT__')or isD('__CYGWIN__')or isD('_WIN32'):
 			conf.env.DEST_BINFMT='pe'
-			conf.env.LIBDIR=conf.env['PREFIX']+'/bin'
+			conf.env.LIBDIR=conf.env.BINDIR
 		elif isD('__APPLE__'):
 			conf.env.DEST_BINFMT='mac-o'
@@ -667,4 +667,20 @@
 	else:
 		conf.fatal('Could not determine the XLC version.')
+@conf
+def get_suncc_version(conf,cc):
+	cmd=cc+['-V']
+	try:
+		out,err=conf.cmd_and_log(cmd,output=0)
+	except Errors.WafError:
+		conf.fatal('Could not find suncc %r'%cmd)
+	version=(out or err)
+	version=version.split('\n')[0]
+	version_re=re.compile(r'cc:\s+sun\s+(c\+\+|c)\s+(?P<major>\d*)\.(?P<minor>\d*)',re.I).search
+	match=version_re(version)
+	if match:
+		k=match.groupdict()
+		conf.env['CC_VERSION']=(k['major'],k['minor'])
+	else:
+		conf.fatal('Could not determine the suncc version.')
 @conf
 def add_as_needed(self):
Index: waflib/Tools/c_preproc.py
===================================================================
--- waflib/Tools/c_preproc.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/c_preproc.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -22,5 +22,5 @@
 re_pragma_once=re.compile('^\s*once\s*',re.IGNORECASE)
 re_nl=re.compile('\\\\\r*\n',re.MULTILINE)
-re_cpp=re.compile(r"""(/\*[^*]*\*+([^/*][^*]*\*+)*/)|//[^\n]*|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)""",re.MULTILINE)
+re_cpp=re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',re.DOTALL|re.MULTILINE)
 trig_def=[('??'+a,b)for a,b in zip("=-/!'()<>",r'#~\|^[]{}')]
 chr_esc={'0':0,'a':7,'b':8,'t':9,'n':10,'f':11,'v':12,'r':13,'\\':92,"'":39}
@@ -38,8 +38,8 @@
 skipped='s'
 def repl(m):
-	s=m.group(1)
-	if s:
+	s=m.group(0)
+	if s.startswith('/'):
 		return' '
-	return m.group(3)or''
+	return s
 def filter_comments(filename):
 	code=Utils.readf(filename)
@@ -476,5 +476,5 @@
 				break
 			found=self.cached_find_resource(n,filename)
-		if found:
+		if found and not found in self.ban_includes:
 			self.nodes.append(found)
 			if filename[-4:]!='.moc':
@@ -519,4 +519,5 @@
 			bld.parse_cache={}
 			self.parse_cache=bld.parse_cache
+		self.current_file=node
 		self.addlines(node)
 		if env['DEFINES']:
@@ -558,10 +559,9 @@
 				elif token=='include'or token=='import':
 					(kind,inc)=extract_include(line,self.defs)
-					if inc in self.ban_includes:
-						continue
-					if token=='import':self.ban_includes.add(inc)
 					if ve:debug('preproc: include found %s    (%s) ',inc,kind)
 					if kind=='"'or not strict_quotes:
-						self.tryfind(inc)
+						self.current_file=self.tryfind(inc)
+						if token=='import':
+							self.ban_includes.add(self.current_file)
 				elif token=='elif':
 					if state[-1]==accepted:
@@ -584,5 +584,5 @@
 				elif token=='pragma':
 					if re_pragma_once.match(line.lower()):
-						self.ban_includes.add(self.curfile)
+						self.ban_includes.add(self.current_file)
 			except Exception ,e:
 				if Logs.verbose:
Index: waflib/Tools/ccroot.py
===================================================================
--- waflib/Tools/ccroot.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/ccroot.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -3,5 +3,5 @@
 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
 
-import os
+import os,re
 from waflib import Task,Utils,Node,Errors
 from waflib.TaskGen import after_method,before_method,feature,taskgen_method,extension
@@ -71,7 +71,10 @@
 				pattern='%s'
 			folder,name=os.path.split(target)
-			if self.__class__.__name__.find('shlib')>0:
-				if self.env.DEST_BINFMT=='pe'and getattr(self.generator,'vnum',None):
-					name=name+'-'+self.generator.vnum.split('.')[0]
+			if self.__class__.__name__.find('shlib')>0 and getattr(self.generator,'vnum',None):
+				nums=self.generator.vnum.split('.')
+				if self.env.DEST_BINFMT=='pe':
+					name=name+'-'+nums[0]
+				elif self.env.DEST_OS=='openbsd':
+					pattern='%s.%s.%s'%(pattern,nums[0],nums[1])
 			tmp=folder+os.sep+pattern%name
 			target=self.generator.path.find_or_declare(tmp)
@@ -198,4 +201,6 @@
 		if getattr(y,'export_includes',None):
 			self.includes.extend(y.to_incnodes(y.export_includes))
+		if getattr(y,'export_defines',None):
+			self.env.append_value('DEFINES',self.to_list(y.export_defines))
 	for x in names:
 		try:
@@ -274,4 +279,5 @@
 		return
 	self.implib_install_task=self.bld.install_as('${LIBDIR}/%s'%implib.name,implib,self.env)
+re_vnum=re.compile('^([1-9]\\d*|0)[.]([1-9]\\d*|0)[.]([1-9]\\d*|0)$')
 @feature('cshlib','cxxshlib','dshlib','fcshlib','vnum')
 @after_method('apply_link','propagate_uselib_vars')
@@ -280,4 +286,6 @@
 		return
 	link=self.link_task
+	if not re_vnum.match(self.vnum):
+		raise Errors.WafError('Invalid version %r for %r'%(self.vnum,self))
 	nums=self.vnum.split('.')
 	node=link.outputs[0]
@@ -292,13 +300,19 @@
 		v=self.env.SONAME_ST%name2
 		self.env.append_value('LINKFLAGS',v.split())
-	self.create_task('vnum',node,[node.parent.find_or_declare(name2),node.parent.find_or_declare(name3)])
+	if self.env.DEST_OS!='openbsd':
+		self.create_task('vnum',node,[node.parent.find_or_declare(name2),node.parent.find_or_declare(name3)])
 	if getattr(self,'install_task',None):
 		self.install_task.hasrun=Task.SKIP_ME
 		bld=self.bld
 		path=self.install_task.dest
-		t1=bld.install_as(path+os.sep+name3,node,env=self.env,chmod=self.link_task.chmod)
-		t2=bld.symlink_as(path+os.sep+name2,name3)
-		t3=bld.symlink_as(path+os.sep+libname,name3)
-		self.vnum_install_task=(t1,t2,t3)
+		if self.env.DEST_OS=='openbsd':
+			libname=self.link_task.outputs[0].name
+			t1=bld.install_as('%s%s%s'%(path,os.sep,libname),node,env=self.env,chmod=self.link_task.chmod)
+			self.vnum_install_task=(t1,)
+		else:
+			t1=bld.install_as(path+os.sep+name3,node,env=self.env,chmod=self.link_task.chmod)
+			t2=bld.symlink_as(path+os.sep+name2,name3)
+			t3=bld.symlink_as(path+os.sep+libname,name3)
+			self.vnum_install_task=(t1,t2,t3)
 	if'-dynamiclib'in self.env['LINKFLAGS']:
 		try:
@@ -342,9 +356,9 @@
 		return Task.SKIP_ME
 @conf
-def read_shlib(self,name,paths=[]):
-	return self(name=name,features='fake_lib',lib_paths=paths,lib_type='shlib')
+def read_shlib(self,name,paths=[],export_includes=[],export_defines=[]):
+	return self(name=name,features='fake_lib',lib_paths=paths,lib_type='shlib',export_includes=export_includes,export_defines=export_defines)
 @conf
-def read_stlib(self,name,paths=[]):
-	return self(name=name,features='fake_lib',lib_paths=paths,lib_type='stlib')
+def read_stlib(self,name,paths=[],export_includes=[],export_defines=[]):
+	return self(name=name,features='fake_lib',lib_paths=paths,lib_type='stlib',export_includes=export_includes,export_defines=export_defines)
 lib_patterns={'shlib':['lib%s.so','%s.so','lib%s.dylib','lib%s.dll','%s.dll'],'stlib':['lib%s.a','%s.a','lib%s.dll','%s.dll','lib%s.lib','%s.lib'],}
 @feature('fake_lib')
Index: waflib/Tools/cs.py
===================================================================
--- waflib/Tools/cs.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/cs.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -104,5 +104,5 @@
 			for x in('/r:','/reference:','/resource:','/lib:','/out:'):
 				if flag.startswith(x):
-					flag='%s"%s"'%(x,flag[len(x):])
+					flag='%s"%s"'%(x,'","'.join(flag[len(x):].split(',')))
 					break
 			else:
Index: waflib/Tools/fc_config.py
===================================================================
--- waflib/Tools/fc_config.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/fc_config.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -52,6 +52,6 @@
 def fortran_modifier_darwin(conf):
 	v=conf.env
-	v['FCFLAGS_fcshlib']=['-fPIC','-compatibility_version','1','-current_version','1']
-	v['LINKFLAGS_fcshlib']=['-dynamiclib']
+	v['FCFLAGS_fcshlib']=['-fPIC']
+	v['LINKFLAGS_fcshlib']=['-dynamiclib','-Wl,-compatibility_version,1','-Wl,-current_version,1']
 	v['fcshlib_PATTERN']='lib%s.dylib'
 	v['FRAMEWORKPATH_ST']='-F%s'
Index: waflib/Tools/gcc.py
===================================================================
--- waflib/Tools/gcc.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/gcc.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -3,6 +3,4 @@
 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
 
-import os,sys
-from waflib import Configure,Options,Utils
 from waflib.Tools import ccroot,ar
 from waflib.Configure import conf
@@ -60,6 +58,6 @@
 def gcc_modifier_darwin(conf):
 	v=conf.env
-	v['CFLAGS_cshlib']=['-fPIC','-compatibility_version','1','-current_version','1']
-	v['LINKFLAGS_cshlib']=['-dynamiclib']
+	v['CFLAGS_cshlib']=['-fPIC']
+	v['LINKFLAGS_cshlib']=['-dynamiclib','-Wl,-compatibility_version,1','-Wl,-current_version,1']
 	v['cshlib_PATTERN']='lib%s.dylib'
 	v['FRAMEWORKPATH_ST']='-F%s'
@@ -84,4 +82,7 @@
 	v['cshlib_PATTERN']='lib%s.sl'
 @conf
+def gcc_modifier_openbsd(conf):
+	conf.env.SONAME_ST=[]
+@conf
 def gcc_modifier_platform(conf):
 	gcc_modifier_func=getattr(conf,'gcc_modifier_'+conf.env.DEST_OS,None)
Index: waflib/Tools/gxx.py
===================================================================
--- waflib/Tools/gxx.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/gxx.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -3,6 +3,4 @@
 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
 
-import os,sys
-from waflib import Configure,Options,Utils
 from waflib.Tools import ccroot,ar
 from waflib.Configure import conf
@@ -60,6 +58,6 @@
 def gxx_modifier_darwin(conf):
 	v=conf.env
-	v['CXXFLAGS_cxxshlib']=['-fPIC','-compatibility_version','1','-current_version','1']
-	v['LINKFLAGS_cxxshlib']=['-dynamiclib']
+	v['CXXFLAGS_cxxshlib']=['-fPIC']
+	v['LINKFLAGS_cxxshlib']=['-dynamiclib','-Wl,-compatibility_version,1','-Wl,-current_version,1']
 	v['cxxshlib_PATTERN']='lib%s.dylib'
 	v['FRAMEWORKPATH_ST']='-F%s'
@@ -84,4 +82,7 @@
 	v['cxxshlib_PATTERN']='lib%s.sl'
 @conf
+def gxx_modifier_openbsd(conf):
+	conf.env.SONAME_ST=[]
+@conf
 def gxx_modifier_platform(conf):
 	gxx_modifier_func=getattr(conf,'gxx_modifier_'+conf.env.DEST_OS,None)
Index: waflib/Tools/javaw.py
===================================================================
--- waflib/Tools/javaw.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/javaw.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -203,5 +203,5 @@
 		finally:
 			if tmp:
-				os.unlink(tmp)
+				os.remove(tmp)
 		return ret
 	def post_run(self):
@@ -271,7 +271,5 @@
 	shutil.rmtree(javatestdir,True)
 	os.mkdir(javatestdir)
-	java_file=open(os.path.join(javatestdir,'Test.java'),'w')
-	java_file.write(class_check_source)
-	java_file.close()
+	Utils.writef(os.path.join(javatestdir,'Test.java'),class_check_source)
 	self.exec_command(self.env['JAVAC']+[os.path.join(javatestdir,'Test.java')],shell=False)
 	cmd=self.env['JAVA']+['-cp',classpath,'Test',classname]
Index: waflib/Tools/msvc.py
===================================================================
--- waflib/Tools/msvc.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/msvc.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -4,5 +4,5 @@
 
 import os,sys,re,tempfile
-from waflib import Utils,Task,Logs,Options
+from waflib import Utils,Task,Logs,Options,Errors
 from waflib.Logs import debug,warn
 from waflib.TaskGen import after_method,feature
@@ -29,5 +29,5 @@
 wintrust wldap32 wmiutils wow32 ws2_32 wsnmp32 wsock32 wst wtsapi32 xaswitch xolehlp
 '''.split()
-all_msvc_platforms=[('x64','amd64'),('x86','x86'),('ia64','ia64'),('x86_amd64','amd64'),('x86_ia64','ia64')]
+all_msvc_platforms=[('x64','amd64'),('x86','x86'),('ia64','ia64'),('x86_amd64','amd64'),('x86_ia64','ia64'),('x86_arm','arm')]
 all_wince_platforms=[('armv4','arm'),('armv4i','arm'),('mipsii','mips'),('mipsii_fp','mips'),('mipsiv','mips'),('mipsiv_fp','mips'),('sh4','sh'),('x86','cex86')]
 all_icl_platforms=[('intel64','amd64'),('em64t','amd64'),('ia32','x86'),('Itanium','ia64')]
@@ -67,5 +67,5 @@
 echo PATH=%%PATH%%
 echo INCLUDE=%%INCLUDE%%
-echo LIB=%%LIB%%
+echo LIB=%%LIB%%;%%LIBPATH%%
 """%(vcvars,target))
 	sout=conf.cmd_and_log(['cmd','/E:on','/V:on','/C',batfile.abspath()])
@@ -73,15 +73,4 @@
 	if not lines[0]:
 		lines.pop(0)
-	if version=='11.0':
-		if lines[0].startswith('Error'):
-			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_1)')
-	else:
-		for x in('Setting environment','Setting SDK environment','Intel(R) C++ Compiler','Intel Parallel Studio','Intel(R) Parallel Studio','Intel(R) Composer','Intel Corporation. All rights reserved.'):
-			if lines[0].find(x)>-1:
-				lines.pop(0)
-				break
-		else:
-			debug('msvc: get_msvc_version: %r %r %r -> not found',compiler,version,target)
-			conf.fatal('msvc: Could not find a valid architecture for building (get_msvc_version_2)')
 	MSVC_PATH=MSVC_INCDIR=MSVC_LIBDIR=None
 	for line in lines:
@@ -233,5 +222,6 @@
 		except conf.errors.ConfigurationError:
 			pass
-	versions.append(('msvc '+version,targets))
+	if targets:
+		versions.append(('msvc '+version,targets))
 @conf
 def gather_wince_targets(conf,versions,version,vc_path,vsvars,supported_platforms):
@@ -254,4 +244,14 @@
 			versions.append((device+' '+version,cetargets))
 @conf
+def gather_winphone_targets(conf,versions,version,vc_path,vsvars):
+	targets=[]
+	for target,realtarget in all_msvc_platforms[::-1]:
+		try:
+			targets.append((target,(realtarget,conf.get_msvc_version('winphone',version,target,vsvars))))
+		except conf.errors.ConfigurationError ,e:
+			pass
+	if targets:
+		versions.append(('winphone '+version,targets))
+@conf
 def gather_msvc_versions(conf,versions):
 	vc_paths=[]
@@ -272,4 +272,7 @@
 		if wince_supported_platforms and os.path.isfile(vsvars):
 			conf.gather_wince_targets(versions,version,vc_path,vsvars,wince_supported_platforms)
+		vsvars=os.path.join(vs_path,'VC','WPSDK','WP80','vcvarsphoneall.bat')
+		if os.path.isfile(vsvars):
+			conf.gather_winphone_targets(versions,'8.0',vc_path,vsvars)
 	for version,vc_path in vc_paths:
 		vs_path=os.path.dirname(vc_path)
@@ -370,8 +373,10 @@
 					patch_url='http://software.intel.com/en-us/forums/topic/328487'
 					compilervars_arch=os.path.join(path,'bin','compilervars_arch.bat')
-					vs_express_path=os.environ['VS110COMNTOOLS']+r'..\IDE\VSWinExpress.exe'
-					dev_env_path=os.environ['VS110COMNTOOLS']+r'..\IDE\devenv.exe'
-					if(r'if exist "%VS110COMNTOOLS%..\IDE\VSWinExpress.exe"'in Utils.readf(compilervars_arch)and not os.path.exists(vs_express_path)and not os.path.exists(dev_env_path)):
-						Logs.warn(('The Intel compilervar_arch.bat only checks for one Visual Studio SKU ''(VSWinExpress.exe) but it does not seem to be installed at %r. ''The intel command line set up will fail to configure unless the file %r''is patched. See: %s')%(vs_express_path,compilervars_arch,patch_url))
+					for vscomntool in['VS110COMNTOOLS','VS100COMNTOOLS']:
+						if vscomntool in os.environ:
+							vs_express_path=os.environ[vscomntool]+r'..\IDE\VSWinExpress.exe'
+							dev_env_path=os.environ[vscomntool]+r'..\IDE\devenv.exe'
+							if(r'if exist "%VS110COMNTOOLS%..\IDE\VSWinExpress.exe"'in Utils.readf(compilervars_arch)and not os.path.exists(vs_express_path)and not os.path.exists(dev_env_path)):
+								Logs.warn(('The Intel compilervar_arch.bat only checks for one Visual Studio SKU ''(VSWinExpress.exe) but it does not seem to be installed at %r. ''The intel command line set up will fail to configure unless the file %r''is patched. See: %s')%(vs_express_path,compilervars_arch,patch_url))
 			except WindowsError:
 				pass
@@ -545,6 +550,7 @@
 		conf.find_program('MT',path_list=path,var='MT')
 		v['MTFLAGS']=['/NOLOGO']
-	conf.load('winres')
-	if not conf.env['WINRC']:
+	try:
+		conf.load('winres')
+	except Errors.WafError:
 		warn('Resource compiler not found. Compiling resource file is disabled')
 @conf
@@ -564,9 +570,8 @@
 	v['CC_SRC_F']=''
 	v['CC_TGT_F']=['/c','/Fo']
-	if v['MSVC_VERSION']>=8:
-		v['CC_TGT_F']=['/FC']+v['CC_TGT_F']
 	v['CXX_SRC_F']=''
 	v['CXX_TGT_F']=['/c','/Fo']
-	if v['MSVC_VERSION']>=8:
+	if(v.MSVC_COMPILER=='msvc'and v.MSVC_VERSION>=8)or(v.MSVC_COMPILER=='wsdk'and v.MSVC_VERSION>=6):
+		v['CC_TGT_F']=['/FC']+v['CC_TGT_F']
 		v['CXX_TGT_F']=['/FC']+v['CXX_TGT_F']
 	v['CPPPATH_ST']='/I%s'
@@ -682,5 +687,4 @@
 	return ret
 def exec_command_msvc(self,*k,**kw):
-	assert self.env['CC_NAME']=='msvc'
 	if isinstance(k[0],list):
 		lst=[]
@@ -725,2 +729,21 @@
 for k in'c cxx cprogram cxxprogram cshlib cxxshlib cstlib cxxstlib'.split():
 	wrap_class(k)
+def make_winapp(self,family):
+	append=self.env.append_unique
+	append('DEFINES','WINAPI_FAMILY=%s'%family)
+	append('CXXFLAGS','/ZW')
+	append('CXXFLAGS','/TP')
+	for lib_path in self.env.LIBPATH:
+		append('CXXFLAGS','/AI%s'%lib_path)
+@feature('winphoneapp')
+@after_method('process_use')
+@after_method('propagate_uselib_vars')
+def make_winphone_app(self):
+	make_winapp(self,'WINAPI_FAMILY_PHONE_APP')
+	conf.env.append_unique('LINKFLAGS','/NODEFAULTLIB:ole32.lib')
+	conf.env.append_unique('LINKFLAGS','PhoneAppModelHost.lib')
+@feature('winapp')
+@after_method('process_use')
+@after_method('propagate_uselib_vars')
+def make_windows_app(self):
+	make_winapp(self,'WINAPI_FAMILY_DESKTOP_APP')
Index: waflib/Tools/python.py
===================================================================
--- waflib/Tools/python.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/python.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -171,5 +171,5 @@
 	conf.parse_flags(all_flags,'PYEXT')
 	result=None
-	for name in('python'+env['PYTHON_VERSION'],'python'+env['PYTHON_VERSION'].replace('.','')):
+	for name in('python'+env['PYTHON_VERSION'],'python'+env['PYTHON_VERSION']+'m','python'+env['PYTHON_VERSION'].replace('.','')):
 		if not result and env['LIBPATH_PYEMBED']:
 			path=env['LIBPATH_PYEMBED']
@@ -231,7 +231,10 @@
 	except conf.errors.ConfigurationError:
 		xx=conf.env.CXX_NAME and'cxx'or'c'
-		conf.check_cfg(msg='Asking python-config for the flags (pyembed)',path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=['--cflags','--libs','--ldflags'])
+		flags=['--cflags','--libs','--ldflags']
+		for f in flags:
+			conf.check_cfg(msg='Asking python-config for pyembed %s flags'%f,path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=[f])
 		conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx))
-		conf.check_cfg(msg='Asking python-config for the flags (pyext)',path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=['--cflags','--libs','--ldflags'])
+		for f in flags:
+			conf.check_cfg(msg='Asking python-config for pyext %s flags'%f,path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=[f])
 		conf.check(header_name='Python.h',define_name='HAVE_PYTHON_H',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions')
 @conf
Index: waflib/Tools/qt4.py
===================================================================
--- waflib/Tools/qt4.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/qt4.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -21,6 +21,6 @@
 EXT_UI=['.ui']
 EXT_QT4=['.cpp','.cc','.cxx','.C']
-QT4_LIBS="QtCore QtGui QtUiTools QtNetwork QtOpenGL QtSql QtSvg QtTest QtXml QtXmlPatterns QtWebKit Qt3Support QtHelp QtScript QtDeclarative"
-class qxx(cxx.cxx):
+QT4_LIBS="QtCore QtGui QtUiTools QtNetwork QtOpenGL QtSql QtSvg QtTest QtXml QtXmlPatterns QtWebKit Qt3Support QtHelp QtScript QtDeclarative QtDesigner"
+class qxx(Task.classes['cxx']):
 	def __init__(self,*k,**kw):
 		Task.Task.__init__(self,*k,**kw)
@@ -28,9 +28,13 @@
 	def scan(self):
 		(nodes,names)=c_preproc.scan(self)
+		lst=[]
 		for x in nodes:
 			if x.name.endswith('.moc'):
-				nodes.remove(x)
-				names.append(x.path_from(self.inputs[0].parent.get_bld()))
-		return(nodes,names)
+				s=x.path_from(self.inputs[0].parent.get_bld())
+				if s not in names:
+					names.append(s)
+			else:
+				lst.append(x)
+		return(lst,names)
 	def runnable_status(self):
 		if self.moc_done:
@@ -42,4 +46,19 @@
 			self.add_moc_tasks()
 			return Task.Task.runnable_status(self)
+	def create_moc_task(self,h_node,m_node):
+		try:
+			moc_cache=self.generator.bld.moc_cache
+		except AttributeError:
+			moc_cache=self.generator.bld.moc_cache={}
+		try:
+			return moc_cache[h_node]
+		except KeyError:
+			tsk=moc_cache[h_node]=Task.classes['moc'](env=self.env,generator=self.generator)
+			tsk.set_inputs(h_node)
+			tsk.set_outputs(m_node)
+			gen=self.generator.bld.producer
+			gen.outstanding.insert(0,tsk)
+			gen.total+=1
+			return tsk
 	def add_moc_tasks(self):
 		node=self.inputs[0]
@@ -91,10 +110,5 @@
 				raise Errors.WafError('no header found for %r which is a moc file'%d)
 			bld.node_deps[(self.inputs[0].parent.abspath(),m_node.name)]=h_node
-			task=Task.classes['moc'](env=self.env,generator=self.generator)
-			task.set_inputs(h_node)
-			task.set_outputs(m_node)
-			gen=bld.producer
-			gen.outstanding.insert(0,task)
-			gen.total+=1
+			task=self.create_moc_task(h_node,m_node)
 			moctasks.append(task)
 		tmp_lst=bld.raw_deps[self.uid()]=mocfiles
@@ -103,10 +117,5 @@
 			name=d.name
 			if name.endswith('.moc'):
-				task=Task.classes['moc'](env=self.env,generator=self.generator)
-				task.set_inputs(bld.node_deps[(self.inputs[0].parent.abspath(),name)])
-				task.set_outputs(d)
-				gen=bld.producer
-				gen.outstanding.insert(0,task)
-				gen.total+=1
+				task=self.create_moc_task(bld.node_deps[(self.inputs[0].parent.abspath(),name)],d)
 				moctasks.append(task)
 		self.run_after.update(set(moctasks))
@@ -176,5 +185,5 @@
 			else:
 				lst.append(flag)
-	self.env['MOC_FLAGS']=lst
+	self.env.append_value('MOC_FLAGS',lst)
 @extension(*EXT_QT4)
 def cxx_hook(self,node):
@@ -225,4 +234,5 @@
 	self.find_qt4_binaries()
 	self.set_qt4_libs_to_check()
+	self.set_qt4_defines()
 	self.find_qt4_libraries()
 	self.add_qt4_rpath()
@@ -406,5 +416,5 @@
 def add_qt4_rpath(self):
 	env=self.env
-	if Options.options.want_rpath:
+	if getattr(Options.options,'want_rpath',False):
 		def process_rpath(vars_,coreval):
 			for d in vars_:
@@ -430,4 +440,12 @@
 		self.qt4_vars_debug=[a+'_debug'for a in self.qt4_vars]
 	self.qt4_vars_debug=Utils.to_list(self.qt4_vars_debug)
+@conf
+def set_qt4_defines(self):
+	if sys.platform!='win32':
+		return
+	for x in self.qt4_vars:
+		y=x[2:].upper()
+		self.env.append_unique('DEFINES_%s'%x.upper(),'QT_%s_LIB'%y)
+		self.env.append_unique('DEFINES_%s_DEBUG'%x.upper(),'QT_%s_LIB'%y)
 def options(opt):
 	opt.add_option('--want-rpath',action='store_true',default=False,dest='want_rpath',help='enable the rpath for qt libraries')
Index: waflib/Tools/suncc.py
===================================================================
--- waflib/Tools/suncc.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/suncc.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -22,4 +22,5 @@
 	v['CC']=cc
 	v['CC_NAME']='sun'
+	conf.get_suncc_version(cc)
 @conf
 def scc_common_flags(conf):
Index: waflib/Tools/suncxx.py
===================================================================
--- waflib/Tools/suncxx.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/suncxx.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -23,4 +23,5 @@
 	v['CXX']=cc
 	v['CXX_NAME']='sun'
+	conf.get_suncc_version(cc)
 @conf
 def sxx_common_flags(conf):
Index: waflib/Tools/tex.py
===================================================================
--- waflib/Tools/tex.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/tex.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -79,5 +79,8 @@
 							Logs.debug('tex: trying %s%s'%(path,k))
 							found=node.parent.find_resource(path+k)
-							if found and not found in self.outputs:
+							for tsk in self.generator.tasks:
+								if not found or found in tsk.outputs:
+									break
+							else:
 								nodes.append(found)
 								add_name=False
@@ -97,20 +100,16 @@
 			raise Errors.WafError("%r command exit status %r"%(msg,retcode))
 	def bibfile(self):
-		need_bibtex=False
-		try:
-			for aux_node in self.aux_nodes:
+		for aux_node in self.aux_nodes:
+			try:
 				ct=aux_node.read()
-				if g_bibtex_re.findall(ct):
-					need_bibtex=True
-					break
-		except(OSError,IOError):
-			Logs.error('error bibtex scan')
-		else:
-			if need_bibtex:
+			except(OSError,IOError):
+				Logs.error('Error reading %s: %r'%aux_node.abspath())
+				continue
+			if g_bibtex_re.findall(ct):
 				Logs.warn('calling bibtex')
 				self.env.env={}
 				self.env.env.update(os.environ)
 				self.env.env.update({'BIBINPUTS':self.TEXINPUTS,'BSTINPUTS':self.TEXINPUTS})
-				self.env.SRCFILE=self.aux_nodes[0].name[:-4]
+				self.env.SRCFILE=aux_node.name[:-4]
 				self.check_status('error when calling bibtex',self.bibtex_fun())
 	def bibunits(self):
@@ -139,4 +138,8 @@
 			self.env.env={}
 			self.check_status('error when calling makeindex %s'%idx_path,self.makeindex_fun())
+	def bibtopic(self):
+		p=self.inputs[0].parent.get_bld()
+		if os.path.exists(os.path.join(p.abspath(),'btaux.aux')):
+			self.aux_nodes+=p.ant_glob('*[0-9].aux')
 	def run(self):
 		env=self.env
@@ -159,4 +162,5 @@
 		self.aux_nodes=self.scan_aux(node.change_ext('.aux'))
 		self.idx_node=node.change_ext('.idx')
+		self.bibtopic()
 		self.bibfile()
 		self.bibunits()
@@ -230,11 +234,14 @@
 			except KeyError:
 				tree.node_deps[task.uid()]=deps_lst
+		v=dict(os.environ)
+		p=node.parent.abspath()+os.pathsep+self.path.abspath()+os.pathsep+self.path.get_bld().abspath()+os.pathsep+v.get('TEXINPUTS','')+os.pathsep
+		v['TEXINPUTS']=p
 		if self.type=='latex':
 			if'ps'in outs:
 				tsk=self.create_task('dvips',task.outputs,node.change_ext('.ps'))
-				tsk.env.env={'TEXINPUTS':node.parent.abspath()+os.pathsep+self.path.abspath()+os.pathsep+self.path.get_bld().abspath()}
+				tsk.env.env=dict(v)
 			if'pdf'in outs:
 				tsk=self.create_task('dvipdf',task.outputs,node.change_ext('.pdf'))
-				tsk.env.env={'TEXINPUTS':node.parent.abspath()+os.pathsep+self.path.abspath()+os.pathsep+self.path.get_bld().abspath()}
+				tsk.env.env=dict(v)
 		elif self.type=='pdflatex':
 			if'ps'in outs:
Index: waflib/Tools/waf_unit_test.py
===================================================================
--- waflib/Tools/waf_unit_test.py	(revision 0fa325b040d442d9b1c268f55d85c2879fff77f1)
+++ waflib/Tools/waf_unit_test.py	(revision 988345f8275ddf91d02daef58b175f63004de716)
@@ -37,5 +37,7 @@
 				for tg in g:
 					if getattr(tg,'link_task',None):
-						lst.append(tg.link_task.outputs[0].parent.abspath())
+						s=tg.link_task.outputs[0].parent.abspath()
+						if s not in lst:
+							lst.append(s)
 			def add_path(dct,path,var):
 				dct[var]=os.pathsep.join(Utils.to_list(path)+[os.environ.get(var,'')])
