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 ; 14import gcc ; 15 16feature.extend toolset : pgi ; 17toolset.inherit pgi : unix ; 18generators.override pgi.prebuilt : builtin.lib-generator ; 19generators.override pgi.searched-lib-generator : searched-lib-generator ; 20 21# Documentation and toolchain description located 22# http://www.pgroup.com/resources/docs.htm 23 24rule init ( version ? : command * : options * ) 25{ 26 local condition = [ common.check-init-parameters pgi : version $(version) ] ; 27 28 local l_command = [ common.get-invocation-command pgi : pgCC : $(command) ] ; 29 30 common.handle-options pgi : $(condition) : $(l_command) : $(options) ; 31 32 command_c = $(command_c[1--2]) $(l_command[-1]:B=pgcc) ; 33 34 toolset.flags pgi CONFIG_C_COMMAND $(condition) : $(command_c) ; 35 36 flags pgi.compile DEFINES $(condition) : 37 [ feature.get-values <define> : $(options) ] : unchecked ; 38 39 # IOV_MAX support 40 flags pgi.compile DEFINES $(condition) : __need_IOV_MAX : unchecked ; 41 42 # set link flags 43 flags pgi.link FINDLIBS-ST : [ 44 feature.get-values <find-static-library> : $(options) ] : unchecked ; 45 46 # always link lib rt to resolve clock_gettime() 47 flags pgi.link FINDLIBS-SA : rt [ 48 feature.get-values <find-shared-library> : $(options) ] : unchecked ; 49 50 gcc.init-link-flags pgi gnu $(condition) ; 51} 52 53# Declare generators 54generators.register-c-compiler pgi.compile.c : C : OBJ : <toolset>pgi ; 55generators.register-c-compiler pgi.compile.c++ : CPP : OBJ : <toolset>pgi ; 56generators.register-fortran-compiler pgi.compile.fortran : FORTRAN : OBJ : <toolset>pgi ; 57 58# Declare flags and actions for compilation 59flags pgi.compile OPTIONS : -Kieee ; 60flags pgi.compile OPTIONS <link>shared : -fpic -fPIC ; 61flags pgi.compile OPTIONS <debug-symbols>on : -gopt ; 62flags pgi.compile OPTIONS <profiling>on : -xprofile=tcov ; 63flags pgi.compile OPTIONS <optimization>speed : -fast -Mx,8,0x10000000 ; 64flags pgi.compile OPTIONS <optimization>space : -xO2 -xspace ; 65# flags pgi.compile OPTIONS <threading>multi : -mt ; 66 67flags pgi.compile OPTIONS <warnings>off : -Minform=severe ; 68flags pgi.compile OPTIONS <warnings>on : -Minform=warn ; 69 70flags pgi.compile.c++ OPTIONS <inlining>off : -INLINE:none ; 71 72flags pgi.compile OPTIONS <cflags> ; 73flags pgi.compile.c++ OPTIONS <cxxflags> ; 74flags pgi.compile DEFINES <define> ; 75flags pgi.compile INCLUDES <include> ; 76 77flags pgi.compile.fortran OPTIONS <fflags> ; 78 79actions compile.c 80{ 81 "$(CONFIG_C_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" 82} 83 84actions compile.c++ 85{ 86 "$(CONFIG_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" 87} 88 89actions compile.fortran 90{ 91 "$(CONFIG_F_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" 92} 93 94# Declare flags and actions for linking 95flags pgi.link OPTIONS <debug-symbols>on : -gopt ; 96# Strip the binary when no debugging is needed 97flags pgi.link OPTIONS <debug-symbols>off : -s ; 98flags pgi.link OPTIONS <profiling>on : -xprofile=tcov ; 99flags pgi.link OPTIONS <linkflags> ; 100flags pgi.link OPTIONS <link>shared : -fpic -fPIC ; 101flags pgi.link LINKPATH <library-path> ; 102flags pgi.link FINDLIBS-ST <find-static-library> ; 103flags pgi.link FINDLIBS-SA <find-shared-library> ; 104flags pgi.link FINDLIBS-SA <threading>multi : pthread rt ; 105flags pgi.link LIBRARIES <library-file> ; 106flags pgi.link LINK-RUNTIME <runtime-link>static : static ; 107flags pgi.link LINK-RUNTIME <runtime-link>shared : dynamic ; 108flags pgi.link RPATH <dll-path> ; 109 110# On gcc, there are separate options for dll path at runtime and 111# link time. On Solaris, there's only one: -R, so we have to use 112# it, even though it's bad idea. 113flags pgi.link RPATH <xdll-path> ; 114 115rule link ( targets * : sources * : properties * ) 116{ 117 SPACE on $(targets) = " " ; 118} 119 120# reddish can only link statically and, somehow, the presence of -Bdynamic on the link line 121# marks the executable as a dynamically linked exec even though no dynamic libraries are supplied. 122# Yod on redstorm refuses to load an executable that is dynamically linked. 123# removing the dynamic link options should get us where we need to be on redstorm. 124# "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME) 125actions link bind LIBRARIES 126{ 127 "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Bstatic -l$(FINDLIBS-ST) -Bdynamic -l$(FINDLIBS-SA) -B$(LINK-RUNTIME) 128} 129 130# Slight mods for dlls 131rule link.dll ( targets * : sources * : properties * ) 132{ 133 SPACE on $(targets) = " " ; 134} 135 136# "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" -h$(<[1]:D=) -G "$(>)" "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME) 137 138actions link.dll bind LIBRARIES 139{ 140 "$(CONFIG_COMMAND)" $(OPTIONS) -shared -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" -Wl,-h -Wl,$(<[1]:D=) "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME) 141} 142 143actions updated together piecemeal pgi.archive 144{ 145 ar -rc$(ARFLAGS:E=) "$(<)" "$(>)" 146} 147 148