##
##  texlive.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_base   2014
%define       V_source 20140525
%define       V_texmf  20140525

#   package information
Name:         texlive
Summary:      The TeX Typesetting System
URL:          http://tug.org/texlive/
Vendor:       TeX User Group, Sebastian Rahtz et al.
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Typesetting
License:      GPL
Version:      %{V_base}
Release:      20141209

#   list of sources
Source0:      ftp://tug.org/historic/systems/texlive/%{V_base}/texlive-%{V_source}-source.tar.xz
Source1:      ftp://tug.org/historic/systems/texlive/%{V_base}/texlive-%{V_texmf}-texmf.tar.xz
Patch0:       texlive.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  make, gcc, gcc::with_cxx = yes, flex, bison, pkgconfig
PreReq:       psutils, texinfo, ghostscript
BuildPreReq:  ncurses, png, zlib, t1lib, freetype, fontconfig, gd, graphite, poppler, zziplib, cairo, libpixman
PreReq:       ncurses, png, zlib, t1lib, freetype, fontconfig, gd, graphite, poppler, zziplib, cairo, libpixman

%description
    TeX Live is a complete TeX distribution for Unix compatible systems,
    maintained by the TeX User Group. It was originally developed
    by Sebastian Rahtz and is based on Karl Berry's original Web2c
    distribution and Thomas Esser's teTeX distribution. TeX was invented
    by Donald E. Knuth, and the most popular TeX macro set (LaTeX) for
    TeX was invented by Leslie Lamport.

%track
    prog texlive:source = {
        version   = %{V_source}
        url       = ftp://tug.org/historic/systems/texlive/%{V_base}/
        regex     = texlive-(__VER__)-source\.tar\.xz
    }
    prog texlive:texmf = {
        version   = %{V_texmf}
        url       = ftp://tug.org/historic/systems/texlive/%{V_base}/
        regex     = texlive-(__VER__)-texmf\.tar\.xz
    }

%prep
    %setup -q -n texlive-%{V_source}-source
    %patch -p0

%build
    #   substitute paths
    %{l_shtool} subst -e 's;texmf-dist;texmf;g' \
        `find . -name "Makefile.in" -print`

    #   configure and build programs
    export CC="%{l_cc}"
    export CXX="%{l_cxx}"
    export CFLAGS="%{l_cflags -O}"
    export CXXFLAGS="%{l_cxxflags -O}"
    export CPPFLAGS="%{l_cppflags icu .}"
    export LDFLAGS="%{l_ldflags}"
    export LIBS="`pkg-config fontconfig --libs`"
    ./configure \
        --enable-build-in-source-tree \
        --prefix=%{l_prefix} \
        --datadir=%{l_prefix}/share \
        --datarootdir=%{l_prefix}/share \
        --infodir=%{l_prefix}/info \
        --mandir=%{l_prefix}/man \
        --with-banner-add="(OpenPKG)" \
        --disable-multiplatform \
        --disable-compiler-warnings \
        --disable-shared \
        --enable-static \
        --enable-web2c \
        --enable-pdftex \
        --disable-t1utils \
        --disable-texdoctk \
        --disable-xindy \
        --disable-xpdfopen \
        --disable-dump-share \
        --disable-lcdf-typetools \
        --disable-debug \
        --disable-xdvik \
        --disable-xdvipdfmx \
        --with-gs=%{l_prefix}/bin/gs \
        --with-system-cairo \
        --with-system-pixman \
        --with-system-poppler \
        --with-system-ncurses \
        --with-system-libpng \
        --with-system-zlib \
        --with-system-zziplib \
        --with-system-t1lib \
        --with-system-gd \
        --with-system-icu \
        --with-system-freetype2 \
        --without-system-graphite2 \
        --without-mf-x-toolkit \
        --without-x
    %{l_make} %{l_mflags}

%install
    #   create installation hierarchy
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/share \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/info \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man5

    #   install TeX and MetaFont data
    %{l_xz} -d -c %{SOURCE1} |\
        ( umask 0 && cd $RPM_BUILD_ROOT%{l_prefix}/share && %{l_tar} xf - ) || exit $?
    mv  $RPM_BUILD_ROOT%{l_prefix}/share/texlive-%{V_texmf}-texmf/* \
        $RPM_BUILD_ROOT%{l_prefix}/share/
    rmdir $RPM_BUILD_ROOT%{l_prefix}/share/texlive-%{V_texmf}-texmf

    #   install program files
    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT

    #   strip down installation
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

