| 1 | #==================================================================== |
|---|
| 2 | # NeXus - Neutron & X-ray Common Data Format |
|---|
| 3 | # |
|---|
| 4 | # $Id: Makefile.am 961 2007-09-04 12:31:49Z Freddie Akeroyd $ |
|---|
| 5 | # |
|---|
| 6 | # Top level scons file for coordinating NeXus build |
|---|
| 7 | # |
|---|
| 8 | # Copyright (C) 2008 Freddie Akeroyd |
|---|
| 9 | # |
|---|
| 10 | # This library is free software; you can redistribute it and/or |
|---|
| 11 | # modify it under the terms of the GNU Lesser General Public |
|---|
| 12 | # License as published by the Free Software Foundation; either |
|---|
| 13 | # version 2 of the License, or (at your option) any later version. |
|---|
| 14 | # |
|---|
| 15 | # This library is distributed in the hope that it will be useful, |
|---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 18 | # Lesser General Public License for more details. |
|---|
| 19 | # |
|---|
| 20 | # You should have received a copy of the GNU Lesser General Public |
|---|
| 21 | # License along with this library; if not, write to the Free |
|---|
| 22 | # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|---|
| 23 | # MA 02111-1307 USA |
|---|
| 24 | # |
|---|
| 25 | # For further information, see <http://www.nexusformat.org/> |
|---|
| 26 | # |
|---|
| 27 | ######################## Subversion Reposity details ######################## |
|---|
| 28 | # Repository Location $HeadURL$ |
|---|
| 29 | # Revision of last commit $LastChangedRevision$ |
|---|
| 30 | # Date of last commit $LastChangedDate$ |
|---|
| 31 | # Author of last commit $LastChangedBy$ |
|---|
| 32 | ############################################################################ |
|---|
| 33 | |
|---|
| 34 | import os |
|---|
| 35 | import platform |
|---|
| 36 | import sys |
|---|
| 37 | import shutil |
|---|
| 38 | import re |
|---|
| 39 | import string |
|---|
| 40 | from socket import gethostname |
|---|
| 41 | |
|---|
| 42 | import nexus_scons_utils |
|---|
| 43 | |
|---|
| 44 | opts = Options('scons_options.py') |
|---|
| 45 | opts.Add('mingw','Set to 1 to use MinGW on Windows', 0) |
|---|
| 46 | opts.Add('msvc','Set to 1 to use Microsoft Visual Studio Compiler on Windows', 1) |
|---|
| 47 | opts.Add('debug','Set to 1 to build debug', 0) |
|---|
| 48 | |
|---|
| 49 | base_env = Environment(ENV=os.environ, options = opts) |
|---|
| 50 | mingw_env = Environment(ENV=os.environ, options = opts, tools = [ 'mingw' ]) |
|---|
| 51 | Help(opts.GenerateHelpText(base_env)) |
|---|
| 52 | mingw = ARGUMENTS.get('mingw', 0) |
|---|
| 53 | msvc = ARGUMENTS.get('msvc', 1) |
|---|
| 54 | debug = ARGUMENTS.get('debug', 0) |
|---|
| 55 | if int(msvc) : |
|---|
| 56 | env = base_env |
|---|
| 57 | if int(mingw) : |
|---|
| 58 | env = mingw_env |
|---|
| 59 | #get libraries and the library directories |
|---|
| 60 | print 'Current path == ',os.getcwd() |
|---|
| 61 | cwdpath=os.getcwd() |
|---|
| 62 | uppath=os.path.abspath('../') |
|---|
| 63 | |
|---|
| 64 | shlibList = [] |
|---|
| 65 | libList = [] |
|---|
| 66 | if not env.GetOption('clean'): # do not re-rerun checking on a "scons -c" |
|---|
| 67 | conf = Configure(env) |
|---|
| 68 | # if conf.CheckLib() |
|---|
| 69 | env = conf.Finish() |
|---|
| 70 | |
|---|
| 71 | shlibDirList = [] |
|---|
| 72 | libDirList = [] |
|---|
| 73 | cflags = [] |
|---|
| 74 | shcflags = [] |
|---|
| 75 | cxxflags = [] |
|---|
| 76 | shcxxflags = [] |
|---|
| 77 | ccflags = [] |
|---|
| 78 | shccflags = [] |
|---|
| 79 | dirList = [] |
|---|
| 80 | cppPaths = [] |
|---|
| 81 | cppDefines = [ ('HDF5',1), ('NXXML',1), ('HDF4',1) ] |
|---|
| 82 | #Get paths |
|---|
| 83 | if os.name == 'nt': |
|---|
| 84 | print "* COMMENCING WINDOWS BUILD *" |
|---|
| 85 | |
|---|
| 86 | libList.append('hdf5') |
|---|
| 87 | libList.append('szlib') |
|---|
| 88 | libList.append('zlib') |
|---|
| 89 | libList.append('hd423.lib') |
|---|
| 90 | libList.append('hm423.lib') |
|---|
| 91 | libList.append('xdr.lib') |
|---|
| 92 | libList.append('libjpeg.lib') |
|---|
| 93 | libList.append('ws2_32.lib') |
|---|
| 94 | libList.append('mxml_libcmt.lib') |
|---|
| 95 | shlibList.append('hdf5dll') |
|---|
| 96 | shlibList.append('hd423m.lib') |
|---|
| 97 | shlibList.append('hm423m.lib') |
|---|
| 98 | shlibList.append('mxml_msvcrt.lib') |
|---|
| 99 | libDirList.append('C:/Program Files/hdf/jpeg6-vs2005/lib') |
|---|
| 100 | libDirList.append('c:/program files/hdf/5-167-win-vs2005/lib') |
|---|
| 101 | libDirList.append('c:/program files/hdf/42r3-win-vs2005/lib') |
|---|
| 102 | shlibDirList.append('c:/program files/hdf/5-167-win-vs2005/dll') |
|---|
| 103 | shlibDirList.append('c:/program files/hdf/42r3-win-vs2005/dll') |
|---|
| 104 | shlibDirList.append('c:/msys/1.0/local/lib') |
|---|
| 105 | # libDirList.append('C:/Program Files/hdf/zlib123-vs2005/lib') |
|---|
| 106 | libDirList.append('C:/Install Kits/zlib-1.2.3') |
|---|
| 107 | libDirList.append('C:/Program Files/hdf/szip21-vs2005-noenc/lib') |
|---|
| 108 | libDirList.append('c:/msys/1.0/local/lib') |
|---|
| 109 | cppPaths.append(['c:/msys/1.0/local/include','c:/program files/hdf/5-167-win-vs2005/include','c:/program files/hdf/42r3-win-vs2005/include']) |
|---|
| 110 | |
|---|
| 111 | if int(mingw) : |
|---|
| 112 | cflags = ['-g', '-O2'] |
|---|
| 113 | env.Append(LINKFLAGS=['-g','-Wl,--export-all-symbols']) |
|---|
| 114 | shcflags.append(['-D_HDF5USEDLL_=1']) |
|---|
| 115 | else : |
|---|
| 116 | if int(debug) : |
|---|
| 117 | ccflags = [ '/W3', '/Od', '/FD', '/EHsc', '/MTd', '/TP', '/D_DEBUG', '/DMS_VISUAL_STUDIO=1', '/DWIN32', '/D_WINDOWS', '/DWINVER=0x0500', '/D_USE_MATH_DEFINES', '/D_SCL_SECURE_NO_WARNINGS', '/D_CRT_SECURE_NO_WARNINGS', '/wd4275', '/wd4996' ] |
|---|
| 118 | shccflags = [ '/W3', '/Od', '/FD', '/EHsc', '/MDd', '/TP', '/D_DEBUG', '/DMS_VISUAL_STUDIO=1', '/DWIN32', '/D_WINDOWS', '/DWINVER=0x0500', '/D_USE_MATH_DEFINES', '/D_SCL_SECURE_NO_WARNINGS', '/D_CRT_SECURE_NO_WARNINGS', '/wd4275', '/wd4996' ] |
|---|
| 119 | else : |
|---|
| 120 | cflags = [ '/TC' ] |
|---|
| 121 | shcflags = cflags |
|---|
| 122 | cxxflags = [ '/TP' ] |
|---|
| 123 | shcxxflags = cxxflags |
|---|
| 124 | ccflags = ['/Ox', '/Ot', '/W3','/EHsc', '/MT', '/DMS_VISUAL_STUDIO=1', '/DWIN32', '/D_WINDOWS', '/DWINVER=0x0500', '/D_USE_MATH_DEFINES', '/D_SCL_SECURE_NO_WARNINGS', '/D_CRT_SECURE_NO_WARNINGS', '/wd4275'] |
|---|
| 125 | shccflags = ['/Ox', '/Ot', '/W3','/EHsc', '/MD', '/DMS_VISUAL_STUDIO=1', '/DWIN32', '/D_WINDOWS', '/DWINVER=0x0500', '/D_USE_MATH_DEFINES', '/D_SCL_SECURE_NO_WARNINGS', '/D_CRT_SECURE_NO_WARNINGS', '/wd4275'] |
|---|
| 126 | cppPaths.append(['#Windows_extra/include']) |
|---|
| 127 | shccflags.append(['/D_HDF5USEDLL_=1']) |
|---|
| 128 | else : |
|---|
| 129 | print "* COMMENCING LINUX BUILD *" |
|---|
| 130 | ccflags.append(['-Wall','-Wno-unused-variable','-Wno-sign-compare','-Wno-comment']) |
|---|
| 131 | if int(debug) : |
|---|
| 132 | ccflags.append(['-g','-O0']) |
|---|
| 133 | else : |
|---|
| 134 | ccflags.append(['-g','-O3']) |
|---|
| 135 | ccflags.append(['-fPIC']) |
|---|
| 136 | shccflags = ccflags |
|---|
| 137 | |
|---|
| 138 | env.Append(LINKFLAGS=['-g']) |
|---|
| 139 | libList.append(['hdf5','mfhdf','df','mxml','jpeg','z']) |
|---|
| 140 | libDirList.append(['/usr/lib64/hdf','/usr/lib/hdf']) |
|---|
| 141 | shlibList.append(['hdf5','mfhdf','df','mxml','jpeg','z']) |
|---|
| 142 | shlibDirList.append(['/usr/lib64/hdf','/usr/lib/hdf']) |
|---|
| 143 | cppPaths.append(['/usr/include/hdf']) |
|---|
| 144 | |
|---|
| 145 | libDirList.append('#Bin/Static') |
|---|
| 146 | shlibDirList.append('#Bin/Shared') |
|---|
| 147 | |
|---|
| 148 | #Export for SConscripts |
|---|
| 149 | env.Replace(SHOBJSUFFIX='.sob') # force separate shared and static objects |
|---|
| 150 | env.Replace(CFLAGS=cflags) |
|---|
| 151 | env.Replace(SHCFLAGS=shcflags) |
|---|
| 152 | env.Append(CXXFLAGS=cxxflags) |
|---|
| 153 | env.Append(SHCXXFLAGS=shcxxflags) |
|---|
| 154 | env.Replace(CCFLAGS=ccflags) |
|---|
| 155 | env.Replace(SHCCFLAGS=shccflags) |
|---|
| 156 | env.Append(CPPPATH=cppPaths) |
|---|
| 157 | env.Append(CPPDEFINES=cppDefines) |
|---|
| 158 | env.Replace(MYLIBLIST=libList) |
|---|
| 159 | env.Replace(MYLIBDIRLIST=libDirList) |
|---|
| 160 | env.Replace(MYSHLIBLIST=shlibList) |
|---|
| 161 | env.Replace(MYSHLIBDIRLIST=shlibDirList) |
|---|
| 162 | |
|---|
| 163 | Export('env') |
|---|
| 164 | |
|---|
| 165 | #Real work begins here |
|---|
| 166 | subProjs = [] |
|---|
| 167 | |
|---|
| 168 | subProjs.append('src') |
|---|
| 169 | subProjs.append('bindings/cpp') |
|---|
| 170 | |
|---|
| 171 | # we want to link libraries in the reverse order we build them |
|---|
| 172 | shared_libraries = [] |
|---|
| 173 | static_libraries = [] |
|---|
| 174 | shared_objects = [] |
|---|
| 175 | lib_list = [] |
|---|
| 176 | orig_libs = env['MYLIBLIST'] |
|---|
| 177 | shorig_libs = env['MYSHLIBLIST'] |
|---|
| 178 | |
|---|
| 179 | for subproj in subProjs: |
|---|
| 180 | ret = SConscript([subproj+'/SConscript']) |
|---|
| 181 | env.Install('Bin/Shared', ret['shared']) |
|---|
| 182 | env.Install('Bin/Static', ret['static']) |
|---|
| 183 | shared_libraries.insert(0,ret['shared']) |
|---|
| 184 | static_libraries.insert(0,ret['static']) |
|---|
| 185 | shared_objects = shared_objects + ret['sharedobjs'] |
|---|
| 186 | lib_list.insert(0,ret['libs']) |
|---|
| 187 | env.Replace(MYLIBLIST=lib_list + orig_libs) |
|---|
| 188 | env.Replace(MYSHLIBLIST=lib_list + shorig_libs) |
|---|
| 189 | |
|---|
| 190 | env.Replace(SHARED_LIST=shared_libraries) |
|---|
| 191 | env.Replace(STATIC_LIST=static_libraries) |
|---|
| 192 | |
|---|
| 193 | # |
|---|
| 194 | # Correct bug in windows scons - OBJSUFFIX is not substituted for some reason |
|---|
| 195 | # |
|---|
| 196 | for i in range(len(shared_objects)) : |
|---|
| 197 | shared_objects[i] = string.replace(shared_objects[i], '$OBJSUFFIX', env['OBJSUFFIX']) |
|---|
| 198 | |
|---|
| 199 | # main program |
|---|
| 200 | ret = SConscript(['applications/SConscript']) |
|---|
| 201 | env.Install('Bin/Shared', ret['shared']) |
|---|
| 202 | env.Install('Bin/Static', ret['static']) |
|---|
| 203 | |
|---|
| 204 | ret = SConscript(['test/SConscript']) |
|---|
| 205 | env.Install('Bin/Shared', ret['shared']) |
|---|
| 206 | env.Install('Bin/Static', ret['static']) |
|---|