import os import commands # Only get potentially one variable from the environment # This can also be overridden in IDFS.py sddas_home = os.environ.get ('SDDAS_HOME') or \ os.environ.get ('SDDAS_HOME', 'None') # Define all the options to the build in the IDFS.py # TODO - make this more like configure where it will find this information opts = Options ('IDFS.py') opts.AddOptions ( BoolOption ('BUILD_SHARED', 'Set to build shared libraries', 0), BoolOption ('BUILD_STATIC', 'Set to build static libraries', 1), BoolOption ('DEBUG', 'Compile with debug symbols', 0), BoolOption ('PROFILE', 'Compile with profiling', 0), BoolOption ('ERMINE', 'Build with ErminePro', 0), EnumOption ('DATABASE', 'Set the database to use', 'SwRI', allowed_values = ('SwRI', 'MySQL', 'SQLite', 'ALL'), ignorecase=0), EnumOption ('GUI', 'Set the GUI to use', 'Motif', allowed_values = ('Motif', 'FLTK', 'Qt', 'ALL'), ignorecase=0), PathOption ('SDDAS_HOME', 'Where SDDAS is being built', sddas_home), PathOption ('CDF_DIR', 'The root directory of the CDF installation', "/usr/local"), PathOption ('netCDF_DIR', 'The root directory of the netCDF installation', "/usr/local"), PathOption ('VTK_DIR', 'The root directory of the VTK binary installation', "/usr/local"), PathOption ('VTK_BIN_DIR', 'The root directory of the VTK binary libraries', "/usr/local"), PathOption ('VTK_SRC_DIR', 'The root directory of the VTK includes installation', "/usr/local"), PathOption ('TCL_TK_DIR', 'The root directory of the Tcl/Tk installation', "/usr"), EnumOption ('TCL_TK_VERSION', 'The version of the Tcl/Tk installation', "8.4", allowed_values = ('8.4', '8.5')), ('TILE_VERSION', 'The version of the Tcl/Tk/Tile installation', "0.7.6"), ('TDOM_VERSION', 'The version of the Tcl/Tk/TDOM installation', "0.8.0"), ('TCLDOM_VERSION', 'The version of the Tcl/Tk/TclDOM installation', "3.0"), ('TCLDOMXML_VERSION', 'The version of the Tcl/Tk/TclXML installation', "3.1"), ('TCLLIB_VERSION', 'The version of the Tcl/Tk/TclLib installation', "1.10"), ('TCLSOAP_VERSION', 'The version of the Tcl/Tk/TclSOAP installation', "1.6.7"), ('MYSQLTCL_VERSION', 'The version of the Tcl/Tk/MySQL installation', "3.03"), ('SQLITETCL_VERSION', 'The version of the Tcl/Tk/SQLite installation', "3.6.5"), EnumOption ('TCL_TK_BUILD_TYPE', 'The way to build Tcl/Tk executables', "mta", allowed_values = ('mta', 'kit')), PathOption ('TCL_TK_SUPPORT_DIR', 'The support (sdx.kit and tclkit) directory of the Tcl/Tk installation', "/usr"), PackageOption ('TCLKIT', 'The tclkit program', "disable"), PackageOption ('TCLKITnoTK', 'The tclkit (without Tk) program', "disable"), PathOption ('SQLITE3_DIR', 'The root directory of the SQLite v3 installation', "/usr"), PathOption ('MYSQL_DIR', 'The root directory of the MySQL installation', "/usr"), PathOption ('IDL_DIR', 'The root directory of the IDL installation', "."), PathOption ('LUA_DIR', 'The root directory of the Lua installation', "/usr"), PathOption ('BOOST_DIR', 'The root directory of the Boost installation', "/usr"), PathOption ('STXXL_DIR', 'The root directory of the STXXL installation', "/usr"), PathOption ('SWIG_DIR', 'The root directory of a SWIG installation', "/"), PathOption ('IMAGEMAGICK', 'The root directory of the ImageMagick installation', "/usr"), EnumOption ('IDL_VERSION_NUM', 'The version of the IDL installation (currently only 6.0 supported!)', "6.0", allowed_values = ('5.4', '6.0')) ) # Try to figure out on what machine type/platform we are building. # Add things in the path which are specific to that platform. # This will largely be specific to our needs. plat = Platform().name tools = ["gcc", "g++", "gnulink", "ar", "lex", "yacc", "swig"] if plat == "sunos": path = ['/bin', '/opt/csw/bin', '/opt/local/bin', '/usr/ccs/bin', '/opt/SUNWspro/bin'] elif plat == "win32": path = ["C:/MinGW/bin", "C:/Program Files/GnuWin32/bin", 'C:/Qt/3.3.5/bin', 'C:/Windows', 'C:/Windows/system32'] if "no-cygwin" in COMMAND_LINE_TARGETS: tools = ["mingw", "qt", "lex", "yacc"] else: tools = ["gcc", "qt", "lex", "yacc"] elif plat == "irix": path = ['/bin', '/usr/freeware/bin'] elif plat == "darwin": path = ['/usr/bin', '/bin', '/sw/bin'] tools.append ("macosx") tools.append ("applelink") else: path = ['/usr/bin', '/bin'] # Define our environment. We only use the default parameters for the platform. # We are forcing the use of gcc and g++. This prevents using Visual C++ on # Windows and CC on Solaris. # env = Environment (ENV = {'PATH' : path}, options = opts, tools=["gnulink", "gcc", "g++", "gas", "ar", "lex", "yacc", "qt"]) # env = Environment (ENV = {'PATH' : path}, options = opts, tools=["default", "gcc", "g++", "qt"]) # env = Environment (ENV = {'PATH' : path}, options = opts, tools=["default", "qt"]) env = Environment (ENV = {'PATH' : path}, options = opts, tools = tools) print "SDDAS_HOME is:", env ['SDDAS_HOME'] print "Building on : ", plat # hopefully nothing below show have to be modified! env ['ENV']['HOME'] = os.environ.get ('HOME') or \ os.environ.get ('HOME', '/tmp') env ['IDL_VERSION'] = env ['IDL_VERSION_NUM'].replace (".", "") env ['TCL_TK_DIR_ESC'] = env ['TCL_TK_DIR'].replace ("/", "\\/") if ARGUMENTS.get ('REAL_BUILD', '0') == '1': env ['SVNVERSION'] = commands.getoutput ("svnversion -n .") else: env ['SVNVERSION'] = "00000" env ['VERSION_NUM'] = env ['SVNVERSION'] env ['CDF_INC'] = env ['CDF_DIR'] + "/include" env ['netCDF_INC'] = env ['netCDF_DIR'] + "/include" env ['CDF_LIB'] = env ['CDF_DIR'] + "/lib" env ['netCDF_LIB'] = env ['netCDF_DIR'] + "/lib" env ['SDDAS_BIN'] = env ['SDDAS_HOME'] + '/bin' env ['SDDAS_INCLUDE'] = [env ['SDDAS_HOME'] + '/include'] env ['SDDAS_LIB'] = [env ['SDDAS_HOME'] + '/lib'] env ['SDDAS_SHARED_LIB'] = [env ['SDDAS_HOME'] + '/sharedlib'] env ['YACCFLAGS'] = '-d' env ['ZLIB'] = 'z' env ['SQLITE3_LIB'] = File (env ['SQLITE3_DIR'] + '/lib64/libsqlite3' + env ['SHLIBSUFFIX']) env ['MYSQL_LIB'] = File (env ['MYSQL_DIR'] + '/lib64/mysql/libmysqlclient' + env ['SHLIBSUFFIX']) env ['SQLITE3_SH_LIB'] = File (env ['SQLITE3_DIR'] + '/lib64/libsqlite3' + env ['SHLIBSUFFIX']) env ['MYSQL_SH_LIB'] = File (env ['MYSQL_DIR'] + '/lib/mysql/libmysqlclient' + env ['SHLIBSUFFIX']) env ['SQLITE3_LIBS'] = [env ['SQLITE3_LIB']] env ['SQLITE3_SH_LIBS'] = [env ['SQLITE3_SH_LIB']] env ['MYSQL_LIBS'] = [env ['MYSQL_LIB']] env ['MYSQL_SH_LIBS'] = [env ['MYSQL_SH_LIB']] env ['MYSQL_LIBS'].append (env ['ZLIB']) env ['MYSQL_SH_LIBS'].append ('z') env ['GL'] = ['GL'] if env ['SWIG_DIR'] != "/": env ['SWIG'] = env ['SWIG_DIR'] + '/bin/swig' env ['SWIGFLAGS'] = ['-c++', '-lua'] # platform specific changes # posix = linux, darwin = macosx env ['EXTRA_LIBS'] = [] env ['CPPLIB'] = ['stdc++'] env ['DLLIB'] = [] if env ['PLATFORM'] == "darwin": env.Append (CPPDEFINES = ['__DARWIN__']) # env.Append (LINKFLAGS = ["-flat_namespace", "-Wl,-multiply_defined,suppress"]) env.Append (LINKFLAGS = ["-Wl,-multiply_defined,suppress"]) env.Append (SHCCFLAGS = ['-fno-common']) env.Append (CCFLAGS = ["-isysroot", "/Developer/SDKs/MacOSX10.4u.sdk", "-arch", "i386", "-arch", "ppc"]) env.Append (LINKFLAGS = ["-Wl,-syslibroot", "/Developer/SDKs/MacOSX10.4u.sdk", "-arch", "i386", "-arch", "ppc"]) env ['SHLINKFLAGS'] = env ['LINKFLAGS'] + ["-dynamiclib", "-install_name", "${TARGET.file}"] env ['MOTIF'] = File ("/usr/OpenMotif-2.3.0/lib/libXm.a") env ['OTHER_XLIBS'] = ['Xrender', 'Xft', 'freetype', 'fontconfig', 'Xp', 'Xmu', 'Xt', 'Xext', 'X11'] env ['X_INCLUDE'] = ['/usr/X11R6/include', '/usr/OpenMotif-2.3.0/include', '/sw/include'] env ['X_LIB'] = '/usr/X11R6/lib' env ['LINK'] = "g++" env ['FRAMEWORKS'] = ['AppKit', 'Carbon', 'System'] env ['EXTRA_LIBS'].append ('iconv') elif env ['PLATFORM'] == "sunos": env ['MOTIF'] = File ("/usr/dt/lib/libXm.so") env ['OTHER_XLIBS'] = ['Xi', 'Xmu', 'Xt', 'X11'] env ['X_INCLUDE'] = ['/usr/openwin/include'] env ['X_LIB'] = '/usr/openwin/lib' env ['EXTRA_LIBS'].append ('rt') env ['EXTRA_LIBS'].append ('socket') env ['EXTRA_LIBS'].append ('nsl') env ['DLLIB'] = ['dl'] if env ['LEX'] == 'flex': env ['LEXFLAGS'] = '--nounput' env ['YACC'] = 'yacc' env ['LINK'] = 'gcc' elif env ['PLATFORM'] == "posix": env ['MOTIF'] = 'Xm' env ['OTHER_XLIBS'] = ['Xi', 'Xmu', 'Xp', 'Xt', 'X11'] env ['X_INCLUDE'] = ['/usr/X11R6/include'] env ['X_LIB'] = '/usr/X11R6/lib' env ['DLLIB'] = ['dl'] env ['EXTRA_LIBS'].append ('pthread') elif env ['PLATFORM'] == "irix": env ['CXX'] = "g++" env ['LINK'] = "g++" env ['YACC'] = "yacc" env ['MOTIF'] = [] env ['OTHER_XLIBS'] = ['Xm', 'Xt', 'X11'] env ['X_INCLUDE'] = ['/usr/include'] env ['X_LIB'] = '' env ['CPPLIB'] = [] elif env ['PLATFORM'] == "cygwin": if "no-cygwin" in COMMAND_LINE_TARGETS: env ['MYSQL_SH_LIB'] = File ('/cygdrive/f/sddas/mysql-mingw/lib/libmysqlclient.a') env ['ZLIB'] = File ('/cygdrive/c/mingw/lib/libz.a') env ['MYSQL_LIBS'] = [env ['MYSQL_LIB'], env ['ZLIB']] else: env ['MYSQL_SH_LIB'] = File (env ['MYSQL_DIR'] + '/lib/mysql/libmySQL' + env ['SHLIBSUFFIX']) env ['MYSQL_SH_LIBS'] = [env ['MYSQL_SH_LIB']] env ['MYSQL_SH_LIBS'].append ('z') env ['MOTIF'] = [] env ['OTHER_XLIBS'] = ['Xm', 'Xt', 'X11'] env ['X_INCLUDE'] = ['/usr/X11R6/include'] env ['X_LIB'] = '/usr/X11R6/lib' env ['LINK'] = "g++" if env ['LEX'] == 'flex': env ['LEXFLAGS'] = '--nounput' env.Append (LINKFLAGS = "-Wl,--enable-auto-import,--enable-runtime-pseudo-reloc") env ['GL'] = ['opengl32', 'glu32'] env ['SIGNED_CHAR'] = '' # certain systems need -fsigned-char defined if env ['PLATFORM'] == "cygwin": env ['LEXLIB'] = ['fl'] elif env ['PLATFORM'] == "win32": env ['LEXLIB'] = [File ("C:/Program Files/GnuWin32/lib/libfl.a")] else: env ['LEXLIB'] = ['l'] env ['X_LIBS'] = [env ['MOTIF'], env ['OTHER_XLIBS']] # always add X and SDDAS_INCLUDE to include line # TODO - remove X in the general sense and add to the specific areas that need it env.Append (CPPPATH = env ['X_INCLUDE'] + env ['SDDAS_INCLUDE']) # this variable has the special include directories for our newer applications env ['CPPPATH_NEW'] = ['#/libGeneric', '#/libIDFSPromote', '#/libNewIDFSObjs'] # if we are developing, add the debug symbols (DEBUG defined) if env ['CC'] == "gcc": env.Append (CCFLAGS = ['-Wall']) if env ['DEBUG'] == 1: # env.Append (CPPFLAGS = ['-gstabs+']) env.Append (CPPFLAGS = ['-g']) if env ['PROFILE'] == 1: env.Append (CCFLAGS = ['-pg']) env.Append (LINKFLAGS = ['-pg']) # Add compile defines, include dirs, for the database library if env ['DATABASE'] == 'SwRI': env.Append (CPPDEFINES = ['SwRI_DB']) env.Append (DBLIBS = ['server', 'dB']) env.Append (DB_SH_LIBS = ['server', 'dB']) elif env ['DATABASE'] == 'MySQL': env.Append (CPPDEFINES = ['MYSQL_DB']) env.Append (CPPPATH = [env ['MYSQL_DIR'] + '/include/mysql']) env.Append (DBLIBS = ['dbMySQL'] + env ['MYSQL_LIBS']) env.Append (DB_SH_LIBS = ['dbMySQL'] + env ['MYSQL_SH_LIBS']) elif env ['DATABASE'] == 'SQLite': env.Append (CPPDEFINES = ['SQLITE_DB']) env.Append (CPPPATH = [env ['SQLITE3_DIR'] + '/include']) env.Append (DBLIBS = ['dbSQLite'] + [env ['SQLITE3_LIBS']]) env.Append (DB_SH_LIBS = ['dbSQLite'] + [env ['SQLITE3_SH_LIBS']]) elif env ['DATABASE'] == 'ALL': env.Append (CPPDEFINES = ['ALL_DB']) env.Append (CPPPATH = [env ['SQLITE3_DIR'] + '/include', env ['MYSQL_DIR'] + '/include/mysql']) env.Append (DBLIBS = ['dbWrapper', 'server', 'dB'] + [env ['SQLITE3_LIBS']] + env ['MYSQL_LIBS']) env.Append (DB_SH_LIBS = ['dbWrapper', 'server', 'dB'] + [env ['SQLITE3_SH_LIBS']] + env ['MYSQL_SH_LIBS']) if env ['CC'] != "gcc": env.Append (DBLIBS = File ("/opt/local/gcc-current/lib/libgcc_s.so")) # Add compile defines, include dirs, for the GUI library # will build a library (honors shared/static) # will release static to $SDDAS_LIB # will release shared to $SDDAS_SHARED_LIB # will release headers to $SDDAS_HOME/include def SDDASBuildLibrary (env, libname, sources, headers, deplibs = [], sharable = True, extra_static_obj = [], extra_shared_obj = [], deplibdirs = [], frameworks = []): if sharable and env ['BUILD_SHARED'] == 1: shared_lib = env.SharedLibrary (libname, sources + extra_shared_obj, FRAMEWORKS = Flatten (frameworks + env ['FRAMEWORKS']), LIBS = deplibs + env ['EXTRA_LIBS'], LIBPATH = env ['LIBPATH'] + env ['SDDAS_SHARED_LIB'] + deplibdirs) env.Default (shared_lib) env.Alias (target="release", source=env.Install (dir=env ['SDDAS_SHARED_LIB'], source=shared_lib)) if env ['BUILD_STATIC'] == 1: static_lib = env.StaticLibrary (libname, sources + extra_static_obj) env.Default (static_lib) env.Alias (target="release", source=env.Install (dir=env ['SDDAS_LIB'], source=static_lib)) env.Alias (target="release", source=env.Install (dir=env ['SDDAS_INCLUDE'], source=headers)) return def SDDASBuildProgram (env, program, sources, libs = [], other_objects = [], libpaths = [], isNativeOnMac = False, doRelease = True): if len(sources) == 0: objs = []; else: objs = env.Object (sources) prog = env.Program (program, objs + other_objects, LIBS = libs + env ['EXTRA_LIBS'], LIBPATH = libpaths + env ['SDDAS_LIB']) env.Default (prog) if env ['PLATFORM'] == "darwin" and isNativeOnMac: env ['VERSION_NAME'] = program + '.app' bundle = env.MakeBundle (program + '.app', prog, 'com.SwRI.' + program, 'Info.plist', 'APPL', 'SwRI', '#/MAC_ICONS/' + program + '.icns') env.Default (bundle) inst = env.InstallBundle (env ['SDDAS_BIN'], bundle) else: inst = env.Install (dir=env ['SDDAS_BIN'], source=prog) if env ['PLATFORM'] == "darwin": env.AddPostAction (inst, Action ('strip -x -S $TARGET')) else: strip = env.AddPostAction (inst, Action ('strip $TARGET')) if env ['ERMINE'] == 1: ermine1 = env.AddPostAction (strip, Action ('ErminePro --with-nss=internal $TARGET --output ${TARGET}.exe')) env.AddPostAction (ermine1, Action ('mv ${TARGET}.exe $TARGET')) if doRelease: env.Alias (target="release", source=inst) env.Alias (target="pure", source=env.Program (program + '.pure', objs + other_objects, LIBS = libs + env ['EXTRA_LIBS'], LIBPATH = libpaths + env ['SDDAS_LIB'], LINKCOM = 'purify -best-effort ' + env ['LINKCOM'])) return (prog) from SCons.Script.SConscript import SConsEnvironment SConsEnvironment.SDDASBuildLibrary = SDDASBuildLibrary SConsEnvironment.SDDASBuildProgram = SDDASBuildProgram env.SConsignFile () # Define all the directories to be built # Add any new directories to the appropriate phase first = Split ("libant libCfg") if env ['DATABASE'] == 'ALL': dblibs = Split ("libdB libserver libdbSQL dBCmds mysqlCmds sqlLiteCmds") elif env ['DATABASE'] == 'MySQL': dblibs = Split ("libdbSQL mysqlCmds") elif env ['DATABASE'] == 'SQLite': dblibs = Split ("libdbSQL sqlLiteCmds") elif env ['DATABASE'] == 'SwRI': dblibs = Split ("libdB libserver dBCmds") second = Split ("libVIDF libPIDF libbase_idfs libtrec_idfs libIDFSMath libIDFSFill libIDFSTensor libPromote") final = Split ("IDFS_EXAMPLES") ant = ['libantX'] if "Qtran" in COMMAND_LINE_TARGETS: dirs = ["ThirdParty/qtran/src"] else: all_dirs = first + dblibs + ant + second + final dirs = all_dirs env.SourceCode("/", None) SetOption ('diskcheck', ['match']) if env ['PLATFORM'] == "cygwin": # ok, this stuff is strictly for the native Windows version of SDDAS if "no-cygwin" in COMMAND_LINE_TARGETS: print "Building without dependence on CYGWIN.DLL!" env ['SDDAS_LIB'] = [env ['SDDAS_HOME'] + '/no-cygwin-lib'] env ['CC'] = "gcc -mthreads -mno-cygwin" env ['CXX'] = "g++ -mthreads -mno-cygwin" env ['EXTRA_LIBS'].append (['Ws2_32', 'pthreadGC2']) env.Append (LINKFLAGS = "-mthreads -mno-cygwin") env ['PLATFORM'] = "win32" remove_dirs = Split ("exportIDFS IDFStoPDS graphical XYPlot \ ScanSensor PhiTheta ScanAngle tabular \ Correlogram SpectroScalar scfedit \ sdview libBlocksCDE libBlocks \ libViewer libBoxMngCDE libCommonGUI \ libIDFSObjs libRandomRead libPlotBoxAtt \ Scripts") else: remove_dirs = Split ("exportMoments sdcatalog Contour Orbit \ mk_idf dump_hd idfs_time TclScripts \ sdhelp libHdr libNewIDFSObjs libCEFPromote libGeneric gPlot") if env ['GUI'] == 'Qt': remove_dirs.append ("liblegos") remove_dirs.append ("libantQt") remove_dirs.append ("libBlocksQt") remove_dirs.append ("libPromoteQt") if env ['DATABASE'] == 'ALL': remove_dirs.append ("mysqlCmds") remove_dirs.append ("sqlLiteCmds") remove_dirs.append ("dBCmds") elif env ['DATABASE'] == 'MySQL': remove_dirs.append ("mysqlCmds") elif env ['DATABASE'] == 'SQLite': remove_dirs.append ("sqlLiteCmds") elif env ['DATABASE'] == 'SwRI': remove_dirs.append ("dBCmds") for x in remove_dirs: dirs.remove (x) # If you wish to only build one directory, override the dirs directory right here. # It is just a comma separated list of directories. # dirs = ['libantQt', 'libNewIDFSObjs', 'libGeneric', 'libBlocksQt', 'libBlocks', 'liblegos', 'sdcatalog'] # qt issues # dirs = ['ScanAngle'] Export ('env') for dir in dirs: env.SourceCode (dir, None) env.SConscript (dir + '/SConscript') if "no-cygwin" in COMMAND_LINE_TARGETS: # cygbuild = filter (lambda x, # elem=".dll": x.name.find (elem) != -1, # DEFAULT_TARGETS) # Alias ('no-cygwin', cygbuild) Alias ('no-cygwin', DEFAULT_TARGETS) # print "build targets are:", map (str, BUILD_TARGETS) # print "default targets are:", map (str, DEFAULT_TARGETS) # print "real targets are:", map (str, cygbuild)