1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
#!/bin/sh -f
do_nothing() {
return 0;
}
device () {
df -k $1 | grep -v '^Filesystem' | awk '{print $1;}'
}
inumber () {
ls -id "$1" | awk '{print $1;}'
}
#
# This function returns:
# 0 if the files are identical,
# 100 if either of the parameters are the empty string.
# 101 if either of the parameters does not name a directory
# 102 if both parameters name different directories.
#
files_are_equal() {
local inode1 inode2 dev1 dev2
if [ -z "$1" ] || [ -z "$2" ] ; then
return 100;
fi
#
# For the purposes of this script, if either directory
# does not exist, then they are not equal.
#
if [ ! -d "$1" ] || [ ! -d "$2" ] ; then
return 101
fi
inode1=`inumber $1`
inode2=`inumber $2`
dev1=`device $1`
dev2=`device $2`
[ "$dev1" = "$dev2" ] && [ "$inode1" = "$inode2" ] && return 0
return 102
}
rm="/bin/rm -rf"
DONE=NO
DO_CONFIGURE=NO
DO_BUILD=NO
DO_CLEAN=NO
DO_GENERATE=NO
BUILD_DIRECTORY=build
MAKE_HISTORY_FILE=make.hst
CONFIGURE_OPTIONS=
BUILD_IS_DOT=NO
while [ ! -z "$1" ] && [ "$DONE" != YES ] ; do
case "$1" in
--help)
echo 'usage: chores.3dfx [options]'
echo ' Handle some 3dfx specific configuration chores'
echo 'Options:'
echo ' --help This note.'
echo ' --clean Delete some files in the source'
echo ' directory. Since we do not generally'
echo ' run make in the source directory,'
echo ' the "make clean" rules are not so'
echo ' useful there. The files deleted'
echo ' are:'
echo ' configure,'
echo ' makefile.autoconf.{in},'
echo ' aclocal.m4'
echo ' *~, #*#, xx, yy, zz'
echo ' Note that you need to put local macros'
echo ' in acinclude.m4, not aclocal.m4. The'
echo ' former is included in the latter.'
echo ' --debug-build Add configuration option for a'
echo ' debug build.'
echo ' --texus2 Add configuration option to use'
echo ' the texus2 library. (Do not use this'
echo ' unless you know what you are doing.)'
echo ' --architecture=arch Configure for the given architecture.'
echo ' Equivalent to giving'
echo ' --enable-build-architecture=arch'
echo ' to "configure".'
echo ' --generate: Generate configure script and'
echo ' makefile.autoconf.in files.'
echo ' This is essentially just:'
echo ' aclocal; automake; autoconf'
echo ' --build-dir=dir'
echo ' Set the build directory to dir.'
echo ' --configure="configure options"'
echo ' Configure in the build directory'
echo ' with the given options.'
echo ' NOTE: this will delete and recreate'
echo ' your build directory if it'
echo ' exists.'
echo ' --build[=dirname] Build in the given build directory.'
echo ' o The default directory name is'
echo ' named "build".'
echo ' o The directory does not need to'
echo ' be a subdirectory of the source'
echo ' directory.'
echo ' This option is equivalent to specifying'
echo ' --build-directory=dirname --build'
echo ''
echo 'Note that the operations are done in logical order, not'
echo 'in the order that the operations are specified on the'
echo 'command line.'
echo ''
exit 100
;;
--debug-build)
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --enable-fx-debug"
shift
;;
--texus2)
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --enable-fx-texlib=texus2"
shift
;;
--generate)
DO_GENERATE=YES
shift
;;
--arch*=*)
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --enable-build-architecture=`echo $1 | sed 's/--arch[^=]*=//'`"
shift
;;
--configure)
DO_CONFIGURE=YES
shift
;;
--configure=*)
DO_CONFIGURE=YES
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS `echo $1 | sed 's/--configure=//'`"
shift
;;
--build-dir*=*)
BUILD_DIRECTORY=`echo $1 | sed 's/--build-dir[^=]*=//'`
shift
;;
--build=*)
DO_BUILD=YES
BUILD_DIRECTORY=`echo $1 | sed 's/--build=//'`
shift
;;
--build)
DO_BUILD=YES
shift
;;
--clean)
DO_CLEAN=YES
shift
;;
--make-hst=*)
MAKE_HISTORY_FILE=`echo "$1" | sed 's/--make-hst=//'`
shift
;;
*)
echo "chores.3dfx: Unknown command line parameter $1"
exit 100
;;
esac
done
if [ "$DO_CLEAN" = YES ] ; then
#
# Remove detritus.
#
echo -n 'Removing detritus...'
find . '(' -name config.cache -o -name config.status -o -name build.3dfx -o -name config.h -o -name stamp-h -name config.log -o -name aclocal.m4 -o -name configure -o -name '*~' -o -name '#*#' -o -name makefile.autoconf.in -o -name xx -o -name yy -o -name zz ')' -a -exec $rm {} \;
echo 'Done'
fi
if [ "$DO_GENERATE" = YES ] ; then
#
# Regenerate everything.
#
echo -n 'Regenerating everything...'
echo -n 'Libtoolize...'
if libtoolize --copy --force ; then
do_nothing
else
echo 'Failed!!'
exit 100
fi
echo -n 'Aclocal...'
if aclocal ; then
do_nothing
else
echo 'Failed!!'
exit 100
fi
echo -n 'Automake...'
if automake -a -f -c; then
do_nothing
else
echo 'Failed!!'
exit 100
fi
echo -n 'Autoconf...'
if autoconf ; then
do_nothing
else
echo 'Failed!!'
exit 100
fi
echo 'Done.'
fi
#
# See if the build directory is the current directory.
#
if files_are_equal "${PWD}" "${BUILD_DIRECTORY}" ; then
BUILD_IS_DOT=YES
fi
if [ "$DO_CONFIGURE" = YES ] ; then
if [ "$BUILD_IS_DOT" = NO ] ; then
#
# Get rid of the build directory.
#
echo -n 'Getting rid of the old build directory...'
/bin/rm -rf $BUILD_DIRECTORY
echo 'Done.'
else
echo 'Old build directory is current directory.'
fi
if [ ! -d "$BUILD_DIRECTORY" ] ; then
#
# Now, make a build directory, and configure in it.
#
echo -n "Making build directory $BUILD_DIRECTORY..."
mkdir -p $BUILD_DIRECTORY
echo 'Done'
fi
#
# Configure.
#
echo -n "Configuring..."
SRCDIR="${PWD}"
(cd $BUILD_DIRECTORY; ${SRCDIR}/configure --quiet $CONFIGURE_OPTIONS)
echo 'Done.'
fi
if [ "$DO_BUILD" = YES ] ; then
#
# Build in it.
#
cd $BUILD_DIRECTORY
./build.3dfx all | tee $MAKE_HISTORY_FILE
fi
|