#
# spec file for package gambas3
#
# copyright (c) Tom Callaway <spot@fedoraproject.org>
# copyright (c) Benoît Minisini <benoit.minisini@gambas-basic.org>
#
# @{about}@
#

# Feature flags (Fedora-specific)
%global enablejit 1
%global __brp_remove_la_files %nil
%undefine _fortify_level

# Needed to link against poppler
%global build_cxxflags %{build_cxxflags} -std=c++20

# This component depends on ancient and super-abandoned things.
# But they're alive again, sortof...
%global gtkopengl 1

# Qt6 support flag
%global qt6 1

# Disable obsolete components
@{disable gb-db-sqlite2 gb-qt4* gb-mongodb}@
@{if version >= 16.0}@
  @{disable gb-qt5-webkit gb-pdf}@
  @{disable gb-sdl gb-sdl-sound}@
@{endif}@

# Merge components
@{merge gb-qt5 gb-qt5-x11 gb-qt5-wayland}@
@{merge gb-qt6 gb-qt6-x11 gb-qt6-wayland}@
@{merge gb-gtk3 gb-gtk3-x11 gb-gtk3-wayland}@

Name:           gambas3
Summary:        IDE based on a basic interpreter with object extensions
Version:        @{version}@
Release:        @{package-version}@
License:        GPL-2.0-or-later
URL:            @{website-url}@
Source0:        gambas-%{version}.tar.bz2
Source99:       %{name}.rpmlintrc

# Global BuildRequires (replaces hardcoded list)
BuildRequires:  gcc, gcc-c++
BuildRequires:  automake, autoconf
BuildRequires:  pkgconfig
BuildRequires:  make
BuildRequires:  libtool
BuildRequires:  xdg-utils
BuildRequires:  glibc-devel, libffi-devel
BuildRequires:  bzip2-devel, zlib-devel, zstd-devel
BuildRequires:  pcre2-devel
BuildRequires:  sqlite-devel, sqlite3-devel
BuildRequires:  unixODBC-devel
BuildRequires:  mariadb-connector-c-devel
BuildRequires:  poppler-devel, poppler-glib-devel, poppler-cpp-devel
BuildRequires:  librsvg2-devel
BuildRequires:  cairo-devel
BuildRequires:  dbus-devel
BuildRequires:  libxml2-devel, libxslt-devel
BuildRequires:  gmp-devel, gsl-devel
BuildRequires:  glew-devel
BuildRequires:  imlib2-devel
BuildRequires:  ncurses-devel
BuildRequires:  libX11-devel, libXtst-devel, libICE-devel
BuildRequires:  libXcursor-devel, libXft-devel
BuildRequires:  libpng-devel, libjpeg-devel
BuildRequires:  libv4l-devel
BuildRequires:  openssl-devel
@%{if 0%{?fedora} >= 41}@
BuildRequires:  openssl-devel-engine
@%{endif}@
BuildRequires:  gstreamer1-devel, gstreamer1-plugins-base-devel
BuildRequires:  openal-soft-devel, alure-devel
BuildRequires:  gmime30-devel
BuildRequires:  fluidsynth-devel, SDL2-devel, SDL2_mixer-devel, SDL2_image-devel, SDL2_ttf-devel
BuildRequires:  qt5-qtbase-devel, qt5-qtsvg-devel, qt5-qtx11extras-devel
BuildRequires:  desktop-file-utils, gettext-devel
BuildRequires:  curl-devel
@%{if 0%{?fedora} >= 35}@
BuildRequires:  postgresql-private-devel
@%{else}@
BuildRequires:  libpq-devel
@%{endif}@
@%{if 0%{?qt6}}@
BuildRequires:  qt6-qtbase-devel, qt6-qtsvg-devel
@%{endif}@

@{dependencies all}@

# Architecture exclusions
ExcludeArch:    i686

# Patches (preserve original Fedora patches)
Patch1:  %{name}-3.12.2-nolintl.patch
Patch2:  %{name}-3.12.2-noliconv.patch
Patch5:  %{name}-3.14.1-gst1.patch
Patch6:  %{name}-3.19.4-c++20-do-not-try-to-override-std-functions.patch

%description
Gambas3 is a free development environment based on a Basic interpreter
with object extensions, like Visual Basic (but it is NOT a clone !).
With Gambas3, you can quickly design your program GUI, access MySQL/MariaDB
or PostgreSQL databases, pilot KDE applications with DCOP, translate your
program into many languages, create network applications easily, and so
on...

