Clarify tooltip for 'Align to View' option for adding objects -
[blender.git] / SConstruct
index 83ec6c1b7189dbdcfa53bfbd3e925c884f3b05f6..30d8788f040936311e892937c4da87d9a4187c15 100644 (file)
@@ -124,7 +124,10 @@ if toolset:
                #if env:
                #       btools.SetupSpawn(env)
 else:
-       env = BlenderEnvironment(ENV = os.environ)
+       if bitness==64 and platform=='win32':
+               env = BlenderEnvironment(ENV = os.environ, MSVS_ARCH='amd64')
+       else:
+               env = BlenderEnvironment(ENV = os.environ)
 
 if not env:
        print "Could not create a build environment"
@@ -166,7 +169,9 @@ if crossbuild and env['PLATFORM'] != 'win32':
        env.Tool('crossmingw', ['tools'])
        # todo: determine proper libs/includes etc.
        # Needed for gui programs, console programs should do without it
-       env.Append(LINKFLAGS=['-mwindows'])
+
+       # Now we don't need this option to have console window
+       # env.Append(LINKFLAGS=['-mwindows'])
 
 userconfig = B.arguments.get('BF_CONFIG', 'user-config.py')
 # first read platform config. B.arguments will override
@@ -183,14 +188,28 @@ opts.Update(env)
 if not env['BF_FANCY']:
        B.bc.disable()
 
+
+# remove install dir so old and new files are not mixed.
+# NOTE: only do the scripts directory for now, otherwise is too disruptive for developers
+# TODO: perhaps we need an option (off by default) to not do this altogether...
+if not env['WITHOUT_BF_INSTALL'] and not env['WITHOUT_BF_OVERWRITE_INSTALL']:
+       scriptsDir = env['BF_INSTALLDIR'] + os.sep + '.blender' + os.sep + 'scripts'
+       if os.path.isdir(scriptsDir):
+               print B.bc.OKGREEN + "Clearing installation directory%s: %s" % (B.bc.ENDC, os.path.abspath(scriptsDir))
+               shutil.rmtree(scriptsDir)
+
+
 SetOption('num_jobs', int(env['BF_NUMJOBS']))
-print "Build with %d parallel jobs" % (GetOption('num_jobs'))
+print B.bc.OKGREEN + "Build with parallel jobs%s: %s" % (B.bc.ENDC, GetOption('num_jobs'))
 
-# disable elbeem (fluidsim) compilation?
-if env['BF_NO_ELBEEM'] == 1:
-       env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
-       env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
-       env['CCFLAGS'].append('-DDISABLE_ELBEEM')
+# BLENDERPATH is a unix only option to enable typical style paths this is
+# spesifically a data-dir, which is used a lot but cant replace BF_INSTALLDIR
+# because the blender binary is installed in $BF_INSTALLDIR/bin/blender
+
+if env['WITH_BF_FHS']:
+       BLENDERPATH = os.path.join(env['BF_INSTALLDIR'], 'share', 'blender', env['BF_VERSION'])
+else:
+       BLENDERPATH = env['BF_INSTALLDIR']
 
 if env['WITH_BF_OPENMP'] == 1:
                if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
@@ -198,7 +217,7 @@ if env['WITH_BF_OPENMP'] == 1:
                                env['CPPFLAGS'].append('/openmp')
                                env['CXXFLAGS'].append('/openmp')
                else:
-                       if env['CC'][-3:] == 'icc': # to be able to handle CC=/opt/bla/icc case
+                       if env['CC'].endswith('icc'): # to be able to handle CC=/opt/bla/icc case
                                env.Append(LINKFLAGS=['-openmp', '-static-intel'])
                                env['CCFLAGS'].append('-openmp')
                                env['CPPFLAGS'].append('-openmp')
@@ -208,6 +227,16 @@ if env['WITH_BF_OPENMP'] == 1:
                                env.Append(CPPFLAGS=['-fopenmp'])
                                env.Append(CXXFLAGS=['-fopenmp'])
 
