File: Makefile-bits

package info (click to toggle)
openimageio 2.2.10.1%2Bdfsg-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 45,344 kB
  • sloc: cpp: 127,812; python: 3,538; sh: 847; makefile: 383; ansic: 2
file content (489 lines) | stat: -rw-r--r-- 21,065 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# SPI-specific settings
ifneq (${VERBOSE},)
$(info Including spi/Makefile-bits)
endif

# For SpComp2 builds, do:
#
#     make OIIO_SPCOMP2=1 spcomp2_install
# or
#     make OIIO_SPCOMP2=1 SPCOMP2_LOCAL_PATH=/test/path spcomp2_install_local
#
# For Arnold builds, do:
#
#     make OIIO_ARNOLD=1
#
# For a Rez-bound build, do:
#
#     make OIIO_SPIREZ=1 spi
#
#     (Options: OIIO_REZ_NAME=blah REZ_PACKAGE_ROOT=path)
#
# Otherwise a default 'make' will make a fully generic OIIO build.

OIIO_SPCOMP2 ?= 0
OIIO_ARNOLD ?= 0
OIIO_SPIREZ ?= 0
OIIO_REZ_NAME ?= OpenImageIO
OIIO_VERS = $(shell grep "OpenImageIO VERSION" CMakeLists.txt | egrep -o "[0-9.]+")
ONEVERS = $(shell site/spi/format_version.py ${OIIO_VERS})
OPENIMAGEIO_SPCOMP2_VERSION ?= ${ONEVERS}

ifeq (${OIIO_SPCOMP2},1)
    $(info Building for SpComp2)
    OIIO_ARNOLD := 0
    NAMESPACE ?= 'OpenImageIO_SpComp2'
    SOVERSION ?= ${OPENIMAGEIO_SPCOMP2_VERSION}
    PYLIB_LIB_PREFIX ?= 1
    PYLIB_INCLUDE_SONAME ?= 1
else ifeq (${OIIO_ARNOLD},1)
    $(info Building for Arnold)
    NAMESPACE ?= 'OpenImageIO_Arnold'
else ifeq (${OIIO_SPIREZ},1)
    $(info Building for Rez distribution)
    # NAMESPACE ?= 'OpenImageIO'
    MY_CMAKE_FLAGS += -DOIIO_SPIREZ=1 -DOIIO_REZ_PACKAGE_NAME=${OIIO_REZ_NAME}
    MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
else
    $(info Building generic OpenImageIO)
    # NAMESPACE ?= 'OpenImageIO'
endif
#$(info MAKECMDGOALS = $(MAKECMDGOALS))


## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_COMPILER,
## and PYTHON_VERSION. Lots of other decisions are based on these.
ifeq (${SP_OS}, rhel7)
    # Rhel7 (current)
    platform := rhel7
    SPI_COMPILER_PLATFORM ?= gcc-6.3
    ifeq (${SPI_COMPILER_PLATFORM},gcc-4.8)
        SPCOMP2_COMPILER ?= gcc48m64
        CMAKE_CXX_STANDARD ?= 11
        LLVM_VERSION ?= 9.0.1-1
    else
        SPCOMP2_COMPILER ?= gcc63
        CMAKE_CXX_STANDARD ?= 14
        LLVM_VERSION ?= 10.0.0-1
    endif
    SP_PLATFORM ?= linux
    SP_PROC ?= x86_64
    SP_REZ_OS ?= CentOS-7
else ifeq (${platform}, macosx)
    # Generic OSX machines (including LG's laptop)
    COMPILER ?= clang
    SPCOMP2_COMPILER ?= clang
    SP_OS ?= macosx
    SP_PLATFORM ?= macosx
    SP_PROC ?= x86_64
    SP_REZ_OS ?= MacOS
else
    $(error Unknown SP_OS=${SP_OS} platform=${platform})
endif  # endif ${SP_OS}