# ============================================
# MAIN PACKAGES (IDE, runtime, dev-tools, scripter)
# ============================================

%package runtime
Summary: Runtime environment for Gambas3
License: GPL-2.0-or-later
@{dependencies runtime}@
Provides: %{name}-gb-gui = %{version}-%{release}
Obsoletes: %{name}-gb-gui <= 3.4
Provides: %{name}-gb-test = %{version}-%{release}
Obsoletes: %{name}-gb-test <= 3.15.2
@{desc runtime}@

%description runtime
Gambas3 is a free development environment based on a Basic interpreter
with object extensions, like Visual Basic. This package contains the
runtime components necessary to run programs designed in Gambas3.

%package dev-tools
Summary: Development environment for Gambas3
License: GPL-2.0-or-later
@{dependencies dev-tools}@
Requires: gettext-runtime
Provides: %{name}-devel = %{version}-%{release}
Obsoletes: %{name}-devel <= 3.15.2
Provides: %{name}-dev = %{version}-%{release}
Obsoletes: %{name}-dev < %{version}
@{desc dev-tools}@

%description dev-tools
The gambas3-dev-tools package contains the tools needed to compile Gambas3
projects without having to install the complete development environment
(gambas3-ide).

%package scripter
Summary: Scripter program that allows the creation of Gambas3 scripts
License: GPL-2.0-or-later AND OFL-1.1
@{dependencies scripter}@
Requires: %{name}-runtime = %{version}-%{release}
Requires: %{name}-gb-pcre = %{version}-%{release}
Provides: %{name}-script = %{version}-%{release}
Obsoletes: %{name}-script < %{version}
BuildArch: noarch
@{desc scripter}@

%description scripter
This package includes the scripter program that allows the user to
write script files in Gambas.

%package gui
Summary: Virtual package for Gambas3 packages that just need a gui
License: GPL-2.0-or-later
@{dependencies gui}@
@{desc gui}@

%description gui
This package is a virtual package that depends on one of the following
packages: gambas3-gb-qt4, gambas3-gb-qt5, gambas3-gb-gtk, gambas3-gb-gtk3.
It is used as a dependency for packages that requires any GUI package (like
gambas3-gb-form).

%package ide
Summary: The complete Gambas3 Development Environment
License: GPL-2.0-or-later AND OFL-1.1 AND MIT
@{dependencies ide}@
Requires: gettext-tools
Requires: gzip
Requires: tar
Requires: unzip
Requires: zip
Recommends: autoconf
Recommends: automake
Recommends: pngquant
Recommends: patch
Recommends: rpm-build
Recommends: translate-shell
BuildArch: noarch
@{desc ide}@

%description ide
This package includes the complete Gambas3 Development Environment.
It pulls in the Gambas3 components necessary for the IDE to function.

@{--
# ============================================
# COMPONENT PACKAGES using @{package} directive
# Format: @{package gb.component}
#   [Fedora-specific BuildRequires here]
# @}
# ============================================
--}@

@{package gb.cairo
BuildRequires:  pkgconfig(cairo)
}@

@{package gb.clipper
License:        GPL-2.0-or-later AND BSL-1.0
}@

@{package gb.clipper2
License:        GPL-2.0-or-later AND BSL-1.0
}@

@{package gb.compress.bzlib2
BuildRequires:  pkgconfig(bzip2)
}@

@{package gb.compress.zlib
BuildRequires:  pkgconfig(zlib)
}@

@{package gb.compress.zstd
BuildRequires:  pkgconfig(libzstd)
}@

@{package gb.crypt
}@

@{package gb.data
}@

@{package gb.db.mysql
BuildRequires:  pkgconfig(libmariadb)
}@

@{package gb.db.odbc
BuildRequires:  pkgconfig(odbc)
}@

@{package gb.db.postgresql
BuildRequires:  postgresql-devel
}@

@{package gb.db.sqlite3
BuildRequires:  pkgconfig(sqlite3)
}@

@{package gb.db2.mysql
BuildRequires:  pkgconfig(libmariadb)
}@

@{package gb.db2.odbc
BuildRequires:  pkgconfig(odbc)
}@

@{package gb.db2.postgresql
BuildRequires:  postgresql-devel
}@

