# 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: 18.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:
    - name: mesa-libGLU
      sources:
          - type: archive
            url: https://mesa.freedesktop.org/archive/glu/glu-9.0.0.tar.bz2
            sha256: 1f7ad0d379a722fcbd303aa5650c6d7d5544fde83196b42a73d1193568a4df12
      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

    - name:  zlib
      sources:
          - type: archive
            url: http://zlib.net/zlib-1.2.11.tar.gz
            sha256: c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1

    - 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: 5.1.511-Beta
            commit: c3b67169f
          - type: patch
            path: flatpak/src/0008-flatpak-Add-a-shell-wrapper.patch
