# -*- 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
# $Id: Portfile 91019 2012-03-22 09:39:19Z jmr@macports.org $

PortSystem 1.0

name               glew
version            1.7.0
revision           1
categories         graphics devel
platforms          darwin
license            GPL-2+ BSD MIT
maintainers        jmr openmaintainer
description        OpenGL Extension Wrangler Library
long_description   The OpenGL Extension Wrangler Library (GLEW) is a \
                   cross-platform C/C++ extension loading library. GLEW \
                   provides efficient run-time mechanisms for determining \
                   which OpenGL extensions are supported on the target \
                   platform. OpenGL core and extension functionality is \
                   exposed in a single header file.

homepage           http://glew.sourceforge.net/
master_sites       sourceforge:project/${name}/${name}/${version}/
extract.suffix     .tgz
checksums          md5 fb7a8bb79187ac98a90b57f0f27a3e84 \
                   sha1 9266f2360c1687a96f2ea06419671d370b2928d1 \
                   rmd160 cb3869893afcbbc0348d768d115996c41dcfcaa0

patchfiles         config_Makefile.darwin.patch

post-patch {
    reinplace "s:/usr/X11R6:${prefix}:g" ${worksrcpath}/config/Makefile.darwin
}

use_configure      no
build.env          GLEW_DEST=${prefix}
build.args         CC=${configure.cc} LD=${configure.cc}
destroot.env       GLEW_DEST=${destroot}${prefix}
destroot.target    install.all

variant universal {
    patchfiles-append patch-Makefile.diff
}
build.args-append CFLAGS.ARCH="[get_canonical_archflags cc]" \
                  LDFLAGS.ARCH="[get_canonical_archflags ld]"

variant x11 description {Build libGLEW for GLX rather than OpenGL.framework} {
    depends_lib-append port:mesa
    build.args-append GLEW_APPLE_GLX=1
    destroot.args-append GLEW_APPLE_GLX=1
}

if {${os.subplatform} != "macosx"} {
    default_variants +x11
}

livecheck.type     sourceforge