+if env['WITH_GHOST_COCOA'] == True:
+       env.Append(CFLAGS=['-DGHOST_COCOA']) 
+       env.Append(CXXFLAGS=['-DGHOST_COCOA'])
+       env.Append(CPPFLAGS=['-DGHOST_COCOA'])
+    
+if env['USE_QTKIT'] == True:
+       env.Append(CFLAGS=['-DUSE_QTKIT']) 
+       env.Append(CXXFLAGS=['-DUSE_QTKIT'])
+       env.Append(CPPFLAGS=['-DUSE_QTKIT'])
+
 #check for additional debug libnames
 
 if env.has_key('BF_DEBUG_LIBS'):
@@ -215,40 +244,6 @@ if env.has_key('BF_DEBUG_LIBS'):
 
 printdebug = B.arguments.get('BF_LISTDEBUG', 0)
 
-# see if this linux distro has libalut
-
-if env['OURPLATFORM'] == 'linux2' :
-       if env['WITH_BF_OPENAL']:
-               mylib_test_source_file = """
-               #include "AL/alut.h"
-               int main(int argc, char **argv)
-               {
-                       alutGetMajorVersion();
-                       return 0;
-               }
-               """
-
-               def CheckFreeAlut(context,env):
-                       context.Message( B.bc.OKGREEN + "Linux platform detected:\n  checking for FreeAlut... " + B.bc.ENDC )
-                       env['LIBS'] = 'alut'
-                       result = context.TryLink(mylib_test_source_file, '.c')
-                       context.Result(result)
-                       return result
-
-               env2 = env.Clone( LIBPATH = env['BF_OPENAL'] ) 
-               sconf_temp = mkdtemp()
-               conf = Configure( env2, {'CheckFreeAlut' : CheckFreeAlut}, sconf_temp, '/dev/null' )
-               if conf.CheckFreeAlut( env2 ):
-                       env['BF_OPENAL_LIB'] += ' alut'
-               del env2
-               root = ''
-               for root, dirs, files in os.walk(sconf_temp, topdown=False):
-                       for name in files:
-                               os.remove(os.path.join(root, name))
-                       for name in dirs:
-                               os.rmdir(os.path.join(root, name))
-               if root: os.rmdir(root)
-
 if len(B.quickdebug) > 0 and printdebug != 0:
        print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
        for l in B.quickdebug:
@@ -295,13 +290,19 @@ if 'blenderlite' in B.targets:
                if k not in B.arguments:
                        env[k] = v
 
+# disable elbeem (fluidsim) compilation?
+if env['BF_NO_ELBEEM'] == 1:
+       env['CPPFLAGS'].append('-DDISABLE_ELBEEM')
+       env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
+       env['CCFLAGS'].append('-DDISABLE_ELBEEM')
+
 if env['WITH_BF_SDL'] == False and env['OURPLATFORM'] in ('win32-vc', 'win32-ming', 'win64-vc'):
        env['PLATFORM_LINKFLAGS'].remove('/ENTRY:mainCRTStartup')
        env['PLATFORM_LINKFLAGS'].append('/ENTRY:main')
 
 # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
 B.root_build_dir = env['BF_BUILDDIR']
-B.doc_build_dir = env['BF_DOCDIR']
+B.doc_build_dir = os.path.join(BLENDERPATH, 'doc')
 if not B.root_build_dir[-1]==os.sep:
        B.root_build_dir += os.sep
 if not B.doc_build_dir[-1]==os.sep:
@@ -356,7 +357,7 @@ if not os.path.isdir ( B.root_build_dir):
        os.makedirs ( B.root_build_dir + 'extern' )
        os.makedirs ( B.root_build_dir + 'lib' )
        os.makedirs ( B.root_build_dir + 'bin' )
