##
##  jam.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_perforce  2.5
%define       V_boost     3.1.18
%define       V_freetype  2.5.3rc2

#   package information
Name:         jam
Summary:      Perforce Jam
URL:          http://www.perforce.com/jam/jam.html
Vendor:       Perforce Software, Inc.
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Building
License:      Freely distributable
Version:      %{V_perforce}
Release:      20100323

#   list of sources
Source0:      ftp://ftp.perforce.com/jam/jam-%{V_perforce}.tar
Source1:      http://download.sourceforge.net/boost/boost-jam-%{V_boost}.tgz
Source2:      http://david.freetype.org/jam/ftjam-%{V_freetype}.tar.bz2
Patch0:       jam.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, bison, gcc
PreReq:       OpenPKG, openpkg >= 20160101

%description
    Jam is a software build tool that makes building simple things
    simple and building complicated things manageable. Jam is a very
    good solution for conventional C/C++ compile-and-link builds.
    Because Jam understands C/C++ dependencies, there is no need to
    declare header or object files. The built-in Jam rule "Main" handles
    header file dependencies and object files both automatically and
    on-the-fly.

    This OpenPKG package contains both the original Jam from Perforce
    (jam), the enhanced Jam from the Boost Build system (bjam) and the
    enhanced Jam from the FreeType project (ftjam).

%track
    prog jam:jam = {
        version   = %{V_perforce}
        url       = ftp://ftp.perforce.com/jam/
        regex     = jam-(__VER__)\.tar
    }
    prog jam:bjam = {
        version   = %{V_boost}
        url       = http://sourceforge.net/projects/boost/files/
        regex     = boost-jam-(__VER__)\.tgz
    }
    prog jam:ftjam = {
        version   = %{V_freetype}
        url       = http://david.freetype.org/jam/
        regex     = ftjam-(__VER__)\.tar\.bz2
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %patch -p0

%build
    ( cd jam-%{V_perforce}
      %{l_shtool} subst \
          -e 's;^\(CC[ 	]*=\).*$;\1 %{l_cc};' \
          -e 's;^\(CFLAGS[ 	]*=\).*$;\1 %{l_cflags} -O0;' \
          Makefile
      %{l_make} %{l_mflags}
    ) || exit $?
    ( cd boost-jam-%{V_boost}
      sh ./build.sh
    ) || exit $?
    ( cd ftjam-%{V_freetype}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      ./configure \
          --prefix=%{l_prefix}
      %{l_make} %{l_mflags}
    ) || exit $?

%install
    %{l_shtool} mkdir -f -p 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin
    %{l_shtool} install -c -s -m 755 \
        jam-%{V_perforce}/bin.*/jam $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_shtool} install -c -s -m 755 \
        boost-jam-%{V_boost}/bin.*/bjam $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_shtool} install -c -s -m 755 \
        ftjam-%{V_freetype}/bin.unix/jam $RPM_BUILD_ROOT%{l_prefix}/bin/ftjam
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

