== FFMPEG ==
[blender.git] / SConstruct
index cd63bc5fd360eb924bc3f77646e91361564411eb..2cacb91d10342114d1b9ef5d2baf5fbd853b863f 100644 (file)
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
-# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# The Original Code is Copyright (C) 2006, Blender Foundation
 # All rights reserved.
 #
-# The Original Code is: none of this file.
+# The Original Code is: all of this file.
 #
 # Contributor(s): Nathan Letwory.
 #
@@ -38,6 +38,7 @@ import os.path
 import string
 import shutil
 import glob
+import re
 
 import tools.Blender
 import tools.btools
@@ -50,6 +51,8 @@ B = tools.Blender
 ### globals ###
 platform = sys.platform
 quickie = None
+quickdebug = None
+nsis_build = None
 
 ##### BEGIN SETUP #####
 
@@ -57,6 +60,7 @@ B.possible_types = ['core', 'common', 'blender', 'intern',
                     'international', 'game', 'game2',
                     'player', 'player2', 'system']
 
+B.binarykind = ['blender' , 'blenderplayer']
 ##################################
 # target and argument validation #
 ##################################
@@ -67,6 +71,11 @@ if platform=='win32':
 
 if not use_color=='1':
     B.bc.disable()
+    
+ #on defaut white Os X terminal, some colors are totally unlegible
+if platform=='darwin':
+    B.bc.OKGREEN = '\033[34m'
+    B.bc.WARNING = '\033[36m'
 
 # arguments
 print B.bc.HEADER+'Command-line arguments'+B.bc.ENDC
@@ -86,11 +95,18 @@ btools.print_targets(B.targets, B.bc)
 
 # first check cmdline for toolset and we create env to work on
 quickie = B.arguments.get('BF_QUICK', None)
+quickdebug = B.arguments.get('BF_QUICKDEBUG', None)
+
+if quickdebug:
+    B.quickdebug=string.split(quickdebug, ',')
+else:
+    B.quickdebug=[]
+
 if quickie:
     B.quickie=string.split(quickie,',')
 else:
     B.quickie=[]
-
+    
 toolset = B.arguments.get('BF_TOOLSET', None)
 if toolset:
     print "Using " + toolset
@@ -99,6 +115,8 @@ if toolset:
         env.Tool('mstoolkit', ['tools'])
     else:
         env = BlenderEnvironment(tools=[toolset], ENV = os.environ)
+        if env:
+            btools.SetupSpawn(env)
 else:
     env = BlenderEnvironment(ENV = os.environ)
 
@@ -106,11 +124,21 @@ if not env:
     print "Could not create a build environment"
     Exit()
 
+
+cc = B.arguments.get('CC', None)
+cxx = B.arguments.get('CXX', None)
+if cc:
+    env['CC'] = cc
+if cxx:
+    env['CXX'] = cxx
+
 if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32':
     platform = 'win32-vc'
 elif env['CC'] in ['gcc'] and sys.platform=='win32':
     platform = 'win32-mingw'
 
+env.SConscriptChdir(0)
+
 crossbuild = B.arguments.get('BF_CROSS', None)
 if crossbuild and platform!='win32':
     platform = 'linuxcross'
@@ -142,6 +170,56 @@ else:
 opts = btools.read_opts(optfiles, B.arguments)
 opts.Update(env)
 
+# 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')
+
+#check for additional debug libnames
+
+if env.has_key('BF_DEBUG_LIBS'):
+    B.quickdebug += env['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.Copy( LIBPATH = env['BF_OPENAL'] ) 
+        conf = Configure( env2, {'CheckFreeAlut' : CheckFreeAlut}, '.sconf_temp', '/dev/null' )
+        if conf.CheckFreeAlut( env2 ):
+            env['BF_OPENAL_LIB'] += ' alut'
+        del env2
+        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))
+        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:
+        print "\t" + l
+
 # check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
 if 'blenderplayer' in B.targets:
     env['WITH_BF_PLAYER'] = True
@@ -155,7 +233,7 @@ B.root_build_dir = env['BF_BUILDDIR']
 env['BUILDDIR'] = B.root_build_dir
 if not B.root_build_dir[-1]==os.sep:
     B.root_build_dir += os.sep
