--- C:\Dokumente und Einstellungen\Ralf\Lokale Einstellungen\Temp\svn002.tmp.py	Mon Jan 02 15:19:31 2006
+++ F:\daten\kdelibs\bksys\kde4.py	Sat Dec 31 12:41:26 2005
@@ -136,7 +136,7 @@
 	env['BUILDERS']['Meinproc']=Builder(action='$MEINPROC --check --cache $TARGET $SOURCE',suffix='.cache.bz2')
 
 	def kcfg_buildit(target, source, env):
-		comp='$KCONFIGCOMPILER -d%s %s %s' % (str(target[0].get_dir()), source[1].path, source[0].path)
+		comp='$KCONFIGCOMPILER -d%s %s %s' % (env['_BUILDDIR_'], source[1].path, source[0].path)
 		return env.Execute(comp)
 	
 	def kcfg_stringit(target, source, env):
@@ -282,50 +282,130 @@
 					print "Files generated by kconfig_compiler (settings.h, settings.cpp) must not be included"
 		return src
 
+	def kdeinstallicon(lenv, icname='*', path='./', restype='KDEICONS', subdir=''):
+		KDEicon(lenv, icname, path, restype, subdir)
+
+	def kdeInstallAuto( lenv, programname=None ):
+		""" this function automatically installs kde-specific files, to keep the SConscript files simpler
+		it does the following tasks:
+		- install *.desktop file
+		- install *ui.rc file
+		- install eventsrc file
+		- installs icon files
+		- installs *.kcfg
+		"""
+		if not env['_INSTALL_']:
+			return;
+		print "this autoinstalls kde files"
+		# try to get dir
+		if not programname:
+			mydir=SCons.Node.FS.default_fs.Dir('.').path
+			print "kdeauto dir: %s" % mydir
+			sep = SCons.Util.rightmost_separator( mydir, '/' )
+			if sep == -1:
+				progname = mydir
+			else:
+				progname = mydir[sep+1:]
+		else:
+			progname = programname
+		print "programname: %s" % progname
+
+		mydir=SCons.Node.FS.default_fs.Dir('.').path
+		import os
+		lenv.kdesktopfile( '*.desktop' )
+
+		# FIXME make checking for files in source dir work
+		#if os.path.isfile( mydir + os.sep + progname + 'ui.rc' ):
+		lenv.kdeappdata( progname + 'ui.rc*', progname )
+		#if os.path.isfile( mydir + os.sep + 'eventsrc' ):
+		lenv.kdeappdata( 'eventsrc*', progname )
+		#if os.path.isfile( mydir + os.sep + progname + '.kcfg' ):
+		lenv.kdekcfg( progname + '.kcfg*' )
+		lenv.kdeicon( progname )
+
+	def kdeinstallinternal( lenv, files, subdir, type ):
+		if not env['_INSTALL_']: return
+		print "kdeinstallinternal files: %s" % files
+		basedir=lenv.getInstDirForResType( type )
+		import string
+		if string.find( files, '*' ) == -1:
+			# no glob char in files
+			lenv.bksys_install( env.join( basedir, subdir ), files )
+		else:
+			# try to apply globbing to the files string
+			sourcedir=SCons.Node.FS.default_fs.Dir('.').srcnode()
+			
+			#import os
+			#print "cwd in kde4.py: %s" % os.getcwd()
+			#print "sourcedir: %s" % sourcedir
+			import glob
+			expandedfiles = []
+			for i in files.split():
+				tmpfiles = glob.glob( str(sourcedir) + '/' + i )
+				for tmpfile in tmpfiles:
+					expandedfiles.append( tmpfile )
+			#print "expandedfiles: %s" % expandedfiles
+			#for i in expandedfiles:
+			#	print "expanded file: %s" % i
+			lenv.bksys_install( env.join( basedir, subdir ), expandedfiles )
+
+	
+	def kdeheaders(lenv, files, subdir=''): kdeinstallinternal(lenv, files, subdir, 'KDEINCLUDE' )
+	def kdeappdata(lenv, files, subdir=''): kdeinstallinternal(lenv, files, subdir, 'KDEAPPS' )
+	def kdedata   (lenv, files, subdir=''): kdeinstallinternal(lenv, files, subdir, 'KDEDATA' )
+	def kdekcfg   (lenv, files, subdir=''): kdeinstallinternal(lenv, files, subdir, 'KDEKCFG' )
+	def kdesktopfile(lenv, files, subdir=''): kdeinstallinternal(lenv, files, subdir, 'KDEXDG' )
+
 	#valid_targets = "program convenience shlib kioslave staticlib".split()
