1#  Copyright 2006 Noel Belcourt
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 toolset : flags ;
9import feature ;
10import type ;
11import os ;
12import common ;
13import fortran ;
14
15feature.extend toolset : pathscale ;
16toolset.inherit pathscale : unix ;
17generators.override pathscale.prebuilt : builtin.prebuilt ;
18generators.override pathscale.searched-lib-generator : searched-lib-generator ;
19
20# Documentation and toolchain description located
21# http://www.pathscale.com/docs.html
22
23rule init ( version ? : command * : options * )
24{
25  command = [ common.get-invocation-command pathscale : pathCC : $(command)
26    : /opt/ekopath/bin ] ;
27
28  # Determine the version
29  local command-string = $(command:J=" ") ;
30  if $(command)
31  {
32      version ?= [ MATCH "^([0-9.]+)"
33          : [ SHELL "$(command-string) -dumpversion" ] ] ;
34  }
35
36  local condition = [ common.check-init-parameters pathscale
37    : version $(version) ] ;
38
39  common.handle-options pathscale : $(condition) : $(command) : $(options) ;
40
41  toolset.flags pathscale.compile.fortran90 OPTIONS $(condition) :
42    [ feature.get-values <fflags> : $(options) ] : unchecked ;
43
44  command_c = $(command_c[1--2]) $(command[-1]:B=pathcc) ;
45
46  toolset.flags pathscale CONFIG_C_COMMAND $(condition) : $(command_c) ;
47
48  # fortran support
49  local f-command = [ common.get-invocation-command pathscale : pathf90 : $(command) ] ;
50  local command_f = $(command_f[1--2]) $(f-command[-1]:B=pathf90) ;
51  local command_f90 = $(command_f[1--2]) $(f-command[-1]:B=pathf90) ;
52
53  toolset.flags pathscale CONFIG_F_COMMAND $(condition) : $(command_f) ;
54  toolset.flags pathscale CONFIG_F90_COMMAND $(condition) : $(command_f90) ;
55
56  # always link lib rt to resolve clock_gettime()
57  flags pathscale.link FINDLIBS-SA : rt : unchecked ;
58
59  switch [ os.name ]
60  {
61    case SOLARIS :
62        toolset.flags pathscale.link RPATH_OPTION $(condition) : -Wl,-R, -Wl, : unchecked ;
63
64    case * : # GNU
65        toolset.flags pathscale.link RPATH_OPTION $(condition) : -Wl,-rpath=  : unchecked ;
66  }
67}
68
69# Declare generators
70generators.register-c-compiler pathscale.compile.c : C : OBJ : <toolset>pathscale ;
71generators.register-c-compiler pathscale.compile.c++ : CPP : OBJ : <toolset>pathscale ;
72generators.register-fortran-compiler pathscale.compile.fortran : FORTRAN : OBJ : <toolset>pathscale ;
73generators.register-fortran90-compiler pathscale.compile.fortran90 : FORTRAN90 : OBJ : <toolset>pathscale ;
74
75# Declare flags and actions for compilation
76flags pathscale.compile OPTIONS <optimization>off   : -O0 ;
77flags pathscale.compile OPTIONS <optimization>speed : -O3 ;
78flags pathscale.compile OPTIONS <optimization>space : -Os ;
79
80flags pathscale.compile OPTIONS <inlining>off  : -noinline ;
81flags pathscale.compile OPTIONS <inlining>on   : -inline ;
82flags pathscale.compile OPTIONS <inlining>full : -inline ;
83
84flags pathscale.compile OPTIONS <warnings>off           : -woffall ;
85flags pathscale.compile OPTIONS <warnings>on            : -Wall ;
86flags pathscale.compile OPTIONS <warnings>all           : -Wall ;
87flags pathscale.compile OPTIONS <warnings>extra         : -Wall -Wextra ;
88flags pathscale.compile OPTIONS <warnings>pedantic      : -Wall -Wextra -pedantic ;
89flags pathscale.compile OPTIONS <warnings-as-errors>on  : -Werror ;
90
91flags pathscale.compile OPTIONS <debug-symbols>on : -ggdb ;
92flags pathscale.compile OPTIONS <profiling>on     : -pg ;
93flags pathscale.compile OPTIONS <link>shared      : -fPIC ;
94flags pathscale.compile OPTIONS <address-model>32 : -m32 ;
95flags pathscale.compile OPTIONS <address-model>64 : -m64 ;
96
97flags pathscale.compile USER_OPTIONS <cflags> ;
98flags pathscale.compile.c++ USER_OPTIONS <cxxflags> ;
99flags pathscale.compile DEFINES <define> ;
100flags pathscale.compile INCLUDES <include> ;
101
102flags pathscale.compile.fortran USER_OPTIONS <fflags> ;
103flags pathscale.compile.fortran90 USER_OPTIONS <fflags> ;
104
105actions compile.c
106{
107    "$(CONFIG_C_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
108}
109
110actions compile.c++
111{
112    "$(CONFIG_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
113}
114
115actions compile.fortran
116{
117    "$(CONFIG_F_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
118}
119
120rule compile.fortran90 ( targets * : sources * : properties * )
121{
122  # the space rule inserts spaces between targets and it's necessary
123  SPACE on $(targets) = " " ;
124  # Serialize execution of the compile.fortran90 action
125  # F90 source must be compiled in a particular order so we
126  # serialize the build as a parallel F90 compile might fail
127  JAM_SEMAPHORE on $(targets) = <s>pathscale-f90-semaphore ;
128}
129
130actions compile.fortran90
131{
132    "$(CONFIG_F90_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -module $(<[1]:D) -c -o "$(<)" "$(>)"
133}
134
135# Declare flags and actions for linking
136flags pathscale.link OPTIONS <debug-symbols>on : -ggdb -rdynamic ;
137# Strip the binary when no debugging is needed
138flags pathscale.link OPTIONS <debug-symbols>off : -g0 ;
139flags pathscale.link OPTIONS <profiling>on : -pg ;
140flags pathscale.link USER_OPTIONS <linkflags> ;
141flags pathscale.link LINKPATH <library-path> ;
142flags pathscale.link FINDLIBS-ST <find-static-library> ;
143flags pathscale.link FINDLIBS-SA <find-shared-library> ;
144flags pathscale.link FINDLIBS-SA <threading>multi : pthread ;
145flags pathscale.link LIBRARIES <library-file> ;
146flags pathscale.link LINK-RUNTIME <runtime-link>static : static ;
147flags pathscale.link LINK-RUNTIME <runtime-link>shared : dynamic ;
148flags pathscale.link RPATH <dll-path> ;
149# On gcc, there are separate options for dll path at runtime and
150# link time. On Solaris, there's only one: -R, so we have to use
151# it, even though it's bad idea.
152flags pathscale.link RPATH <xdll-path> ;
153
154rule link ( targets * : sources * : properties * )
155{
156    SPACE on $(targets) = " " ;
157}
158
159actions link bind LIBRARIES
160{
161    "$(CONFIG_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -L"$(LINKPATH)" $(RPATH_OPTION:E=-Wl,-rpath=)"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST)
162}
163
164# Slight mods for dlls
165rule link.dll ( targets * : sources * : properties * )
166{
167    SPACE on $(targets) = " " ;
168}
169
170actions link.dll bind LIBRARIES
171{
172    "$(CONFIG_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -L"$(LINKPATH)" $(RPATH_OPTION:E=-Wl,-rpath=)"$(RPATH)" -o "$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST)
173}
174
175# Declare action for creating static libraries
176# "$(CONFIG_COMMAND)" -ar -o "$(<)" "$(>)"
177actions piecemeal archive
178{
179    ar $(ARFLAGS) ru "$(<)" "$(>)"
180}
181