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 <warnings>extra : -fullwarn ;
73flags mipspro.compile OPTIONS <warnings>pedantic : -fullwarn -ansiW -diag_suppress 1429 ; # suppress long long is nonstandard warning
74flags mipspro.compile OPTIONS <warnings-as-errors>on : -w2 ;
75flags mipspro.compile OPTIONS <optimization>speed : -Ofast ;
76flags mipspro.compile OPTIONS <optimization>space : -O2 ;
77flags mipspro.compile OPTIONS <cflags> : "-LANG:std" ;
78flags mipspro.compile.c++ OPTIONS <inlining>off : "-INLINE:none" ;
79flags mipspro.compile.c++ OPTIONS <cxxflags> ;
80flags mipspro.compile DEFINES <define> ;
81flags mipspro.compile INCLUDES <include> ;
82
83
84flags mipspro.compile.fortran OPTIONS <fflags> ;
85
86actions compile.c
87{
88    "$(CONFIG_C_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
89}
90
91actions compile.c++
92{
93    "$(CONFIG_COMMAND)" -FE:template_in_elf_section -ptused $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
94}
95
96actions compile.fortran
97{
98    "$(CONFIG_F_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
99}
100
101# Declare flags and actions for linking
102flags mipspro.link OPTIONS <debug-symbols>on : -g ;
103# Strip the binary when no debugging is needed
104# flags mipspro.link OPTIONS <debug-symbols>off : -s ;
105# flags mipspro.link OPTIONS <profiling>on : -xprofile=tcov ;
106# flags mipspro.link OPTIONS <threading>multi : -mt ;
107
108flags mipspro.link OPTIONS $(cpu-arch-32) : -n32 ;
109flags mipspro.link OPTIONS $(cpu-arch-64) : -64 ;
110
111flags mipspro.link OPTIONS <optimization>speed : -Ofast ;
112flags mipspro.link OPTIONS <optimization>space : -O2 ;
113flags mipspro.link OPTIONS <linkflags> ;
114flags mipspro.link LINKPATH <library-path> ;
115flags mipspro.link FINDLIBS-ST <find-static-library> ;
116flags mipspro.link FINDLIBS-SA <find-shared-library> ;
117flags mipspro.link FINDLIBS-SA <threading>multi : pthread ;
118flags mipspro.link LIBRARIES <library-file> ;
119flags mipspro.link LINK-RUNTIME <runtime-link>static : static ;
120flags mipspro.link LINK-RUNTIME <runtime-link>shared : dynamic ;
121flags mipspro.link RPATH <dll-path> ;
122
123rule link ( targets * : sources * : properties * )
124{
125    SPACE on $(targets) = " " ;
126}
127
128actions link bind LIBRARIES
129{
130    "$(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
131}
132
133# Slight mods for dlls
134rule link.dll ( targets * : sources * : properties * )
135{
136    SPACE on $(targets) = " " ;
137}
138
139actions link.dll bind LIBRARIES
140{
141    "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME)
142}
143
144# Declare action for creating static libraries
145actions piecemeal archive
146{
147    ar -cr "$(<)" "$(>)"
148}
149