MY_CMAKE_FLAGS += -DSP_OS=${SP_OS} -DSP_PLATFORM=${SP_PLATFORM}
MY_CMAKE_FLAGS += -DSP_PROC=${SP_PROC} -DSP_REZ_OS=${SP_REZ_OS}
MY_CMAKE_FLAGS += -DSPI_COMPILER_PLATFORM=${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOIIO_SPI=1" -DOIIO_SITE:STRING=spi
MY_CMAKE_FLAGS += -DSPI_TESTS=1
MY_CMAKE_FLAGS += -DOIIO_NAMESPACE_INCLUDE_PATCH=1
REZ_PACKAGE_ROOT ?= /shots/spi/home/software/packages
SPCOMP2_ROOT ?= /shots/spi/home/lib/SpComp2


## Rhel7 (current)
ifeq (${SP_OS}, rhel7)
    PYTHON_VERSION ?= 2.7
    USE_SIMD ?= sse4.1,aes
    CMAKE ?= cmake
    USE_NINJA ?= 1
    NINJA ?= ninja
    ifeq ($(USE_NINJA),1)
        MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
    endif
    export CCACHE_CPP2 ?= 1
    # Override lib64 and use SPI convention of lib
    MY_CMAKE_FLAGS += -DCMAKE_INSTALL_LIBDIR="${INSTALL_PREFIX}/lib"
    ifeq (${OIIO_SPCOMP2},1)
        MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
    else ifeq (${OIIO_SPIREZ},1)
        MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
    else ifeq (${OIIO_ARNOLD},1)
        OIIO_LIBNAME_SUFFIX=_Arnold
    endif

    #
    # Compilers:
    #
    # A variety of tags can be used to try specific versions of gcc or
    # clang from the site-specific places we have installed them.
    LLVM_DIRECTORY ?= /shots/spi/home/software/packages/llvm/${LLVM_VERSION}/${SPI_COMPILER_PLATFORM}
    ifeq (${COMPILER},clang7)
        LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_7.0.1
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
    else ifeq (${COMPILER},clang8)
        LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_8.0.0
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
    else ifeq (${COMPILER},clang9)
        LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/9.0.1-1/${SPI_COMPILER_PLATFORM}
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
    else ifeq (${COMPILER},clang10)
        LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/10.0.0-1/${SPI_COMPILER_PLATFORM}
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
    else ifeq (${COMPILER},clang11)
        LLVM_DIRECTORY := /shots/spi/home/software/packages/llvm/11.0.0/${SPI_COMPILER_PLATFORM}
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
    else ifeq (${COMPILER},clang)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
    else ifeq (${COMPILER}, gcc6)
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/gcc \
           -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/g++
    else ifeq (${COMPILER},gcc)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
    else ifeq (${COMPILER},)
        # default compiler is clang, taken from the LLVM directory
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
           -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
    endif
    ifeq (${SPI_COMPILER_PLATFORM},gcc-4.8)
            MY_CMAKE_FLAGS += -DCMAKE_C_FLAGS="--gcc-toolchain=/usr" \
                              -DCMAKE_CXX_FLAGS="--gcc-toolchain=/usr" \
                              -DTOOLCHAIN_FLAGS="--gcc-toolchain=/usr"
    endif

    #
    # Boost
    #
    BOOSTVERS ?= 1.70
    BOOSTSPSUFFIX ?=
    BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
    MY_CMAKE_FLAGS += -DBOOST_VERS_SP=${BOOSTVERSSP}
    # $(info BOOSTVERSSP ${BOOSTVERSSP})
    ifeq (${BOOSTVERS},1.55)
        SPBOOST_INC_DIR ?= /usr/include/boost_${BOOSTVERSSP}
        SPBOOST_LIB_DIR ?= /usr/lib64/boost_${BOOSTVERSSP}
        ifeq (${BOOSTSPSUFFIX}, sp)
            SPBOOST_LIBNAMESTART ?= lib${BOOSTSPSUFFIX}boost_${shell echo ${BOOSTVERS} | sed "s/\\./_/"}_0
        else
            SPBOOST_LIBNAMESTART ?= lib${BOOSTSPSUFFIX}boost
        endif
        SPBOOST_LIBNAMEEND ?= -gcc48-mt-${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
        MY_CMAKE_FLAGS += \
            -DBOOST_CUSTOM=1 \
            -DBoost_VERSION=${BOOSTVERS} \
            -DBoost_INCLUDE_DIRS=${SPBOOST_INC_DIR} \
            -DBoost_LIBRARY_DIRS=${SPBOOST_LIB_DIR} \
            -DBoost_LIBRARIES:STRING="${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_filesystem${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_regex${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_system${SPBOOST_LIBNAMEEND}.so;${SPBOOST_LIB_DIR}/${SPBOOST_LIBNAMESTART}_thread${SPBOOST_LIBNAMEEND}.so"
    else
        # Our Boost >= 1.61 setup is MUCH simpler and more standard
	SPBOOST_INC_DIR := /usr/include/boostroot/boost${BOOSTVERSSP}.0
	SPBOOST_LIB_DIR := /usr/lib64/boostroot/boost${BOOSTVERSSP}.0
        MY_CMAKE_FLAGS += \
            -DBOOST_INCLUDEDIR=${SPBOOST_INC_DIR} \
            -DBOOST_LIBRARYDIR=${SPBOOST_LIB_DIR}
    endif

    #
    # Python
    #
    PYTHON_INCLUDE_DIR ?= /usr/include/python${PYTHON_VERSION}
    PYTHON_LIBRARY_DIR ?= /usr/lib64
    PYTHON_LIBRARY ?= ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}.so
    ifeq (${PYTHON_VERSION},3.6)
        # Special sauce for Python 3.6
        PYTHON_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}m
        PYTHON_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}m.so
        MY_CMAKE_FLAGS += \
            -DPYTHONINTERP_FOUND=1 \
            -DPYTHON_VERSION_STRING=3.6.3 \
            -DPYTHON_VERSION_MAJOR=3 \
            -DPYTHON_VERSION_MINOR=6 \
            -DPYTHON_VERSION_PATCH=3 \
            -DPython_ADDITIONAL_VERSIONS="${PYTHON_VERSION}"
    else ifeq (${PYTHON_VERSION},3.7)
        # Special sauce for Python 3.7
        PYTHON_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}m
        PYTHON_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}m.so
        MY_CMAKE_FLAGS += \
            -DPYTHONINTERP_FOUND=1 \
            -DPYTHON_VERSION_STRING=3.7.3 \
            -DPYTHON_VERSION_MAJOR=3 \
            -DPYTHON_VERSION_MINOR=7 \
            -DPYTHON_VERSION_PATCH=3 \
            -DPython_ADDITIONAL_VERSIONS="${PYTHON_VERSION}"
    else ifeq (${PYTHON_VERSION},2.7)
        # Special sauce for Python 2.7
        PYTHON_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}
        PYTHON_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}.so
        MY_CMAKE_FLAGS += \
            -DPYTHONINTERP_FOUND=1 \
            -DPYTHON_VERSION_STRING=2.7.5 \
            -DPYTHON_VERSION_MAJOR=2 \
            -DPYTHON_VERSION_MINOR=7 \
            -DPYTHON_VERSION_PATCH=5 \
            -DPython_ADDITIONAL_VERSIONS="${PYTHON_VERSION}"
    endif
    MY_CMAKE_FLAGS += \
        -DPYTHON_INCLUDE_DIR:STRING=${PYTHON_INCLUDE_DIR} \
        -DPYTHON_LIBRARY:STRING=${PYTHON_LIBRARY} \
        -Dpybind11_ROOT:STRING=${REZ_PACKAGE_ROOT}/pybind11/2.4.3/python-${PYTHON_VERSION}

    # Set our preferred OpenEXR path, but allow env variable to override
    # with custom/test version.
    OPENEXR_VERSION ?= 2.4.0
    OpenEXR_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenEXR/${OPENEXR_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}
    MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}

    #
    # SpComp2 and other weird SPI-installed packages
    #
    NUKE_VERSION ?= 11.2v3
    SPCOMP2_FULLBOOST_SUFFIX = ${SP_OS}-${SPCOMP2_COMPILER}-boost${shell echo ${BOOSTVERSSP} | sed "s/\\.//"}
    # $(info SPCOMP2_FULLBOOST_SUFFIX ${SPCOMP2_FULLBOOST_SUFFIX})
    ifeq (${OIIO_SPCOMP2},1)
        OCIO_SPCOMP_VERSION ?= 2
        OpenColorIO_ROOT ?= ${SPCOMP2_ROOT}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}
        # OPENVDB_SPCOMP2_VERSION ?= v6020001
        # OpenVDB_ROOT ?= ${SPCOMP2_ROOT}/openvdb/${SPCOMP2_FULLBOOST_SUFFIX}/${OPENVDB_SPCOMP2_VERSION}
        OPENVDB_VERSION ?= 6.2.2-3
        OpenVDB_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenVDB/${OPENVDB_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERS}
    else
        OPENCOLORIO_VERSION ?= 1.1.1-1
        OpenColorIO_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenColorIO/${OPENCOLORIO_VERSION}/${SPI_COMPILER_PLATFORM}
        MY_CMAKE_FLAGS += -DOPENCOLORIO_LIBRARY=${OpenColorIO_ROOT}/lib/libOpenColorIO_SPI.so
        # Anybody remember why we needed Field3d disabled for SpComp2?
        Field3D_ROOT ?= ${SPCOMP2_ROOT}/Field3D/${SPCOMP2_FULLBOOST_SUFFIX}/v412
        OPENVDB_VERSION ?= 6.2.2-3
        OpenVDB_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenVDB/${OPENVDB_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERS}
	endif
    TBB_ROOT ?= /net/apps/rhel7/intel/tbb
    TBB_LIBRARY ?= /net/apps/rhel7/intel/tbb/lib/intel64/gcc4.7
    Libheif_ROOT=/shots/spi/home/lib/arnold/rhel7/libheif-1.3.2
    MY_CMAKE_FLAGS += \
        -DOpenColorIO_ROOT=${OpenColorIO_ROOT} \
        -DField3D_ROOT=${Field3D_ROOT} \
        -DOpenVDB_ROOT=${OpenVDB_ROOT} \
        -DTBB_ROOT=${TBB_ROOT} \
        -DTBB_LIBRARY=${TBB_LIBRARY} \
        -DTBB_USE_DEBUG_BUILD=0 \
        -DHDF5_CUSTOM=1 \
        -DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
        -DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION} \
        -DLibheif_ROOT=${Libheif_ROOT} \
        -DFFMPEG_INCLUDES=/usr/include/ffmpegroot/ffmpeg34 \
        -DFFMPEG_LIBRARIES="/usr/lib64/ffmpegroot/ffmpeg345/libavcodec.so;/usr/lib64/ffmpegroot/ffmpeg345/libavformat.so;/usr/lib64/ffmpegroot/ffmpeg345/libavutil.so;/usr/lib64/ffmpegroot/ffmpeg345/libswscale.so;" \
        -DUSE_OPENCV=0 \
        -DVISIBILITY_MAP_FILE:STRING="${working_dir}/site/spi/hidesymbols.map"

    # LibRaw
    ifeq (${SPI_COMPILER_PLATFORM},gcc-4.8)
        MY_CMAKE_FLAGS += -DLIBRAW_INCLUDEDIR_HINT=/usr/include/libraw-0.18.11
        MY_CMAKE_FLAGS += -DLIBRAW_LIBDIR_HINT=/usr/lib64/libraw-0.18.11
        LIBRAW_LIBDIR = /usr/lib64/libraw-0.18.11
    else
        LibRaw_ROOT ?= /shots/spi/home/software/packages/LibRaw/0.20.0-dev3/${SPI_COMPILER_PLATFORM}
        MY_CMAKE_FLAGS += -DLibRaw_ROOT=${LibRaw_ROOT}
        LIBRAW_LIBDIR = ${LibRaw_ROOT}/lib
    endif

    # Use libtiff I built myself, static, and try to hide its symbols.
    MY_CMAKE_FLAGS += \
        -DTIFF_INCLUDE_DIR:STRING=/usr/include \
        -DTIFF_LIBRARIES:STRING=/net/soft_scratch/users/lg/tiff-4.0.3/rhel7/lib/libtiff.a \
        -DEXTRA_DSO_LINK_ARGS:STRING="-Wl,--exclude-libs,libtiff.a"

    # end rhel7

