-- local git_ref = 'texlive-2025.2'
local git_ref = 'svn78399'
local modrev = '2.12'
local specrev = "2"

local repo_url = 'https://github.com/TeX-Live/texlive-source'

rockspec_format = '3.0'
package = 'makeindex'
version = modrev .. '-' .. specrev


description = {
  summary = 'Process bibliographies (bib files) for LaTeX or other formats',
  detailed =
  [[A general purpose hierarchical index generator; it accepts one or more input files (often produced by a text formatter such as TeX or troff), sorts the entries, and produces an output file which can be formatted. The formats of the input and output files are specified in a style file; by default, input is assumed to be an .idx file, as generated by LaTeX.]],
  labels = {},
  homepage = repo_url,
  license = 'LPPL-1.3c'
}

source = {
  url = repo_url .. '/archive/' .. git_ref .. '.zip',
  dir = 'texlive-source-' .. git_ref,
}

if modrev == 'scm' or modrev == 'dev' then
  source = {
  }
end

build_dependencies = {}

dependencies = {}

build = {
  type = 'command',
  build_command = [[
  mkdir work
  cd work
  ../configure --without-x
  make recurse
  mkdir -p texk/makeindexk
  cd texk/makeindexk
  eval "$(sed 's,auxdir/auxsub,texk/makeindexk,g' ../../subsubdir-conf.cmd)"
  make
]],
  install = {
    bin = {
      'work/texk/makeindexk/makeindex'
    },
    conf = {
      ['../doc/makeindex.1'] = 'texk/makeindexk/makeindex.1'
    },
    -- https://github.com/luarocks/luarocks/issues/1817
    lib = {
      ['makeindex/README'] = 'README'
    },
  }
}
