##
##  apache-utils.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 information
Name:         apache-utils
Summary:      Apache HTTP Server Utilities
URL:          http://httpd.apache.org/
Vendor:       Apache Software Foundation
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Web
License:      ASF
Version:      2.4.38
Release:      20190227

#   list of sources
Source0:      http://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl, make
PreReq:       OpenPKG, openpkg >= 20160101, perl
BuildPreReq:  apr, pcre
PreReq:       apr, pcre

%description
    These are the utilities htpasswd(1), htdigest(1) and ab(1) from the
    Apache HTTP Server.

%track
    prog apache = {
        version   = %{version}
        url       = http://www.apache.org/dist/httpd/
        regex     = httpd-(\d+\.\d+\.\d+)\.tar\.(bz2|gz)
    }

%prep
    #   unpack Apache distribution
    %setup -q -n httpd-%{version}

%build
    #   configure package
    ( echo "ac_cv_func_uuid_create=no"
    ) >config.cache
    export CC="%{l_cc}"
    export CFLAGS="%{l_cflags -O}"
    export CPPFLAGS="%{l_cppflags}"
    export LDFLAGS="%{l_ldflags}"
    export LIBS=""
    case "%{l_platform -t}" in
        *-sunos* ) LIBS="$LIBS -lrt" ;;
    esac
    ./configure \
        --cache-file=./config.cache \
        --enable-layout=GNU \
        --prefix=%{l_prefix} \
        --with-program-name=apache \
        --sysconfdir=%{l_prefix}/etc/apache \
        --libexecdir=%{l_prefix}/libexec/apache \
        --includedir=%{l_prefix}/include/apache \
        --datadir=%{l_prefix}/share/apache \
        --localstatedir=%{l_prefix}/var/apache \
        --with-apr=%{l_prefix}/bin/apr-1-config \
        --with-apr-util=%{l_prefix}/bin/apu-1-config \
        --with-pcre=%{l_prefix} \
        --disable-threads \
        --disable-shared

    #   build package
    (   cd support
        %{l_make} %{l_mflags} htpasswd htdigest ab
    ) || exit $?

%install
    #   create directories
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/sbin

    #   install utilities
    %{l_shtool} install -c -s -m 755 \
        support/htpasswd $RPM_BUILD_ROOT%{l_prefix}/sbin/apache-htpasswd
    %{l_shtool} install -c -s -m 755 \
        support/htdigest $RPM_BUILD_ROOT%{l_prefix}/sbin/apache-htdigest
    %{l_shtool} install -c -s -m 755 \
        support/ab $RPM_BUILD_ROOT%{l_prefix}/sbin/apache-ab

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

%files -f files

%clean

