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

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

build:
  number: 1
  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]
    - m2-patch  # [win]
  host:
    - ncurses 6.4  # [not win]
    - readline 8.0  # [not ((linux and aarch64) or (osx and arm64) or win)]
    - readline 8.1  # [(linux and aarch64) or (osx and arm64)]
    - zlib 1.2  # [not win]
  run:
    - {{ pin_compatible('ncurses') }}   # [not win]
    - {{ pin_compatible('readline') }}  # [not win]
    - {{ pin_compatible('zlib') }}      # [not win]

test:
  requires:
    - binutils  # [linux]
  commands:
    - sqlite3 --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
