The algorithm for updating the cmake-less build files on a system very
similar to the target but with cmake available is roughly as follows:

Compile cdrkit with:

rm -rf cdrkit-1.1.10
tar xzf cdrkit-1.1.10.tar.gz
cd cdrkit-1.1.10

PATH=~/cmake/bin:$PATH strace -o ../strace.log -fFvs 999 -e execve make PREFIX=~/cdrkit CFLAGS=-O0

Process the build directories and the strace log with:

cat > ../cdrkit-build << EOF
set -ex
SRCDIR=\`pwd\`
EOF
find build -type d \( -name '*.dir' -o -name diag -o -name stdio \) | LC_COLLATE=C sort -r | sed -nr '/cmTryCompileExec/d; s/^/mkdir -p /; G; /^(.*)\n\1/d; P; s/\n[^\n]*$//; h' >> ../cdrkit-build
sed -e '/cmTryCompileExec\|CMakeCCompilerId/d' -e "s,`pwd`,\$SRCDIR,g" -nre '\!^[0-9]+ +execve\("/usr/bin/(gcc|ar)", \["/usr/bin/(gcc|ar)", ! { s/^[^,]*, //; s,/usr/bin/gcc,$CC,; s,/usr/bin/ar,$AR,; s/-O0/$CFLAGS/; s/[",]//g; s/^\[([^]]+)\].* PWD=([^ ]+) .*$/cd \2; \1/; G; /^([^;]*; )[^\n]*\n\1/ { s/^[^;]*; ([^\n]*)\n.*$/\1/p; d; }; P; s/\n[^\n]*$//; h }' < ../strace.log >> ../cdrkit-build

This captures the current directory paths left over by the shell in $PWD
of processes other than the shell.  Luckily, this is good enough for us.
The "-v" option to strace is crucial for this to work.

From the cmake-enabled build, save two files:

mkdir ../cdrkit-h
cp -av build/include/{align,xconfig}.h ../cdrkit-h

NB: These files will differ on 32- vs. 64-bit systems!  xconfig.h might
also differ on little- vs. big-endian.

Proceed with the temporary install:

mkdir ~/cdrkit
PATH=~/cmake/bin:$PATH make install PREFIX=~/cdrkit

Find the installed files:

exec 3> ../cdrkit-files
pushd ~/cdrkit
find . -type f -printf '%P %m\n' | LC_COLLATE=C sort >&3
popd
exec 3<&-

Find the same files in the build tree, creating an install script:

echo 'set -ex' > ../cdrkit-install
sed -n 's,^bin,$BINDIR,p; s,^sbin,$SBINDIR,p; s,^share/man,$MANDIR,p' < ../cdrkit-files | while read f m; do echo "install -pDm $m `find . -type f -name $(basename $f) -printf '%P\n' | head -1` \$DESTDIR$f"; done >> ../cdrkit-install
echo 'ln -s cdda2ogg $DESTDIR$BINDIR/cdda2mp3' >> ../cdrkit-install

That's all - the scripts are ready.  Now to test them:

cd ..
rm -rf cdrkit-1.1.10
tar xzf cdrkit-1.1.10.tar.gz
cd cdrkit-1.1.10

mkdir -p build/include
cp -av ../cdrkit-h/*.h build/include
CC=gcc AR=ar CFLAGS='-O2 -fomit-frame-pointer' sh ../cdrkit-build
mkdir ../cdrkit-myinst
DESTDIR=../cdrkit-myinst BINDIR=/usr/bin SBINDIR=/usr/sbin MANDIR=/usr/share/man sh ../cdrkit-install

$Owl: Owl/packages/cdrkit/README-cmakeless,v 1.4 2010/08/23 21:42:40 solar Exp $
