/ src / SConscript
SConscript
 1  #
 2  # Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved.
 3  #
 4  # Redistribution and use in source and binary forms, with or without modification,
 5  # are permitted provided that the following conditions are met:
 6  # 1. Redistributions of source code must retain the above copyright notice,
 7  #    this list of conditions and the following disclaimer.
 8  # 2. Redistributions in binary form must reproduce the above copyright notice,
 9  #    this list of conditions and the following disclaimer in the documentation
10  #    and/or other materials provided with the distribution.
11  # 3. Neither the name of the copyright holder nor the names of its contributors
12  #    may be used to endorse or promote products derived from this software without
13  #    specific prior written permission.
14  #
15  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16  # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19  # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21  # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24  # POSSIBILITY OF SUCH DAMAGE.
25  
26  # Inherit global environment
27  Import('env')
28  from os.path import join as joinpath
29  
30  builddir = joinpath(env['BUILDROOT'], 'src')
31  
32  e = env.Clone()
33  e.Append(
34      CCFLAGS = ['-Wall', '-W', '-Wstrict-prototypes', '-Werror',
35                 #'-Wno-unused-but-set-parameter',
36                 '-Wno-unused-parameter',
37                 '-fPIC',
38                 '-mavx2', '-march=znver2'],
39      # CPPPATH = [],
40      # CCFLAGS = [],
41      # LINKFLAGS = [],
42      LINKERSCRIPT = 'src/ld-syms-libm.lds',
43      STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME = 1
44  )
45  
46  alm_objs = []
47  
48  almenv = e.Clone()
49  almenv.Append(
50      LINKFLAGS = ['-ealm_main'], # ['-T$LINKERSCRIPT']
51      LIBS      = ['c'],
52  )
53  
54  subdirs = ['isa', 'optmized', 'iface', 'arch', 'ref']
55  for d in subdirs:
56  	denv = almenv.Clone()
57  	sdir = joinpath(denv['CWD'], d)
58  	denv.Append(
59  		CWD = sdir
60  	)
61  	alm_objs += SConscript('%s/SConscript'%d,
62  			    exports = {'env' : denv},
63  			    duplicate = 0,
64                              src_dir = sdir,
65                              variant_dir = joinpath(builddir, '%s'%d))
66  
67  lib_excludes = ['MapEntryPoints.c']
68  lib_srcs = Glob('*.[c]', exclude=lib_excludes)
69  
70  alm_objs += almenv.StaticObject(lib_srcs)
71  
72  libm = almenv.StaticLibrary('alm', alm_objs)
73  libmso = almenv.SharedLibrary('alm', alm_objs)
74  
75  
76  fast_libm = SConscript('fast/SConscript',
77                         exports = {'env' : e},
78                         duplicate = 0,
79                         src_dir = '#src/fast',
80                         variant_dir = joinpath(builddir, 'fast'))
81  
82  Depends(libmso, '#src/ld-syms-libm.lds')
83  
84  Return('fast_libm', 'libm', 'libmso')
85