## Generic OSX machines (including LG's laptop)
else ifeq (${platform}, macosx)
    USE_SIMD ?= sse4.2
    MY_CMAKE_FLAGS += \
        -DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \
        -DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"

    # A variety of tags can be used to try specific versions of gcc or
    # clang from the site-specific places we have installed them.
    ifeq (${COMPILER}, gcc48)
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8
        USE_LIBCPLUSPLUS := 0
    else ifeq (${COMPILER}, gcc5)
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5
        USE_LIBCPLUSPLUS := 0
    else ifeq (${COMPILER}, gcc6)
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
        USE_LIBCPLUSPLUS := 0
    else ifeq (${COMPILER}, gcc8)
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8
        USE_LIBCPLUSPLUS := 0
    else ifeq (${COMPILER}, gcc9)
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
        USE_LIBCPLUSPLUS := 0
    else ifeq (${COMPILER}, gcc10)
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
        USE_LIBCPLUSPLUS := 0
    else ifeq (${COMPILER},clang7)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@7/bin/clang \
        				  -DCMAKE_CXX_COMPILER=/usr/local/llvm@7/bin/clang++
    else ifeq (${COMPILER},clang8)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@8/bin/clang \
        				  -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@8/bin/clang++
    else ifeq (${COMPILER},clang9)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@9/bin/clang \
        				  -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@9/bin/clang++
    else ifeq (${COMPILER},clang10)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \
        				  -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++
    else ifeq (${COMPILER},clang)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
    else ifeq (${COMPILER},gcc)
        MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
    else ifeq (${COMPILER},)
        # default compiler is clang, taken from the LLVM directory
        MY_CMAKE_FLAGS += \
           -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
           -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
    endif

    # end generic OSX

