bksys on win32/mingw development notes

TODO 
---- 

- complete build system 
	-	fix depending library ordering problem  (is in work)
	- add required qt defines to qt component packages 
	- fix installation of files 

- build or add notes where to get source/binary packages of required libraries 		
		- zlib 
		- bzip2 
		- libart_lgpl
		- others 
		
		it may be possible to use cygwin mirrors as a repository for source packages 
		because of its dependency feature
		the cygsetup tool from http://sf.net/projects/kde-cygwin (see cvs repository 
		tools/cygsetup) may be used a starting point 

	

History
-------

2005-10-09 Ralf Habacker 
- tried to fix broken env.kdeinitobj support
	on win32 this kdeinit support seems not be necessary because forking isn't available
	for which the kdeinit stuff is designed 

	-> in most cases using of kde4obj or qt4obj is better

- export symbols problem 
	the libDCOP shared library uses a convenience kICE library. The mingw compiler exports the symbols 
	(objdump -x shows them) but they are not exported to import library `
	-> because kICE is used in more than one libraries, build it as shared library 

- general bksys dependency problem 
	libtool has support for adding depending library automatically, which bksys does not have such 
	support. 
	For example: 
		shared libDCOP uses static libKICE, which required shared wsock32 library 
		->  you have to specifiy wsock32 as dependency for libDCOP
 

2005-10-08 Ralf Habacker 
- moved to native mingw system using a dos shell (without cygwin) to see if there are 
  some leaving path problems 
  Requirements: 
  	- Python 2.4 
		- scons-96.91 
  	- Mingw compile environment which comes with QT/win32 
		- MSYS - mingw shell environment 
		- cygwin (required for perl, see dcop/dcopidlng/dcopidl.bat) may be replaced  
		  by native perl, but havent' tested yet 

  I'm using the following configure line

set MSYS=c:\MSYS\1.0
set QTDIR=c:\Qt\4.0.1
set MINGW=c:\MingwQT
set PYTHON=c:\Python24
set CYGWIN=c:\cygwin
set PATH=%PYTHON%;%PATH%
set PATH=%QTDIR%\bin;%PATH%
set PATH=%MINGW%\bin;%PATH%
set PATH=%MSYS%\bin;%PATH%
scons configure 

- cleanup library naming 
	- using libxxx as target is platform specific better is using xxx because scons/bksys 
		will add platform specific prefix for creating and search for libraries

	- using <path>/xxx.la or <path>/xxx.a is also platform specific and must be separated 
	  from the library name 
	
	- recently I'm using the following code ('/' as delimiter in any case)
	  
	obj.libpaths = ['../libltdl','../win','../dcop','']
	obj.libs     = ['ltdlc','kdewin32','DCOP','wsock32']
	
	or

	obj.libpaths = ['../libltdl ../win ../dcop ']
	obj.libs     = ['ltdlc kdewin32 DCOP wsock32']

	or 
	
	obj.libpaths = '../libltdl ../win ../dcop '
	obj.libs     = 'ltdlc kdewin32 DCOP wsock32'
	
	note that the last library is a system library, which search path is added by default 
	
	-> a patch for this is in test phase 

btw: another approach may be using sub lists, but I currently don't if this is valid python syntax. 

	obj.libs     = [['path',lib'],['lib']]
  
 
  
- while working with the different compilers on windows I recognized that a better naming schema is required  
	if env['WINDOWS']:
		if env['CC'] == 'gcc': 
			.. this is very long  

		platform   				compiler 			MAKESPEC  	(1)
	[sys.platform] 		 	env['CC']			
	env['PLATFORM']
		win32							gcc 					win32-g++
											cl 						win32-msvc win32-msvc.net win32-msvc2005 (2)
		cygwin						gcc						cygwin-g++

		(1) this MAKESPEC definition is similar to the one QT uses 
		    (could be readed from $QTDIR/.qmake.cache)
		
		(2) currently no idea how to distinct the different compilers 
				(scons have this info internal Tool/msvs.py Tool/msvc.py)
		
		-> i suggest to add one new env variables  env['MAKESPEC'] which will be 
	


	

History
-------

2005-10-07 Ralf Habacker 
- mingw linker seems to export symbols from imported static libraries, which results in twice defined symbols in some cases 
	
	libDCOP uses kICE uses kdewin32 
	dcop.exe uses libDCOP and kdewin32 -> linking failed 
	
- _Winmain undefined errors  ->  worarkound by using a specific WinMain to main converter, qt has such support
	currently don't know ho to use 

- configure debug=1 does not set -g option for c code in cache/generic.cache.py (gcc compile line  is okay, g++ has to -g options)

- only with one manual intervention (moving libDCOP.a into the right place, see 2005-10-06.2) libdcop, dcopserver and dcop tools could be build 
	-> dcopserver segfaults
	-> dcopfind could be started 

- installed mingw zlib library and added Mingw include/lib dirs to configure command, which looks now: 
export QTDIR=/c/Qt/4.0.1 
export PATH=$QTDIR/bin:$PATH
export MINGW=/c/MingwQT
export PATH=$MINGW/bin:$PATH

scons configure

- it seems that the g++ compile command line includes CCFLAGS and CXXFLAGS, so that for CXXFLAGS no repeated setting 
  of CCFLAGS is required (I don't know if this is all the cases)



- library dependency ordering update 
   There must be a general rule adding libs 
   

 set QTDIR=c:\Qt\4.0.1
 set MINGW=c:\MingwQT
 set PYTHON=c:\Python24

 set PATH=%QTDIR%\bin;%PATH%
 set PATH=%MINGW%\bin;%PATH%
 set PATH=%PYTHON%;%PATH%


2005-10-06 Ralf Habacker 
- encountered two problems today 

	1. library dependency ordering 
	
	dcop/SConscript contains 
	
	obj.libs = ['../dcop/KDE-ICE/libkICE.a','../win/libkdewin32.la','/usr/lib/w32api/libwsock32.a']
	
	the real link is ordered like 	-lkdewin32 -lkICE -lwsock32 and there is no possibility to change the ordering 
	
	-> the problem is located genobj.execute() where shared libs and static are splitted and independently added as dependency 
	

	2. wrong output dir of import library - win32/detect_generic.py:bksys_shlib requires the recent library output dir 
			currently no idea where to get from 
	
	3. bksys requires .a and .la extension in genobj.libs attribute, which isn't platform independent 
	
		obj.libs = ['../dcop/KDE-ICE/libkICE.a','/usr/lib/w32api/libwsock32.a','../win/libkdewin32.la']
		
		if someone changes a library from static to shared and vice versa, all references must be changed 
		-> there must be used .la files at all or 
				- static libraries must be extended with .la file creation 
			the library name without the extension and prefix 
				- ['/usr/xxx/lib','mylib']  (is it possible to define sub lists e.g. ['liba',['pathb',libb']] )
				- ['mylib'] using LIBPATH


2005-10-05 Ralf Habacker 
- shared library could be build with gcc, the only problem is that the import library will not be 
  deleted when running scons -c (file seems not to be registrated by scons, install will probably fail too) 

- the compiler specific include file problem was discussed with Jaruslav and he agreed to split the win headers 
  into win/include for platform independent headers and win/include/<compiler> for platform specific headers.
  Submitted the required changes and added minimal mingw headers to compile kdewin32, KDE-ICE, kdefx and dcop. 

- first try to avoid qt related headers dependencies for runtime headers like unistd.h and pwd.h because 
  obj.genobj does not add qt headers by default. 
  
- a problem arised with bksys compiling dcop relating to library ordering. Some network related symbols are not 
  resolved in kICE. I've triedto use obj.uselibs and obk.libs to make sure kdewin32 and wsock32 are added at 
  the end of the link line without any success. 
  Using obj.uselibs does not add any library and using obj.libs like shown below places kICE at the end of the link line 

	neither 
	
		obj.libs = []
		if env['WINDOWS'] and env['CC'] == 'gcc': 
			obj.libs += ['kdewin32','wsock32'] 
		obj.libs   += [env.join('KDE-ICE', 'libkICE.a')]

	nor 

		obj.libs = []
		obj.libs   += [env.join('KDE-ICE', 'libkICE.a')]
		if env['WINDOWS'] and env['CC'] == 'gcc': 
			obj.libs += ['kdewin32','wsock32'] 

	works
  
  a workaround is to use the full path of the system library, which is not platform independent -> fix in bksys required 
  	obj.libs += [env.join('../win','libkdewin32.a')]
  	obj.libs += [env.join('/usr/lib/w32api','libwsock32.a')] 


- update configure command to 
		export QTDIR=/c/Qt/4.0.1 
		CFLAGS="-mno-cygwin " CXXFLAGS="-mno-cygwin -DUNICODE -DQT_LARGEFILE_SUPPORT \
		-DQT_EDITION=QT_EDITION_DESKTOP -DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_THREAD_SUPPORT -I$QTDIR/include" \
		LDFLAGS="-mno-cygwin" scons configure
	
	the qt definitions are required because detect_qt4.py does not provide them 
	
- kdecore could not be build because scons searchs for dcopidl2cpp and not for dcopidl2cpp.exe  -> detect_kde4.py requires a patch


2005-09-27 Ralf Habacker 
added initial win32 mingw support using cygwin build environment and -mno-cygwin flag. 

- configure with 
		export QTDIR=/c/Qt/4.0.1
	  CFLAGS="-mno-cygwin -Ikdecore -Imingw" CXXFLAGS="-mno-cygwin -Ikdecore -Imingw" LDFLAGS="-mno-cygwin" scons configure

problems 
- include files from win are partial not usable, I'm currently using a subset of them in a separate 
  folder called mingw (discussion with Jaruslav required where to place). May be the win dir should 
  have a compiler specific structure at now to reduce such conflicts until different compiler 
  support is stable. Then they could be merged together 

- CFLAGS and LDFLAGS/LINKFLAGS are not stored in cache/generic.cache.py GENCCFLAGS -> fixed in svn


