# -*- mode: makefile -*-
#
# Makefile of ROOT for Linux with glibc and KCC compiler

# When changing OPT to -O you can also change +K0 to +K1
# When changing OPT to -g you can also change +K1 to +K0

PLATFORM      = linux

DEBUGFLAGS    = -g -O0 +K0
OPTFLAGS      = -O2 +K3 --backend -m486 --backend -malign-loops=4 --backend \
                -malign-functions=4 --backend -malign-jumps=4
ifeq (debug,$(findstring debug,$(ROOTBUILD)))
OPT           = -g -O0
COPT          =
CXXOPT        = +K0
NOOPT         =
else
OPT           = -O2
COPT          = -m486 -malign-loops=4 -malign-functions=4 -malign-jumps=4
CXXOPT        = +K3 --backend -m486 --backend -malign-loops=4 --backend \
                -malign-functions=4 --backend -malign-jumps=4
NOOPT         =
endif

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

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

# Compiler:
CXX           = KCC
CC            = gcc
CXXFLAGS      = $(EXCEPTION) --signed_chars -D_EXTERN_INLINE=inline \
                --display_error_number --diag_suppress 191 --diag_suppress 830 \
                --one_instantiation_per_object -fPIC $(CXXOPT) $(EXTRA_CXXFLAGS)
CFLAGS        = $(COPT) -fPIC $(EXTRA_CFLAGS)
CINTCXXFLAGS  = $(EXCEPTION) --signed_chars -D_EXTERN_INLINE=inline \
                --display_error_number --diag_suppress 191 --diag_suppress 830 \
                --one_instantiation_per_object -fPIC -DG__REGEXP -DG__UNIX -DG__SHAREDLIB \
                -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO \
                $(CXXOPT) $(EXTRA_CXXFLAGS)
CINTCFLAGS    = $(COPT) -fPIC -D__KCC -DG__REGEXP -DG__UNIX -DG__SHAREDLIB \
                -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO \
                -D__KCC $(EXTRA_CFLAGS)

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

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

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

# Fortran:
F77           = f2c
F77FLAGS      =
F77LIBS       = -lf2c -lnsl

# Extras

# fix for libGui.so that needs lstat
GUILIBEXTRA   = -lc

