#!/bin/sh
##**************************************************************
##
## Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
## University of Wisconsin-Madison, WI.
## 
## Licensed under the Apache License, Version 2.0 (the "License"); you
## may not use this file except in compliance with the License.  You may
## obtain a copy of the License at
## 
##    http://www.apache.org/licenses/LICENSE-2.0
## 
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
##**************************************************************

# This script builds the new ClassAd library
# It is meant to be given to the Condor external build system
# It is unlikely that anyone will want to use it. 
# This script is renamed to something like build_classads-0.9.7

cd $PACKAGE_BUILD_DIR/$PACKAGE_NAME/

##### Configure and Build ClassAds #####

# Why --without-pcre?  Because if we want to link to PCRE, we should
# explicitly define PCRE as an external dependency, and we should
# explicitly point at that version.  Also, all other things that link
# with classads must then link with pcre as well (e.g. blahp external).

./configure --without-pcre --disable-shared --enable-static --enable-namespace --prefix=$PACKAGE_INSTALL_DIR CC=g++
if [ $? -ne 0 ]
then
    echo "Configure failed"
    exit 1
fi

make
if [ $? -ne 0 ]
then
    echo "Build failed"
    exit 1
fi

##### Test the ClassAd build #####
#./classad_unit_tester
#if [ $? -ne 0 ]
#then
#    echo "Unit tests failed"
#    exit 2
#fi
#
#./classad_functional_tester functional_tests.txt
#if [ $? -ne 0 ]
#then
#    echo "Functional tests failed"
#    exit 2
#fi
make check
if [ $? -ne 0 ]
then
    echo "make check"
    exit 2
fi

##### Install the ClassAd build #####
make install
if [ $? -ne 0 ]
then
    echo "Install failed"
    exit 3
fi

exit 0