@{package gb.db2.sqlite3
BuildRequires:  pkgconfig(sqlite3)
}@

@{package gb.dbus
BuildRequires:  pkgconfig(dbus-1)
}@

@{package gb.dbus.trayicon
}@

@{package gb.desktop
Requires:       %{name}-gb-desktop-x11 = %{version}
Requires:       %{name}-gb-image = %{version}
Requires:       %{name}-runtime = %{version}
Requires:       xdg-utils
Recommends:     libsecret-tools
}@

@{package gb.desktop.gnome.keyring
BuildRequires:  pkgconfig(gnome-keyring-1)
Provides:       %{name}-gb-desktop-gnome = %{version}
Obsoletes:      %{name}-gb-desktop-gnome < %{version}
}@

@{package gb.desktop.x11
BuildRequires:  pkgconfig(xtst)
}@

@{package gb.eval.highlight
}@

@{package gb.form
}@

@{package gb.form.dialog
}@

@{package gb.form.editor
}@

@{package gb.form.htmlview
}@

@{package gb.form.mdi
Requires:       %{name}-gb-settings = %{version}
}@

@{package gb.form.print
}@

@{package gb.form.stock
}@

@{package gb.form.terminal
Requires:       %{name}-gb-term = %{version}
}@

@{package gb.gmp
BuildRequires:  gmp-devel
}@

@{package gb.gsl
BuildRequires:  pkgconfig(gsl)
}@

@{package gb.gtk
BuildRequires:  pkgconfig(fribidi)
BuildRequires:  pkgconfig(gdk-pixbuf-2.0)
BuildRequires:  pkgconfig(gtk+-2.0)
BuildRequires:  pkgconfig(gtkglext-1.0)
BuildRequires:  pkgconfig(ice)
BuildRequires:  pkgconfig(librsvg-2.0)
BuildRequires:  pkgconfig(pango)
BuildRequires:  pkgconfig(sm)
Provides:       %{name}-gui = %{version}
}@

@{package gb.gtk.opengl
Provides:       %{name}-gui-opengl = %{version}
}@

@{package gb.gtk3
BuildRequires:  pkgconfig(fribidi)
BuildRequires:  pkgconfig(gdk-pixbuf-2.0)
BuildRequires:  pkgconfig(gdk-wayland-3.0)
BuildRequires:  pkgconfig(gdk-x11-3.0)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(gtkglext-1.0)
BuildRequires:  pkgconfig(ice)
BuildRequires:  pkgconfig(librsvg-2.0)
BuildRequires:  pkgconfig(pango)
BuildRequires:  pkgconfig(sm)
Requires:       %{name}-gb-image = %{version}
Provides:       %{name}-gb-gtk3-wayland = %{version}
Obsoletes:      %{name}-gb-gtk3-wayland < %{version}
Provides:       %{name}-gb-gtk3-x11 = %{version}
Obsoletes:      %{name}-gb-gtk3-x11 < %{version}
Provides:       %{name}-gui = %{version}
}@

@{package gb.gtk3.opengl
Provides:       %{name}-gui-opengl = %{version}
}@

@{package gb.gtk3.webview
BuildRequires:  pkgconfig(webkit2gtk-4.1)
Provides:       %{name}-gui-webview = %{version}
}@

@{package gb.gtk3.x11
}@

@{package gb.gtk3.wayland
}@

@{package gb.hash
}@

@{package gb.highlight
BuildRequires:  pkgconfig(libpcre2-8)
}@

@{package gb.httpd
}@

@{package gb.image
}@

@{package gb.image.effect
}@

@{package gb.image.imlib
BuildRequires:  pkgconfig(imlib2)
}@

@{package gb.image.io
BuildRequires:  pkgconfig(gdk-pixbuf-2.0)
}@

@{package gb.inotify
}@

@{if 0%{?enablejit}}@
@{package gb.jit
BuildRequires:  gcc
}@
@%{endif}@

@{package gb.libxml
BuildRequires:  pkgconfig(libxml-2.0)
}@

@{package gb.logging
}@

@{package gb.map
Requires:       %{name}-gb-net = %{version}
Requires:       %{name}-gb-net-curl = %{version}
}@

@{package gb.markdown
}@

@{package gb.media
BuildRequires:  pkgconfig(gstreamer-1.0)
BuildRequires:  pkgconfig(gstreamer-video-1.0)
}@

@{package gb.media.form
}@