-if not os.path.isdir(B.doc_build_dir):
+if not os.path.isdir(B.doc_build_dir) and env['WITH_BF_DOCS']:
        os.makedirs ( B.doc_build_dir )
 
 Help(opts.GenerateHelpText(env))
@@ -370,7 +371,7 @@ else:
        if toolset=='msvc':
                B.msvc_hack(env)
 
-print B.bc.HEADER+'Building in '+B.bc.ENDC+B.root_build_dir
+print B.bc.HEADER+'Building in: ' + B.bc.ENDC + os.path.abspath(B.root_build_dir)
 env.SConsignFile(B.root_build_dir+'scons-signatures')
 B.init_lib_dict()
 
@@ -401,7 +402,7 @@ thestatlibs, thelibincs = B.setup_staticlibs(env)
 thesyslibs = B.setup_syslibs(env)
 
 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
-       env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
+       env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist + thestatlibs, [], thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
 if env['WITH_BF_PLAYER']:
        playerlist = B.create_blender_liblist(env, 'player')
        playerlist += B.create_blender_liblist(env, 'intern')
@@ -426,7 +427,10 @@ if  env['OURPLATFORM']=='darwin':
                        source=[dp+os.sep+f for f in df]
                        blenderinstall.append(env.Install(dir=dir,source=source))
 else:
-       blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
+       if env['WITH_BF_FHS']:  dir= os.path.join(env['BF_INSTALLDIR'], 'bin')
+       else:                                   dir= env['BF_INSTALLDIR']
+       
+       blenderinstall = env.Install(dir=dir, source=B.program_list)
 
 #-- .blender
 #- dont do .blender and scripts for darwin, it is already in the bundle
@@ -450,7 +454,13 @@ if  env['OURPLATFORM']!='darwin':
                                                continue
                                
                                dotblendlist.append(os.path.join(dp, f))
-                               dottargetlist.append(env['BF_INSTALLDIR']+dp[3:]+os.sep+f)
+                               if env['WITH_BF_FHS']:  dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[2:]))      # skip bin/.blender
+                               else:                                   dir= os.path.join(*([BLENDERPATH] + dp.split(os.sep)[1:]))      # skip bin
+                               
+                               # print dir+ os.sep + f
+                               print dir
+                               dottargetlist.append(dir + os.sep + f)
+                                       
 
                dotblenderinstall = []
                for targetdir,srcfile in zip(dottargetlist, dotblendlist):
@@ -458,14 +468,18 @@ if  env['OURPLATFORM']!='darwin':
                        dotblenderinstall.append(env.Install(dir=td, source=srcfile))
                
                if env['WITH_BF_PYTHON']:
-                       #-- .blender/scripts, .blender/ui, .blender/io
-                       scriptpaths=['release/scripts', 'release/ui', 'release/io']
+                       #-- .blender/scripts
+                       scriptpaths=['release/scripts']
                        for scriptpath in scriptpaths:
                                for dp, dn, df in os.walk(scriptpath):
                                        if '.svn' in dn:
                                                dn.remove('.svn')
-                                       dir=env['BF_INSTALLDIR']+'/.blender/'+os.path.basename(scriptpath)+dp[len(scriptpath):]
-                                       source=[dp+os.sep+f for f in df]
+                                       
+                                       if env['WITH_BF_FHS']:          dir = BLENDERPATH
+                                       else:                                           dir = os.path.join(env['BF_INSTALLDIR'], '.blender')                            
+                                       dir += os.sep + os.path.basename(scriptpath) + dp[len(scriptpath):]
+                                       
+                                       source=[os.path.join(dp, f) for f in df if f[-3:]!='pyc']
                                        scriptinstall.append(env.Install(dir=dir,source=source))
 
 #-- icons
@@ -477,8 +491,8 @@ if env['OURPLATFORM']=='linux2':
                if '.svn' in tn:
                        tn.remove('.svn')
                for f in tf:
