# SPI-specific settings
$(info Including spi/Makefile-bits-arnold)

# READ THIS FIRST
#
# If you are building for Arnold, just make.


# Default namespace
NAMESPACE ?= 'OpenImageIO_Arnold'

## OS X machines
ifeq (${platform}, macosx)
    MY_CMAKE_FLAGS += \
        -DBUILD_WITH_INSTALL_RPATH=1 \
        -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
endif

## Spinux (current)
ifeq ($(SP_ARCH), spinux1_x86_64)
    platform=spinux1
    COMPILER=gcc44m64
    INSTALL_SPCOMP2_LOCATION = /shots/spi/home/lib/SpComp2
    # At SPI, we have two "flavors" of spinux.  One is based on Foresight, which
    # uses a special libGL (below).  The other is based on Fedora which uses
    # the standard libGL.  This attempts to detect which libGL to use.
    SPINUX_GL_LIB = /usr/lib64/xorg.nvidia.3d/libGL.so
    MY_CMAKE_FLAGS += $(if $(wildcard ${SPINUX_GL_LIB}), -DOPENGL_gl_LIBRARY=${SPINUX_GL_LIB})
    MY_CMAKE_FLAGS += \
	  -DILMBASE_CUSTOM=1 \
	  -DILMBASE_CUSTOM_LIBRARIES="SpiImath SpiHalf SpiIlmThread SpiIex" \
	  -DOPENEXR_CUSTOM=1 \
	  -DOPENEXR_CUSTOM_LIBRARY="SpiIlmImf"
    ifeq (${OCIO_PATH},)
        MY_CMAKE_FLAGS += -DOCIO_PATH="${INSTALL_SPCOMP2_LOCATION}/OpenColorIO/${platform}-${COMPILER}/v2"
    endif
endif  # endif spinux1_x86_64


## CentOS (deprecated)
ifeq (${SP_ARCH}, rhel40_x86_64)
    platform=rhel40m64
    # used by spcomp2 installer
    COMPILER=gcc34m64
    OPENEXR_VERSION=1.4.0
    BOOST_VERSION=1_34_1
    Boost_VERSION="103401"
    QTDIR=/usr/local64/qt-4.4
    Boost_LIBRARIES="-lboost_filesystem-gcc34-mt-${BOOST_VERSION} -lboost_regex-gcc34-mt-${BOOST_VERSION} -lboost_thread-gcc34-mt-${BOOST_VERSION} "

    MY_CMAKE_FLAGS += \
	-DSPECIAL_COMPILE_FLAGS="-include ${working_dir}/site/spi/include/spi_ns.h -include ${working_dir}/site/spi/include/tiff.h -DTIFF_OLD_VERSION" \
	-DBOOST_CUSTOM=1 \
	-DBoost_INCLUDE_DIRS=/usr/local64/include/boost-${BOOST_VERSION} \
	-DBoost_LIBRARY_DIRS=/usr/local64/lib/boost-${BOOST_VERSION} \
	-DBoost_LIBRARIES=$(Boost_LIBRARIES) \
	-DBoost_VERSION=$(Boost_VERSION) \
	-DILMBASE_HOME=/usr/local64/openexr/${OPENEXR_VERSION} \
	-DILMBASE_INCLUDE_DIR=/usr/local64/openexr/${OPENEXR_VERSION}/include \
	-DOPENEXR_VERSION=${OPENEXR_VERSION} \
	-DOPENEXR_VERSION_DIGITS="010400" \
	-DOPENEXR_HOME=/usr/local64/openexr/${OPENEXR_VERSION} \
	-DQT_SEARCH_PATH=${QTDIR} \
	-DQT_QMAKE_EXECUTABLE=${QTDIR}/bin/qmake

    ifeq (${USE_PYTHON},1)
        PYTHON_VERSION ?= 2.5

        ifeq (${PYTHON_VERSION},2.5)
            PYTHONLIB=/usr/local64/lib/libspi-python2.5.so
            Boost_Python_LIBRARIES="-L/net/apps/rhel40m64/boost/1_34_1/gcc34/lib/python25 -Wl,-rpath,/net/apps/rhel40m64/boost/1_34_1/gcc34/lib/python25 -lboost_python-gcc34-mt-${BOOST_VERSION}"
        else
            PYTHONLIB=/usr/local64/lib/libpython${PYTHON_VERSION}.so
            Boost_Python_LIBRARIES="-lboost_python-gcc34-mt-${BOOST_VERSION}"
        endif

        Boost_FOUND=TRUE
        MY_CMAKE_FLAGS += \
		-DQT_DIR=/usr/local \
		-DBoost_Python_LIBRARIES=${Boost_Python_LIBRARIES} \
		-DPYTHON_INCLUDE_PATH=/usr/local64/include/python${PYTHON_VERSION} \
		-DPYTHON_LIBRARIES=${PYTHONLIB} \
		-DPYTHONLIBS_FOUND=1

    endif

endif # endif rhel40_x86_64



all: dist

.PHONY: clean all

comma:= ,
empty:=
space:= $(empty) $(empty)

local: dist
