#
#     Copyright (c) 2017-2018, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#

# Compiler Configurations common to native compilers
#

variable LIBATOMICSTATICERROR is default($land($STATICLIB,$LIBATOMICSTATICNOTFOUND));
variable LIBATOMICSTATICERRORMESSAGE is default("The static version 'libatomic.a' was not found in this system. Please, remove '-static' from the compilation line, use '-static-nvidia', or install the missing library.");
error($if($land($LOCALRC,$LIBATOMICSTATICERROR),$LIBATOMICSTATICERRORMESSAGE));

variable LIBATOMICSTATICNOTFOUND is
    help("Set to 1 when static version of libatomic library is not present in the system.")
    default(0);

set LIBATOMICSTATICNOTFOUND=$not($lor($isfile($GCCDIR/libatomic.a),$isdir($LIBATOMICSTATICDIR)));

# Global variables that need to be visible at earliest include
variable LLVMOPTUSERARGS is default();
variable LLVMLLCUSERARGS is default();
variable LLVM_NOSLP is default(0);

# See FS#33287 for context
variable SLPVECTORIZEHOR is default(1);

# File suffixes
suffix c is
	string(c $CPPASC $SITECSUFFIX $USERCSUFFIX $if($PREPROCONLY,$CHEADERSUFFIX))
	help(C source: preprocess, compile, assemble, link);
suffix i is
	string(i)
	help(Preprocessed C source: compile, assemble, link);
suffix cpp is
	string($CPPASCPP $SITECPPSUFFIX $USERCPPSUFFIX $if($PREPROCONLY,$CPPHEADERSUFFIX))
	help(C++ source: preprocess, compile, assemble, link);
suffix cu is
    hide
	string($CUASCU $SITECUSUFFIX $USERCUSUFFIX $if($PREPROCONLY,$CUHEADERSUFFIX))
	help(CUDA C/C++ source: preprocess, compile, assemble, link);
suffix cup is
    hide
	string($CUPASCUP $SITECUPSUFFIX $USERCUPSUFFIX)
	help(CUDA Preprocessed C/C++ source: compile, assemble, link);

# C, C++, Fortran drivers supported
variable DRIVER is default();

# Is `-Werror` enabled?
variable ISWERROR is default(0);

variable ISFTN is default(0);
variable IS_C_OR_CPP is default($if($or($equal($DRIVERLANG,"C"),$equal($DRIVERLANG,"CPP")),YES));
variable CPPASC is default();
variable CPPASCPP is default($DEFAULTCPPASCPP);
variable DEFAULTCPPASCPP is default(C cpp cc cxx "c++");
variable COMPLIBSTATIC is default();
variable DEFAULTCHEADERS is default(h);
variable CHEADERSUFFIX is default($DEFAULTCHEADERS);
variable DEFAULTCPPHEADERS is default(H hpp hh hxx "h++");
variable CPPHEADERSUFFIX is default($DEFAULTCPPHEADERS);
variable NEEDLOCSCRIPT is default(0) help(Flag whether to include the linker script for shared objects);
variable LOCSCRIPT is default($NEEDLOCSCRIPT) help(Flag whether to include the linker script for shared objects);
variable NUMFILES is default($count($files));
variable SINGLE_FILE is default($if($expr($NUMFILES==1),YES));
variable SINGLE_CXX_FILE is default($if($and($IS_C_OR_CPP,$SINGLE_FILE),YES));

# FS#32731 FS#33125
# An nvidia mod overrides alias analysis in some cases because of a Fortran
# bug, and this hinders TBAA. The LLVM option -override-aa-for-tbaa=false
# enables upstream behavior.
variable OVERRIDE_AA_FOR_TBAA is default(1);

# CUDA ".cu" extenstion
variable DEFAULTCUASCU is default(cu);
variable CUASCU is default($DEFAULTCUASCU);
variable DEFAULTCUHEADERS is default(cuh);
variable CUHEADERSUFFIX is default($DEFAULTCUHEADERS);

# CUDA ".cup" extenstion
variable DEFAULTCUPASCUP is default(cup);
variable CUPASCUP is default($DEFAULTCUPASCUP);
variable CUPHEADERSUFFIX is default($DEFAULTCUPHEADERS);

suffix asm is
	string($ASMSUFFIXES $SITEASMSUFFIX $USERASMSUFFIX)
	help(Assembler source: assemble, link);
suffix ASM is
	string(S $SITEASMPPSUFFIX $USERASMPPSUFFIX)
	help(Assembler source: preprocess, assemble, link);
suffix o is
	string($OBJSUFFIXES oo $SITEOBJSUFFIX $USEROBJSUFFIX)
	help(Object file: link);
suffix a is
	string($LIBSUFFIX $SITELIBSUFFIX $USERLIBSUFFIX)
	help(Object library: link);
suffix linker is hide
	help(Used for positional switches passed to linker);
suffix other is
	default
	help(Other files: passed to linker);

variable MAJOR is default(2025) help(Major release version);

variable SITEASMSUFFIX is default();
variable SITEASMPPSUFFIX is default();
variable SITECSUFFIX is default();
variable SITECPPSUFFIX is default();
variable SITECUSUFFIX is default();
variable SITEOBJSUFFIX is default();
variable SITELIBSUFFIX is default();
variable USERASMSUFFIX is default();
variable USERASMPPSUFFIX is default();
variable USERCSUFFIX is default();
variable USERCPPSUFFIX is default();
variable USERCUSUFFIX is default();
variable USEROBJSUFFIX is default();
variable USERLIBSUFFIX is default();

variable AS is			# can be changed by targetrc
	help(Name of assembler program)
	default($DEFAS);

variable DEFAS is		# can be changed by targetrc
	help(Name of assembler program)
	default(as);

variable ASARGS is		# set by -Wa
	help(Arguments to assembler)
	default($if($equal($SYS64,linux86-64-nollvm),--noexecstack));

variable ASDIR is		# set by -Ya targetrc
	help(Directory containing assembler program)
	default($DEFASDIR);

variable ASMCOMMAND is		# set for some targets
	help(Internal command to process assembler file)
	default(asm);

variable ASMONLY is		# set by -c
	help(Compile and assemble, do not link)
	default();

variable ASMSUFFIX is		# set for some targets
	help(Suffix of assembler file)
	default(s);

variable ASMSUFFIXES is		# List
	help(Suffix allowed for assembler file)
	default(s);

variable ASTYPE is		# set by -Mcoff, -Melf
	help(What type of object file to produce)
	values(COFF ELF AOUT)
	default($if($DEFASTYPE,$DEFASTYPE,COFF));

variable CARGS is		# appended by many switches
	help(Switches to C compiler);

# Things that go in CARGS
# is default -c99? yes for C, Fortran, no for C++
variable DEFC99 is default($if($equal($DRIVER,C++),0,1));

variable C99 is default($if($DEFC99,-x 123 0x80000000,-y 123 0x80000000));
variable C_ONLY is default($if($DEFC99,-x 123 0x80000000,-y 123 0x80000000));

variable STRICTBMODE is default($if($DEFC99,-x 123 4));	# what to use for strict mode
variable DEFBMODE is default(-x 123 4);		# default
variable BMODE is default($DEFBMODE);		# set by -B
variable IS_CPLUS is default($if($equal($DRIVER,C++),1,0));
variable GNU_EXTENSIONS is default(1);
variable DIALECT_FLAG is default(); # precise flag user specified when setting the dialect
variable PREINCLUDE is default(); # $ifn($IS_CPLUS,-preinclude _c_macros.h)); #will find empty file, or overridden by our include_gccX/_c_macros.h if available

# disable strict aliasing and TBAA metadata when less than -O2 and C or C++
# or on windows -- FS#33531
variable ALIASMODE is
  default(
    $if(
      $or(
        $equal($TARGET,win64-llvm),
        $land(
          $expr($OPTLEVELUSE < 2),
          $or($equal($DRIVER,C), $equal($DRIVER,C++))
        )
      ),
      -x 2 0x400 -x 209 0x10
    )
  );

append CARGS=$C99 $BMODE $ALIASMODE;

variable CGARGS is		# appended by many switches
	help(Code Generation switches to native compiler);

variable COMMONARGS is hide		# initial C compiler switches
	default(
		$DEBUG
		-opt $OPTLEVELUSE
		$if($VERSION,-version)
		$ifn($VERBOSE,-terse 1)
		$INFORM
	);

variable COMMONCGARGS is hide		# initial C compiler switches
	default(
		$if($equal($ASTYPE,COFF),-astype 1)
		$if($equal($ASTYPE,ELF),-astype 0)
		$if($REALNOFRAME,-x 121 1)
		$ifn($equal($IEEE,),-ieee $IEEE)
	);


variable CCOMPDIR is		# set by -Y0
	help(Directory containing the C compiler)
	default($DEFCCOMPDIR);

variable CEXTARGS is		# set by -Mextract
	help(Arguments for extracting)
	default(-x 14 0x80);

variable COMPILECMDS is hide	# set by other hosts
	help(Other compile commands)
	default();

variable USECLANG is hide 
        help(Use clang instead of opt and llc)
        default(0);

variable USENVBE is hide 
        help(Use nvbe instead of opt and llc)
        default(0);

variable PRECOMPILECMDS is hide	# set by other hosts
	help(Precompile commands)
	default();

variable COMPILEONLY is		# set by -E, -S
	help(Compile, do not assemble)
	default();

variable COMPBIN is		#
	help(Compiler binary directory)
	default($COMPBASE/$COMPSYS/$COMPVER/$COMPBBIN);

variable COMPLIB is		# set by -YC
	help(Compiler library directory)
	default($LOCALCOMPLIB $foreach(dd,$COMPLIBDIR,$COMPBASE/$COMPSYS/$COMPVER/$(COMPLIBPREFIX)$dd ));

variable COMPINC is
	help(Compiler include directory)
	default($COMPBASE/$COMPSYS/$COMPVER/$(COMPLIBPREFIX)include);

variable LOCALCOMPLIB is
	help(Local compiler library directory)
	default();

variable COMPINCDIR is		# set by some targets
	help(Compiler include subdirectory)
	default(include);
set COMPINCDIR=include; # will be appended to, so must be set, not just default

variable COMPLIBDIR is		# set by some targets
	help(Compiler library subdirectory)
	default(lib);

variable COMPLIBOBJ is		# where to get objects from
	default($COMPLIB);

variable CONCURCOMPILE is		# set by -Mconcur
	help(Compiling with -Mconcur or -mp)
	default();

variable CONCUR is		# set by -Mconcur -mp
	help(Add multiprocessor thread libraries)
	default($if($ANYCU,YES,));

variable CONCURSW is		# set by -Mconcur -mp
	help(Add multiprocessor thread libraries)
	default(YES);

variable CSUFFIX is
	help(Suffixes to be compiled by C compiler)
	default(c i);

variable CPPSUFFIX is
	help(Suffixes to be compiled by C++ compiler)
	default(cpp);

variable CUSUFFIX is
	help(Suffixes for CUDA code to be compiled by C++ compiler)
	default(cu);

variable CUPSUFFIX is
	help(Suffixes for CUDA preprocessed code to be compiled by C++ compiler)
	default(cup);

variable CUCOMMANDS is
	help(Commands to run for CUDA files)
	default($DEFCUCOMMANDS);

variable DEBUG is		# set by -g
	default()
	help(Debug setting);

variable DEBUGSET is default();

variable DEBUGFLAG is default(0);

variable DEBUG2 is		# dwarf level in code generator
	default($DEBUG2DEF)
	help(Debug dwarf level);

variable DEBUG2DEF is		# default dwarf level in code generator
	default()
	help(Debug debug dwarf level);

variable DEFLINKOUT is
	default()
	help(Default output of link step);

variable DRYRUN is		# set by -dryrun, -###
	default(0)
	help(Display but do not execute each command);

variable DRYSTDINC is		# set by -drystdinc, -###
	default()
	help(Display standard include directories and exit);

variable PREPROCONLY is		# set by -P, -E
	default()
	help(Stop after preprocessor);

variable ECHONAME is
	default(1)
	help(Echo file names as they are compiled);

variable EXTRACT is		# set by -Mextract
	default($if($EXTRACTINLINE,YES));

variable EXTRACTINLINE is		# set by -Minline
	default($if($INLINE,YES,));

variable EXTRACTLIBDEF is	# default value
	default(Extract.dir);

variable EXTRACTLIB is		# set by -Mextract=lib:
				# or, if -Mextract, set by -o file
				# or, if not extract only, temp directory
	default($ifn($equal($EXTRACTLIBVAL,),$EXTRACTLIBVAL,$if($EXTRACT,
		    $ifn($EXTRACTONLY,
			 $tempdir(ext), # -Minline
			 $if($equal($OUTFILE,),
			     $mkdir($EXTRACTLIBDEF),
			     $mkdir($OUTFILE))
		    ))));
variable EXTRACTLIBVAL is	# set by -Mextract=lib:
	default();
variable EXTRACTTOC is
	default($if($EXTRACT,$mkfile($EXTRACTLIB/TOC)));
variable EXTRACTLIBSET is default();

variable EXTRACTONLY is		# set by -Mextract
	default();

variable GENPREPROCESS is default(genpreprocess);

variable HELPSWITCH is hide	# set by -help
	default();

variable I8STORAGE is		# set by -i8storage
	help(Indicates whether to include f90i8st.$HOSTOBJSUFFIX object)
	default();

variable IEEE is		# set by -Kieee
	help(IEEE conformance)
	default();

variable ILMONLY is hide		# set by -Milm
	help(Nonblank to stop after generating ilm file)
	default();

variable IMPSW is		# set by some hosts
	help(Linker switch for import libraries)
	default(-defaultlib:);

variable INCSEP is hide
	help(Separator between standard include directories)
	default(":");

variable INFORM is		# set by -Minform
	help(What level of informative messages)
	default( $ifn($VERBOSE,-inform warn) );

variable INLINE is		# set by -Minline
	default();

variable AUTOINLINE is		# set by -Mautoinline
	default();

variable INLINEARGS is		# used by compilers
	help(Inlining arguments to compiler/extractor)
	default($INLINEARGLIB $INLINELIST);

variable INLINELIST is		# used in INLINEARGS
	help(Inlining arguments to compiler/extractor)
	default();

