# # x86 (linux) Target System Configurations
#

set PGI_TARGET=I386

set ENDIAN=LITTLE
set ASTYPE=ELF
set APX=NO
set SYSV_PROF=YES

ifndef $SYSTEM  set $SYSTEM="linux86"
ifndef $OS      set $OS=unix
ifndef $MACHINE set $MACHINE=$SYSTEM

#
# User defined switches
#
switch mp=-Mmp -Wh,-mp
switch fast=-O2 -Munroll -Mnoframe
switch Kpic=-Mx,62,8
switch KPIC=-Mx,62,8
switch fpic=-Mx,62,8
switch fPIC=-Mx,62,8
switch R*=-Wl,-R*
switch shared=-Wl,-shared
switch m=-Wl,-M

#
# Switches ignored by compiler
#

#
# PGI Compiler Configurations
#

ifndef PGI set PGI="/usr/pgi"
if PGHPF \
    ifndef $_HPF_MPI set $_HPF_MPI "/usr/local/mpi/lib/LINUX/ch_p4/libmpi.a" \
endif
ifndef _HPVM_ROOT set _HPVM_ROOT="/usr/local/hpvm/lib"
if PGHPF set HPF_HPVM "$(_HPVM_ROOT)/libsma.a \
        $(_HPVM_ROOT)/libFM.a $(_HPVM_ROOT)/libLanaiDevice.a"

ifndef COMP_COMMON	set COMP_COMMON="-x 122 0x40 -x 119 0x10000 -x 123 0x1000 -x 119 0x800000 -x 127 4"
if -Kieee \
    set COMP_COMMON = "$(COMP_COMMON) -x 6 0x100"

if -Mnollalign \
    set COMP_COMMON = "$(COMP_COMMON) -x 119 0x100000" \
    if PGC++ \
	set CPLUSARGS="$CPLUSARGS --nollalign"

ifndef COMP_ARGS_C      set COMP_ARGS_C="$(DEBUG) $COMP_COMMON -x 119 0x8000000"
ifndef COMP_ARGS_FTN    set COMP_ARGS_FTN="$(DEBUG) -x 124 0x1400 $COMP_COMMON -x 51 0x20"
set EXTRA_ARGS_HPF="-x 57 12 -x 124 0x1000 -x 51 0x20"

ifndef COMPDIR          set COMPDIR="$PGI/$SYSTEM/bin"
ifndef PGIDIR           set PGIDIR="$PGI/$SYSTEM/lib" 
ifndef CRTDIR           set CRTDIR="/usr/lib" # now use our own crt files
#ifndef CRTDIR           set CRTDIR="$PGI/$SYSTEM/lib"
                                                     
ifndef LIBDIR           set LIBDIR="/usr/lib"

#
# gcc configurations
#
# The following two variables depend on where gcc's libgcc.a and include files
# are installed:
#   GCCDIR - where libgcc.a lives; also, this directory contains an include
#            directory
#   GCCINC - gcc's optional include directory
#
# Note that it's assumed that system include files will also reside in the
# 'standard' directories, /usr/local/include and /usr/include.
#
set GCCDIR=/usr/lib/gcc-lib/i586-unknown-linuxlibc1/2.7.2.2.f.2
set GCCINC=/usr/i486-linux/include

#
# g77 configuration
switch -g77libs =
#
# The -g77libs switch will have the effect of including the g77 library
# (libf2c.a) when the link is performed.
# The value of the variable, G77DIR, is where the g77 library is installed.
#
set G77DIR=/usr/lib/gcc-lib/i586-unknown-linuxlibc1/2.7.2.2.f.2
                                                     
ifndef INCDIR           set INCDIR="$CPLUSINC$PGI/$SYSTEM/include:/usr/local/include:$(GCCINC):$(GCCDIR)/include:/usr/include"

ifndef DRIVER_ARGS_C    set DRIVER_ARGS_C=""
ifndef DRIVER_ARGS_FTN  set DRIVER_ARGS_FTN=""
ifndef DRIVER_ARGS_HPF  set DRIVER_ARGS_HPF=""