-	from SCons.Script.SConscript import SConsEnvironment
-	class kdeobj(SConsEnvironment.qt4obj):
-		def __init__(self, val, senv=None):
-			if senv: SConsEnvironment.qt4obj.__init__(self, val, senv)
-			else: SConsEnvironment.qt4obj.__init__(self, val, env)
-		def execute(self):
-			import sys
-			if self.executed: return
-			if self.orenv.has_key('DUMPCONFIG'):
-				self.executed=1
-				self.xml()
-				return
-			if self.type=='shlib':
-				self.instdir=self.orenv.getInstDirForResType('KDELIB')
-			elif self.type=='kioslave':
-				self.instdir=self.orenv.getInstDirForResType('KDEMODULE')
-				self.libprefix=''
-				if sys.platform == 'darwin':
-					self.libsuffix='.so'
-			elif self.type=='module':
-				self.instdir=self.orenv.getInstDirForResType('KDEMODULE')
-				self.libprefix=''
-				if sys.platform == 'darwin':
-					self.libsuffix='.so'
-			elif self.type=='program':
-				self.instdir=self.orenv.getInstDirForResType('KDEBIN')
-				self.perms=0755
+ 	from SCons.Script.SConscript import SConsEnvironment
+ 	class kdeobj(SConsEnvironment.qt4obj):
+ 		def __init__(self, val, senv=None):
+ 			if senv: SConsEnvironment.qt4obj.__init__(self, val, senv)
+ 			else: SConsEnvironment.qt4obj.__init__(self, val, env)
+ 		def execute(self):
+ 			import sys
+ 			if self.executed: return
+ 			if self.orenv.has_key('DUMPCONFIG'):
+ 				self.executed=1
+ 				self.xml()
+ 				return
+ 			if self.type=='shlib':
+ 				self.instdir=self.orenv.getInstDirForResType('KDELIB')
+ 			elif self.type=='kioslave':
+ 				self.instdir=self.orenv.getInstDirForResType('KDEMODULE')
+ 				self.libprefix=''
+ 				if sys.platform == 'darwin':
+ 					self.libsuffix='.so'
+ 			elif self.type=='module':
+ 				self.instdir=self.orenv.getInstDirForResType('KDEMODULE')
+ 				self.libprefix=''
+ 				if sys.platform == 'darwin':
+ 					self.libsuffix='.so'
+ 			elif self.type=='program':
+ 				self.instdir=self.orenv.getInstDirForResType('KDEBIN')
+ 				self.perms=0755
 
-			self.env=self.orenv.Copy()
+ 			self.env=self.orenv.Copy()
 
-			self.source = KDEfiles(self.env, self.joinpath(self.target), self.joinpath(self.source))
-			SConsEnvironment.qt4obj.execute(self)
+ 			self.source = KDEfiles(self.env, self.joinpath(self.target), self.joinpath(self.source))
+ 			SConsEnvironment.qt4obj.execute(self)
 
-		def xml(self):
-			dirprefix = reldir('.')
+ 		def xml(self):
+ 			dirprefix = reldir('.')
 			if not dirprefix: dirprefix=self.dirprefix
 			ret='<compile type="%s" dirprefix="%s" target="%s" cxxflags="%s" cflags="%s" includes="%s" linkflags="%s" libpaths="%s" libs="%s" vnum="%s" libprefix="%s">\n' % (self.type, dirprefix, self.target, self.cxxflags, self.cflags, self.includes, self.linkflags, self.libpaths, self.libs, self.vnum, self.libprefix)
-			if self.source:
+ 			if self.source:
 				for i in self.orenv.make_list(self.source): ret+='    <source file="%s"/>\n' % i
 			ret+="</compile>\n"
 			self.orenv.add_dump(ret)
 
 	from SCons.Script.SConscript import SConsEnvironment
+	SConsEnvironment.kdeInstallAuto = kdeInstallAuto
+	SConsEnvironment.kdeheaders = kdeheaders
+	SConsEnvironment.kdeappdata = kdeappdata
+	SConsEnvironment.kdedata = kdedata
+	SConsEnvironment.kdekcfg = kdekcfg
+	SConsEnvironment.kdesktopfile = kdesktopfile
 	SConsEnvironment.KDEicon = KDEicon
 	SConsEnvironment.kdeobj = kdeobj
 
@@ -334,7 +414,7 @@
 			if not senv:
 				senv = env
 			SConsEnvironment.kdeobj.__init__(self, 'shlib', senv)
-		
+
 			if env['WINDOWS']:
 				self.type = 'program'
 			else:
@@ -349,20 +429,20 @@
 			if env['WINDOWS']:
 				SConsEnvironment.kdeobj.execute(self)
 				return
-        
+
 			# 'dcopserver' is the real one
 			self.binary.target   = self.target
 			# 'libkdeinit_dcopserver'
 			self.kdeinitlib.target = 'libkdeinit_' + self.target
 			# 'dcopserver' (lib)
-			
+
 			self.kdeinitlib.libs     = self.libs
 			self.kdeinitlib.libpaths = self.libpaths
 			self.kdeinitlib.uselib   = self.uselib
 			self.kdeinitlib.source   = self.source
 			self.kdeinitlib.includes = self.includes
 			self.kdeinitlib.execute()
-					
+
 			self.binary.uselib       = self.uselib
 			self.binary.libs         = [self.kdeinitlib.target + ".la"] + self.orenv.make_list(self.libs)
 			#self.binary.libdirs      = "build/dcop"
@@ -380,7 +460,7 @@
 				if sext[0] == self.target or not myname:
 					myname = sext[0]
 					myext  = sext[1]
-					
+
 			def create_kdeinit_cpp(target, source, env):
 				""" Creates the dummy kdemain file for the binary"""
 				dest=open(target[0].path, 'w')
@@ -407,9 +487,9 @@
 			env.KdeinitLaCpp(myname)
 			self.source = 'kdeinit_' + self.target + '.la.cpp'
 			# TODO scons clean?
-						
+
 			SConsEnvironment.kdeobj.execute(self)
-		
+
 	SConsEnvironment.kdeinitobj = kdeinitobj
 
 	# (js) apply KDE***FLAGS
