source: trunk/SConstruct @ 1822

Revision 1107, 7.5 KB checked in by Freddie Akeroyd, 4 years ago (diff)

Add DLL_EXPORT for scons c++ on Windows. Refs #112.

  • Property svn:keywords set to HeadURL LastChangedBy LastChangedRevision LastChangedDate
Line 
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
34import os
35import platform
36import sys
37import shutil
38import re
39import string
40from socket import gethostname
41
42import nexus_scons_utils
43 
44opts = Options('scons_options.py')
45opts.Add('mingw','Set to 1 to use MinGW on Windows', 0)
46opts.Add('msvc','Set to 1 to use Microsoft Visual Studio Compiler on Windows', 1)
47opts.Add('debug','Set to 1 to build debug', 0)
48
49base_env = Environment(ENV=os.environ, options = opts)
50mingw_env = Environment(ENV=os.environ, options = opts, tools = [ 'mingw' ])
51Help(opts.GenerateHelpText(base_env))
52mingw = ARGUMENTS.get('mingw', 0)
53msvc = ARGUMENTS.get('msvc', 1)
54debug = ARGUMENTS.get('debug', 0)
55if int(msvc) :
56        env = base_env
57if int(mingw) :
58        env = mingw_env
59#get libraries and the library directories
60print 'Current path == ',os.getcwd()
61cwdpath=os.getcwd()
62uppath=os.path.abspath('../')
63
64shlibList = []
65libList = []
66if 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
71shlibDirList = []
72libDirList = []
73cflags = []
74shcflags = []
75cxxflags = []
76shcxxflags = []
77ccflags = []
78shccflags = []
79dirList = []
80cppPaths = []
81cppDefines = [ ('HDF5',1), ('NXXML',1), ('HDF4',1) ]
82#Get paths
83if 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'])
128else :
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
145libDirList.append('#Bin/Static')
146shlibDirList.append('#Bin/Shared')
147
148#Export for SConscripts
149env.Replace(SHOBJSUFFIX='.sob') # force separate shared and static objects
150env.Replace(CFLAGS=cflags)
151env.Replace(SHCFLAGS=shcflags)
152env.Append(CXXFLAGS=cxxflags)
153env.Append(SHCXXFLAGS=shcxxflags)
154env.Replace(CCFLAGS=ccflags)
155env.Replace(SHCCFLAGS=shccflags)
156env.Append(CPPPATH=cppPaths)
157env.Append(CPPDEFINES=cppDefines)
158env.Replace(MYLIBLIST=libList)
159env.Replace(MYLIBDIRLIST=libDirList)
160env.Replace(MYSHLIBLIST=shlibList)
161env.Replace(MYSHLIBDIRLIST=shlibDirList)
162
163Export('env')
164
165#Real work begins here
166subProjs = []
167
168subProjs.append('src')
169subProjs.append('bindings/cpp')
170
171# we want to link libraries in the reverse order we build them
172shared_libraries = []
173static_libraries = []
174shared_objects = []
175lib_list = []
176orig_libs = env['MYLIBLIST']
177shorig_libs = env['MYSHLIBLIST']
178
179for 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
190env.Replace(SHARED_LIST=shared_libraries)
191env.Replace(STATIC_LIST=static_libraries)
192
193#
194# Correct bug in windows scons - OBJSUFFIX is not substituted for some reason
195#
196for i in range(len(shared_objects)) :
197    shared_objects[i] = string.replace(shared_objects[i], '$OBJSUFFIX', env['OBJSUFFIX'])
198
199# main program
200ret = SConscript(['applications/SConscript'])
201env.Install('Bin/Shared', ret['shared'])
202env.Install('Bin/Static', ret['static'])
203
204ret = SConscript(['test/SConscript'])
205env.Install('Bin/Shared', ret['shared'])
206env.Install('Bin/Static', ret['static'])
Note: See TracBrowser for help on using the repository browser.