if PROFILE      \
  ifn -g                set DEBUG="-debug -nosymbol"  \
      		        set CPLUSARGS="$CPLUSARGS -g" endif

# I386 linux /usr/include/asm/types.h uses __signed__, and is accepted by
# g++, so we define it here in order to compile this system header file.
# - dac
# bert linux86 defines size_t an uint, so remove  "--size_t_int_kind ulong"
if PGC++ \
set PREDEFS="-D__signed__\=signed -D__inline__\= -Dunix -Di386 -Dlinux -D__unix__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -D__NO_MATH_INLINES" \
set CPLUSARGS="$CPLUSARGS"  \
else \
set PREDEFS="-Dunix -Di386 -Dlinux -D__unix__ -D__inline__\= -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -D__NO_MATH_INLINES" \
endif

set PREPREDS="#machine(i386) #lint(off) #system(unix) #system(posix) #cpu(i386)"

if PGF90 if -Mmp set EXTRA_ARGS_HPF="$EXTRA_ARGS_HPF -mp" endif endif

#
# Linux tool configurations
#

ifndef AS               set AS=as
                                 
ifndef ASDIR            set ASDIR="$_PATH"

ifndef ASARGS           set ASARGS=""

ifndef LD               set LD=ld                  

set LDARGS="-m elf_i386 -dynamic-linker /lib/ld-linux.so.1"
                                 
ifndef LDDIR            set LDDIR="$_PATH"


set LD_LOPT=YES

##ifndef LDLDIRS set LDLDIRS="-L$PGIDIR -L$LIBDIR -L$GCCDIR"
# changed to a driver readable variable dac
ifndef LD_DEFDIRS set LD_DEFDIRS="-L$PGIDIR -L$LIBDIR -L$GCCDIR"
if -g77libs \
     set LD_DEFDIRS="$(LD_DEFDIRS) -L$G77DIR" \
endif


#
# Linker Startup files
#

ifn -shared \
    set LCRT0="$CRTDIR/crt1.o" \
    set LCRT1="$CRTDIR/crti.o" \
endif
# set LCRT1="$CRTDIR/crti.o $CRTDIR/crtbegin.o"

ifndef LPGPROF \
  if PROFILE            set LPGPROF="$PGIDIR/init_pgpf.o"       endif \
  if PROF_MCOUNT        set LPGPROF="$PGIDIR/init_pgpfm.o"      endif \
  if PROF_GPROF         set LPGPROF="$PGIDIR/init_pgpfg.o"

set LD_STARTUP="$LD_STARTUP $LCRT0 $LCRT1 $LPGPROF $LMP $LVALUES $PGFMAIN"
# set LD_ENDUP="$CRTDIR/crtend.o $CRTDIR/crtn.o" 
set LD_ENDUP="$CRTDIR/crtn.o" 


#
# Linker Libraries
#

ifndef PROF_LIBS \
    if PROF_SAMPLE      set PROF_LIBS="-lpgpf$(H)"	endif \
    if PROF_FUNC        set PROF_LIBS="-lpgnod_prof"    endif \
    if PROF_LINES       set PROF_LIBS="-lpgnod_prof"    endif \
    if PROF_FTIME       set PROF_LIBS="-lpgpf$(H)t"	endif \
    if PROF_LTIME       set PROF_LIBS="-lpgpf$(H)t"	endif \
    if PROF_COVER       set PROF_LIBS="-lpgpf$(H)c"	endif \
    if PROF_MCOUNT      set PROF_LIBS="-lpgpfm"         endif \
    if PROF_GPROF       set PROF_LIBS="-lpgpfg"         endif \
endif

ifndef LM               set LM="-lm"

ifndef LPGC             set LPGC="-lpgc"

ifndef LC \
    set LC="-lgcc -lc -lgcc" \
    if -g77libs set LFC="-lf2c" endif \
endif

ifndef LIBS             set LIBS=" $(PROF_LIBS) $(MP_LIBS) $(HPF_LIBS) $(LPGFTNRTL) $(LFC) $(LM) $(LPGC) $(LC)"
