id: io.github.dosemu2.dosemu2
runtime: org.freedesktop.Sdk
runtime-version: '25.08'
sdk: org.freedesktop.Sdk
command: dosemu

modules:
  - name: nasm-segelf
    buildsystem: autotools
    sources:
      - type: git
        url: https://github.com/stsp/nasm.git
        branch: master
    cleanup:
      - '*'

  - name: thunk-gen
    buildsystem: meson
    sources:
      - type: git
        url: https://github.com/stsp/thunk_gen.git
        branch: main
    cleanup:
      - '*'

  - name: binutils
    buildsystem: autotools
    sources:
      - type: git
        url: git://sourceware.org/git/binutils-gdb.git
        branch: master
    config-opts:
      - --target=i686-unknown-linux-gnu
      - --disable-gdb
      - --disable-texinfo
      - --disable-sim
    cleanup:
      - '*'

  - name: fdpp
    buildsystem: meson
    config-opts:
      - --cross-file
      - "/run/build/fdpp/fdpp/kernel/toolchain.ini"
    sources:
      - type: git
        url: https://github.com/dosemu2/fdpp.git
        branch: master
    cleanup:
      - '/include'

  - name: smallerc
    buildsystem: simple
    build-commands:
      - make prefix=${FLATPAK_DEST}
      - make install prefix=${FLATPAK_DEST}
    sources:
      - type: git
        url: https://github.com/alexfru/smallerc.git
        branch: master
    cleanup:
      - '*'

  - name: djstub
    buildsystem: simple
    build-commands:
      - make -j ${FLATPAK_BUILDER_N_JOBS} prefix=${FLATPAK_DEST}
      - make install prefix=${FLATPAK_DEST}
    sources:
      - type: git
        url: https://github.com/stsp/djstub.git
        branch: main
    cleanup:
      - '*'

  - name: ctags
    buildsystem: autotools
    sources:
      - type: git
        url: https://github.com/universal-ctags/ctags.git
        branch: master
    cleanup:
      - '*'

  - name: dj64dev
    buildsystem: autotools
    build-options:
      env: ['CROSS_PREFIX=i686-unknown-linux-gnu-']
    sources:
      - type: git
        url: https://github.com/stsp/dj64dev.git
        branch: master
    builddir: false
    cleanup:
      - '/include'
      - '*.a'

  - name: jansson
    buildsystem: autotools
    sources:
      - type: git
        url: https://github.com/akheron/jansson.git
        branch: master
      - type: script
        commands: ['autoreconf -v -i']
    cleanup:
      - '/include'

  - name: libsearpc
    buildsystem: autotools
    sources:
      - type: git
        url: https://github.com/haiwen/libsearpc.git
        branch: master
    cleanup:
      - '/include'

  - name: json-c
    buildsystem: cmake
    config-opts:
    - -DCMAKE_POLICY_VERSION_MINIMUM=3.5
    sources:
      - type: git
        url: https://github.com/json-c/json-c.git
        branch: master
    cleanup:
      - '/include'

  - name: libslirp
    buildsystem: meson
    sources:
      - type: git
        url: https://gitlab.freedesktop.org/slirp/libslirp.git
        branch: master
    cleanup:
      - '/include'

  - name: fluidsynth
    buildsystem: cmake
    config-opts:
      - -Denable-limiter=OFF
    sources:
      - type: git
        url: https://github.com/FluidSynth/fluidsynth.git
        branch: master
    cleanup:
      - '/include'

  - name: libb64
    buildsystem: simple
    sources:
      - type: git
        url: https://github.com/libb64/libb64.git
        branch: master
    build-commands:
      - make -j ${FLATPAK_BUILDER_N_JOBS} all_src
      - cp -r include ${FLATPAK_DEST}
      - cp src/libb64.a ${FLATPAK_DEST}/lib

  - name: dosemu2
    buildsystem: autotools
    build-options:
      env: ['CROSS_PREFIX=i686-unknown-linux-gnu-']
      append-path: /app/sbin
    sources:
      - type: dir
        path: .

  - name: comcom64
    buildsystem: simple
    build-commands:
      - make -j ${FLATPAK_BUILDER_N_JOBS} prefix=${FLATPAK_DEST} \
          CROSS_PREFIX=i686-unknown-linux-gnu-
      - make install prefix=${FLATPAK_DEST}
    sources:
      - type: git
        url: https://github.com/dosemu2/comcom64.git
        branch: master

  - name: install-freedos
    buildsystem: simple
    build-commands:
      - make install prefix=${FLATPAK_DEST}
    sources:
      - type: git
        url: https://github.com/dosemu2/install-freedos.git
        branch: master

  - name: install-win31
    buildsystem: simple
    build-commands:
      - make install prefix=${FLATPAK_DEST}
    sources:
      - type: git
        url: https://github.com/dosemu2/install-win31.git
        branch: master

  - name: soundfont
    buildsystem: simple
    sources:
      - type: git
        url: https://github.com/TheGammaSqueeze/jelos_generaluser-gs.git
        branch: main
    build-commands:
      - mkdir -p ${FLATPAK_DEST}/share/soundfonts
      - cp "GeneralUser GS v1.471.sf2" ${FLATPAK_DEST}/share/soundfonts/default.sf2

finish-args:
  - --socket=wayland
  - --socket=x11
  - --socket=pulseaudio
  - --filesystem=home
  - --filesystem=/run/user
  - --device=kvm
  - --device=dri
  - --share=network
  - --env=LADSPA_PATH=/usr/lib/x86_64-linux-gnu/ladspa
