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>latest : -std=c++17 ; 61 62flags pgi.compile OPTIONS <link>shared : -fpic ; 63flags pgi.compile OPTIONS <debug-symbols>on : -gopt ; 64flags pgi.compile OPTIONS <optimization>off : -O0 ; 65flags pgi.compile OPTIONS <optimization>speed : -fast ; 66flags pgi.compile OPTIONS <optimization>space : -fast ; 67 68flags pgi.compile OPTIONS <warnings>off : -Minform=severe ; 69flags pgi.compile OPTIONS <warnings>on : -Minform=warn ; 70flags pgi.compile OPTIONS <warnings>all : -Minform=warn ; 71flags pgi.compile OPTIONS <warnings-as-errors>on : -Werror ; 72 73flags pgi.compile.c++ OPTIONS <rtti>off : --no_rtti ; 74flags pgi.compile.c++ OPTIONS <exception-handling>off : --no_exceptions ; 75 76flags pgi.compile OPTIONS <cflags> ; 77flags pgi.compile.c++ OPTIONS <cxxflags> ; 78flags pgi.compile DEFINES <define> ; 79flags pgi.compile INCLUDES <include> ; 80 81flags pgi.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)" $(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 pgi.link OPTIONS <debug-symbols>on : -gopt ; 100# Strip the binary when no debugging is needed 101flags pgi.link OPTIONS <debug-symbols>off : -s ; 102flags pgi.link OPTIONS <linkflags> ; 103flags pgi.link OPTIONS <link>shared : -fpic ; 104flags pgi.link LINKPATH <library-path> ; 105flags pgi.link FINDLIBS-ST <find-static-library> ; 106flags pgi.link FINDLIBS-SA <find-shared-library> ; 107flags pgi.link FINDLIBS-SA <threading>multi : pthread rt ; 108flags pgi.link LIBRARIES <library-file> ; 109flags pgi.link LINK-RUNTIME <runtime-link>static : static ; 110flags pgi.link LINK-RUNTIME <runtime-link>shared : dynamic ; 111flags pgi.link RPATH <dll-path> ; 112 113rule link ( targets * : sources * : properties * ) 114{ 115 SPACE on $(targets) = " " ; 116} 117 118actions link bind LIBRARIES 119{ 120 "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) 121} 122 123# Slight mods for dlls 124rule link.dll ( targets * : sources * : properties * ) 125{ 126 SPACE on $(targets) = " " ; 127} 128 129actions link.dll bind LIBRARIES 130{ 131 "$(CONFIG_COMMAND)" $(OPTIONS) -shared -L"$(LINKPATH)" -R"$(RPATH)" -soname $(<[-1]:D=) -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) 132} 133 134actions updated together piecemeal pgi.archive 135{ 136 ar -rc$(ARFLAGS:E=) "$(<)" "$(>)" 137} 138 139