1#  Copyright Noel Belcourt 2007.
2#  Copyright 2017, NVIDIA CORPORATION.
3#  Distributed under the Boost Software License, Version 1.0.
4#    (See accompanying file LICENSE_1_0.txt or copy at
5#          http://www.boost.org/LICENSE_1_0.txt)
6
7import property ;
8import generators ;
9import os ;
10import toolset : flags ;
11import feature ;
12import fortran ;
13import type ;
14import common ;
15import gcc ;
16
17feature.extend toolset : pgi ;
18toolset.inherit pgi : unix ;
19generators.override pgi.prebuilt : builtin.lib-generator ;
20generators.override pgi.searched-lib-generator : searched-lib-generator ;
21
22# Documentation and toolchain description located
23# http://www.pgroup.com/resources/docs.htm
24
25rule init ( version ? : command * : options * )
26{
27  local condition = [ common.check-init-parameters pgi : version $(version) ] ;
28
29  local l_command = [ common.get-invocation-command pgi : pgc++ : $(command) ] ;
30
31  common.handle-options pgi : $(condition) : $(l_command) : $(options) ;
32
33  command_c = $(command_c[1--2]) $(l_command[-1]:B=pgcc) ;
34
35  toolset.flags pgi CONFIG_C_COMMAND $(condition) : $(command_c) ;
36
37  flags pgi.compile DEFINES $(condition) :
38    [ feature.get-values <define> : $(options) ] : unchecked ;
39
40  # set link flags
41  flags pgi.link FINDLIBS-ST : [
42    feature.get-values <find-static-library> : $(options) ] : unchecked ;
43}
44
45# Declare generators
46generators.register-c-compiler pgi.compile.c : C : OBJ : <toolset>pgi ;
47generators.register-c-compiler pgi.compile.c++ : CPP : OBJ : <toolset>pgi ;
48generators.register-fortran-compiler pgi.compile.fortran : FORTRAN : OBJ : <toolset>pgi ;
49
50# Declare flags and actions for compilation
51flags pgi.compile.c++ OPTIONS <cxxstd>98 : -std=c++03 ;
52flags pgi.compile.c++ OPTIONS <cxxstd>03 : -std=c++03 ;
53flags pgi.compile.c++ OPTIONS <cxxstd>0x : -std=c++11 ;
54flags pgi.compile.c++ OPTIONS <cxxstd>11 : -std=c++11 ;
55flags pgi.compile.c++ OPTIONS <cxxstd>1y : -std=c++14 ;
56flags pgi.compile.c++ OPTIONS <cxxstd>14 : -std=c++14 ;
57flags pgi.compile.c++ OPTIONS <cxxstd>1z : -std=c++17 ;
58flags pgi.compile.c++ OPTIONS <cxxstd>17 : -std=c++17 ;
59flags pgi.compile.c++ OPTIONS <cxxstd>2a : -std=c++17 ;
60flags pgi.compile.c++ OPTIONS <cxxstd>20 : -std=c++17 ;
61flags pgi.compile.c++ OPTIONS <cxxstd>latest : -std=c++17 ;
62
63flags pgi.compile OPTIONS <link>shared : -fpic ;
64flags pgi.compile OPTIONS <debug-symbols>on : -gopt ;
65flags pgi.compile OPTIONS <optimization>off : -O0 ;
66flags pgi.compile OPTIONS <optimization>speed : -fast ;
67flags pgi.compile OPTIONS <optimization>space : -fast ;
68
69flags pgi.compile OPTIONS <warnings>off : -Minform=severe ;
70flags pgi.compile OPTIONS <warnings>on : -Minform=warn ;
71flags pgi.compile OPTIONS <warnings>all : -Minform=warn ;
72flags pgi.compile OPTIONS <warnings>extra : -Minform=inform ;
73flags pgi.compile OPTIONS <warnings>pedantic : -Minform=inform ;
74flags pgi.compile OPTIONS <warnings-as-errors>on : -Werror ;
75
76flags pgi.compile.c++ OPTIONS <rtti>off : --no_rtti ;
77flags pgi.compile.c++ OPTIONS <exception-handling>off : --no_exceptions ;
78
79flags pgi.compile OPTIONS <cflags> ;
80flags pgi.compile.c++ OPTIONS <cxxflags> ;
81flags pgi.compile DEFINES <define> ;
82flags pgi.compile INCLUDES <include> ;
83
84flags pgi.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)" $(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 pgi.link OPTIONS <debug-symbols>on : -gopt ;
103# Strip the binary when no debugging is needed
104flags pgi.link OPTIONS <debug-symbols>off : -s ;
105flags pgi.link OPTIONS <linkflags> ;
106flags pgi.link OPTIONS <link>shared : -fpic ;
107flags pgi.link LINKPATH <library-path> ;
108flags pgi.link FINDLIBS-ST <find-static-library> ;
109flags pgi.link FINDLIBS-SA <find-shared-library> ;
110flags pgi.link FINDLIBS-SA <threading>multi : pthread rt ;
111flags pgi.link LIBRARIES <library-file> ;
112flags pgi.link LINK-RUNTIME <runtime-link>static : static ;
113flags pgi.link LINK-RUNTIME <runtime-link>shared : dynamic ;
114flags pgi.link RPATH <dll-path> ;
115
116rule link ( targets * : sources * : properties * )
117{
118    SPACE on $(targets) = " " ;
119}
120
121actions link bind LIBRARIES
122{
123    "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA)
124}
125
126# Slight mods for dlls
127rule link.dll ( targets * : sources * : properties * )
128{
129    SPACE on $(targets) = " " ;
130}
131
132actions link.dll bind LIBRARIES
133{
134    "$(CONFIG_COMMAND)" $(OPTIONS) -shared -L"$(LINKPATH)" -R"$(RPATH)" -soname $(<[-1]:D=) -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST)
135}
136
137actions updated together piecemeal pgi.archive
138{
139    ar -rc$(ARFLAGS:E=) "$(<)" "$(>)"
140}
141
142