variable IPAINLINELIST is	# used for IPA
	default();

variable INLINESIZE is	# used for IPA
	default();

variable INLINEARGLIB is		# used in INLINEARGS
	help(Inlining arguments to compiler/extractor)
	default($if($EXTRACTINLINE,-inlib $EXTRACTLIB));

variable INLINECARGS is		# used by compilers
	help(Inlining arguments to compiler)
	default();

variable IPAINLINE is		# set by -Mipa=inline
	default();

variable NOINSTRFUNCS is      # used in Minstrument-exclude-func-list
    help(Function exclude list for Minstrument. Looks for given string as substring of function name)
    default();

variable NOINSTRFILELIST is      # used in Minstrument-exclude-file-list
    help(File exclude list for Minstrument. Looks for given path as substring of full path)
    default();

variable KEEPASM is		# set by -S, -Mkeepasm
	help(Keeps the assembler file)
	default();

variable KEEPIL is		# set by +i
	help(Keeps the intermediate C++ .il and F90 .ilm files)
	default();

variable KEEPCCI is		
	help(Keeps the intermediate call context information file)
	default();

variable KEEPINLONLY is		
	help(Keeps the intermediate inline only file)
	default();

variable USEINLONLYFILE is
	help(Set when using -Minline=pragma)
	default();

variable KEEPPREPRO is		# set by -P
	help(Keep preprocessor file)
	default($DEFKEEPPREPRO);

variable DEFKEEPPREPRO is	# set by -P
	help(Keep preprocessor file)
	default();

variable DEFKEEPOBJ is		# set by -c
	help(Default keep object file behavior)
	default();

variable KEEPOBJ is		# set by -c
	help(Keep object file)
	default($DEFKEEPOBJ);

variable KEEPTEMP is
	help(Keep temporary files)
	default();

variable NEEDSTDCPPLIB is
    help(Set to 1 when -lstdc++ is needed)
    default($if($equal($DRIVER,C++),1,0));

variable NEEDSTDCPPLIBFORCUF is
    help(Set to 1 when -lstdc++ is needed for CUDA Fortran)
    default($if($land($lor($STATICLIB,$ISSTATIC),$if($expr($CUDAXXYY>=13000),1,0),$lor($ISCUDAFORLIB,$ANYCUF,$land($$ISFTN,$TGTCUDA))),1,0));

variable STARTGROUP is default($if($equal($PGISTATICX,-Bstatic),--start-group));
variable ENDGROUP is default($if($equal($PGISTATICX,-Bstatic),--end-group));

# Files in this variable are treated as tempfiles (deleted when the compiler
# finishes).
variable TEMPFILES is default();

switch --tempfiles=arg is hide
  help(Mark file as a tempfile. Used to preserve tempfiles across restart)
  append(TEMPFILES=$arg);

variable LD_ENV is default() environment(NVCOMPILER_LINKER);
variable LD is			# can be changed by targetrc
	help(Name of loader)
	default($if($notequal($LD_ENV,),$LD_ENV,$DEFLD));

variable DEFLD is		# can be changed by targetrc
	help(Name of loader)
	default(ld);

variable DEFLDARGS is		# can be changed by targetrc
	help(Default linker args);

variable LDINPUTPRE is default();
variable LDINPUTPOST is default();

variable LDLIBS is		# appended to by -L
	help(Loader libraries);

variable LDLIBARGS is		# appended to by -L
	help(Loader arguments);

variable CMDLINE_LDLIBS is		# appended to by -L
	help(Loader libraries);

variable CMDLINE_LDLIBARGS is		# appended to by -L
	help(Loader arguments);

variable LIBRARY_PATH_ENV is environment(LIBRARY_PATH);
variable LIBRARY_PATH is default($foreach(l,$replace($LIBRARY_PATH_ENV,:, ), $(LDIRSW)$l));

variable LDARGS is		# appended to by -l, -Wl, -YL, -YU
	help(Loader arguments)
	default();
append LDARGS=$CPPLDARGS $if($PASSPIE,-pie) $LDSHARED;

variable LDLIB1 is hide;	# used for -Mmpi -Mprof=mpi, mpi2, msmpi
variable LDLIB2 is hide;	# used for -Mmpi -Mprof=mpi, mpi2, msmpi
variable LDLIB3 is hide;	# used for -Mmpi -Mprof=mpi, mpi2, msmpi

variable LDSHARED is default(); # set by -shared

variable linkfiles is hide;
variable DEFLINKFILES is default($OMPLINKFILE);

variable MSLINK is		# set in ntrc for nt hosted/targetted compilers
	default();

variable LDSWITCHES is		# appended to by -m, -r, -s, -u
	help(Loader switches);

variable LDDIR is		# set by -Yl
	help(Directory containing loader)
	default($DEFLDDIR);

# LLVM Linker Directory
variable LLVMBINDIR is
	help(Directory containing LLVM tools)
	default($LLVMDIR/bin);

variable LIBDIR is		# set by -YL
	help(Standard linker library directory)
	default($DEFLIBDIR);

variable LIBSUFFIX is		# set by some hosts
	help(Suffix for library files)
	default(a so);

variable LIBSW is		# set by some hosts
	help(Linker switch for libraries)
	default(-l);