-                       iconlist.append(tp+os.sep+f)
-                       icontargetlist.append(env['BF_INSTALLDIR']+tp[19:]+os.sep+f)
+                       iconlist.append(os.path.join(tp, f))
+                       icontargetlist.append( os.path.join(*([BLENDERPATH] + tp.split(os.sep)[2:] + [f])) )
 
        iconinstall = []
        for targetdir,srcfile in zip(icontargetlist, iconlist):
@@ -489,7 +503,11 @@ if env['OURPLATFORM']=='linux2':
 # TODO - add more libs, for now this lets blenderlite run
 if env['OURPLATFORM']=='linuxcross':
        dir=env['BF_INSTALLDIR']
-       source = ['../lib/windows/pthreads/lib/pthreadGC2.dll']
+       source = []
+
+       if env['WITH_BF_OPENMP']:
+               source += ['../lib/windows/pthreads/lib/pthreadGC2.dll']
+
        scriptinstall.append(env.Install(dir=dir, source=source))
 
 #-- plugins
@@ -498,25 +516,27 @@ plugtargetlist = []
 for tp, tn, tf in os.walk('release/plugins'):
        if '.svn' in tn:
                tn.remove('.svn')
+       df = tp[8:] # remove 'release/'
        for f in tf:
-               pluglist.append(tp+os.sep+f)
-               plugtargetlist.append(env['BF_INSTALLDIR']+tp[7:]+os.sep+f)
+               pluglist.append(os.path.join(tp, f))
+               plugtargetlist.append( os.path.join(BLENDERPATH, df, f) )
+
 
 # header files for plugins
 pluglist.append('source/blender/blenpluginapi/documentation.h')
-plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'documentation.h')
+plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'documentation.h'))
 pluglist.append('source/blender/blenpluginapi/externdef.h')
-plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'externdef.h')
+plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'externdef.h'))
 pluglist.append('source/blender/blenpluginapi/floatpatch.h')
-plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'floatpatch.h')
+plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'floatpatch.h'))
 pluglist.append('source/blender/blenpluginapi/iff.h')
-plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'iff.h')
+plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'iff.h'))
 pluglist.append('source/blender/blenpluginapi/plugin.h')
-plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'plugin.h')
+plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.h'))
 pluglist.append('source/blender/blenpluginapi/util.h')
-plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep +'util.h')
+plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'util.h'))
 pluglist.append('source/blender/blenpluginapi/plugin.DEF')
-plugtargetlist.append(env['BF_INSTALLDIR'] + os.sep + 'plugins' + os.sep + 'include' + os.sep + 'plugin.def')
+plugtargetlist.append(os.path.join(BLENDERPATH, 'plugins', 'include', 'plugin.def'))
 
 plugininstall = []
 for targetdir,srcfile in zip(plugtargetlist, pluglist):
@@ -531,7 +551,7 @@ for tp, tn, tf in os.walk('release/text'):
        for f in tf:
                textlist.append(tp+os.sep+f)
 
-textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
+textinstall = env.Install(dir=BLENDERPATH, source=textlist)
 
 if  env['OURPLATFORM']=='darwin':
                allinstall = [blenderinstall, plugininstall, textinstall]
@@ -540,45 +560,57 @@ elif env['OURPLATFORM']=='linux2':
 else:
                allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
 