else
    $(error Unknown SP_OS=${SP_OS} platform=${platform})
endif  # endif ${SP_OS}



ifeq (${OIIO_SPIREZ},1)
    # Rpath touch-ups
    # NOTE: This MUST match the order and naming of the Rez variants
    # set in rez/package.py.in
    REZ_INSTALL_PATH := ${REZ_PACKAGE_ROOT}/${OIIO_REZ_NAME}/${OIIO_VERS}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERSSP}
    MY_CMAKE_FLAGS += -DOIIO_REZ_INSTALL_PATH=${REZ_INSTALL_PATH}
    MY_CMAKE_FLAGS += -DCMAKE_INSTALL_RPATH=${REZ_INSTALL_PATH}/lib
    INSTALL_PREFIX := ${working_dir}/dist/${platform}
endif


ifneq (${VERBOSE},)
    $(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
endif



############################################################################
# SpComp2 magic incantations follow. Here be dragons.
############################################################################


CPPSTDSUFFIX=
SPCOMP2_INSTALL_ROOT ?= $(SPCOMP2_ROOT)
BOOSTVERSSP?=${BOOSTVERS}${BOOSTSPSUFFIX}
SPARCH=${SP_OS}-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
OIIO_SPCOMP2_PATH := ${SPCOMP2_INSTALL_ROOT}/OpenImageIO/${SPARCH}/v${OPENIMAGEIO_SPCOMP2_VERSION}
# $(info New rhel7 OIIO_SPCOMP2_PATH is ${OIIO_SPCOMP2_PATH})

PYVERNOSPACE=${shell echo ${PYTHON_VERSION} | sed "s/\\.//"}
SPPYARCH=$(SPARCH)-py$(PYVERNOSPACE)



all: dist

local: dist

.PHONY: spcomp2_install spcomp2_install_local spi clean all

spi: MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=_d
spi: debug dist



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

INSTALL_SPCOMP2_CURRENT = $(SPCOMP2_INSTALL_ROOT)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)
INSTALL_BIN_LOCATION = $(INSTALL_SPCOMP2_CURRENT)/bin
SPCOMP2_LOCAL_PATH ?= /net/soft_scratch/users/$(USER)/SpComp2_test