@{package gb.memcached
Requires:       %{name}-gb-net = %{version}
}@

@{package gb.mime
BuildRequires:  pkgconfig(gmime-3.0)
}@

@%{if 0%{?fedora} >= 35}@
@%{package gb.mongodb
BuildRequires:  pkgconfig(libmongoc-1.0)
}@
@%{endif}@

@{package gb.mysql
Requires:       %{name}-gb-db-mysql = %{version}
}@

@{package gb.ncurses
BuildRequires:  pkgconfig(ncurses)
}@

@{package gb.net
}@

@{package gb.net.curl
BuildRequires:  pkgconfig(libcurl)
}@

@{package gb.net.pop3
Requires:       %{name}-gb-mime = %{version}
}@

@{package gb.net.smtp
}@

@{package gb.openal
BuildRequires:  pkgconfig(alure)
BuildRequires:  pkgconfig(openal)
}@

@{package gb.opengl
BuildRequires:  pkgconfig(glew)
}@

@{package gb.opengl.glu
}@

@{package gb.opengl.glsl
}@

@{package gb.opengl.sge
}@

@{package gb.openssl
BuildRequires:  pkgconfig(libssl)
}@

@{package gb.option
}@

@{package gb.pcre
BuildRequires:  pkgconfig(libpcre2-8)
}@

@%{if version < 16.0}@
@{package gb.pdf
BuildRequires:  pkgconfig(poppler)
}@
@%{endif}@

@{package gb.poppler
BuildRequires:  pkgconfig(poppler-cpp)
BuildRequires:  pkgconfig(poppler-glib)
}@

@{package gb.qt4
BuildRequires:  pkgconfig(Qt4Core)
BuildRequires:  pkgconfig(Qt4Gui)
BuildRequires:  pkgconfig(Qt4Network)
BuildRequires:  pkgconfig(Qt4Sql)
BuildRequires:  pkgconfig(Qt4Xml)
}@

@{package gb.qt4.ext
}@

@{package gb.qt4.opengl
BuildRequires:  pkgconfig(Qt4OpenGL)
}@

@%{if version < 16.0}@
@{package gb.qt4.webkit
BuildRequires:  pkgconfig(Qt4WebKit)
BuildRequires:  pkgconfig(Qt4WebKitWidgets)
}@
@%{endif}@

@{package gb.qt4.webview
}@

@{package gb.qt5
BuildRequires:  pkgconfig(Qt5Core) >= 5.5.0
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5PrintSupport)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  pkgconfig(Qt5Xml)
BuildRequires:  pkgconfig(x11-xcb)
Provides:       %{name}-gb-qt5-wayland = %{version}
Obsoletes:      %{name}-gb-qt5-wayland < %{version}
Provides:       %{name}-gb-qt5-x11 = %{version}
Obsoletes:      %{name}-gb-qt5-x11 < %{version}
Provides:       %{name}-gui = %{version}
}@

@{package gb.qt5.ext
}@

@{package gb.qt5.opengl
BuildRequires:  pkgconfig(Qt5OpenGL)
Provides:       %{name}-gui-opengl = %{version}
}@

@%{ifnarch ppc64le s390x}@
@{package gb.qt5.webview
BuildRequires:  pkgconfig(Qt5WebEngine)
Provides:       %{name}-gui-webview = %{version}
}@
@%{endif}@

@%{if version < 16.0}@
@{package gb.qt5.webkit
BuildRequires:  pkgconfig(Qt5WebKit)
BuildRequires:  pkgconfig(Qt5WebKitWidgets)
}@
@%{endif}@

@{package gb.qt5.x11
}@

@{package gb.qt5.wayland
}@

@{if 0%{?qt6}}@
@{package gb.qt6
BuildRequires:  pkgconfig(Qt6Core)
BuildRequires:  pkgconfig(Qt6Gui)
BuildRequires:  pkgconfig(Qt6Network)
BuildRequires:  pkgconfig(Qt6PrintSupport)
BuildRequires:  pkgconfig(Qt6Svg)
BuildRequires:  pkgconfig(Qt6Widgets)
BuildRequires:  pkgconfig(Qt6Xml)
Provides:       %{name}-gb-qt6-wayland = %{version}
Obsoletes:      %{name}-gb-qt6-wayland < %{version}
Provides:       %{name}-gb-qt6-x11 = %{version}
Obsoletes:      %{name}-gb-qt6-x11 < %{version}
Provides:       %{name}-gui = %{version}
}@

