# -*- mode: makefile -*-
#
# Makefile of ROOT for SGI IRIX 6.x with KCC compiler

# You can steer the build with the variable ROOTBUILD
# The following options are supported: debug, exception, n32
# Do something like: export ROOTBUILD="debug n32"


PLATFORM      = sgi
SGI_REL      := $(subst .,,$(shell uname -r))

DEBUGFLAGS    = -g -O0 +K0
OPTFLAGS      = -O1 +K1
ifeq (debug,$(findstring debug,$(ROOTBUILD)))
CXXOPT        = +K0
OPT           = -g -O0
NOOPT         =
else
CXXOPT        = +K1
OPT           = -O2
NOOPT         =
endif

ifeq ($(EXCEPTIONS),yes)
EXCEPTION     = --exceptions -DG__EXCEPTIONWRAPPER
else
EXCEPTION     = --no_exceptions
endif

ifeq ($(O32),)
ABI           = -n32
else
ABI           = -32 -mips2
endif

ifeq ($(ENABLETHREAD),yes)
CXXOPT        += --thread_safe
endif

# Compiler:
CXX           = KCC
CC            = cc
CXXFLAGS      = $(ABI) $(EXCEPTION) --signed_chars --display_error_number \
                --diag_suppress 608 --diag_suppress 68 --diag_suppress 191 \
                --one_instantiation_per_object $(CXXOPT) -DSGI_REL=$(SGI_REL) \
                $(EXTRA_CXXFLAGS)
CFLAGS        = $(ABI) -signed $(EXTRA_CFLAGS)
CINTCXXFLAGS  = $(ABI) $(EXCEPTION) --signed_chars --display_error_number \
                --diag_suppress 608 --diag_suppress 68 --diag_suppress 191 \
                --one_instantiation_per_object -DG__REGEXP1 -DG__UNIX -DG__SHAREDLIB \
                -DG__OSFDLL -DG__SIGNEDCHAR -DG__ROOT -DG__REDIRECTIO $(CXXOPT) \
                $(EXTRA_CXXFLAGS)
CINTCFLAGS    = $(ABI) -signed -w -DG__REGEXP1 -DG__UNIX -DG__SHAREDLIB \
                -DG__OSFDLL -DG__SIGNEDCHAR -DG__ROOT -DG__REDIRECTIO \
                -D__KCC $(EXTRA_CFLAGS)

ifeq ($(EXCEPTIONS),yes)
CINTCFLAGS   += -DG__EXCEPTIONWRAPPER
endif

# Linker:
LD            = KCC
LDFLAGS       = $(OPT) $(CXXOPT) $(ABI) $(EXCEPTION) $(EXTRA_LDFLAGS)
AR            = KCC
ARFLAGS       = $(OPT) $(CXXOPT) $(ABI) $(EXCEPTION)
SOFLAGS       =
SOEXT         = so

# System libraries:
SYSLIBS       = -lm -ldl
XLIBS         = $(XPMLIBDIR) $(XPMLIB) $(X11LIBDIR) -lX11
CILIBS        = -lm -ltermcap -lbsd -ldl -lgen
CRYPTLIBS     = -lcrypt

# Fortran:
F77           = f77
F77FLAGS      = $(ABI)
ifeq ($(O32),)
F77LIBS       = -lftn
else
F77LIBS       = -lI77 -lU77 -lF77 -lisam
endif

# Override default in Makefile.config
INSTALL      := cp -pR
INSTALLDATA  := cp -pR

# Extras


