1#  Copyright Noel Belcourt 2007.
2#  Distributed under the Boost Software License, Version 1.0.
3#    (See accompanying file LICENSE_1_0.txt or copy at
4#          http://www.boost.org/LICENSE_1_0.txt)
5
6import property ;
7import generators ;
8import os ;
9import toolset : flags ;
10import feature ;
11import fortran ;
12import type ;
13import common ;
14
15feature.extend toolset : mipspro ;
16toolset.inherit mipspro : unix ;
17generators.override mipspro.prebuilt : builtin.lib-generator ;
18generators.override mipspro.searched-lib-generator : searched-lib-generator ;
19
20#  Documentation and toolchain description located
21#  http://www.sgi.com/products/software/irix/tools/
22
23rule init ( version ? : command * : options * )
24{
25  local condition = [
26    common.check-init-parameters mipspro : version $(version) ] ;
27
28  command = [ common.get-invocation-command mipspro : CC : $(command) ] ;
29
30  common.handle-options mipspro : $(condition) : $(command) : $(options) ;
31
32  command_c = $(command_c[1--2]) $(command[-1]:B=cc) ;
33
34  toolset.flags mipspro CONFIG_C_COMMAND $(condition) : $(command_c) ;
35
36  # fortran support
37  local command = [
38    common.get-invocation-command mipspro : f77 : $(command) : $(install_dir) ] ;
39
40  command_f = $(command_f[1--2]) $(command[-1]:B=f77) ;
41  toolset.flags mipspro CONFIG_F_COMMAND $(condition) : $(command_f) ;
42
43  # set link flags
44  flags mipspro.link FINDLIBS-ST : [
45    feature.get-values <find-static-library> : $(options) ] : unchecked ;
46
47  flags mipspro.link FINDLIBS-SA : [
48    feature.get-values <find-shared-library> : $(options) ] : unchecked ;
49}
50
51# Declare generators
52generators.register-c-compiler mipspro.compile.c : C : OBJ : <toolset>mipspro ;
53generators.register-c-compiler mipspro.compile.c++ : CPP : OBJ : <toolset>mipspro ;
54generators.register-fortran-compiler mipspro.compile.fortran : FORTRAN : OBJ : <toolset>mipspro ;
55
56cpu-arch-32 =
57  <architecture>/<address-model>
58  <architecture>/<address-model>32 ;
59
60cpu-arch-64 =
61  <architecture>/<address-model>64 ;
62
63flags mipspro.compile OPTIONS $(cpu-arch-32) : -n32 ;
64flags mipspro.compile OPTIONS $(cpu-arch-64) : -64 ;
65
66# Declare flags and actions for compilation
67flags mipspro.compile OPTIONS <debug-symbols>on : -g ;
68# flags mipspro.compile OPTIONS <profiling>on : -xprofile=tcov ;
69flags mipspro.compile OPTIONS <warnings>off : -w ;
70flags mipspro.compile OPTIONS <warnings>on : -ansiW -diag_suppress 1429 ; # suppress long long is nonstandard warning
71flags mipspro.compile OPTIONS <warnings>all : -fullwarn ;
72flags mipspro.compile OPTIONS <optimization>speed : -Ofast ;
73flags mipspro.compile OPTIONS <optimization>space : -O2 ;
74flags mipspro.compile OPTIONS <cflags> : "-LANG:std" ;
75flags mipspro.compile.c++ OPTIONS <inlining>off : "-INLINE:none" ;
76flags mipspro.compile.c++ OPTIONS <cxxflags> ;
77flags mipspro.compile DEFINES <define> ;
78flags mipspro.compile INCLUDES <include> ;
79
80
81flags mipspro.compile.fortran OPTIONS <fflags> ;
82
83actions compile.c
84{
85    "$(CONFIG_C_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
86}
87
88actions compile.c++
89{
90    "$(CONFIG_COMMAND)" -FE:template_in_elf_section -ptused $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
91}
92
93actions compile.fortran
94{
95    "$(CONFIG_F_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
96}
97
98# Declare flags and actions for linking
99flags mipspro.link OPTIONS <debug-symbols>on : -g ;
100# Strip the binary when no debugging is needed
101# flags mipspro.link OPTIONS <debug-symbols>off : -s ;
102# flags mipspro.link OPTIONS <profiling>on : -xprofile=tcov ;
103# flags mipspro.link OPTIONS <threading>multi : -mt ;
104
105flags mipspro.link OPTIONS $(cpu-arch-32) : -n32 ;
106flags mipspro.link OPTIONS $(cpu-arch-64) : -64 ;
107
108flags mipspro.link OPTIONS <optimization>speed : -Ofast ;
109flags mipspro.link OPTIONS <optimization>space : -O2 ;
110flags mipspro.link OPTIONS <linkflags> ;
111flags mipspro.link LINKPATH <library-path> ;
112flags mipspro.link FINDLIBS-ST <find-static-library> ;
113flags mipspro.link FINDLIBS-SA <find-shared-library> ;
114flags mipspro.link FINDLIBS-SA <threading>multi : pthread ;
115flags mipspro.link LIBRARIES <library-file> ;
116flags mipspro.link LINK-RUNTIME <runtime-link>static : static ;
117flags mipspro.link LINK-RUNTIME <runtime-link>shared : dynamic ;
118flags mipspro.link RPATH <dll-path> ;
119
120rule link ( targets * : sources * : properties * )
121{
122    SPACE on $(targets) = " " ;
123}
124
125actions link bind LIBRARIES
126{
127    "$(CONFIG_COMMAND)" -FE:template_in_elf_section -ptused $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME) -lm
128}
129
130# Slight mods for dlls
131rule link.dll ( targets * : sources * : properties * )
132{
133    SPACE on $(targets) = " " ;
134}
135
136actions link.dll bind LIBRARIES
137{
138    "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME)
139}
140
141# Declare action for creating static libraries
142actions piecemeal archive
143{
144    ar -cr "$(<)" "$(>)"
145}
146