ngspice/autogen.sh

228 lines
4.9 KiB
Bash
Raw Normal View History

2000-04-27 22:03:57 +02:00
#!/bin/sh
2010-09-19 20:27:16 +02:00
# Configuration script for ngspice.
#
2010-09-19 20:27:16 +02:00
# This script performs initial configuration of ngspice source
# package.
#
#
2010-09-08 19:14:44 +02:00
# temp-adms.ac: modified configure.ac if --adms is selected
2010-08-18 19:13:26 +02:00
# for temporary use by autoconf, will be deleted automatically
2010-09-08 19:14:44 +02:00
# configure.ac stays untouched
2000-04-27 22:03:57 +02:00
PROJECT=ngspice
2000-04-27 22:03:57 +02:00
# ADMS variables
ADMSDIR=src/spicelib/devices/adms
XMLPATH=src/spicelib/devices/adms/admst
ADMSXML=${ADMSXML:-admsXml}
ADMS=0
# Exit variable
2000-04-27 22:03:57 +02:00
DIE=0
2012-10-29 23:47:02 +01:00
# Check for Mac OS X
uname -a | grep -q "Darwin"
if [ $? -eq 0 ]; then
LIBTOOLIZE=glibtoolize
else
LIBTOOLIZE=libtoolize
fi
help()
{
2010-09-19 20:27:16 +02:00
echo
echo "$PROJECT autogen.sh help"
echo
echo "--adms -a: enables adms feature"
echo "--help -h: print this file"
echo "--version -v: print version"
echo
}
version()
{
2010-09-19 20:27:16 +02:00
echo
echo "$PROJECT autogen.sh 1.0"
echo
}
2010-09-19 20:27:16 +02:00
error_and_exit()
2010-08-01 21:02:23 +02:00
{
2010-09-19 20:27:16 +02:00
echo "Error: $1"
if [ "$ADMS" -eq 1 ]; then
rm -f temp-adms.ac
fi
exit 1
2010-08-01 21:02:23 +02:00
}
2010-08-18 20:08:11 +02:00
check_awk()
{
2010-09-19 20:27:16 +02:00
(awk --version) < /dev/null > /dev/null 2>&1 || {
2010-08-18 20:08:11 +02:00
echo
echo "You must have awk installed to compile $PROJECT with --adms."
exit 1
2010-09-19 20:27:16 +02:00
}
}
check_autoconf()
{
2010-09-19 20:27:16 +02:00
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
2000-04-27 22:03:57 +02:00
echo
echo "You must have autoconf installed to compile $PROJECT."
echo "See http://www.gnu.org/software/automake/"
echo "(newest stable release is recommended)"
2000-04-27 22:03:57 +02:00
DIE=1
2010-09-19 20:27:16 +02:00
}
2000-04-27 22:03:57 +02:00
2012-10-29 23:47:02 +01:00
($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
2000-04-27 22:03:57 +02:00
echo
echo "You must have libtool installed to compile $PROJECT."
echo "See http://www.gnu.org/software/libtool/"
echo "(newest stable release is recommended)"
2000-04-27 22:03:57 +02:00
DIE=1
2010-09-19 20:27:16 +02:00
}
2000-04-27 22:03:57 +02:00
2010-09-19 20:27:16 +02:00
(automake --version) < /dev/null > /dev/null 2>&1 || {
2000-04-27 22:03:57 +02:00
echo
echo "You must have automake installed to compile $PROJECT."
echo "See http://www.gnu.org/software/automake/"
echo "(newest stable release is recommended)"
2000-04-27 22:03:57 +02:00
DIE=1
2010-09-19 20:27:16 +02:00
}
2000-04-27 22:03:57 +02:00
}
check_adms()
{
($ADMSXML --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have admsXml installed to compile adms models."
echo "See http://mot-adms.sourceforge.net"
echo "(newest stable release is recommended)"
DIE=1
2010-09-19 20:27:16 +02:00
}
}
case "$1" in
"--adms" | "-a")
2010-09-19 20:27:16 +02:00
check_adms
ADMS=1
;;
"--help" | "-h")
2010-09-19 20:27:16 +02:00
help
exit 0
;;
"--version" | "-v")
2010-09-19 20:27:16 +02:00
version
exit 0
;;
*)
2010-09-19 20:27:16 +02:00
;;
esac
check_autoconf
2010-09-19 20:27:16 +02:00
if [ "$DIE" -eq 1 ]; then
exit 1
2000-04-27 22:03:57 +02:00
fi
2010-09-19 20:27:16 +02:00
[ -f "DEVICES" ] || {
echo "You must run this script in the top-level $PROJECT directory"
exit 1
2000-04-27 22:03:57 +02:00
}
2010-08-18 19:13:26 +02:00
# only for --adms:
2011-05-19 19:47:40 +02:00
if [ "$ADMS" -gt 0 ]; then
2010-09-19 20:27:16 +02:00
check_awk
# add adms related Makefile entries to a configure.ac style file for
# autoconf and automake
# Find all lines with "#VLAMKF" and put the second token of each line
# into a shell variable
adms_Makefiles=`awk '$1 ~ /#VLAMKF/ { print "./" $2 }' < configure.ac`
# just the same, but escape newlines with '\' for the following sed expression
znew=`awk '$1 ~ /#VLAMKF/ { print " " $2 "\\\\" }' < configure.ac`
# Find "tests/vbic/Makefile" and insert the list of Makefiles
# some sed's fail to process the '\n' escape on the RHS,
# thus use an escaped plain newline
2010-09-19 20:27:16 +02:00
sed \
-e "s,tests\\/vbic\\/Makefile,&\\
$znew
," \
2010-09-19 20:27:16 +02:00
configure.ac > temp-adms.ac
for adms_dir in `ls $ADMSDIR` ; do
if [ -d "$ADMSDIR/$adms_dir" ]; then
case "$adms_dir" in
"admst")
echo "Skipping scripts dir"
;;
*)
echo "Entering into directory: $adms_dir"
echo "-->"$ADMSDIR/$adms_dir
(
cd $ADMSDIR/$adms_dir
$ADMSXML `ls admsva/*.va` -Iadmsva -xv \
-e ../admst/ngspiceVersion.xml \
-e ../admst/ngspiceMakefile.am.xml
2010-09-19 20:27:16 +02:00
)
;;
esac
fi
done
fi
2012-10-29 23:47:02 +01:00
echo "Running $LIBTOOLIZE"
$LIBTOOLIZE --copy --force \
|| error_and_exit "$LIBTOOLIZE failed"
2010-09-17 18:26:06 +02:00
echo "Running aclocal $ACLOCAL_FLAGS"
aclocal $ACLOCAL_FLAGS --force -I m4 \
|| error_and_exit "aclocal failed"
# optional feature: autoheader
2010-09-19 20:27:16 +02:00
(autoheader --version) < /dev/null > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Running autoheader"
autoheader --force \
2010-09-19 20:27:16 +02:00
|| error_and_exit "autoheader failed"
fi
echo "Running automake -Wall --copy --add-missing"
2010-09-19 20:27:16 +02:00
automake -Wall --copy --add-missing \
|| error_and_exit "automake failed"
2011-05-19 19:47:40 +02:00
if [ "$ADMS" -gt 0 ]; then
2010-09-19 20:27:16 +02:00
echo "Running automake for adms"
automake -Wall --copy --add-missing $adms_Makefiles \
|| error_and_exit "automake failed"
2010-08-18 19:13:26 +02:00
fi
2010-08-18 19:13:26 +02:00
echo "Running autoconf"
2011-05-19 19:47:40 +02:00
if [ "$ADMS" -gt 0 ]; then
autoconf --force temp-adms.ac > configure \
2010-09-19 20:27:16 +02:00
|| error_and_exit "autoconf failed, with adms"
rm -f temp-adms.ac
chmod +x configure
2010-08-18 19:13:26 +02:00
else
autoconf --force \
2010-09-19 20:27:16 +02:00
|| error_and_exit "autoconf failed"
2010-08-01 12:28:18 +02:00
fi
echo "Success."
2010-08-01 12:28:18 +02:00
exit 0