@{package gb.qt6.ext
}@

@{package gb.qt6.opengl
BuildRequires:  pkgconfig(Qt6OpenGL)
BuildRequires:  pkgconfig(Qt6OpenGLWidgets)
Provides:       %{name}-gui-opengl = %{version}
}@

@{package gb.qt6.webview
BuildRequires:  pkgconfig(Qt6WebEngineCore)
BuildRequires:  pkgconfig(Qt6WebEngineWidgets)
Provides:       %{name}-gui-webview = %{version}
}@

@{package gb.qt6.x11
}@

@{package gb.qt6.wayland
}@

@%{if version < 16.0}@
@{package gb.qt6.webkit
BuildRequires:  pkgconfig(Qt6WebKit)
BuildRequires:  pkgconfig(Qt6WebKitWidgets)
}@
@%{endif}@
@%{endif}@

@{package gb.report
Requires:       %{name}-gb-form = %{version}
}@

@{package gb.report2
Requires:       %{name}-gb-form = %{version}
}@

@{package gb.scanner
Requires:       sane-backends
}@

@{package gb.sdl
BuildRequires:  pkgconfig(SDL_ttf)
BuildRequires:  pkgconfig(glew)
}@

@{package gb.sdl.sound
BuildRequires:  pkgconfig(SDL_mixer)
}@

@{package gb.sdl2
BuildRequires:  pkgconfig(SDL2_image)
BuildRequires:  pkgconfig(SDL2_ttf)
}@

@{package gb.sdl2.audio
BuildRequires:  pkgconfig(SDL2_mixer)
}@

@{package gb.settings
}@

@{package gb.signal
}@

@{package gb.term
}@

@{package gb.term.form
}@

@{package gb.util
}@

@{package gb.util.web
}@

@{package gb.v4l
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libv4l2)
}@

@{package gb.vb
}@

@{package gb.web
Requires:       %{name}-gb-util-web = %{version}
}@

@{package gb.web.feed
Requires:       %{name}-gb-xml = %{version}
Requires:       %{name}-gb-util = %{version}
}@

@{package gb.web.form
Requires:       %{name}-gb-util-web = %{version}
Requires:       %{name}-gb-util = %{version}
}@

@{package gb.web.gui
Requires:       %{name}-gb-signal = %{version}
Requires:       %{name}-gb-util-web = %{version}
Requires:       %{name}-gb-util = %{version}
}@

@{package gb.xml
}@

@{package gb.xml.html
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(libxslt)
}@

@{package gb.xml.rpc
}@

@{package gb.xml.xslt
BuildRequires:  pkgconfig(libxslt)
}@

@{package}@

# ============================================
# BUILD SECTIONS
# ============================================

%prep
%setup -q -n gambas-%{version}
%patch -P 1 -p1 -b .nolintl
%patch -P 2 -p1 -b .noliconv
%patch -P 5 -p1 -b .gst1
%patch -P 6 -p1 -b .c++20
for i in `find . |grep acinclude.m4`; do
 sed -e 's|$AM_CFLAGS -O3|$AM_CFLAGS|g' $i
 sed -e 's|$AM_CXXFLAGS -Os -fno-omit-frame-pointer|$AM_CXXFLAGS|g' $i
 sed -e 's|$AM_CFLAGS -Os|$AM_CFLAGS|g' $i
 sed -e 's|$AM_CFLAGS -O0|$AM_CFLAGS|g' $i
 sed -e 's|$AM_CXXFLAGS -O0|$AM_CXXFLAGS|g' $i
done
# Need this for gcc44
sed -i 's|-fno-exceptions||g' gb.db.sqlite3/acinclude.m4
./reconf-all

# clean up some spurious exec perms
chmod -x main/gbx/gbx_local.h
chmod -x main/gbx/gbx_subr_file.c
chmod -x gb.qt4/src/CContainer.cpp
chmod -x main/lib/option/getoptions.*
chmod -x main/lib/option/main.c

