# -*- csh -*-
#
#Here are the Shibboleth Build Instructions.
#
#On Solaris:

if ( "x$ATHENA_SYS" == "x" ) then
   echo "ATHENA_SYS not set!"
   exit 1
endif

#
# Build CURL
#
if ( ! $?HAVE_CURL ) then
cd curl-7.10.4 || exit 1
./configure --prefix=/mit/shibboleth/arch/$ATHENA_SYS --with-ssl=/usr/athena
gmake all |& tee -i ../makelog-curl || exit 1
gmake install || exit 1
cd ..
endif


#
# Build libuuid (from e2fsprogs)
#
if ( 0 == 1 ) then
cd e2fsprogs-1.32
./configure --prefix=/mit/shibboleth/arch/$ATHENA_SYS --enable-elf-shlibs \
        --with-cc=gcc --with-linker=gcc
cd lib/uuid
gmake
gmake install
gmake install
mkdir /mit/shibboleth/arch/$ATHENA_SYS/include/uuid
cp uuid.h /mit/shibboleth/arch/$ATHENA_SYS/include/uuid
cd ../../..
endif

#
# Build Xerces-C
#
if ( ! $?HAVE_XERCES ) then
setenv XERCESCROOT /mit/shibboleth/build/@sys/xerces-c-src2_2_0
cd $XERCESCROOT/src/xercesc || exit 1
./runConfigure -psolaris -cgcc -xg++ -minmem -nsocket -tnative -rpthread \
        -P/mit/shibboleth/arch/$ATHENA_SYS || exit 1
gmake all |& tee -i ../../../makelog-xerces || exit 1
gmake install || exit 1
cd ../../..
endif

#
# Build xml-security
#
if ( ! $?HAVE_XSEC ) then
cd xml-security/c/src || exit 1
env CXXFLAGS=-I/usr/athena/include CPPFLAGS=-I/usr/athena/include \
        LDFLAGS=-L/usr/athena/lib ./configure \
        --prefix=/mit/shibboleth/arch/$ATHENA_SYS --without-xalan || exit 1
gmake all |& tee -i ../../../makelog-xmlsec || exit 1
#
# There is no "make install" rule...
#
gtar -C .. -cf - lib include | gtar -C /mit/shibboleth/arch/$ATHENA_SYS -xf -
cd ../../..
endif


#
# Build log4cpp
#
if ( ! $?HAVE_LOG4CPP ) then
cd log4cpp-0.3.2 || exit 1
./configure --prefix=/mit/shibboleth/arch/$ATHENA_SYS || exit 1
gmake all |& tee -i ../makelog-log4cpp || exit 1
gmake install || exit 1
cd ..
endif


#
# Build OpenSAML
#
if ( ! $?HAVE_SAML ) then
cd opensaml/c || exit 1
./configure --prefix=/mit/shibboleth/arch/$ATHENA_SYS \
	--with-xerces=/mit/shibboleth \
        --with-log4cpp=/mit/shibboleth --with-xmlsec=/mit/shibboleth \
        --with-openssl=/usr/athena --with-curl=/mit/shibboleth \
        --disable-libtool-lock || exit 1
gmake config.h
rm -f config.h config.h.in
ln -s ../../../../src/opensaml/c/config.h.in
gmake all |& tee -i ../../makelog-opensaml || exit 1
gmake install || exit 1
cd ../..
endif

#
# Build Apache
#
# follow instructions in /mit/ops/services/apache/doc/how-to-build
#
# ./configure --with-layout=Apache --prefix=/var/https \
#             --enable-module=rewrite --enable-module=so --enable-shared=max \
#	      --enable-rule=SHARED_CORE


#
# Build libapreq
#
if ( ! $?HAVE_APREQ ) then
if ( -d /var/httpd/include ) then
cd libapreq-1.0 || exit 1
./configure --prefix=/mit/shibboleth/arch/$ATHENA_SYS --disable-libtool-lock \
        --with-apache-includes=/var/httpd/include || exit 1
gmake all |& tee -i ../makelog-libapreq || exit 1
gmake install || exit 1
cd ..
endif
endif

#
# Build Shibboleth
#
if ( -f /var/httdp/bin/apxs ) then
  set WITH_HTTP = "--with-apxs=/var/httpd/bin/apxs"
else
  set WITH_HTTP = "--disable-apache-13"
endif

cd shibboleth/c || exit 1
./configure --prefix=/mit/shibboleth/arch/$ATHENA_SYS \
	--with-saml=/mit/shibboleth \
        --with-xerces=/mit/shibboleth --with-log4cpp=/mit/shibboleth \
        --with-xmlsec=/mit/shibboleth --with-openssl=/usr/athena \
	--with-mysql=/mit/mysql $WITH_HTTP --disable-libtool-lock || exit 1
gmake config.h
rm -f config.h config.h.in
ln -s ../../../../src/shibboleth/c/config.h.in
gmake all |& tee -i ../../makelog-shibboleth || exit 1
gmake install || exit 1
cd ../..


#
# Build the MySQL Credential Cache
#
if ( 1 == 0 ) then
cd shib-mysql-ccache
./configure --prefix=/mit/shibboleth/arch/$ATHENA_SYS \
	--with-xerces=/mit/shibboleth \
        --with-mysql=/mit/mysql --with-openssl=/usr/athena --disable-libtool-lock
gmake all |& tee -i ../makelog-mysql
gmake install
cd ..
endif
