{% set version = "3.49.2" %}
{% set year = "2025" %}
{% set version_split = version.split(".") %}
{% set major = version_split[0] %}
{% set minor = version_split[1]|int * 10 %}
{% set bugfix = version_split[2]|int * 100 %}
{% set version_coded=(major ~ (("%03d" % minor)|string) ~ (("%03d" % bugfix)|string)) %}

package:
  name: sqlite-split
  version: {{ version }}

source:
  url: https://www.sqlite.org/{{ year }}/sqlite-autoconf-{{ version_coded }}.tar.gz
  sha256: 5c6d8697e8a32a1512a9be5ad2b2e7a891241c334f56f8b0fb4fc6051e1652e8
  patches:
    - expose_symbols.patch  # [win]

build:
  number: 0

requirements:
  build:
    - {{ compiler('c') }}
    - {{ stdlib("c") }}
    - make  # [not win]
  host:
    - ncurses  # [not win]
    - readline  # [not win]
    - zlib  # [not win]


outputs:
  - name: libsqlite
    build:
      run_exports:
        # sometimes adds new symbols.  Default behavior is OK.
        #    https://abi-laboratory.pro/tracker/timeline/sqlite/
        - {{ pin_subpackage('libsqlite') }}
    files:
      - include/sqlite*.h          # [unix]
      - lib/libsqlite*             # [unix]
      - lib/pkgconfig/sqlite3.pc   # [unix]
      - Library\bin\sqlite3.dll    # [win]
      - Library\lib\sqlite3.lib    # [win]
      - Library\include\sqlite*.h  # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ stdlib("c") }}
        - make  # [not win]
      host:
        # readline and ncurses are only required by the executable
        # not the library. Leaving it out of the host requirements
        # ensures it doesn't appear in the run section (through run_export)
        - zlib  # [not win]
    test:
      commands:
        - if not exist %PREFIX%\\Library\bin\sqlite3.dll exit 1  # [win]
        - if not exist %PREFIX%\\Library\lib\sqlite3.lib exit 1  # [win]
        - test -f $PREFIX/lib/libsqlite3${SHLIB_EXT}  # [not win]
        - test ! -f $PREFIX/lib/libsqlite3.a  # [not win]
        - if not exist %PREFIX%\\Library\include\sqlite3.h exit 1  # [win]
        - if not exist %PREFIX%\\Library\include\sqlite3ext.h exit 1  # [win]
        - test -f $PREFIX/include/sqlite3.h  # [not win]
        - test -f $PREFIX/include/sqlite3ext.h  # [not win]
  - name: sqlite
    build:
      run_exports:
        # sometimes adds new symbols.  Default behavior is OK.
        #    https://abi-laboratory.pro/tracker/timeline/sqlite/
        - {{ pin_subpackage('libsqlite') }}
    files:
      - bin/sqlite3              # [unix]
      - Library\bin\sqlite3.exe  # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ stdlib("c") }}
        - make  # [not win]
      host:
        - ncurses  # [not win]
        - readline  # [not win]
        - zlib  # [not win]
      run:
        - {{ pin_subpackage('libsqlite', exact=True) }}
    test:
      commands:
        - sqlite3 --version

about:
  home: http://www.sqlite.org/
  license: Unlicense
  license_url: http://www.sqlite.org/copyright.html
  summary: Implements a self-contained, zero-configuration, SQL database engine
  description: |
    SQLite is a self-contained, high-reliability, embedded, full-featured,
    public-domain, SQL database engine.It is the most used database engine
    in the world.
  doc_url: http://www.sqlite.org/docs.html
  doc_source_url: https://github.com/mackyle/sqlite/tree/master/doc
  dev_url: https://github.com/mackyle/sqlite

extra:
  recipe-maintainers:
    - jakirkham
    - msarahan
    - ocefpaf
    - mingwandroid
    - flaviomartins