spcomp2_install_local: SPCOMP2_INSTALL_ROOT = $(SPCOMP2_LOCAL_PATH)
spcomp2_install_local: INSTALL_BIN_LOCATION = $(INSTALL_SPCOMP2_CURRENT)/bin
spcomp2_install_local: spcomp2_install

SPCOMP2_RPATH_OPT ?= ${OpenEXR_ROOT}/lib:${OpenColorIO_ROOT}/lib:${Field3D_ROOT}/lib:${LIBRAW_LIBDIR}:${OpenVDB_ROOT}/lib:${Libheif_ROOT}/lib:shots/spi/home/lib/arnold/rhel7/libde265-1.0.3/lib:${TBB_ROOT}/lib/intel64/gcc4.7:${SPBOOST_LIB_DIR}
SPCOMP2_RPATH_DEBUG ?= ${OpenEXR_ROOT}/lib:${OpenColorIO_ROOT}/lib:${Field3D_ROOT}/lib/debug:${LIBRAW_LIBDIR}:${OpenVDB_ROOT}/lib/debug:${Libheif_ROOT}/lib:shots/spi/home/lib/arnold/rhel7/libde265-1.0.3/lib:${TBB_ROOT}/lib/intel64/gcc4.7:${SPBOOST_LIB_DIR}
PYSPCOMP2_RPATH_OPT ?= ${SPCOMP2_RPATH_OPT}:${OIIO_SPCOMP2_PATH}/lib:${PYTHON_LIBRARY_DIR}
PYSPCOMP2_RPATH_DEBUG ?= ${SPCOMP2_RPATH_DEBUG}:${OIIO_SPCOMP2_PATH}/lib/debug:${PYTHON_LIBRARY_DIR}