-
+    
 # We do a shortcut for clean when no quicklist is given: just delete
 # builddir without reading in SConscripts
 do_clean = None
@@ -163,13 +241,16 @@ if 'clean' in B.targets:
     do_clean = True
 
 if not quickie and do_clean:
-    print B.bc.HEADER+'Cleaning...'+B.bc.ENDC
-    dirs = os.listdir(B.root_build_dir)
-    for dir in dirs:
-        if os.path.isdir(B.root_build_dir + dir) == 1:
-            print "clean dir %s"%(B.root_build_dir+dir)
-            shutil.rmtree(B.root_build_dir+dir)
-    print B.bc.OKGREEN+'...done'+B.bc.ENDC
+    if os.path.exists(B.root_build_dir):
+        print B.bc.HEADER+'Cleaning...'+B.bc.ENDC
+        dirs = os.listdir(B.root_build_dir)
+        for dir in dirs:
+            if os.path.isdir(B.root_build_dir + dir) == 1:
+                print "clean dir %s"%(B.root_build_dir+dir)
+                shutil.rmtree(B.root_build_dir+dir)
+        print B.bc.OKGREEN+'...done'+B.bc.ENDC
+    else:
+        print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
     Exit()
 
 if not os.path.isdir ( B.root_build_dir):
@@ -198,8 +279,6 @@ B.init_lib_dict()
 ##### END SETUP ##########
 
 Export('env')
-#Export('root_build_dir') # this one is still needed for makesdna
-##TODO: improve makesdna usage
 
 BuildDir(B.root_build_dir+'/intern', 'intern', duplicate=0)
 SConscript(B.root_build_dir+'/intern/SConscript')
@@ -219,28 +298,36 @@ for tp in B.possible_types:
 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
     B.propose_priorities()
 
-dobj = B.buildinfo(env, "dynamic")
+dobj = B.buildinfo(env, "dynamic") + B.resources
 thestatlibs, thelibincs = B.setup_staticlibs(env)
 thesyslibs = B.setup_syslibs(env)
 
-env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist + thestatlibs, [], thesyslibs, [B.root_build_dir+'/lib'] + thelibincs)
+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, 'core')
-    playerlist += B.create_blender_liblist(env, 'common')
-    playerlist += B.create_blender_liblist(env, 'intern')
-    playerlist += B.create_blender_liblist(env, 'international')
-    playerlist += B.create_blender_liblist(env, 'game')
-    playerlist += B.create_blender_liblist(env, 'game2')
-    playerlist += B.create_blender_liblist(env, 'player2')
-    env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist + thestatlibs, [], thesyslibs, [B.root_build_dir+'/lib'] + thelibincs)
+    env.BlenderProg(B.root_build_dir, "blenderplayer", dobj + playerlist + thestatlibs, [], thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blenderplayer')
 
 ##### Now define some targets
 
 
 #------------ INSTALL
 
-blenderinstall = env.Install(dir=env['BF_INSTALLDIR'], source=B.program_list)
+#-- binaries
+blenderinstall = []
+if  env['OURPLATFORM']=='darwin':
+    for prg in B.program_list:
+        bundle = '%s.app' % prg[0]
+        bundledir = os.path.dirname(bundle)
+        for dp, dn, df in os.walk(bundle):
+            if 'CVS' in dn:
+                dn.remove('CVS')
+            if '.svn' in dn:
+                dn.remove('.svn')
+            dir=env['BF_INSTALLDIR']+dp[len(bundledir):]
+            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)
 
 #-- .blender
 dotblendlist = []
@@ -248,6 +335,8 @@ dottargetlist = []
 for dp, dn, df in os.walk('bin/.blender'):
     if 'CVS' in dn:
         dn.remove('CVS')
+    if '.svn' in dn:
+        dn.remove('.svn')
     for f in df:
         dotblendlist.append(dp+os.sep+f)
         dottargetlist.append(env['BF_INSTALLDIR']+dp[3:]+os.sep+f)
@@ -258,8 +347,16 @@ for targetdir,srcfile in zip(dottargetlist, dotblendlist):
     dotblenderinstall.append(env.Install(dir=td, source=srcfile))
 
 #-- .blender/scripts
