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

PortSystem              1.0
PortGroup               wxWidgets 1.0
PortGroup               boost 1.0
PortGroup               app 1.0

name                    codeblocks-devel
conflicts               codeblocks

categories              devel aqua x11
license                 GPL-3+
license_noconflict      boost
maintainers             nomaintainer
homepage                https://www.codeblocks.org/

description             Open Source, Cross-platform, Free C/C++/D IDE
long_description        {*}${description}. This port tracks the upstream development \
                        of CodeBlocks.

fetch.type              svn
svn.url                 svn://svn.code.sf.net/p/codeblocks/code/trunk
svn.revision            13598

# hold back until resolved https://trac.macports.org/ticket/71733
if {${os.platform} eq "darwin" && ${os.version} < 11} {
    svn.revision        r13593
}

svn.method              checkout
version                 20250101-r${svn.revision}
revision                0

worksrcdir              trunk

svn.args-append         --ignore-externals

# svn info https://svn.code.sf.net/p/fortranproject/code/trunk
set fortranproject_rev  385
post-fetch {
    system -W ${worksrcpath}/src/plugins/contrib/ "${svn.cmd} checkout -r${fortranproject_rev} https://svn.code.sf.net/p/fortranproject/code/trunk FortranProject"
}

use_autoconf            yes
autoconf.cmd            ./bootstrap
depends_build-append    port:autoconf \
                        port:automake \
                        port:libtool \
                        port:pkgconfig

boost.depends_type      build

# bzip2 is used by the libhelp_plugin
depends_lib-append      port:hunspell \
                        port:bzip2

compiler.cxx_standard   2011
# the build issue this was based on has scrolled off the buildbot logs
compiler.blacklist-append {clang < 801}

# FileManager does not build with Carbon/Cocoa
# and reportedly requires "gamin" to be installed when using wxGTK
configure.args          --with-boost=[boost::install_area] \
                        --with-contrib-plugins=all,-FileManager

# work around missing link lib since r13594
# https://forums.codeblocks.org/index.php/topic,25932.msg176620.html#msg176620
if {${os.platform} eq "darwin" && ${os.version} > 10} {
    configure.ldflags-append -framework Security
}

# work around a directory layout issue based on MacPorts default non-bundled layout
post-destroot {
    ln -s ${prefix}/lib/codeblocks/plugins ${destroot}${prefix}/share/codeblocks/plugins
}

# this will need to be reassessed if we use the full bundle build
app.name                CodeBlocks
app.executable          codeblocks
app.use_launch_script   yes
app.icon                src/src/resources/icons/app.icns
app.hide_dock_icon      yes

variant wxwidgets32 conflicts wxgtk30  description {Use Cocoa-based wxWidgets 3.2} {
    wxWidgets.use           wxWidgets-3.2
    depends_lib-append      port:${wxWidgets.port}
    autoconf.env-append     ACLOCAL_PATH=${wxWidgets.prefix}/share/aclocal
    configure.args-append   --with-wxdir=${wxWidgets.wxdir}
}

variant wxgtk30 conflicts wxwidgets32 description {Use wxWidgets 3.0 with GTK} {
    wxWidgets.use           wxGTK-3.0-cxx11
    depends_lib-append      port:${wxWidgets.port}
    autoconf.env-append     ACLOCAL_PATH=${wxWidgets.prefix}/share/aclocal
    configure.args-append   --with-wxdir=${wxWidgets.wxdir}

    depends_lib-append      port:atk \
                            path:lib/pkgconfig/cairo.pc:cairo \
                            path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                            path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                            path:lib/pkgconfig/glib-2.0.pc:glib2 \
                            path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                            port:gettext-runtime \
                            path:lib/pkgconfig/pango.pc:pango
}

if {![variant_isset wxwidgets32] && ![variant_isset wxgtk30]} {
    if {${os.platform} eq "darwin" && ${os.major} > 15} {
      default_variants +wxwidgets32
    } else {
      default_variants +wxgtk30
    }
}

notes {
for information about how to configure the spellchecker module\
please see https://trac.macports.org/ticket/71176
}

livecheck.type          none