spcomp2: MY_CMAKE_FLAGS += \
		-DCMAKE_SKIP_BUILD_RPATH:BOOL=OFF \
		-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)/lib \
		-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
		-DPYLIB_INCLUDE_SONAME:BOOL=ON \
		-DPYLIB_LIB_PREFIX:BOOL=ON \
		-DPYMODULE_SUFFIX="V${OPENIMAGEIO_SPCOMP2_VERSION}"

spcomp2: dist

spcomp2_debug: MY_CMAKE_FLAGS += \
		-DCMAKE_SKIP_BUILD_RPATH:BOOL=OFF \
		-DCMAKE_INSTALL_RPATH=$(SPCOMP2_INSTALL_ROOT)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)/lib \
		-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
		-DPYLIB_INCLUDE_SONAME:BOOL=ON \
		-DPYLIB_LIB_PREFIX:BOOL=ON \
		-DPYMODULE_SUFFIX="V${OPENIMAGEIO_SPCOMP2_VERSION}"

spcomp2_debug: debug

spcomp2_install_fixup_rhel7: spcomp2 spcomp2_debug
	echo $(SPCOMP2_INSTALL_ROOT)
	patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/libOpenImageIO$(OIIO_LIBNAME_SUFFIX).so
	patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/libOpenImageIO$(OIIO_LIBNAME_SUFFIX).so
	patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/libOpenImageIO_Util$(OIIO_LIBNAME_SUFFIX).so
	patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/libOpenImageIO_Util$(OIIO_LIBNAME_SUFFIX).so
	patchelf --set-rpath ${PYSPCOMP2_RPATH_OPT} ${dist_dir}/python/libPyOpenImageIO.so
	patchelf --set-rpath ${PYSPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/python/libPyOpenImageIO.so

# This goal can't start with 'install' because something elsewhere picks
# it up and starts doing bad things
spcomp2_install: spcomp2_install_fixup_${SP_OS}
	perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
	  --project=OpenImageIO \
	  --version=$(OPENIMAGEIO_SPCOMP2_VERSION) \
	  --root=$(SPCOMP2_INSTALL_ROOT) \
	  --arch=$(SPARCH) \
	  --headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OpenImageIO/*)) \
	  --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
	  --namespace=${NAMESPACE} \
	  --srcdir=${dist_dir}/lib \
	  --builddir_o=${dist_dir}/lib \
	  --builddir_d=${dist_dir}.debug/lib
	perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
	  --project=OpenImageIO_Util \
	  --version=$(OPENIMAGEIO_SPCOMP2_VERSION) \
	  --root=$(SPCOMP2_INSTALL_ROOT) \
	  --arch=$(SPARCH) \
	  --headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OpenImageIO/*)) \
	  --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
	  --namespace=${NAMESPACE} \
	  --srcdir=${dist_dir}/lib \
	  --builddir_o=${dist_dir}/lib \
	  --builddir_d=${dist_dir}.debug/lib
	perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
	  --project=PyOpenImageIO \
	  --version=$(OPENIMAGEIO_SPCOMP2_VERSION) \
	  --root=$(SPCOMP2_INSTALL_ROOT) \
	  --arch=$(SPPYARCH) \
	  --cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread"\
	  --namespace=${NAMESPACE} \
	  --srcdir=${dist_dir}/python \
	  --builddir_o=${dist_dir}/python \
	  --builddir_d=${dist_dir}.debug/python