-scriptlist = glob.glob('release/scripts/*.py')
-scriptinstall = env.Install(dir=env['BF_INSTALLDIR']+'/.blender/scripts', source=scriptlist)
+scriptinstall = []
+scriptpath='release/scripts'
+for dp, dn, df in os.walk(scriptpath):
+    if 'CVS' in dn:
+        dn.remove('CVS')
+    if '.svn' in dn:
+        dn.remove('.svn')
+    dir=env['BF_INSTALLDIR']+'/.blender/scripts'+dp[len(scriptpath):]
+    source=[dp+os.sep+f for f in df]
+    scriptinstall.append(env.Install(dir=dir,source=source))
 
 #-- plugins
 pluglist = []
@@ -267,6 +364,8 @@ plugtargetlist = []
 for tp, tn, tf in os.walk('release/plugins'):
     if 'CVS' in tn:
         tn.remove('CVS')
+    if '.svn' in tn:
+        tn.remove('.svn')
     for f in tf:
         pluglist.append(tp+os.sep+f)
         plugtargetlist.append(env['BF_INSTALLDIR']+tp[7:]+os.sep+f)
@@ -281,6 +380,8 @@ texttargetlist = []
 for tp, tn, tf in os.walk('release/text'):
     if 'CVS' in tn:
         tn.remove('CVS')
+    if '.svn' in tn:
+        tn.remove('.svn')
     for f in tf:
         textlist.append(tp+os.sep+f)
 
@@ -288,22 +389,52 @@ textinstall = env.Install(dir=env['BF_INSTALLDIR'], source=textlist)
 
 allinstall = [blenderinstall, dotblenderinstall, scriptinstall, plugininstall, textinstall]
 
-if sys.platform=='win32':
-    # TODO: gather all needed dlls from lib/windows for inclusion in install
-    windlls = []
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw'):
+    dllsources = ['${LCGDIR}/gettext/lib/gnu_gettext.dll',
+                        '${LCGDIR}/png/lib/libpng.dll',
+                        '#release/windows/extra/python25.zip',
+                        '#release/windows/extra/zlib.pyd',
+                        '${LCGDIR}/sdl/lib/SDL.dll',
+                        '${LCGDIR}/zlib/lib/zlib.dll',
+                        '${LCGDIR}/tiff/lib/libtiff.dll']
+    if env['BF_DEBUG']:
+        dllsources.append('${LCGDIR}/python/lib/${BF_PYTHON_LIB}.dll')
+    else:
+        dllsources.append('${LCGDIR}/python/lib/${BF_PYTHON_LIB}.dll')
+    if env['OURPLATFORM'] == 'win32-mingw':
+        dllsources += ['${LCGDIR}/pthreads/lib/pthreadGC2.dll']
+    else:
+        dllsources += ['${LCGDIR}/pthreads/lib/pthreadVC2.dll']
+    if env['WITH_BF_ICONV']:
+        dllsources += ['${LCGDIR}/iconv/lib/iconv.dll']
+    if env['WITH_BF_FFMPEG']:
+        dllsources += ['${LCGDIR}/ffmpeg/lib/avcodec-51.dll',
+                        '${LCGDIR}/ffmpeg/lib/avformat-51.dll',
+                        '${LCGDIR}/ffmpeg/lib/avutil-49.dll']
+    windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
     allinstall += windlls
 
-installtarget = env.Alias('install', [allinstall])
+installtarget = env.Alias('install', allinstall)
 bininstalltarget = env.Alias('install-bin', blenderinstall)
 
+nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print)
+nsiscmd = env.Command('nsisinstaller', None, nsisaction)
+nsisalias = env.Alias('nsis', nsiscmd)
+
 if env['WITH_BF_PLAYER']:
     blenderplayer = env.Alias('blenderplayer', B.program_list)
+    Depends(blenderplayer,installtarget)
 
 if not env['WITH_BF_GAMEENGINE']:
     blendernogame = env.Alias('blendernogame', B.program_list)
+    Depends(blendernogame,installtarget)
+
+Depends(nsiscmd, allinstall)
 
 Default(B.program_list)
-Default(installtarget)
+
+if not env['WITHOUT_BF_INSTALL']:
+       Default(installtarget)
 
 #------------ RELEASE
 # TODO: zipup the installation