variable LIBSW_NOLIB is
	help(Linker switch for libraries with names that don't begin with lib)
	default(-l);

variable LIBSSW is              # set by some hosts
	help(Linker switch for system libraries)
	default($LIBSW);

variable LPRE is hide default(LIB:);
variable lpre is hide default(lib:);

variable LINKALWAYS is hide     # set by some switches
	default();
variable DEFLINKCMD is hide
	default(linker);
variable LINKCMD is hide        # set by other hosts
	help(Linker command)
	default($DEFLINKCMD);

variable PARTIALLINK is hide
	help(Set to enable or disable partial linking)
	default(0);

variable LINKOBJSUFFIX is		# set by languagerc
	help(Object suffixes to be passed to linker)
	default(o);
variable LINKNOBJSUFFIX is		# set by languagerc
	help(Non-object suffixes to be passed to linker)
	default(a);
variable LINKSUFFIX is		# set by languagerc
	help(Suffixes to be passed to linker)
	default($LINKOBJSUFFIX $LINKNOBJSUFFIX);

variable NOASM is		# set by -E, -P
	help(Indicates whether to generate asm file)
	default();

variable REALNOFRAME is	# set by -Mnoframe
	help(Indicates whether -Mnoframe is selected)
	default($NOFRAME);

variable NOFRAME is		# set by -Mnoframe
	help(Indicates whether -Mnoframe is selected)
	default($ifn($DEFFRAME,YES));

variable NOILM is		# set by -F
	help(Indicates whether to generate .ilm file)
	default();

variable NOSTARTUP is		# set by -Mnostartup
	help(Indicates whether to exclude standard startup object files)
	default();

variable NOSTDLIBS is		# set by -Mnostdlib
	help(Indicates whether to exclude standard libraries)
	default();

variable NOSTDCPPLIBS is		# set by -Mnostdlib, 1 for C, Fortran, 0 for C++
  help(Indicates whether to exclude standard C++ language libraries)
  default($not($lor($NEEDSTDCPPLIB,$NEEDSTDCPPLIBFORCUF)));

variable NOSTDFTNLIBS is		# set by -Mnostdlib
	help(Indicates whether to exclude standard Fortran language libraries)
	default();

variable NOSTDLIBDIRS is		# set by -Mnostdlib
	help(Indicates whether to exclude standard library directories)
	default();

variable NOSTDLIBPATHS is		# set by -Mnostdlib
	help(Indicates whether to exclude standard library directories from rpath)
	default();

variable OBJDIR is		# set by some hosts
	help(default directory in which to keep object files)
	default();

variable OBJSUFFIX is		# set by some hosts
	help(Suffix for object files)
	default(o);

variable OBJSUFFIXES is		# set by some hosts
	help(Suffixes for object files)
	default($OBJSUFFIX);

variable OTHERPREPROCESS is default(otherpreprocess);

variable HOSTOBJSUFFIX is		# set by some hosts
	help(Suffix for object files)
	default($OBJSUFFIX);

variable OPTLEVEL is		# set by -O
	help(Compiler optimization level)
	default($OPTLEVELDEF);

variable OPTLEVELMAX is		# set by -g, other switches
	help(Maximum legal opt level)
	default(4);

variable OPTLEVELMIN is		# set by -Mvect, other switches
	help(Minimum legal opt level)
	default(0);

variable OPTLEVELMINLIMIT is hide	# used for messages
	default();

variable OPTLEVELMAXLIMIT is hide	# used for messages
	default();

variable OPTLEVELUSE is hide	#
	help(The actual opt level to use)
	default($if($expr($OPTLEVEL > $OPTLEVELMAX),
		 $OPTLEVELMAX
		    $info(Switch $OPTLEVELMAXLIMIT " forces " -O$OPTLEVELMAX),
		$if($expr($OPTLEVEL < $min($OPTLEVELMIN,$OPTLEVELMAX)),
		 $OPTLEVELMIN
		    $info(Switch $OPTLEVELMINLIMIT " forces " -O$OPTLEVELMIN),
		$OPTLEVEL)));

variable OPTLEVELDEF is		# overridden by -fast, others
	help(Default optimization level without -O)
	default($OPTLEVELINITDEF);

variable OPTLEVELINITDEF is		# set by -g
	help(Initial default optimization level without -O)
	default($OPTLEVELINITDEF1);

variable OPTLEVELINITDEF1 is		# set by -acc
	help(Initial default optimization level without -O)
	default(1);

variable OUTFILE is		# set by -o
	help(Output file name)
	default($DEFOUTFILE);

variable PREOPTIONS is
	help(Default options to preceed command line)
	default();
variable POSTOPTIONS is
	help(Default options to follow command line)
	default();

variable PREPROSUFFIX is	# reset for fortran to f
	help(Suffix of preprocessor file)
	default(i);

variable PREPRO is		# can be changed by targetrc
	help(Name of preprocessor program)
	default($DEFPREPRO);

variable DEFPREPRO is		# can be changed by targetrc
	help(Name of preprocessor program)
	default(nvprepro);

variable PREPRODIR is		# set by -Yp targetrc
	help(Directory containing preprocessor program)
	default($COMPBIN);

variable PREPROARGS is		# set by -M
	help(Arguments to preprocessor program);

variable PROFILE is		# set by -Mprof, -ql, -qp, -p
	help(Use profile startup and libraries)
	default();

variable PROFILESW is		# set by -Mprof, -ql, -qp, -p
	help(Use profile startup and libraries)
	default();

variable SRCSUFFIX is		# file suffixes that correspond to source files
	help(Source file suffixes);
set SRCSUFFIX=c i cpp asm $if($notequal($SYSACCELS,),cu);

variable SRCFILES is
	help(List of source files)
	default();

variable SITELIB is		# set by siterc
	default();

variable SITEINC is		# set by siterc
	default();

variable SITEDEF is		# set by siterc
	default();

variable STDDEF is		# set by -Mnostddef
	default($DEFDEFS);

variable LOCALDEFS is		# set in localrc
	default();

variable STDDIRPRE is hide	# set in hostrc file
	help(String prefixed to standard library list)
	default($DEFSTDDIRPRE);	# usually -Llib1 -Llib2 -Llib3

variable DEFSTDDIRPRE is hide	# set in hostrc file
	help(String prefixed to standard library list)
	default(-L);		# usually -Llib1 -Llib2 -Llib3

variable LDIRSW is hide		# set in hostrc file
	help(String prefixed to library directory list)
	default(-L);

variable STDDIRIN is hide	# set in hostrc file
	help(String infixed between standard library list)
	default($DEFSTDDIRIN);	# usually -Llib1 -Llib2 -Llib3 (blank required before -L)

variable DEFSTDDIRIN is hide	# set in hostrc file
	help(String infixed between standard library list)
	default("" -L);	# usually -Llib1 -Llib2 -Llib3 (blank required before -L)

variable STDPRED is		# set by -Mnostddef
	default($DEFPRED);

variable STDINC is		# set by -YI, -Mnostdinc
	default($OMPPRESTDINC $ACCPRESTDINC $DEFSTDINC $USRSTDINC);

variable OMPPRESTDINC is default();

variable ACCPRESTDINC is
	default($DEFACCPRESTDINC);
variable DEFACCPRESTDINC is default();

variable USRSTDINC is
	default();

variable STDOBJDIR is		# set by -YS
	help(Directory containing standard startup object files)
	default($DEFSTDOBJDIR);

variable STUBS is default($if($land($ACCSTUBLIB,$NVOMPSTUBLIB),$ASNEEDED $PGISTATICX $ACCSTUBLIB $NVOMPSTUBLIB $PGIUNSTATICX $NOASNEEDED));

variable SYSV_PROF is		# currently unused
	help(Is System V profiling used)
	default();

variable TARGET is		# set by targetrc
	help(Target system)
	default();

variable TIMER is
	default();

variable USRDDEF is		# set by -D
	default();

variable USRDEFDEF is		# set by -D
	default();

variable USRINC is		# set by -I
	default();

variable VERBOSE is		# set by -#, -v
	help(Display each command as it is executed)
	default();

variable NOWARN is		# set by -w
	help(Suppress warning messages)
	default();

variable VERSION is		# set by -V
	help(Display version of driver and tools)
	default();

variable SUPPRESS_WARNINGS is # set by -V
    help(Used to suppress warnings when -V is used)
    default(0);

variable USE_REAL_TIME is
	help(Toggles between CPU and real time timers)
	default(0);
append CGARGS=$if($USE_REAL_TIME, -x 50 0x200);

variable DEFSTDLIBS is default();

# Allow for -c++libs option
variable NORMALSTDLIB is hide default(std);
variable NORMALCPPLIB is hide default(C);
variable CPPSTDLIBS is default();
variable CPPLDARGS is default();
variable CPLUS64LDARGS is default();

# Detect whether runtest option `-rc ...` is being used
variable ISNVLOCALRC is environment(NVLOCALRC);
# Enable linking with alternative GCC version (e.g. when `--gcc-toolchain=...` or `-rc gccX.Y` runtest option are used)
variable GCCPATH is default();
set GCCPATH=$if($isdir($GCCTOOLCHAINDIR),$GCCTOOLCHAINDIR,$action(realpath($GCCDIR/../../../..)));
variable GCCLIBS is default(-L$(GCCPATH)/lib64);
variable GCCRPATH is default($if($land($isdir($GCCPATH),$notequal($GCCPATH,"/usr")),-rpath $(GCCPATH)/lib64));

variable DEFCPPSTDLIBS is default();
variable DEFCPPLDARGS is default();
# support for zero-cost exception handling, which is now the only kind of
# exception handling
variable EXCEPTIONS_ENABLED is hide default(1);
variable ZCSUFFIX is hide
	default( $if($index($TARGET,linux86-64),z));
# zero cost exceptions, flag set for C++
variable ZCDEF is
	default($if($land($EXCEPTIONS_ENABLED,$equal($DRIVER,C++)),-x 117 0x200));

variable ZCLIBS is
	default( $if($index($TARGET,linux86-64),-lzceh -lgcc_eh --eh-frame-hdr));
set ZCLIBS=$PGISTATICX $PGATM $PGIUNSTATICX --eh-frame-hdr;

variable PGATM is default();
variable GNUATOMIC is default();
variable DEFLANGSTDLIB is hide default(stdc++);
variable DEFCPPLIB is default();

variable DEFCPPLIBS is default();
set DEFCPPLIBS=$if($lor($NEEDSTDCPPLIB,$NEEDSTDCPPLIBFORCUF),$ZCLIBS $LIBSW$DEFLANGSTDLIB $CPPSTDLIBS);

variable CNEEDCUDA is hide default($ANYCU);
variable CUDANEEDED is default($ANYCUF);
variable CUDARTNEEDED is default($or($ANYCUF,$ANYCU));
variable CUDARPATHNEEDED is default($if($contains($ACCELS,tesla),1,0));
# variable NVMALLOCNEEDED is default($if($NO_TP_OR_TP_HOST,$contains($TP_HOST,grace,neoverse-v2),$contains($TPVAL,grace,neoverse-v2)));
# variable NVMALLOCNEEDED is default(0);
variable NVMALLOCNEEDED is default($and($index($TARGET,linuxarm64),$equal($LDSHARED,)));
variable DEFCUDARPATH is default($if($or($CUDANEEDED,$CUDARPATHNEEDED), 
                                        $if($notequal($CUDALIBDIR,),-rpath $CUDALIBDIR)
                                        $if($notequal($CUDASITELIB,),-rpath $CUDASITELIB) 
                                        $if($notequal($CUDALIBINSTALL,),-rpath $CUDALIBINSTALL))
                                 $if($or($TGTCUDA,$ISCUDALIB),
                                        $if($NEEDCUTENSORLEGACY,-rpath $CUTENSORLEGACYLIBDIR)
                                        $if($notequal($CUDAMATHLIBDIR,),-rpath $CUDAMATHLIBDIR)
                                        $if($notequal($COMMLIBSRPATHDIR,),$COMMLIBSRPATHDIR)) 
                                 $if($NEEDCUPTI,$if($notequal($CUDACUPTILIBDIR,),-rpath $CUDACUPTILIBDIR)));
variable CUDARPATH is default($DEFCUDARPATH);
variable CUDALIB is default();
variable MATHCUDALIB is default();
variable ANYCUF is default($if($suffixused(cuf,CUF),$if($notequal($SYSACCELS,),1,0),0));
variable ANYCU is default($if($suffixused(cu,cup),$if($notequal($SYSACCELS,),1,0),0));
variable STATICLIB is default(0);
variable CUDARTLIBS is default($ifn($contains($COMPUTECAPS,30,3x),cudadevrt) cudart$CUDARTSTATIC);
variable DEFLCUDALIB is default($if($lor($CUDARTNEEDED,$CUDALIBNEEDED),$PGISTATICX $foreach(l,$CUDARTLIBS, $(LIBSW_NOLIB)$l) $PGIUNSTATICX $ifn($STATICLIB,$if($notequal($PGISTATICX,),$DLLIB)) $ifn($CUDANEEDED,$if($expr($CUDAXXYY>=10010),$lookup($COMPLIBOBJ,cuda_init_register_end.$OBJSUFFIX)))));
variable LCUDALIB is default($DEFLCUDALIB);

variable EXTRACUDAFORLIB is default();
variable DEFLCUDAFORLIB is default($if($land($CUDANEEDED,$equal($DRIVERLANG,Fortran)),
    $CUDAFORLIB_SELECTION
    $(LIBSW)cudafor
    $if($TGTCUDA,$(LIBSW)cublas$(CUDARTSTATIC) $if($expr($CUDAXXYY>10000),$(LIBSW)cublasLt$(CUDARTSTATIC)) $(LIBSW)curand$(CUDARTSTATIC) $(LIBSW)cudaforwrapblas $if($expr($CUDAXXYY>11060),$(LIBSW)cudaforwrapblas117) $EXTRACUDAFORLIB))
    $if($CUDANEEDED,$if($expr($CUDAXXYY>=10010),$lookup($COMPLIBOBJ,cuda_init_register_end.$OBJSUFFIX))));
variable LCUDAFORLIB is default($if($notequal($DEFLCUDAFORLIB,),$PGISTATICX $DEFLCUDAFORLIB $PGIUNSTATICX));
variable DEFLCUDAFOR2LIB is default($if($land($CUDANEEDED,$equal($DRIVERLANG,Fortran)), $(LIBSW)cudafor2, $if($CUDARTNEEDED, $(LIBSW)cudanvhpc)));
variable LCUDAFOR2LIB is default($if($notequal($DEFLCUDAFOR2LIB,),$PGISTATICX $DEFLCUDAFOR2LIB $PGIUNSTATICX));

# Variable used for restart command features
variable RESTARTENV is default(); # Used to set environment variables on restart
variable CURRPATH is environment(PATH); # Used to pass environment PATH variable on restart
variable RESTARTNAME is default();
variable REPLACESWITCHES is default(0);
variable FLAGREPLACEMENTTABLE is default($if($ISCLANG,$CLANGFLAGSTABLE,$if($ISGNU,$GNUFLAGSTABLE)));
variable ADDARGS is default();
variable RMARGS is default();
variable PRINTRESTARTCMD is default(0);
variable MUSTRESTART is default(0);

# Driver variables that can be set in local or site rc (e.g. at NVHPC
# SDK config time). This variable take precedence over NVHPC SDK
# paths, but have less priority than user-set paths. These variables
# are space-separate lists of paths that will be expanded with `-I/-L`.
variable USER_INCLUDE_PATH is default();
variable USER_LIBRARY_PATH is default();

# GCC VERSION variables
variable GCCMAJORVERSION is default($expr($GCCVERSION/10000));
variable GCCMINORVERSION is default($expr(($GCCVERSION%10000)/100));
variable GCCPATCHVERSION is default($expr($GCCVERSION%100));

# What tools can the driver invoke?
# values:
#	name		common name
#	program		command name or name of a variable giving the command
#	directory	command directory or variable giving the directory
#	arguments	list of variables with arguments to the tool

tool asm is help(Assembler)
	program($AS) directory($ASDIR);
tool loader is help(Loader)
	program($LD) directory($LDDIR $LLVMBINDIR);
tool prepro is help(Preprocessor)
	program($PREPRO) directory($PREPRODIR);

# Commands run by the phases
# DEF arguments are generally given in the targetrc file
# the EXTRA arguments are generally given in the .xxrc file

# General preprocess: used with -Mcpp
command genpreprocess is
	help(Preprocess any file)
	nosuffix(linker)
	tool(prepro)
	# ifile is the name of the preprocessed output file
	# if $OUTFILE, set it to $OUTFILE
	# else if $KEEPPREPRO, set it to $basename($input).$PREPROSUFFIX
	# else if not $KEEPPREPRO, leave blank (output to stdout)
	set(ifile=$if($notequal($OUTFILE,),$OUTFILE,$if($KEEPPREPRO,$basename($input).$ifn($equal($suffix($input),.$PREPROSUFFIX),$PREPROSUFFIX,$PREPROSUFFIX$PREPROSUFFIX))))
	arguments($input $PREPROARGS
		$if($equal($suffix($input),.s),-def __ASSEMBLER__)
		$if($STDINC,-stdinc $replace($STDINC,,$INCSEP),-nostdinc)
		$foreach(d,$STDDEF,-def $d )
		$foreach(d,$LOCALDEFS,-def $d )
		$foreach(i,$SITEINC,-idir $i )
		$foreach(i,$USRINC,-idir $i )
		$foreach(i,$replace($USER_INCLUDE_PATH,",", ),-idir $i )
		$foreach(i,$CUDAINC,-idir $i )
		$foreach(d,$SITEDEF,-def $d )
		$USRDEFDEF
	$MPDEFCPP
		$if($ifile,-o $ifile)
	);
command otherpreprocess is
	help(Preprocess any file)
	suffix(other a o asm)
	nosuffix(linker)
	tool(prepro)
	# ifile is the name of the preprocessed output file
	# if $OUTFILE, set it to $OUTFILE
	# else if $KEEPPREPRO, set it to $basename($input).$PREPROSUFFIX
	# else if not $KEEPPREPRO, leave blank (output to stdout)
	set(ifile=$if($notequal($OUTFILE,),$OUTFILE,$if($KEEPPREPRO,$basename($input).$ifn($equal($suffix($input),.$PREPROSUFFIX),$PREPROSUFFIX,$PREPROSUFFIX$PREPROSUFFIX))))
	arguments($input $PREPROARGS
		$if($STDINC,-stdinc $replace($STDINC,,$INCSEP),-nostdinc)
		$foreach(d,$STDDEF,-def $d )
		$foreach(d,$LOCALDEFS,-def $d )
		$foreach(i,$SITEINC,-idir $i )
		$foreach(i,$USRINC,-idir $i )
		$foreach(i,$replace($USER_INCLUDE_PATH,",", ),-idir $i )
		$foreach(i,$CUDAINC,-idir $i )
		$foreach(d,$SITEDEF,-def $d )
		$USRDEFDEF
	$MPDEFCPP
		$if($ifile,-o $ifile)
	);


# preprocess before assembling, used with -Mpreprocess and .s file input
command asmpreprocess is
	help(Preprocess assembler files)
	tool(prepro)
	suffix(asm)
	# ifile is the name of the preprocessed output file
	# if $PREPROCONLY and $OUTFILE, set it to $OUTFILE
	# else if $PREPROCONLY and $KEEPPREPRO, set it to $dirname($input)/$basename($input).$PREPROSUFFIX
	# else if $PREPROCONLY and not $KEEPPREPRO, leave blank (output to stdout)
	# else if $KEEPPREPRO, set it to $dirname($input)/$basename($input).$PREPROSUFFIX
	# else set to tempfile()
	set(ifile=$if($PREPROCONLY,$if($notequal($OUTFILE,),$OUTFILE,$if($KEEPTEMP$KEEPPREPRO,$basename($input).$PREPROSUFFIX)),$if($KEEPTEMP$KEEPPREPRO,$dirname($input)/$basename($input).$PREPROSUFFIX.$ASMSUFFIX,$tempfile($ASMSUFFIX))))
	arguments($input
		-def __ASSEMBLER__
		$if($STDINC,-stdinc $replace($STDINC,,$INCSEP),-nostdinc)
		$foreach(d,$STDDEF,-def $d )
		$foreach(d,$LOCALDEFS,-def $d )
		$foreach(i,$SITEINC,-idir $i )
		$foreach(i,$USRINC,-idir $i )
		$foreach(i,$replace($USER_INCLUDE_PATH,",", ),-idir $i )
		$foreach(i,$CUDAINC,-idir $i )
		$foreach(d,$SITEDEF,-def $d )
		$USRDEFDEF
	$MPDEFCPP
		$if($ifile,-o $ifile)
	)
	execute(
	    condition($equal($NOASM,))
	    input($ifile)
	    command(asm)
	);

# preprocess before assembling, used with .S file input
command preprocessthenasm is
	help(Preprocess assembler files)
	tool(prepro)
	suffix(ASM)
	# ifile is the name of the preprocessed output file
	# if $PREPROCONLY and $OUTFILE, set it to $OUTFILE
	# else if $PREPROCONLY and $KEEPPREPRO, set it to $dirname($input)/$basename($input).$PREPROSUFFIX
	# else if $PREPROCONLY and not $KEEPPREPRO, leave blank (output to stdout)
	# else if $KEEPPREPRO, set it to $dirname($input)/$basename($input).$PREPROSUFFIX
	# else set to tempfile()
	set(ifile=$if($PREPROCONLY,$if($notequal($OUTFILE,),$OUTFILE,$if($KEEPTEMP$KEEPPREPRO,$basename($input).$PREPROSUFFIX)),$if($KEEPTEMP$KEEPPREPRO,$dirname($input)/$basename($input).$PREPROSUFFIX.$ASMSUFFIX,$tempfile($ASMSUFFIX))))
	arguments($input
		-def __ASSEMBLER__
		$if($STDINC,-stdinc $replace($STDINC,,$INCSEP),-nostdinc)
		$foreach(d,$STDDEF,-def $d )
		$foreach(d,$LOCALDEFS,-def $d )
		$foreach(i,$SITEINC,-idir $i )
		$foreach(i,$USRINC $CUDAINC,-idir $i )
		$foreach(d,$SITEDEF,-def $d )
		$USRDEFDEF
	$MPDEFCPP
		$if($ifile,-o $ifile)
	)
	execute(
	    condition($equal($NOASM,))
	    input($ifile)
	    command($ASMCOMMAND)
	);

command Nasm is
	help(Assembler)
	tool(asm)
	# if no post assembler (if -c and -o, use $OUTFILE, else a.o)
	# if post assembler, use tempfile
	set(objfile=$if($and($KEEPTEMP$KEEPOBJ,$equal($POSTASM,)),$if($and($ASMONLY,$notequal($OUTFILE,)),$OUTFILE,$if($notequal($OBJDIR,),$OBJDIR/)$basename($file).$OBJSUFFIX),$tempfile($OBJSUFFIX)))
	append(linkfiles=$if($equal($POSTASM,),$objfile))
	append(objfiles=$if($equal($POSTASM,),$objfile))
	arguments($EXTRAASPREARGS $input $DEFASARGS
		$foreach(i,$SITEINC,-I$i/ )
		$foreach(i,$USRINC,-I$i/ )
		$foreach(i,$replace($USER_INCLUDE_PATH,",", ),-I$i/ )
		$foreach(i,$CUDAINC,-I$i/ )
		$EXTRAASARGS $ASARGS -o $objfile)
	execute(
	    condition($notequal($POSTASM,))
	    input($objfile)
	    command($POSTASM)
	)
	execute(
	    condition($and($doappend,$equal($POSTASM,)))
	    input($objfile)
	    command(append)
	);

command asm is
	help(Assembler)
	tool(asm)
	suffix(asm)
	set(objfile=$if($and($KEEPOBJ,$equal($POSTASM,)),$if($and($ASMONLY,$notequal($OUTFILE,)),$OUTFILE,$if($notequal($OBJDIR,),$OBJDIR/)$basename($file).$OBJSUFFIX),$tempfile($OBJSUFFIX)))
	append(linkfiles=$if($equal($POSTASM,),$objfile))
	append(objfiles=$if($equal($POSTASM,),$objfile))
	echo($if($and($ECHONAME,$expr($count($realfiles)>1)),$file:))
	arguments($EXTRAASPREARGS $input $DEFASARGS
		$foreach(i,$SITEINC,-I$i/ )
		$foreach(i,$USRINC,-I$i/ )
		$foreach(i,$replace($USER_INCLUDE_PATH,",", ),-I$i/ )
		$foreach(i,$CUDAINC,-I$i/ )
		$EXTRAASARGS $ASARGS -o $objfile)
	execute(
	    condition($notequal($POSTASM,))
	    input($objfile)
	    command($POSTASM)
	);

variable KEEPLNK is hide default(0);

command linker is
	help(Linker)
	# tool(loader)
	# first object file, if MSlink
	set(FFILE=$if($MSLINK,$basename($first($realfiles))$OUTEXESUFFIX,$DEFLINKOUT))
	# what will actual executable be named?  either -o, or first object
	set(OOFILE=$if($notequal($OUTFILE,),$ifn($OUTEXESUFFIX,$OUTFILE,$if($suffix($OUTFILE),$OUTFILE,$OUTFILE$OUTEXESUFFIX)),$FFILE))
	set(OXFILE=$if($notequal($OOFILE,),$OOFILE,$DEFEXFILE))	# run POSTLINK with a.out for sua
	# if we are running the postlinker, rename the executable
	set(PDBFILE=$if($and($DEBUGSET,$or($equal($TARGET,win64),$equal($TARGET,win64-llvm))),$dirname($OOFILE)/$basename($OOFILE).pdb))
	set(response=$if($MSLINK,$if($KEEPLNK,pgi.lnk,$tempfile(lnk)),dummy))
	set(arguments=
	    $ifn($PARTIALLINK,
		    $ifn($NOSTARTUP,$DEFLDSTARTUP
		        $FTNALT
		        $if($I8STORAGE,$lookup($COMPLIBOBJ,f90i8st.$HOSTOBJSUFFIX))
		    )
		    $DEFLDARGS
		    $LDLIBARGS
		    $if($NEEDMANPINMEMORYINTERCEPTION, $MANPINMEMORYINTERCEPTION)
		    $if($NVMALLOCNEEDED,
		        $if($notequal($LDSHARED,),$warning(-nvmalloc switch ignored, it can't be used to create shared libraries),
			        $(PGISTATICX) $if($notequal($PGISTATICX,),--whole-archive)
			        $(LIBSW)$if($STATICLIB,
			            nvmalloc_static,
			            $if($and($NEEDMANPINMEMORYINTERCEPTION, $notequal($PGISTATICX,)),
			                nvmalloc_nofree,
			                nvmalloc))
			        $if($notequal($PGISTATICX,),--no-whole-archive $(PGIUNSTATIC))))
		    $foreach(ll,$replace($USER_LIBRARY_PATH,",", ), -L$ll)
		    $CMDLINE_LDLIBARGS
		    $LIBRARY_PATH
		    $foreach(l,$SITELIB,$LDIRSW$l )
		    $ifn($NOSTDLIBDIRS,
		        $if($DEFSTDDIRS,$STDDIRPRE$replace($DEFSTDDIRS,,$STDDIRIN))))
	    $LDINPUTPRE $input $LDINPUTPOST
	    $ifn($PARTIALLINK,
		    $ifn($NOSTDLIBPATHS,$DEFSTDPATHS))
	    $LDSWITCHES $if($notequal($OOFILE,),$ifn($MSLINK,-o $OOFILE,"-out:"$OOFILE))
	    $ifn($PARTIALLINK,
		    $if($PDBFILE,-pdb:$PDBFILE)
		    $LDLIB1 $LDLIB2 $LDARGS
		    $ifn($NOSTDLIBPATHS,$GCCLIBS)
		    $OVLFILES
		    $EXTRALDARGS $LDLIB3
		    $ifn($NOSTDCPPLIBS,$DEFCPPLIBS)
		    $DEFSTDLIBS
		    $ifn($NOSTARTUP,$DEFLDENDUP))
	)
	write(response=$if($MSLINK,$arguments))
	arguments($ACCLINK $tool(loader) $ifn($MSLINK,$arguments,$NOLOGO @$response))
	execute(
	    condition($notequal($POSTLINK,))
	    input($OXFILE)
	    command($POSTLINK)
	);

command copylink is hide
	suffix(linker)
	append(linkfiles=$input);

command copyobj is hide
	suffix($LINKOBJSUFFIX)
	append(linkfiles=$input)
	append(objfiles=$input);

command copynonobj is hide
	suffix($LINKNOBJSUFFIX)
	append(linkfiles=$input);

variable HANDLEOTHER is default(copyother);
command copyother is hide
	suffix(other)
#f20742	echo(File with unknown suffix passed to linker: $input)
	append(linkfiles=$input)
	append(objfiles=$input);

command checkoverwrite is hide
	nosuffix(linker)
	set(dummy=$if($equal($input,$OUTFILE),$error(Output would overwrite input file: $input)));


command copysrc is hide
	suffix($SRCSUFFIX)
	append(SRCFILES=$input);

# Echo simply echos the command line, letting a user see what the command line
# is when the compiler is invoked by a wrapper that adds flags
phase Echophase is hide
	help(Echo the command line)
	forall
	echo($DRIVERCOMMAND $switches $files);

switch -echo is
	help(Echo the command line flags and stop (default) or continue (=go).  This is useful when the compiler is invoked by a script.)
	helpgroup(overall)
	enable(Echophase)
	keyword(
	  go()
	  stop(stopafter(Echophase)))
	nokeyword(stopafter(Echophase));

# NoFiles phase simple checks that there are some files to compile
phase NoFiles is hide
	default
	help(Check that the command line has one or more files to process)
	warning($if($and($equal($files,),$equal($VERSION,)),No files to process));

phase dMphase is hide
	# call dMcommand when there are no input files
	forall
	help(Print preprocessor macros and definitions)
	execute(
	    condition($equal($files,))
	    noinput(1)
	    command(dMcommand) );

phase OtherChecks is hide
	default
	help(Check for output file conflicts)
	execute(input($files) command(copysrc))
	set(dummy=$if($and($ASMONLY,$notequal($OUTFILE,),$expr($count($SRCFILES)>1)),$error(More than one output file will overwrite $OUTFILE)))
	execute( condition($OUTFILE) input($files) command(checkoverwrite) );


variable helpvalues is default();

variable EXE is default($if($equal($PGSYS,win),.exe));

variable DYNAMICLINK is
	help(This is set when creating a shared object or dynamic library)
	default(0);

command Versionscmd is
	set(VSNS=$foreach(l,$readdir($COMPBASE/$COMPSYS),$if($isfile($COMPBASE/$COMPSYS/$l/bin/$DRIVERNAME$EXE), $l )))
	echo(Available $DRIVERNAME versions are: $VSNS);

phase Versions is hide
	forall
	help(Show available compiler versions)
	execute(
	    noinput(1)
	    command(Versionscmd)
	);

# Help phase does -help
phase Help is hide
	action($if($notequal($helpvalues,),helpmessage $helpvalues))
	forall
	help(Show -help for switches);

helpgroup overall is
	help(Overall switches);

helpgroup opt is
	help(Optimization switches);

helpgroup debug is
	help(Debugging switches);

helpgroup prepro is
	help(Preprocessor switches);

helpgroup asm is
	help(Assembler switches);

helpgroup linker is
	help(Linker switches);

helpgroup language is
	help(Language-specific switches);

helpgroup target is
	help(Target-specific switches);

helpgroup other is
	help(Other switches) default;


switch --tools is hide
	enable(Help NoCompile)
	helpgroup(overall)
	keyword( links( set(helpvalues=helptoollink) ) )
	nokeyword( set(helpvalues=helptool) )
	stopafter(NoCompile)
	disable(NoFiles);

switch --flagcheck is
	helpgroup(overall)
	help(Don't compile anything, just emit error messages for command-line switches)
	enable(NoCompile)
	stopafter(NoCompile)
	disable(NoFiles);

# Show phase does -show
phase Show is hide
	action(helpvariable helpphase)
	forall
	help(Show driver variables);

# NoCompile phase is a convenient place to stop when we only want
# to -help, for instance.
phase NoCompile is hide
	forall help(Stop here if only giving help);
# Insert installation help
phase Install is hide
	forall help(Self-installation);

# Extract phase does C, C++, F77, F90 extracting
phase Extract is
	help(Extract subprograms to an extract library for later inlining)
	set(Extract=YES)
	default
	execute(
	    condition($and($equal($PREPROCONLY,),$notequal($EXTRACT$HEXTRACT,),$or($IS_C_OR_CPP,$equal($SINGLE_FILE,))))
	    input($files)
	    command($CPPEXTCOMMANDS $FEXTCOMMANDS $CEXTCOMMANDS)
	)
	set(Extract=);

phase PreCompile is hide
	help(Precompile steps for some hosts)
	default
	execute(
	    input($files)
	    command($PRECOMPILECMDS)
	);

# Preproconly is used if -Mcpp is set
# it preprocesses files only
phase Preproconly is
	help(Preprocess files)
	execute(
	    input($files)
	    command($GENPREPROCESS)
	);

# Compile compiles source down to .o files
# copyobj and copyother commands append .o, .a, and other files
# to the list of objfiles, used as input by the Link phase
phase Compile is
	help(Compile or Assemble source files)
	default
	set(Extract=)
	set(ipofile=)
	set(ipxfile=)
	set(ipmfile=)
	set(ipnfile=)
	set(inlfile=)
	set(modfile=)
	set(mdxfile=)
	set(doappend=)
	execute(
	    input($files)
	    command($CCOMPCOMMANDS $FCOMPCOMMANDS $if($USENVBE,$NVBE,$if($USECLANG,$CLANGCMD,$LLCCMD)) $ASMCOMMAND preprocessthenasm
		copyobj copynonobj copylink $HANDLEOTHER $COMPILECMDS $CUCOMMANDS)
	);

variable linkobjfiles is hide default();

# Link phase
phase Link is
	help(Link object files to executable)
	forall
	default
	execute(
	    condition($and($equal($COMPILEONLY,),$equal($IPALINK,)))
	    noinput($LINKALWAYS)
	    input($if($linkobjfiles,$objfiles,$DEFLINKFILES $linkfiles))
	    command($LINKCMD)
	);


switch "-###" is #not
	help(Display commands that would be executed)
	helpgroup(overall)
	set(DRYRUN=1);

switch "-#" is #not
	help(Display each command as it is run)
	helpgroup(overall)
	set(VERBOSE=YES);

switch -c is
	help(Stop after assemble; output in object file)
	set(KEEPOBJ=YES)
	set(ASMONLY=YES)
	helpgroup(overall)
	stopafter(Compile);

switch -Muse-ld is hide
    # Set the linker to one of the available options. The linker
    # command needs to be in the path.
    keyword(
        gold(
            help(Deprecated; Use the gold linker instead of the default linker.)
            warning(The gold linker has been deprecated and will be removed in a future release)
            set(LD=ld.gold)
        )
        lld(
            help(Use the LLVM lld linker instead of the default linker.)
            set(LD=ld.lld)
        )
        mold(
            help(Use the mold linker instead of the default linker.)
            set(LD=mold)
        )
    );

switch -Mobjdir=objdir is hide
	help(Set output directory for object files; use with -c)
	helpgroup(overall)
	set(OBJDIR=$objdir);

switch -D$macro is
	help(Define a preprocessor macro)
	helpgroup(prepro)
	append(USRDDEF=-D$macro)
	append(USRDEFDEF=-def $macro);

# -debug is a driver builtin switch #not

switch -dryrun is
	help(Display commands that would be executed)
	helpgroup(overall)
	set(KEEPTEMP=YES)
	set(DRYRUN=1);

switch -drystdinc is
	help(Display standard include directories and exit)
	helpgroup(overall)
	enable(Help DryStdInc NoCompile)
	disable(NoFiles)
	stopafter(NoCompile);

switch -drygccinc is
	help(Display standard include directories of the gcc toolchain used and exit)
	helpgroup(overall)
	enable(Help DryGccInc NoCompile)
	disable(NoFiles)
	stopafter(NoCompile);

# -defaultoptions / -nodefaultoptions are builtin switches
switch -defaultoptions is
	helpgroup(overall)
	helpname(-[no]defaultoptions)
	help(Use default options from configuration file);
switch -nodefaultoptions is hide
	helpgroup(overall)
	help(Don't use default options from configuration file);

# Turn on noswitcherror using an environment variable.
variable NV_NOSWITCHERROR is environment(NV_NOSWITCHERROR);
variable NVCOMPILER_NOSWITCHERROR is environment(NVCOMPILER_NOSWITCHERROR);
variable PGI_NOSWITCHERROR is environment(PGI_NOSWITCHERROR);
variable NOSWITCHERROR is default($lor($lor($NV_NOSWITCHERROR, $NVCOMPILER_NOSWITCHERROR), $PGI_NOSWITCHERROR));

variable DRIVERERRORLIMIT is default(0);  # Driver special variable. 0 means no limit.
# -noswitcherror is a builtin switch
switch -noswitcherror is
	helpgroup(overall)
	help(Ignore unknown command line switches);

switch -flags is #not
	help(Show all compiler switches)
	helpgroup(overall)
	set(helpvalues=helpswitch)
	enable(Help NoCompile)
	disable(NoFiles)
	set(HELPSWITCH=-flags)
	stopafter(NoCompile);

switch -g is
	help(Generate information for debugger)
	helpgroup(debug)
	set(DEBUG=-debug $DEFDEBUG $DEBUG2)
	set(DEBUGSET=1)
	set(DEBUGFLAG=1)
	set(DODWARF=)
	set(DEBUG2DEF=-x 120 0x8000)
	append(F901ARGS=-x 49 0x1000)
	append(F902ARGS=$if($expr($CUDAXXYY>=11060), -x 120 0x2000000))
	append(CPP1ARGS=-g $DEBUGCPP)
	append(CPP2ARGS=-x 119 0x08)
	append(FLANG1ARGS=-g)
	min(OPTLEVELINITDEF=0);

variable HIDDEN is hide default();

switch -help is
	help(Show compiler switches)
	helpgroup(overall)
	enable(Help NoCompile)
	disable(NoFiles)
	set(values=)
	keyword(
	    groups(
		append(values=helpgroup)
	    )
	    asm(
		append(values=helpgroup+asm)
	    )
	    debug(
		append(values=helpgroup+debug)
	    )
	    language(
		append(values=helpgroup+language)
	    )
	    linker(
		append(values=helpgroup+linker)
	    )
	    opt(
		append(values=helpgroup+opt)
	    )
	    other(
		append(values=helpgroup+other)
	    )
	    overall(
		append(values=helpgroup+overall)
	    )
	    phase(
		append(values=helpphase)
	    )
	    prepro(
		append(values=helpgroup+prepro)
	    )
	    suffix(
		append(values=helpsuffix)
	    )
	    switch(
		append(values=helpswitch)
	    )
	    target(
		append(values=helpgroup+target)
	    )
	    tools( hide
		append(values=helptool)
	    )
	    variable(
		append(values=helpvariable)
	    )
	    hidden( set(HIDDEN=1) hide )
	)
	nokeyword(
	    set(values=helpswitchbygroup)
	)
	append(helpvalues=$if($equal($values,),helpswitchbygroup,$values))
	set(HELPSWITCH=-help)
	stopafter(NoCompile);

switch --help is hide
	help(Show compiler switches)
	helpgroup(overall)
	enable(Help NoCompile)
	disable(NoFiles)
	set(values=)
	keyword(
	    groups(
		append(values=helpgroup)
	    )
	    asm(
		append(values=helpgroup+asm)
	    )
	    debug(
		append(values=helpgroup+debug)
	    )
	    language(
		append(values=helpgroup+language)
	    )
	    linker(
		append(values=helpgroup+linker)
	    )
	    opt(
		append(values=helpgroup+opt)
	    )
	    other(
		append(values=helpgroup+other)
	    )
	    overall(
		append(values=helpgroup+overall)
	    )
	    phase(
		append(values=helpphase)
	    )
	    prepro(
		append(values=helpgroup+prepro)
	    )
	    suffix(
		append(values=helpsuffix)
	    )
	    switch(
		append(values=helpswitch)
	    )
	    target(
		append(values=helpgroup+target)
	    )
	    tools( hide
		append(values=helptool)
	    )
	    variable(
		append(values=helpvariable)
	    )
	    hidden( set(HIDDEN=1) hide )
	)
	nokeyword(
	    set(values=helpswitchbygroup)
	)
	append(helpvalues=$if($equal($values,),helpswitchbygroup,$values))
	set(HELPSWITCH=--help)
	stopafter(NoCompile);

switch -h is hide
	help(Show compiler switches)
	helpgroup(overall)
	enable(Help NoCompile)
	disable(NoFiles)
	append(helpvalues=helpswitchbygroup)
	set(HELPSWITCH=-h)
	stopafter(NoCompile);

switch -I$incdir is
	help(Add directory to include file search path)
	helpgroup(prepro)
	append(USRINC=$path($incdir));

switch -isystem$incdir is
    help(Add a directory to the include file search path before the standard include directories, and mark it as system include directory)
    helpgroup(prepro)
    append(USRSTDINC=$path($incdir));

switch -L$libdir is
	help(Passed to linker; Add directory to library search path)
	helpgroup(linker)
	append(CMDLINE_LDLIBARGS=$LDIRSW$path($libdir))
	append(CMDLINE_LDLIBS=$LPRE$path($libdir));

switch -l$lib is
	help(Passed to linker; Add library name to library search list)
	helpgroup(linker)
	disable(NoFiles)
	replace($LIBSW$lib)
	positional(linker)
	set(LINKALWAYS=1)
	append(CMDLINE_LDLIBS=$lpre$lib);

switch -Manno is hide
	help(Annotate assembly code with source; implies -Mkeepasm)
	helpgroup(overall)
	set(KEEPASM=YES)
	append(CGARGS=-anno);

switch -Mmpiir is hide
	help(enable the MPI Operator IRs)
	helpgroup(opt)
	append(F902ARGS=-x 235 0x1);

switch -Mmpidfa is hide
	help(enable the MPI DataFlowAnalysis)
	helpgroup(opt)
	append(F902ARGS=-x 235 0x2);

switch -Mmpimanaged is hide
	help(enable the MPI managed memory)
	helpgroup(opt)
	append(F901ARGS=-x 235 0x4);

switch -Mmpiblock2nonblock is hide
	help(enable the MPI block-to-nonblock transformation)
	helpgroup(opt)
	append(F902ARGS=-x 235 0x8);

switch -Mmpidir is hide
	help(enable the MPI directives)
	helpgroup(opt)
	append(F901ARGS=-x 235 0x10);

variable AUTOLEVELS is default(10);
variable AUTOMAXFUNCSIZE is default(400);
variable AUTOMAXTOTALSIZE is default(128000);
variable NOSTATIC is default(0);

variable AUTOINLINE_ARGS is hide default(
	-autoinl $AUTOLEVELS -x 168 $AUTOMAXFUNCSIZE -x 174 $AUTOMAXTOTALSIZE -x 14 0x200000 $ifn($NOSTATIC, -x 14 0x400000)
);

switch -Mautoinline is
	help(Enable automatic function inlining in C/C++)
	helpname(-M[no]autoinline)
	helpgroup(opt)
	keyword(
	    maxsize:n( numeric
		set(AUTOMAXFUNCSIZE=$n)
		help(Automatically inline functions size n and less))
	    totalsize:n( numeric
		set(AUTOMAXTOTALSIZE=$n)
		help(Limit automatic inlining to total size of n))
	    nostatic(
		set(NOSTATIC=1)
		help(Do not inline static functions without inline keyword))
	)
	nokeyword( )
	# -Minline maps to -Mautoinline in a special way and must be able to add
	# these as well, so any changes here must be reflected there as well.
	append(CARGS=$AUTOINLINE_ARGS)
	set(AUTOINLINE=YES);

switch -Mnoautoinline is
	help(Disable automatic function inlining in C/C++)
	hide
	helpgroup(opt)
	append(CARGS=-noautoinl -x 14 0x200000)
	set(NEVER_MAP_MINLINE=YES)
	set(MAP_MINLINE=)
	set(AUTOINLINE=);

switch -finline-functions is hide
   shorthand(-Mautoinline);

switch -fno-inline-functions is hide
   shorthand(-Mnoautoinline);

variable BOUNDSCHECK is default(0);
variable NOBOUNDSCHECK is default(0);

switch -Mbounds is
	help(Generate code to check array bounds)
	helpname(-M[no]bounds)
	helpgroup(debug)
	set(BOUNDSCHECK=1)
	append(CARGS=$ifn($NOBOUNDSCHECK,-x 70 2))
	append(F901ARGS=$ifn($NOBOUNDSCHECK,-x 70 2));

switch -Mnobounds is hide
	help(Do not generate code to check array bounds)
	helpgroup(debug)
	set(BOUNDSCHECK=0)
	append(CARGS=-y 70 2)
	append(F901ARGS=-y 70 2);

switch -Mbuiltin is
	help(Use built-in functions)
	helpgroup(language)
	helpname(-M[no]builtin)
	append(CPP1ARGS=--builtin)
	append(CARGS=-y 122 0x80)
	append(USRDDEF=-U_PGI_NOBUILTINS)
	append(USRDEFDEF=-undef _PGI_NOBUILTINS);

switch -Mnobuiltin is
	hide help(No built-in functions)
	helpgroup(language)
	append(CPP1ARGS=--nobuiltin)
	append(CARGS=-x 122 0x80)
	append(USRDDEF=-D_PGI_NOBUILTINS)
	append(USRDEFDEF=-def _PGI_NOBUILTINS);

switch -fno-builtin == -Mnobuiltin;

switch -Mdalign is
	help(Align doubles on double alignment boundaries)
	helpname(-M[no]dalign)
	helpgroup(language)
	append(CPP1ARGS=--dalign)
	append(CGARGS=-dalign);

switch -Mnodalign is hide
	help(Align doubles on float alignment boundaries)
	helpgroup(language)
	append(CPP1ARGS=--nodalign)
	append(CGARGS=-nodalign);

switch -Mdepchk is
	help(Check dependence relations for vector or parallel code)
	helpgroup(opt)
	helpname(-M[no]depchk)
	append(CGARGS=-depchk)
	append(F901ARGS=-depchk);

switch -Mnodepchk is
	help(Don't check dependence relations for vector or parallel code)
	helpgroup(opt)
	hide
	append(CGARGS=-nodepchk)
	append(F901ARGS=-nodepchk);

switch -Mdwarf2 is
	help(Generate DWARF2 debug information with -g)
	helpgroup(debug)
	set(DEBUG2=-x 120 0x200)
	set(DEBUGCPP=--dwarf2);

switch -Mextract is
	help(Extract subprograms for inlining)
	helpgroup(opt)
	enable($if($and($equal($DRIVERLANG,Fortran),$SINGLE_FILE),Compile, Extract))
	stopafter($if($and($equal($DRIVERLANG,Fortran),$SINGLE_FILE),Compile, Extract))
	set(EXTRACTONLY=YES)
	set(EXTRACT=YES)
	append(CEXTARGS=-x 13 0x100000)
	keyword(
	    "":size(numeric append(CEXTARGS=-exsize $size)
		help(Set maximum function size to extract))
	    "":func(identifier append(CEXTARGS=-exfunc $func)
		help(Extract function func))
	    "":extlib(hide
		error($if($EXTRACTLIBSET,Only one -Mextract=lib: options allowed - $EXTRACTLIBVAL and $extlib))
		append(EXTRACTLIBVAL=$mkdir($extlib))
		append(EXTRACTLIBSET=YES)
		help(Set extract library))
	    lib:extlib(
		error($if($EXTRACTLIBSET,Only one -Mextract=lib: options allowed - $EXTRACTLIBVAL and $extlib))
		set(EXTRACTLIBSET=YES)
		set(EXTRACTLIBVAL=$mkdir($path($extlib)))
		help(Store information in directory extlib))
	    name:func(append(CEXTARGS=-exfunc $func) help(Extract function func))
            pragma(
		set(USEINLONLYFILE=YES)
		help(Inline procedures marked !NVF\$ INLINE))
	    size:n(numeric append(CEXTARGS=-exsize $n) help(Limit size of extracted functions to n))
	    levels:n(hide numeric echo(-Mextract=levels:n no longer supported; use -Minline=levels:n))
	    ccpp(hide append(CEXTARGS=-x 14 0x2000000) help(Export all symbols when extracting to enable inlining C into C++))
	    xfile(hide append(CEXTARGS=-x 14 0x20000000) help(Only extract routines that can be inlined across files))
	    exclude:sdir(
		set(NEVER_MAP_MINLINE=YES)
		append(CEXTARGS=-exclude $path($sdir))
		help(Not extract file in sdir)) 
	);

switch -Mframe is
	help(Generate code to set up a stack frame)
	helpgroup(opt)
	helpname(-M[no]frame)
	set(NOFRAME=);

switch -Mnoframe is
	hide help(Do not generate code to set up a stack frame)
	helpgroup(opt)
	set(NOFRAME=YES);

switch -fomit-frame-pointer is
	shorthand(-Mnoframe)
	help(Do not generate code to set up a stack frame)
	helpgroup(opt)
	helpname(-f[no-]omit-frame-pointer);

switch -fno-omit-frame-pointer is hide
  shorthand(-Mframe);

switch -Minform is
	help(Set error level of messages to display)
	helpgroup(overall)
	keyword(
	    inform(set(INFORM=-inform inform))
	    warn  (set(INFORM=-inform warn))
	    severe(set(INFORM=-inform severe) append(CPP1ARGS=--no_warnings))
	    fatal (set(INFORM=-inform fatal) append(CPP1ARGS=--no_warnings))
	    file  (set(ECHONAME=1) helpname([no]file)help(Print source file names as they are compiled))
	    nofile  (hide set(ECHONAME=) help(Don't print source file names as they are compiled))
	)
	onekeyword;

variable MAXFUNCSIZE is default(600);
variable MAXTOTALSIZE is default(25000);
variable SMALLSIZE is default(5);
# Frustratingly, this must be set for each keyword that can be applied to -Minline
variable NEVER_MAP_MINLINE is hide default();
variable MAP_MINLINE is hide default();

switch -Minline is
	help(Enable function inlining)
	helpgroup(opt)
	set(infunc=infunc)
	set(exfunc=exfunc)
	set(ipafunc=yinl)
	set(havelib=)
	keyword(
	    lib:inlib(
		set(NEVER_MAP_MINLINE=YES)
		append(INLINELIST=-inlib $path($inlib))
		append(INLINECARGS=-x 13 0x100000)
		set(havelib=YES) help(Use extracted functions from inlib))
	    "":maxsize(numeric
		set(NEVER_MAP_MINLINE=YES)
		set(MAXFUNCSIZE=$maxsize)
		append(CEXTARGS=-exsize $maxsize)
		help(Set maximum function size to inline))
	    "":func(identifier
		set(NEVER_MAP_MINLINE=YES)
		append(INLINELIST=-$expand($infunc) $func)
		append(CEXTARGS=-$expand($exfunc) $func)
		append(IPAINLINELIST=-$expand($ipafunc) $func)
		help(Inline function func))
	    "":extlib(hide
		set(NEVER_MAP_MINLINE=YES)
		append(INLINELIST=-inlib $path($extlib))
		append(havelib=YES)
		help(Set extract library))
            keep:inlib(hide
		set(NEVER_MAP_MINLINE=YES)
		set(INLINELIST=-inlib $path($inlib))
		append(INLINECARGS=-x 13 0x100000)
		append(FCGARGS=-x 13 0x800)
		set(EXTRACTLIB=$path($inlib))
		set(EXTRACTLIBVAL=$mkdir($path($inlib)))
		help(Keep extracted functions into inlib))
	    except:func(
		set(NEVER_MAP_MINLINE=YES)
		append(INLINELIST=-noinfunc $func)
		set(infunc=noinfunc)
		set(exfunc=noinfunc)
		set(ipafunc=noinl)
		append(IPAINLINELIST=-noinl $func)
		help(Do not inline function func))
	    name:func(
		set(NEVER_MAP_MINLINE=YES)
		append(INLINELIST=-infunc $func)
		set(infunc=infunc)
		set(ipafunc=yinl)
		append(IPAINLINELIST=-yinl $func)
		append(CEXTARGS=-exfunc $func)
		help(Inline function func))
            pragma(
		set(USEINLONLYFILE=YES)
		help(Inline procedures marked !NVF\$ INLINE))
	    maxsize:n(numeric
		set(NEVER_MAP_MINLINE=YES)
		set(MAXFUNCSIZE=$n)
		set(INLINESIZE=$n)
		append(CEXTARGS=-exsize $n)
		help(Inline only functions smaller than n))
	    size:n(numeric
		set(NEVER_MAP_MINLINE=YES)
		set(MAXFUNCSIZE=$n)
		set(INLINESIZE=$n)
		hide help(Inline only functions smaller than n))
	    totalsize:n(numeric
		set(NEVER_MAP_MINLINE=YES)
		set(MAXTOTALSIZE=$n)
		help(Limit inlining to total size of n))
	    smallsize:n(numeric
		set(NEVER_MAP_MINLINE=YES)
		set(SMALLSIZE=$n)
		help(Always inline functions smaller than n))
	    levels:n(numeric
		set(NEVER_MAP_MINLINE=YES)
		append(INLINECARGS=-x 115 $n)
		append(F901ARGS=-x 115 $n)
		hide help(Inline n levels of functions))
	    reshape(
		set(NEVER_MAP_MINLINE=YES)
		append(FCGARGS=-x 14 0x4000000)
		help(Allow inlining in Fortran even when array shapes do not match))
	    exclude:sdir(
		set(NEVER_MAP_MINLINE=YES)
		append(CEXTARGS=-exclude $path($sdir))
		help(Not extract file in sdir)) 
	)
	nokeyword(
		help(Inline all functions that were extracted)
		set(MAP_MINLINE=$if($SINGLE_CXX_FILE,$ifn($NEVER_MAP_MINLINE,YES)))
		append(CARGS=$if($MAP_MINLINE,$AUTOINLINE_ARGS))
		set(AUTOINLINE=$if($MAP_MINLINE,YES))
	)
	append(INLINELIST=$ifn($MAP_MINLINE,-insize $MAXFUNCSIZE -x 221 $MAXTOTALSIZE -x 222 $SMALLSIZE))
	append(EXTRACTINLINE=$ifn($MAP_MINLINE,$ifn($havelib,YES)))
	append(INLINECARGS=-x 14 32)
	set(INLINE=$ifn($MAP_MINLINE,YES))
	;

switch -Minline_cpu_f is hide
	help(Enable function inlining)
	helpgroup(opt)
	set(infunc=infunc)
	set(exfunc=exfunc)
	set(ipafunc=yinl)
	set(havelib=)
	set(NEVER_MAP_MINLINE=YES)
	keyword(
	    lib:inlib(append(INLINELIST=-inlib $path($inlib))
		append(INLINECARGS=-x 13 0x100000)
		set(havelib=YES) help(Use extracted functions from inlib))
	    "":maxsize(numeric set(MAXFUNCSIZE=$maxsize)
		help(Set maximum function size to inline))
	    "":func(identifier append(INLINELIST=-$expand($infunc) $func)
		append(CEXTARGS=-$expand($exfunc) $func)
		append(IPAINLINELIST=-$expand($ipafunc) $func)
		help(Inline function func))
	    "":extlib(hide append(INLINELIST=-inlib $path($extlib))
		append(havelib=YES)
		help(Set extract library))
	    except:func(append(INLINELIST=-noinfunc $func) set(infunc=noinfunc) set(exfunc=noinfunc) set(ipafunc=noinl) help(Do not inline function func) append(IPAINLINELIST=-noinl $func))
	    name:func(append(INLINELIST=-infunc $func) set(infunc=infunc) set(ipafunc=yinl) help(Inline function func) append(IPAINLINELIST=-yinl $func)
		append(CEXTARGS=-exfunc $func))
	    maxsize:n(numeric set(MAXFUNCSIZE=$n) help(Inline only functions smaller than n) set(INLINESIZE=$n))
	    size:n(numeric set(MAXFUNCSIZE=$n) hide help(Inline only functions smaller than n) set(INLINESIZE=$n))
	    totalsize:n(numeric set(MAXTOTALSIZE=$n) help(Limit inlining to total size of n))
	    smallsize:n(numeric set(SMALLSIZE=$n) help(Always inline functions smaller than n))
	    levels:n(numeric append(INLINECARGS=-x 115 $n)
		append(F901ARGS=-x 115 $n)
		hide help(Inline n levels of functions))
	    reshape( append(FCGARGS=-x 14 0x4000000)
		help(Allow inlining in Fortran even when array shapes do not match))
	)
	append(INLINELIST=$if($equal($DRIVERLANG,Fortran),$ifn($or($LNGACC,$LNGOMP),-insize $MAXFUNCSIZE -x 221 $MAXTOTALSIZE -x 222 $SMALLSIZE)))
	#append(EXTRACTINLINE=$ifn($havelib,YES))
	nokeyword(help(Inline all functions that were extracted))
	append(INLINECARGS=$if($equal($DRIVERLANG,Fortran),$ifn($or($LNGACC,$LNGOMP),-x 14 32)))
	set(INLINE=$if($equal($DRIVERLANG,Fortran),$ifn($or($LNGACC,$LNGOMP),YES)))
	;

switch -Minstrument is
    help(Generate additional code for instrumentation; implies -Mframe)
    helpgroup(opt)
    set(profval=)
    set(profsw=)
    set(mpiprofsw=YES)
    set(mpinotok=1)
    set(mpiused=0)
    keyword(
        functions (
        help(Enable instrumentation of functions)
        append(CGARGS=-x 129 0x800)
        set(profsw=YES)
		)
    )
    nokeyword(
        help(Enable instrumentation of functions)
        append(CGARGS=-x 129 0x800)
        set(profsw=YES)
    )
    set(PROFILE=YES)    # default profile library
    set(mpiprofsw=YES)
    set(mpinotok=0)
    set(LPROFO=)
    append(CGARGS=$if($profsw,-profile $profval));

switch -Minstrument-exclude-func-list is
    helpgroup(opt)
    keyword(
        "":func(append(NOINSTRFUNCS=-noinstrfunc $func) help(Do not instrument function func))
    );

switch -Minstrument-exclude-file-list is
    helpgroup(opt)
    keyword(
        "":file(append(NOINSTRFILELIST=$file) help(Do not instrument funcs in file))
	);

switch -Mnoinline is
	help(Disable function inlining in C/C++/Fortran)
	hide
	helpgroup(opt)
	append(CARGS=-noinline)
	append(F902ARGS=-noinline)
	shorthand(-Mllvm-noinline)
	set(INLINEARGS=)
	set(INLINE=);

switch -Mkeep is
	hide
	help(Preserve intermediate files)
	helpgroup(overall)
	set(KEEPTEMP=YES);

switch -Mkeepasm is
	help(Preserve intermediate assembly language file)
	helpgroup(overall)
	set(KEEPASM=YES);

switch -Mkeepobj is hide
	help(Preserve intermediate object file)
	helpname(-M[no]keepobj)
	helpgroup(overall)
	set(KEEPOBJ=YES);

switch -Mnokeepobj is hide
	help(Delete intermediate object file)
	helpgroup(overall)
	set(KEEPOBJ=);

switch -Mlist is
	help(Generate a listing file)
	helpgroup(overall)
	helpname(-M[no]list)
	append(CARGS=-list)
	append(FARGS=-list);

switch -Mnolist is hide
	help(Do not generate a listing file)
	helpgroup(overall)
	append(CARGS=-nolist)
	append(FARGS=-nolist);

switch -Mpreprocess is
	help(Run preprocessor for assembly and Fortran files)
	helpgroup(prepro)
	set(ASMCOMMAND=asmpreprocess)
	append(FARGS=-preprocess);

switch -cpp is
	shorthand(-Mpreprocess)
	helpgroup(prepro);

switch -Mquad is
	help(Align large objects on quad-word boundaries)
	helpgroup(opt)
	append(CARGS=-quad);

switch -Mnostartup is
	help(Do not use standard linker startup file)
	helpgroup(linker)
	set(NOSTARTUP=YES);

switch -Mnostddef is
	help(Do not use standard macro definitions)
	helpgroup(prepro)
	set(STDDEF=)
	set(STDPRED=);

switch -Mnostdinc is
	help(Do not use standard include directories)
	helpgroup(prepro)
	set(PREINCLUDE=)
	set(STDINC=);

switch -Mnostdlib is
	help(Do not use standard linker libraries)
	helpgroup(linker)
	set(NOSTDLIBS=YES)
	set(NOSTDCPPLIBS=1)
	set(NOSTDFTNLIBS=YES)
	set(NOSTDLIBDIRS=YES)
	set(NOSTDLIBPATHS=YES);

switch -nostdlib is
    help(Do not use standard linker libraries and startup files)
    helpgroup(linker)
    set(NOSTDLIBS=YES)
    set(NOSTARTUP=YES)
    set(NOSTDCPPLIBS=1)
    set(NOSTDFTNLIBS=YES)
    set(NOSTDLIBDIRS=YES)
    append(DEFLDARGS=$EHFRAME)
    set(NOSTDLIBPATHS=YES);

switch -nostartfiles is
    help(Do not use startup files)
    helpgroup(linker)
    set(NOSTARTUP=YES);

switch -pgc++libs is 
    help(Deprecated; see -c++libs)
    shorthand(-c++libs);

switch -c++libs is
    help(Append gnu compatible C++ libraries to the link line)
    helpgroup(linker)
    set(NEEDSTDCPPLIB=1)
    set(NOSTDCPPLIBS=0);

switch -Mreentrant is hide
	help(Avoid optimizations that prevent code from being reentrant)
	helpgroup(opt)
	helpname(-M[no]reentrant)
	append(F901ARGS=-reentrant)
	append(CGARGS=-reentrant);

switch -Mnoreentrant is hide
	help(Disallow optimizations that prevent code from being reentrant)
	helpgroup(opt)
	append(CGARGS=-noreentrant);

switch -Mstack_arrays is
	help(Place automatic arrays on the stack)
	helpname(-M[no]stack_arrays)
	helpgroup(language)
	append(CGARGS=-x 54 0x08)
	append(F901ARGS=-x 54 0x08);

switch -Mnostack_arrays is hide
	help(Do not place automatic arrays on the stack)
	helpgroup(opt)
	append(CGARGS=-y 54 0x08)
	append(F901ARGS=-y 54 0x08);

switch -Mstack_frame_trace is hide
	help(Generate runtime function calls to trace the stack frame)
	helpgroup(overall)
	append(CGARGS=-x 194 0x8000000)
	append(CPP2ARGS=-x 194 0x8000000)
	append(F901ARGS=-x 194 0x8000000);

switch -Mstride0 is
	helpname(-M[no]stride0)
	helpgroup(opt)
	help(Generate code to check for zero loop increments)
	append(CGARGS=-x 70 1);

switch -Mnostride0 is hide
	help(Do not generate code to check for zero loop increments)
	helpgroup(opt)
	append(CGARGS=-y 70 1);

switch -Munroll is
	help(Enable loop unrolling)
	helpgroup(opt)
	helpname(-M[no]unroll)
	set(cval=1)
	set(nval=)
	set(mval=)
	keyword(
	    c:n(set(cval=$n) help(Completely unroll loops with loop count n or less))
	    n:n(set(nval=$n) help(Unroll single-block loops n times))
	    m(set(mval=4) hide help(Unroll multi-block loops 4 times))
	    m:n(set(mval=$n) help(Unroll multi-block loops n times))
	)
	nokeyword(help(Unroll loops with a loop count of 1) set(cval=1))
	max(OPTLEVELDEF=2)
	max(OPTLEVELMIN=2)
	append(OPTLEVELMINLIMIT=" -Munroll")
	append(CGARGS=$if($notequal($cval,),-x 9 $cval)
			$if($notequal($nval,),-x 10 $nval)
			$if($notequal($mval,),-x 157 $mval -x 11 0x200))
	set(LLVMUNROLL=1);
 
switch -Mnounroll is hide
	help(Inhibit loop unrolling)
	helpgroup(opt)
	append (CGARGS=-y 9 0 -x 10 0 -x 157 0)
	set(LLVMUNROLL=0);	
	
switch -Muniform is hide
	help(Uniform numerical results in simd and scalar code)
	helpname(-M[no]uniform)
	helpgroup(opt)
	append(CGARGS=-y 15 0x201);

switch -Mnouniform is hide
	help(Uniform numerical results in simd and scalar code)
	helpname(-M[no]uniform)
	helpgroup(opt)
	append(CGARGS=-x 15 0x201);

variable VASP_FIX_FLAG is default(-x 189 0x20);
switch -Mwarperf is hide
	help(VASP specific flags)
	append(CGARGS=$if($expr($CUDAXXYY>=11050),$VASP_FIX_FLAG))
	;

switch -Mx,xflag is hide #not
	help(Pass x flag to compiler)
	helpgroup(overall)
	append(IPAADD=-Mx,$xflag)
	append(CGARGS=-x $replace($xflag,",", ));

switch -Mq,qflag is hide #not
	help(Pass q flag to compiler)
	helpgroup(overall)
	append(IPAADD=-Mq,$qflag)
	append(CGARGS=-q $replace($qflag,",", ));

switch -Mqq,qflag is hide #not
	help(Pass qq flag to compiler)
	helpgroup(overall)
	append(IPAADD=-Mqq,$qflag)
	append(CGARGS=-qq $replace($qflag,",", ));

switch -Mxf,xflag is hide #not
	help(Pass x flag to compiler for a function)
	helpgroup(overall)
	append(CGARGS=-xf $replace($xflag,",", ));

switch -My,xflag is hide #not
	help(Pass y flag to compiler)
	helpgroup(overall)
	append(CGARGS=-y $replace($xflag,",", ));

switch -Hx,xflag is hide #not
	help(Pass x flag to Fortran front end)
	helpgroup(overall)
	append(IPAADD=-Hx,$xflag)
	append(F901ARGS=-x $replace($xflag,",", ));

switch -Hy,xflag is hide #not
	help(Pass y flag to Fortran front end)
	helpgroup(overall)
	append(IPAADD=-Hy,$xflag)
	append(F901ARGS=-y $replace($xflag,",", ));

switch -Hq,qflag is hide #not
	help(Pass q flag to Fortran front end)
	helpgroup(overall)
	append(IPAADD=-Hq,$qflag)
	append(F901ARGS=-q $replace($qflag,",", ));

switch -Hqq,qflag is hide #not
	help(Pass qq flag to Fortran front end)
	helpgroup(overall)
	append(IPAADD=-Hqq,$qflag)
	append(F901ARGS=-qq $replace($qflag,",", ));

switch -Myf,xflag is hide #not
	help(Pass y flag to compiler for a function)
	helpgroup(overall)
	append(CGARGS=-yf $replace($xflag,",", ));

switch -Mzerotrip is
	helpname(-M[no]zerotrip)
	helpgroup(opt)
	help(Assume loops may not execute";" add zero-trip test)
	append(CGARGS=-y 19 0x800);

switch -Mnozerotrip is hide
	help(Assume loops always execute";" remove zero-trip test)
	helpgroup(opt)
	append(CGARGS=-x 19 0x800);

switch -o$outputfile is
	help(Name the output file)
	helpgroup(overall)
	set(OUTFILE=$path($outputfile));

switch -Mcpp is early
	help(Just preprocess the input files)
	helpgroup(prepro)
	# -Mcpp uses the PGI preprocessor, not the EDG preprocessor
	set(OTHERPREPROCESS=otherpreprocess)
	set(GENPREPROCESS=genpreprocess)
	keyword(
	    m(
		append(PREPROARGS=-m)
		set(KEEPPREPRO=)
		help(Print makefile dependencies)
	    )
	    md(
		append(PREPROARGS=-md)
		set(KEEPPREPRO=)
		help(Print makefile dependencies to .d file)
	    )
	    mm(
		append(PREPROARGS=-mm)
		set(KEEPPREPRO=)
		help(Print makefile dependencies";" ignore system includes)
	    )
	    mmd(
		append(PREPROARGS=-mmd)
		set(KEEPPREPRO=)
		help(Print makefile dependencies to .d file";" ignore system includes)
	    )
	    mq:mqtarget(
		append(PREPROARGS=-mq $mqtarget)
		set(KEEPPREPRO=)
		help(Print makefile dependencies)
	    )
	    mt:mttarget(
		append(PREPROARGS=-mt $mttarget)
		set(KEEPPREPRO=)
		help(Print makefile dependencies)
	    )
	    line(
		append(PREPROARGS=-p)
		help(Insert line numbers into preprocess output)
	    )
	    comment(
		helpname([no]comment)
		append(PREPROARGS=-comment)
		help(Keep comments in preprocessed output)
	    )
	    nocomment( hide
		append(PREPROARGS=-nocomment)
		help(Don't keep comments in preprocessed output)
	    )
	    suffix:suff(
		append(PREPROARGS=$if($suff,-suffix $suff))
		help(Suffix to use for makefile dependencies)
	    )
	    "":suff(
		append(PREPROARGS=$if($suff,-suffix $suff))
		help(Suffix to use for makefile dependencies)
	    )
	    include:file(
		append(PREPROARGS=-include $file)
		help(Include file before processing source file)
	    )
	    b(
		append(PREPROARGS=-b)
		hide help(Support the C++/c99 comment indicator '//')
	    )
	    c89(
		append(PREPROARGS=-c89)
		help(Use the C89 language)
	    )
	    c99(
		append(PREPROARGS=-c99)
		help(Use the C99 language)
	    )
	)
	nokeyword()
	set(DEFKEEPPREPRO=YES)
	set(PREPROCONLY=YES)
	set(NOASM=YES)
	stopafter(Preproconly)
	enable(Preproconly)
	set(COMPILEONLY=YES);

switch -Qdir compdir is #not
	hide
	help(Change compiler directory)
	helpgroup(overall)
	set(CCOMPDIR=$compdir);

switch -pg is
	help(Enable gprof profiling";" implies -Mframe)
	helpgroup(opt)
	set(PROFILE=YES)
	set(PROFILESW=-pg)
	set(REALNOFRAME=)	# override -Mnoframe
	error($if($and($notequal($PROFFLAG,),$notequal($PROFFLAG,-pg)),Profile flag -pg is not valid with $PROFFLAG))
	set(PROFFLAG=-pg)
	append(CGARGS=-profile -x 119 2 $ifn($DEBUGSET,-x 120 0x1000));

switch -p == -pg;
switch -qp == -pg;

switch -Qpath comppath is #not
	hide
	help(Change compiler path)
	helpgroup(overall)
	set(CCOMPDIR=$comppath);

switch -r is
	help(Generate relocatable object; passed to linker)
	helpgroup(linker)
	set(PARTIALLINK=1)
    set(NOSTARTUP=YES)
	append(LDSWITCHES=-r);

# -rc is a driver builtin switch #not

switch -s is
	help(Passed to linker; strip symbol table from exectable)
	helpgroup(linker)
	append(LDSWITCHES=-s);

switch -S is
	help(Stop before assembling; output in .s file)
	helpgroup(overall)
	set(KEEPASM=YES)
	stopafter(Compile)
	set(COMPILEONLY=YES);

# -saverc is a driver builtin switch #not

switch -show is #not
	enable(Show NoCompile)
	helpgroup(overall)
	stopafter(NoCompile)
	keyword(
	    hidden( set(HIDDEN=1) hide )
	)
	nokeyword()
	help(Show compiler configuration);

# the -sshow flag (secret-show) is here for when we want to use
# the '-show' flag but the command line is using a
# wrapper (like mpicc) that eats up the -show flag itself.
switch -sshow is hide shorthand(-show);

switch -silent is
	help(Inhibit warning messages; same as -Minform=severe)
	helpgroup(overall)
	set(INFORM=-inform severe)
	set(NOWARN=YES);

switch -time is #not
	help(Print execution time for each compiler step (default: CPU time))
	keyword(
	    cpu(help(Display CPU time spent in compiler phases)
		set(USE_REAL_TIME=0))
	    real(help(Display wall-clock time spent in compiler phases)
		set(USE_REAL_TIME=1))
	)
	nokeyword(set(USE_REAL_TIME=0))
	append(CGARGS=-x 0 1)
	append(CPP1ARGS=--timing)
	helpgroup(overall);

switch -ctime is hide
	helpgroup(overall)
	help(Print user and system time spent in each phase and tool)
	set(TIMER=YES);

switch -u$undef is
	help(Passed to linker; generate undefined reference)
	helpgroup(linker)
	append(LDSWITCHES=-u $undef);

switch -U$macro is
	help(Undefine a preprocessor macro)
	helpgroup(prepro)
	append(USRDDEF=-U$macro)
	append(USRDEFDEF=-undef $macro);

switch -V$ is
  early
  optional(ver)
  help(Display or change compiler version)
  helpgroup(overall)
  set(SUPPRESS_WARNINGS=1)
  set(VERSION=$ifn($ver,$if($LOCALRC,1,0),0))
  set(v=$expand($if($ver,$ver,$COMPVER)))
  restart($if($notequal($ver,),$if($isdir($COMPBASE/$COMPSYS/$ver/$COMPBBIN),$COMPBASE/$COMPSYS/$ver/$COMPBBIN,$error(Version $ver $COMPBASE/$COMPSYS/$ver/$COMPBBIN is not available in this installation))))
  set(COMPVER=$v);

switch --version is
	early
	help(Display compiler version)
	helpgroup(overall)
  set(VERSION=$if($LOCALRC,1,0));

switch -dumpversion is
	help(Display compiler short version)
	helpgroup(overall)
	echostdout($if($contains($lowercase($NVVERSION),rel,dev),99.99,$NVVERSION))
	enable(NoCompile)
	disable(NoFiles)
	stopafter(NoCompile);

switch -dumpfullversion is shorthand(-dumpversion);

switch -v is
	help(Display each command as it is run)
	helpgroup(overall)
	set(VERBOSE=2);

switch -w is #not
	help(Inhibit warning messages; same as -Minform=severe)
	helpgroup(overall)
	set(INFORM=-inform severe)
	set(NOWARN=YES);

switch -W0,arg is
	help(Pass argument to compiler)
	helpgroup(overall)
	append(CGARGS=$replace($arg,",", ));

switch -Wl,arg is
	help(Pass argument to linker)
	helpgroup(linker)
	disable(NoFiles)
	set(LINKALWAYS=1)
	replace($replace($arg,",", ))
	positional(linker);

switch -Xlinker args is
	switcharg
	help(Specify options directly to the linker.)
	helpgroup(linker)
	disable(NoFiles)
	set(LINKALWAYS=1)
	replace($replace($args,",", ))
	positional(linker);

switch -Wll,arg is hide
	help(Pass argument to linker)
	helpgroup(linker)
	disable(NoFiles)
	set(LINKALWAYS=1)
	replace($arg)
	positional(linker);

switch -Wa,arg is
	help(Pass argument to assembler)
	helpgroup(asm)
	append(ASARGS=$replace($arg,",", ));

switch -Y0,compdir is
	help(Change compiler directory)
	helpgroup(overall)
	set(CCOMPDIR=$path($compdir));

switch -Ya,asdir is
	help(Change assembler directory)
	helpgroup(asm)
	set(ASDIR=$path($asdir));

switch -Yc,compdir is
	help(Change C++ compiler directory)
	helpgroup(overall)
	set(CPPCOMPDIR=$path($compdir));

switch -YC,complibdir is
	help(Change compiler library directory)
	helpgroup(linker)
	set(COMPLIB=$foreach(dd,$replace($complibdir,",", ),$path($dd) ));

switch -Yh,compdir is
	help(Change F90 front end directory)
	helpgroup(overall)
	set(HCOMPDIR=$path($compdir));

switch -YI,incdir is
	help(Change standard include directory)
	helpgroup(prepro)
	set(STDINC=$incdir);

switch -YII,incdir is hide
	help(Append to standard include directory list)
	helpgroup(prepro)
	append(USRSTDINC=$incdir);

switch -Yl,linkdir is
	help(Change linker directory)
	helpgroup(linker)
	set(LDDIR=$path($linkdir));

switch -YL,stdlibdir is
	help(Change standard library directory)
	helpgroup(linker)
	set(LIBDIR=$path($stdlibdir))
	append(LDARGS=-YL$stdlibdir);

switch -Yp,preprodir is
	helpgroup(prepro)
	help(Change preprocessor directory)
	set(PREPRODIR=$path($preprodir));

switch -YS,startupdir is
	help(Change startup object directory)
	helpgroup(linker)
	set(STDOBJDIR=$path($startupdir));

switch -YU,libdir is
	help(Change linker library area)
	helpgroup(linker)
	append(LDARGS=-YU$path($libdir));

variable APPENDTOOL is
	help(Name of object file append module);

tool append is
	help(Object file append module)
	program($APPENDTOOL) directory($CCOMPDIR);

command append is
	help(Append information to object file)
	tool(append)
	arguments(-noerror $input
		$ifn($IPOFILE,$if($ipofile,-name .IPOINFO $ipofile))
		$if($IPAINLINE,
			$if($ipmfile,-name .IPMINFO $ipmfile)
			$if($ipnfile,-name .IPNINFO $ipnfile)
			$if($inlfile,-name .IPKINFO $inlfile))
		$if($and($mdxfile,$modfile),-name .IPDINFO $modfile -name .IPEINFO $mdxfile)
		$if($and($IPAEXPORT,$ipxfile),-name .IPXINFO $ipxfile)
	)
	set(ipofile=)
	set(ipxfile=)
	set(ipmfile=)
	set(ipnfile=)
	set(inlfile=)
	set(modfile=)
	set(mdxfile=)
	set(doappend=);

variable GENCCFF is default(0);
variable CZCCFF is default(-cz);
variable KEEPCCFF is default(-keep);
# -Minfo with no arguments enables inline for Fortran, but not for C++.
# C++ code commonly causes so many messages about inlining that they become
# overwhelming and drown out other messages.
variable DEFCCFFVALUE is default($if($equal($DRIVERLANG,CPP),0x6CFF6,0x6CFF7));

# Used by --gcc-toolchain
variable GCCTOOLCHAINARG is default();
variable GCCTOOLCHAINVER is default();
variable GCCTOOLCHAINDIR is default();
variable TEMPGCCRC is default();

switch -Minfo is
	helpgroup(opt)
	help(Generate informational messages about optimizations)
	helpname(-M[no]info)
	set(DEFCCFF=-x 161 $DEFCCFFVALUE -x 162 0x6CFF6)
	set(CCFFOUT=0)
	set(CCFFFLAG=0)
	set(ENABLECCFF=0)
	keyword(
	    all(help(-Minfo=accel,inline,loop,lre,mp,opt,par,vect,stdpar)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x6CFF7))
	    accel(help(Enable Accelerator information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x4000)
		keyword(
		  detail(hide help(Detailed optimization messages)
		    or(CCFFFLAG=0x200000)
		  )))
	    ccff( hide help(Append information to object file))
	    ftn(help(Enable Fortran-specific information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x400))
	    inline(help(Enable inliner information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x1))
	    intensity(help(Intensity analysis is no longer supported)
		set(msg=Intensity analysis is no longer supported.)
		fatal($if($ISWERROR,$msg))
		warning($ifn($ISWERROR,$ifn($NV_SUPPRESS_GPU_FLAGS_WARNINGS,$msg)))
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x8))
            llvm(hide 
                help(Dump all LLVM optimization remarks)
                append(LLVMOPTUSERARGS=-pass-remarks=.*))
	    loop(help(Enable loop optimization information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x222))
	    lre(help(Enable LRE information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x4))
	    mp(help(Enable OpenMP information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x80))
	    opt(help(Enable optimizer information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x100))
	    par(help(Enable parallelizer information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x800))
	    pcast(help(Enable PCAST information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x20000))
	    pfo(help(Enable profile feedback information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x2000))
	    stat=time	(help(Same as -Minfo=time))
	    time=cputime(help(Same as -Minfo=cputime))
	    cputime(help(Display CPU time spent in compiler phases)
		set(DEFCCFF=)
		set(USE_REAL_TIME=0)
		append(CGARGS=-x 0 1)
		append(CPP1ARGS=--timing))
	    realtime(help(Display wall-clock time spent in compiler phases)
		set(DEFCCFF=)
		set(USE_REAL_TIME=1)
		append(CGARGS=-x 0 1)
		append(CPP1ARGS=--timing))
	    unified(hide help(No longer supported)
		set(ENABLECCFF=1)
		set(CCFFOUT=1))
	    vect(help(Enable vectorizer information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x40))
	    ili(append(CGARGS=-x 0 0x40) hide
		set(DEFCCFF=))
	    extended(help(Enable extended information) hide
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x10000))
			stdpar(help(Enable stdpar information)
		set(ENABLECCFF=1)
		set(CCFFOUT=1)
		or(CCFFFLAG=0x40000))
	)
	nokeyword(set(ENABLECCFF=1) set(CCFFOUT=1))
	append(CGARGS=$if($ENABLECCFF,-x 0 0x1000000 -x 2 0x100000 $if($CCFFOUT,-x 0 0x2000000 $if($CCFFFLAG,-x 161 $CCFFFLAG -x 162 $CCFFFLAG,$DEFCCFF))))
	or(GENCCFF=$if($ENABLECCFF,1,0));

switch -Mnoinfo is
	hide
	help(Disable all -Minfo and -Mneginfo messages)
	helpgroup(opt)
	set(GENCCFF=0)
	append(CGARGS=-y 161 0xffffffff -y 162 0xffffffff);

switch -Mneginfo is
	help(Generate informational messages about optimizations)
	helpgroup(opt)
	set(CCFFFLAG=0)
	keyword(
	    all(help(-Mneginfo=accel,inline,loop,lre,mp,opt,par,vect,stdpar)
		or(CCFFFLAG=0x6CFF7))
	    accel(help(Enable Accelerator information)
		or(CCFFFLAG=0x4000))
	    ftn(help(Enable Fortran-specific information)
		or(CCFFFLAG=0x400))
	    inline(help(Enable inliner information)
		or(CCFFFLAG=0x1))
	    loop(help(Enable loop optimization information)
		or(CCFFFLAG=0x222))
	    lre(help(Enable LRE information)
		or(CCFFFLAG=0x4))
	    mp(help(Enable OpenMP information)
		or(CCFFFLAG=0x80))
	    opt(help(Enable optimizer information)
		or(CCFFFLAG=0x100))
	    par(help(Enable parallelizer information)
		or(CCFFFLAG=0x800))
	    pfo(help(Enable profile feedback information)
		or(CCFFFLAG=0x2000))
	    vect(help(Enable vectorizer information)
		or(CCFFFLAG=0x40))
	    stdpar(help(Enable stdpar information)
		or(CCFFFLAG=0x40000))
	)
	nokeyword(or(CCFFFLAG=0x6CFF7))
	append(CGARGS=-x 162 $CCFFFLAG -x 0 0x2000000);

switch -Mccff is
	hide
	help(Control what CCFF information is stored and how)
	helpgroup(opt)
	keyword(
		demangle(help(Demangle mangled names before entering them in CCFF)
			append(CGARGS=-x 1 0x400000))
		nodemangle(help(Leave mangled names as-is when entering them in CCFF)
			append(CGARGS=-y 1 0x400000))
	);

switch -csuffix=suff is early
	help(Define a C suffix)
	helpgroup(language)
	append(USERCSUFFIX=$suff);

switch --cpp_as_c is hide early
	help(Compile C++ files with nvc)
	helpgroup(language)
	set(CPPASCPP=)
	set(CPPASC=$DEFAULTCPPASCPP)
	set(CPPHEADERSUFFIX=)
	set(CHEADERSUFFIX=$DEFAULTCHEADERS $DEFAULTCPPHEADERS);

switch -asmsuffix=suff is early
	help(Define a assembler language suffix)
	helpgroup(language)
	append(USERASMSUFFIX=$suff);

switch -Mobjsuffix=suff is early
	help(Define a object file suffix)
	helpgroup(language)
	append(USEROBJSUFFIX=$suff);

switch -Mlibsuffix=suff is early
	help(Define a library file suffix)
	helpgroup(language)
	append(USERLIBSUFFIX=$suff);

switch -Mpcast is
	append(CGARGS=-x 215 0x8)
	append(F901ARGS=-x 215 0x8)
	append(CPP1ARGS=--pcast)
	help(Enable PCAST directives);

switch -Mnodbgstub is
	hide
	append(CGARGS=-x 50 0x100);

switch -versions is
	help(Print the available compiler versions)
	helpgroup(overall)
	disable(NoFiles)
	disable(OtherChecks)
	enable(Versions)
	stopafter(Versions);

switch --no_preincludes is
	help(Ignore all preincluded files: used for compiling preprocessed files)
	helpgroup(language)
	set(CPPPREINC=)
	set(PREINCLUDE=)
	set(IGNORE_PREINCLUDES=YES);

switch -Msignextend is
	help(Extend the sign bit when converting shorter to longer integer)
	helpgroup(language)
	helpname(-M[no]signextend)
	or(SIGNEX=1)
	append(F901ARGS=-x 124 1)
	append(CGARGS=-x 122 1 -x 124 1);

switch -Mnosignextend is hide
	help(Don't extend the sign bit when converting shorter to longer integer)
	helpgroup(language)
	andnot(SIGNEX=1)
	append(F901ARGS=-y 124 1)
	append(CGARGS=-y 122 1 -y 124 1);

switch -Munusedfuncopt is hide
	help(Enable the unused functions optimization along with the associated inliner changes)
	append(CGARGS=-x 4 0x20000 -x 4 0x40000);

switch -Mnounusedfuncopt is hide
	help(Enable the unused functions optimization along with the associated inliner changes)
	append(CGARGS=-y 4 0x20000 -y 4 0x40000);

switch -pthread is
  	append(USRDDEF=-D_REENTRANT)
  	append(USRDEFDEF=-def _REENTRANT);

command makegcclocalrc is
  help(Create gcc localrc)
  tool(makelocalrc)
  set(searchdir=$if($GCCTOOLCHAINDIR,$GCCTOOLCHAINDIR $GCCTOOLCHAINDIR/bin))
  # Default toolchain (no version specified)
  set(gccprogdef=$lookup($searchdir,gcc))
  set(gppprogdef=$lookup($searchdir,g++))
  set(_gfortprogdef=$lookup($searchdir,gfortran))
  set(gfortprogdef=$if($_gfortprogdef,$_gfortprogdef,$lookup($searchdir,g77)))
  # Used to check the presence of $GCCTOOLCHAINVER. $if($GCCTOOLCHAINVER,) is
  # sometimes wrongly treated as a switch (e.g. gcc-13, GCCTOOLCHAINVER is -13,
  # which the compiler sees as a switch)
  set(checkver=$ifn($equal($GCCTOOLCHAINVER,),1,0))

  # If version is specified, attempt to find matching versions
  set(gccprogver=$if($checkver,$lookup($searchdir,gcc$GCCTOOLCHAINVER)))
  error($if($checkver,$ifn($gccprogver,Unable to find gcc$GCCTOOLCHAINVER in $GCCTOOLCHAINDIR)))
  set(gppprogver=$if($checkver,$lookup($searchdir,g++$GCCTOOLCHAINVER)))
  error($if($checkver,$ifn($gppprogver,Unable to find g++$GCCTOOLCHAINVER in $GCCTOOLCHAINDIR)))
  set(_gfortprogver=$if($checkver,$lookup($searchdir,gfortran$GCCTOOLCHAINVER)))
  set(gfortprogver=$if($_gfortprogver,$_gfortprogver,$lookup($searchdir,g77$GCCTOOLCHAINVER)))
  error($if($checkver,$ifn($gfortprogver,Unable to find g77$GCCTOOLCHAINVER or gfortran$GCCTOOLCHAINVER in $GCCTOOLCHAINDIR)))

  set(usegccver=$if($gccprogver,$if($gppprogver,$if(gfortprogver,1))))
  set(gccprog=$if($usegccver,$gccprogver,$gccprogdef))
  set(gppprog=$if($usegccver,$gppprogver,$gppprogdef))
  set(gfortprog=$if($usegccver,$gfortprogver,$gfortprogdef))
  echo($if($VERBOSE,$if($gccprog,Selected gcc: $gccprog)))
  echo($if($VERBOSE,$if($gppprog,Selected g++: $gppprog)))
  echo($if($VERBOSE,$if($gfortprog,Selected gfortran: $gfortprog)))
  echo($if($VERBOSE,Writing localrc file to $TEMPGCCRC))
  arguments(
    -f $LOCALRCFILENAME
    -x
    -q
    $if($ISNG,-no-cuda) # Right now we are not adding CUDA toolkits in NG compilers so skip CUDA check, TODO: remove when CUDA toolkits are added
    $if($gccprog,-gcc $gccprog,
        $error(gcc not found in $GCCTOOLCHAINARG))
    $if($gppprog,-gpp $gppprog,
        $error(g++ not found in $GCCTOOLCHAINARG))
    $if($gfortprog,-g77 $gfortprog,
        $error(gfortran not found in $GCCTOOLCHAINARG))
    -d $dirname($TEMPGCCRC)
    -f $filename($TEMPGCCRC));

command makehomelocalrc is
  help(localrc install script)
  tool(makelocalrc)
  error($ifn($HOME,The environment variable "$"HOME is not defined))
  echo($if($VERBOSE,Writing localrc file to $HOMELOCALRC))
  error($ifn($equal($substr($HOMELOCALRC,0,4),$substr($HOME,0,4)),The localrc path is not relative to "$"HOME))
  arguments(
    -f $LOCALRCFILENAME
    -lnet -x
    $if($ISNG,-no-cuda) # Right now we are not adding CUDA toolkits in NG compilers so skip CUDA check, TODO: remove when CUDA toolkits are added            
    $if($equal($COMPVER,mine),-no-cuda)
    -d $dirname($HOMELOCALRC));

switch --gcc-toolchain=arg is
  help(Specify gcc toolchain location using path to gcc directory or gcc executable)
  helpgroup(overall)
  set(GCCTOOLCHAINARG=$arg)
  # Separate out tool (e.g. gcc) and possible version string.
  set(GCCTOOLCHAINVER=$if($isfile($arg),
                          $if($contains($basename($arg),gfortran),
                              $substr($basename($arg),8,),
                              $substr($basename($arg),3,))))
  set(GCCTOOLCHAINDIR=$if($isdir($GCCTOOLCHAINARG),
                          $if($equal($last($replace($GCCTOOLCHAINARG,/, )),bin),
                              $dirname($GCCTOOLCHAINARG),
                              $GCCTOOLCHAINARG),
                          $if($isfile($GCCTOOLCHAINARG),
                              $dirname($dirname($GCCTOOLCHAINARG)),
                              $dirname($lookup($PATH,$GCCTOOLCHAINARG)))))
  set(TEMPGCCRC=$tempfile())
  enable(GccToolchain);

switch -Mno-override-aa-for-tbaa is hide
  set(OVERRIDE_AA_FOR_TBAA=0)
  ;

switch -Moverride-aa-for-tbaa is hide
  set(OVERRIDE_AA_FOR_TBAA=1)
  ;

switch -nvmalloc is
    help(Use nvmalloc$if($index($TARGET,linuxarm64)," (default)"), a host memory allocation library based on jemalloc.)
    helpgroup(linker)
    helpname(-[no]nvmalloc)
    if($index($TARGET,linux86-64,linuxarm64))
    set(NVMALLOCNEEDED=1);
switch -nonvmalloc is hide
    help(Use malloc(3) for memory allocation.)
    helpgroup(linker)
    set(NVMALLOCNEEDED=0);

switch -lnvmalloc is hide
    erase
    warning(-lnvmalloc switch ignored, please use -nvmalloc instead.);

switch -pipe is hide;

phase GccToolchain is
  before(Install)
  forall
  execute(
    condition($equal($GCCLOCALRC,))
    noinput(1) command(makegcclocalrc)
    append(RESTARTENV=GCCLOCALRC=$TEMPGCCRC)
    append(ADDARGS=--tempfiles=$TEMPGCCRC $if($KEEPTEMP,--debugtemp=1))
    set(MUSTRESTART=1)
    restart($ifn($DRYRUN,$COMPBASE/$COMPSYS/$COMPVER/$COMPBBIN))
  );

set NOCHECKLOCALRC=1;
phase SelfInstall is hide
  before(Install)
  forall
  help(Auto localrc installation)
  default
  execute(
    condition($equal($LOCALRC,))
    condition($not($or($equal($TARGET,win64),$equal($TARGET,win64-llvm))))
    noinput(1) command(makehomelocalrc)
    set(MUSTRESTART=1)
    restart($ifn($DRYRUN,$COMPBASE/$COMPSYS/$COMPVER/$COMPBBIN))
  );

phase DryStdInc is
	before(NoCompile)
	execute(
	  condition($not($DRYRUN))
	  # nvc++ now handles system include paths differently from nvfortran
	  echo($replace($if($equal($DRIVERLANG,Fortran),$STDINC,$USRSTDINC $ACCPRESTDINC $OMPPRESTDINC $COMPINCDIRFULL $CUDAINC $SYSTEMINC),,$INCSEP))
	);

phase DryGccInc is
	before(NoCompile)
	execute(
	  condition($not($DRYRUN))
	  echo($replace($SYSTEMINC,,$INCSEP))
	);
