{% set version = "3.51.1" %}
{% 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
  version: {{ version }}

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

build:
  number: 0
  string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
  run_exports:
    # sometimes adds new symbols.  Default behavior is OK.
    #    https://abi-laboratory.pro/tracker/timeline/sqlite/
    - {{ pin_subpackage('sqlite') }}

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

test:
  requires:
    - python
    - binutils  # [linux]
  commands:
    - sqlite3 --version
    - python -c "import sqlite3; print(sqlite3.sqlite_version)"
    - if not exist %PREFIX%\\Library\bin\sqlite3.exe exit 1       # [win]
    - 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/bin/sqlite3                                 # [not 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]
    - test -f $PREFIX/lib/pkgconfig/sqlite3.pc                    # [not win]
    # make sure that soname is set
    - readelf -d $PREFIX/lib/libsqlite3${SHLIB_EXT} | grep SONAME # [linux]

about:
  home: https://www.sqlite.org
  license: blessing
  license_file: LICENSE.md
  license_family: Other
  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: https://www.sqlite.org/docs.html
  dev_url: https://sqlite.org/src/dir?ci=trunk

extra:
  recipe-maintainers:
    - jakirkham
    - jjhelmus
    - msarahan
    - ocefpaf
    - snorfalorpagus
    - mingwandroid
    - xylar