-if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc'):
-       if env['OURPLATFORM'] == 'win64-vc':
-               dllsources = []
-       else:
-               dllsources = ['${LCGDIR}/gettext/lib/gnu_gettext.dll',
-                               '${BF_PNG_LIBPATH}/libpng.dll',
-                               '${BF_ZLIB_LIBPATH}/zlib.dll',
-                               '${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
-       dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
+       dllsources = []
+
+       if not env['OURPLATFORM'] in ('win32-mingw', 'win64-vc', 'linuxcross'):
+               # For MinGW and linuxcross static linking will be used
+               dllsources += ['${LCGDIR}/gettext/lib/gnu_gettext.dll']
+
+       #currently win64-vc doesn't appear to have libpng.dll
+       if env['OURPLATFORM'] != 'win64-vc':
+               dllsources += ['${BF_PNG_LIBPATH}/libpng.dll',
+                               '${BF_ZLIB_LIBPATH}/zlib.dll']
+
+       dllsources += ['${BF_TIFF_LIBPATH}/${BF_TIFF_LIB}.dll']
+
+       if env['OURPLATFORM'] != 'linuxcross':
+               # pthreads library is already added
+               dllsources += ['${BF_PTHREADS_LIBPATH}/${BF_PTHREADS_LIB}.dll']
+
        if env['WITH_BF_SDL']:
                if env['OURPLATFORM'] == 'win64-vc':
                        pass # we link statically already to SDL on win64
                else:
                        dllsources.append('${BF_SDL_LIBPATH}/SDL.dll')
+
        if env['WITH_BF_PYTHON']:
-               ver = env["BF_PYTHON_VERSION"].replace(".", "")
-               
-               dllsources.append('${LCGDIR}/release/python' + ver + '.zip')
-               dllsources.append('${LCGDIR}/release/zlib.pyd')
                if env['BF_DEBUG']:
-                       dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_LIB}_d.dll')
+                       dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll')
                else:
-                       dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_LIB}.dll')
+                       dllsources.append('${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll')
+
        if env['WITH_BF_ICONV']:
                if env['OURPLATFORM'] == 'win64-vc':
                        pass # we link statically to iconv on win64
-               else:
+               elif not env['OURPLATFORM'] in ('win32-mingw', 'linuxcross'):
+                       #gettext for MinGW and cross-compilation is compiled staticly
                        dllsources += ['${BF_ICONV_LIBPATH}/iconv.dll']
+
        if env['WITH_BF_OPENAL']:
                dllsources.append('${LCGDIR}/openal/lib/OpenAL32.dll')
                dllsources.append('${LCGDIR}/openal/lib/wrap_oal.dll')
+
        if env['WITH_BF_SNDFILE']:
                dllsources.append('${LCGDIR}/sndfile/lib/libsndfile-1.dll')
+
        if env['WITH_BF_FFMPEG']:
-               dllsources += ['${LCGDIR}/ffmpeg/lib/avcodec-52.dll',
-                                               '${LCGDIR}/ffmpeg/lib/avformat-52.dll',
-                                               '${LCGDIR}/ffmpeg/lib/avdevice-52.dll',
-                                               '${LCGDIR}/ffmpeg/lib/avutil-50.dll',
-                                               '${LCGDIR}/ffmpeg/lib/swscale-0.dll']
+               dllsources += ['${BF_FFMPEG_LIBPATH}/avcodec-52.dll',
+                                       '${BF_FFMPEG_LIBPATH}/avformat-52.dll',
+                                       '${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
+                                       '${BF_FFMPEG_LIBPATH}/avutil-50.dll',
+                                       '${BF_FFMPEG_LIBPATH}/swscale-0.dll']
+
        if env['WITH_BF_JACK']:
                dllsources += ['${LCGDIR}/jack/lib/libjack.dll']
        windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
@@ -616,13 +648,14 @@ if not env['WITHOUT_BF_INSTALL']:
 
 #------------ EPYDOC
 if env['WITH_BF_DOCS']:
-       try:            import epydoc
-       except: epydoc = None
-       
-       if epydoc:
-               SConscript('source/blender/python/api2_2x/doc/SConscript')
-               SConscript('source/gameengine/PyDoc/SConscript')
-       else:
-               print "No epydoc install detected, Python API and Gameengine API Docs will not be generated "
-       
+    try:
+        import epydoc
+    except ImportError:
+        epydoc = None
+
+    if epydoc:
+        SConscript('source/gameengine/PyDoc/SConscript')
+    else:
+        print "No epydoc install detected, Python API and Gameengine API Docs will not be generated "
+