# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           qt4 1.0

name                lprof
version             20090113
revision            10
categories          graphics
license             GPL
maintainers         nomaintainer
description         LProf open source ICC profiler
long_description    LProf is an open source color profiler that creates ICC \
                    compliant profiles for devices such as cameras, scanners \
                    and monitors. Origanally authored by Marti Maria the \
                    creator of LCMS. Marti has graciously consented to the \
                    creation of this project.

platforms           darwin
homepage            http://lprof.sourceforge.net
master_sites        sourceforge
fetch.type          cvs
cvs.root            :pserver:anonymous@lprof.cvs.sourceforge.net:/cvsroot/lprof
cvs.date            ${version}
cvs.module          lprof

depends_lib-append  port:libusb-compat port:libpng port:tiff \
                    port:zlib port:qt-assistant port:vigra
depends_build-append path:bin/cmake:cmake
depends_skip_archcheck cmake

worksrcdir          lprof

# link final 'lprof' executable with PNG and AppKit
patchfiles          patch-src-CMakeLists.txt.diff

configure.cmd       cmake
configure.ccache    no
configure.args      -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
                    -DCMAKE_VERBOSE_MAKEFILE=ON \
                    -DCMAKE_BUILD_TYPE=Release \
                    -DCMAKE_SYSTEM_PREFIX_PATH=\"${prefix}\;/usr\" \
                    -DCMAKE_INSTALL_PREFIX=${prefix} \
                    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib/ \
                    -DCMAKE_INCLUDE_PATH=${prefix}/include \
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib \
                    ${qt_cmake_defines} \
                    -DJPEG_INCLUDE_DIR=${prefix}/include \
                    -DPNG_PNG_INCLUDE_DIR=${prefix}/include \
                    -DTIFF_INCLUDE_DIR=${prefix}/include \
                    -DQTTRANS_LRELEASE_EXECUTABLE=${qt_lrelease_cmd} \
                    -Wno-dev .

if {${configure.sdkroot} != ""} {
    configure.args-append \
        -DCMAKE_C_FLAGS_RELEASE="-isysroot ${configure.sdkroot}" \
        -DCMAKE_CXX_FLAGS_RELEASE="-isysroot ${configure.sdkroot}" \
        -DCMAKE_LD_FLAGS="-Wl,-syslibroot,${configure.sdkroot}"
}

post-patch {
    # make PNG required
    reinplace "s,PNG,PNG REQUIRED," ${worksrcpath}/CMakeLists.txt

    # fix IOKit header include: G -> g, for case sensitive file systems
    reinplace "/include/s,IOKit/Graphics/IOGraphicsLib,IOKit/graphics/IOGraphicsLib,g" ${worksrcpath}/src/videoLUTutils/LUTutil.h

    # fix use of SysBeep -> NSBeep
    reinplace "s,SysBeep,NSBeep,g" \
        ${worksrcpath}/src/argyll/spectro/unixio.c
}

post-destroot {
    # create an OSX .app
    set appcdir ${destroot}${applications_dir}/LProf.app/Contents
    xinstall -m 755 -d ${appcdir}/MacOS
    xinstall -m 755 -d ${appcdir}/Resources
    xinstall -m 755 -d ${appcdir}/Argyll.kext
    move ${destroot}${prefix}/bin/lprof ${appcdir}/MacOS
    move ${destroot}${prefix}/bin/icc2it8 ${appcdir}/MacOS
    copy ${worksrcpath}/build/darwin/lprof.app/Contents/Info.plist \
        ${appcdir}
    copy ${worksrcpath}/build/darwin/lprof.app/Contents/Resources/lprof.icns ${appcdir}/Resources
    copy ${worksrcpath}/src/argyll/libusb/Argyll.kext/Info.plist \
        ${appcdir}/Argyll.kext
    copy ${qt_apps_dir}/Assistant.app ${appcdir}/MacOS
    move ${destroot}${prefix}/data ${appcdir}/MacOS
}

livecheck.type      none