%build
@%{if 0%{?fedora} <= 37}@
# Gambas can't deal with -Wp,-D_FORTIFY_SOURCE=2 (or 3)
MY_CFLAGS=`echo %{build_cflags} | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g' | sed -e 's/-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3//g'`
@%{endif}@
%configure \
 --disable-silent-rules \
 --datadir="%{_datadir}" \
 --enable-intl \
 --enable-conv \
 --enable-qt4 \
 --enable-kde \
 --enable-net \
 --enable-curl \
 --enable-postgresql \
 --enable-mysql \
 --enable-sqlite3 \
 --enable-sdl \
 --enable-vb \
 --enable-pdf \
 --with-bzlib2-libraries=%{_libdir} \
 --with-crypt-libraries=%{_libdir} \
 --with-curl-libraries=%{_libdir} \
 --with-desktop-libraries=%{_libdir} \
 --with-ffi-includes=`pkg-config libffi --variable=includedir` \
 --with-ffi-libraries=`pkg-config libffi --variable=libdir` \
 --with-intl-libraries=%{_libdir} \
 --with-conv-libraries=%{_libdir} \
 --with-gettext-libraries=%{_libdir} \
 --with-gtk-libraries=%{_libdir} \
 --with-gtk_svg-libraries=%{_libdir} \
 --with-image-libraries=%{_libdir} \
 --with-kde-libraries=%{_libdir} \
 --with-mysql-includes=%{_includedir}/mysql \
 --with-mysql-libraries=%{_libdir}/mariadb \
 --with-net-libraries=%{_libdir} \
 --with-odbc-libraries=%{_libdir} \
 --with-opengl-libraries=%{_libdir} \
 --with-pcre-libraries=%{_libdir} \
 --with-poppler-libraries=%{_libdir} \
 --with-postgresql-libraries=%{_libdir} \
 --with-qt4-libraries=%{_libdir} \
 --with-qt5-libraries=%{_libdir} \
 --with-qtopengl-libraries=%{_libdir} \
 --with-sdl-libraries=%{_libdir} \
 --with-sdl_sound-libraries=%{_libdir} \
 --with-smtp-libraries=%{_libdir} \
 --with-sqlite2-libraries=%{_libdir} \
 --with-sqlite3-libraries=%{_libdir} \
 --with-v4l-libraries=%{_libdir} \
 --with-xml-libraries=%{_libdir} \
 --with-xslt-libraries=%{_libdir} \
 --with-zlib-libraries=%{_libdir} \
@%{if 0%{?fedora} <= 37}@
 AM_CFLAGS="$MY_CFLAGS" AM_CXXFLAGS="$MY_CFLAGS" CC="%{build_cc} $MY_CFLAGS"
@%{else}@
 AM_CFLAGS="%{build_cflags}" AM_CXXFLAGS="%{build_cflags}" CC="%{build_cc} %{build_cflags}"
@%{endif}@
# rpath removal
for i in main; do
 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' $i/libtool
 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' $i/libtool
done
# for some unholy reason, using system libtool breaks on qt5. so we don't.
%make_build -C gb.qt5
%make_build

%install
export PATH=%{buildroot}%{_bindir}:$PATH
%make_install
# Why do we have to run this twice? I HAVE NO IDEA.
%make_install

mkdir -p %{buildroot}%{_datadir}/pixmaps
mkdir -p %{buildroot}%{_datadir}/applications
mkdir -p %{buildroot}%{_datadir}/%{name}/examples/
install -m0644 -p ./app/src/%{name}/.icon.png %{buildroot}%{_datadir}/pixmaps/%{name}.png

desktop-file-install \
  --dir %{buildroot}%{_datadir}/applications \
  %{SOURCE1}

# Get the SVN noise out of the main tree
find %{buildroot}%{_datadir}/%{name}/ -type d -name .svn -exec rm -rf {} 2>/dev/null ';' || :

# Upstream says we don't need those files. Not sure why they install them then. :/
rm -rf %{buildroot}%{_libdir}/%{name}/gb.la %{buildroot}%{_libdir}/%{name}/gb.so*

# No need for the static libs
rm -rf %{buildroot}%{_libdir}/%{name}/*.a

# Mime types.
mkdir -p %{buildroot}%{_datadir}/mime/packages/
install -m 0644 -p app/mime/application-x-gambasscript.xml %{buildroot}%{_datadir}/mime/packages/
install -m 0644 -p main/mime/application-x-gambas3.xml %{buildroot}%{_datadir}/mime/packages/

@{--
# ============================================
# FILE SECTIONS (using @{files} directive)
# ============================================
--}@

%files
%doc INSTALL README
%license COPYING

@{files}@

%changelog
