# Build mod_jk and nsapi_redirector
#

CC=cc
export CC
CFLAGS="$SUNCC_CFLAGS -O -Xa -KPIC"
export CFLAGS

install -m 755 -d "$RPM_BUILD_ROOT$_libdir/httpd/modules"
install -m 755 -d "$RPM_BUILD_ROOT$_confdir/httpd/conf"
pushd native
./configure --with-apxs="$RPM_ROOT_DIR$_libdir/httpd/build/apxs"
test $? -ne 0 && exit 1
make
test $? -ne 0 && exit 1
install -m 755 apache-2.0/mod_jk.so "$RPM_BUILD_ROOT$_libdir/httpd/modules/"
make clean
popd
$__chrpath -r '.:$ORIGIN/../..' $RPM_BUILD_ROOT$_libdir/httpd/modules/*.so || true
for i in mod_jk.conf.sample workers.properties.sample
do
    install -m 644 $_sourcedir/$i "$RPM_BUILD_ROOT$_confdir/httpd/conf/"
done

SUITSPOT_HOME=""
for i in /opt/SUNWwbsrv70 /opt/SUNWwbsrv61/plugins /opt/SUNWwbsvr /opt/SUNWwbsvr/plugins
do
    if [ -f $i/include/nsapi.h ]
    then
        SUITSPOT_HOME="$i"
        break;
    fi
done
test ".$SUITSPOT_HOME" = . && exit 1

cp Makefile native/netscape/
CFLAGS="$SUNCC_CFLAGS -O -Xa -KPIC"
LDFLAGS="-G -KPIC -dy"
EXTRA_LDDEFINES="-lrt -lsocket -lnsl"
export SUITSPOT_HOME
export EXTRA_LDDEFINES
pushd native/netscape
make CFLAGS="$CFLAGS" EXTRA_CFLAGS="-mt -DHAVE_CONFIG_H" LDFLAGS="$LDFLAGS"
test $? -ne 0 && exit 1
install -m 755 nsapi_redirector.so "$RPM_BUILD_ROOT$_libdir/"
popd

files="$_libdir $_confdir"
files_doc="LICENSE NOTICE native/README.txt"
