# Copyright (c) 2018 Alec Leamas
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#

# This manifest is used to build the official flathub package.


app-id: org.opencpn.OpenCPN
runtime: org.freedesktop.Platform
runtime-version: "20.08"
sdk: org.freedesktop.Sdk
command: opencpn.sh

rename-desktop-file: opencpn.desktop
rename-icon: opencpn
rename-appdata-file: opencpn.appdata.xml

finish-args:
    - --socket=x11
    - --socket=pulseaudio
    - --filesystem=home
    - --share=network
    - --device=all

add-extensions:
    org.opencpn.OpenCPN.Plugin:
        directory: extensions
        merge-dirs: lib/opencpn;share/opencpn/plugins;share/locale
        subdirectories: true
        no-autodownload: true
        autodelete: false

modules:
    - shared-modules/glu/glu-9.json
    - name: portaudio
      sources:
          - type: archive
            url: http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz
            sha256: f5a21d7dcd6ee84397446fa1fa1a0675bb2e8a4a6dceb4305a8404698d8d1513
      config-opts:
          - --disable-static
    - name: wxGTK3
      sources:
          - type: archive
            url: https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.4/wxWidgets-3.0.4.tar.bz2
            sha256: 96157f988d261b7368e5340afa1a0cad943768f35929c22841f62c25b17bf7f0
      config-opts:
          - --with-gtk=3
          - --with-opengl
          - --with-sdl
          - --with-gnomeprint
          - --with-libmspack
          - --enable-intl
          - --enable-no_deps
          - --disable-rpath
          - --enable-ipv6
      cleanup:
          - /include/

    - name: opencpn
      buildsystem: cmake
      builddir: true
      config-opts:
          - -DOCPN_BUNDLE_DOCS=ON
          - -DOCPN_BUNDLE_TCDATA=ON
          - -DOCPN_CI_BUILD=ON
          - -DOCPN_FLATPAK=ON
          - -DBUILD_SHARED_LIBS=OFF
          - -DCMAKE_FIND_ROOT_PATH=/app
          - -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
          - -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH
          - -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH
      build-options:
          cxxflags: -DFLATPAK
          cflags: -DFLATPAK
          env:
            BUILD_NUMBER: "0"
      post-install:
          - install -d /app/extensions
          - sed -i '/^Exec=/s/=.*/=opencpn.sh/' /app/share/applications/opencpn.desktop
          - install -Dm 755 ../data/opencpn.sh /app/bin/opencpn.sh
      sources:
          - type: git
            url: https://github.com/OpenCPN/OpenCPN.git
            tag: Release_5.2.4
            disable-fsckobjects: true
          - type: patch
            path: 0001-cmake-linux-Install-correct-appdata-file-2069.patch
          - type: patch
            path: 0002-flatpak-Add-a-shell-wrapper.patch
          - type: patch
            path: 0003-appdata-screenshot-url.patch
          - type: patch
            path: 0004-Add-warning-message-for-aarch64.patch
          - type: patch
            path: 0001-cmake-Upate-flatpak-runtime-version-18.08-20.08.patch
