Solución: hacer una compilación fuera de la fuente
- Como se sugiere en los comentarios, puede hacer una compilación fuera de la fuente.
- El principio es: crear otro directorio, un "árbol de compilación", ejecutar el script de configuración desde ese directorio (con ruta relativa o absoluta).
Ejemplo con verificación automatizada
Por ejemplo, esto buscará y creará GNU hello y comprobará que el árbol de origen no se modifique un poco.
Preparación del árbol fuente
Esta parte recupera y prepara los directorios.
{
wget -S http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
tar zxvf hello-2.10.tar.gz
mv hello-2.10 hello-2.10-pristine
tar zxvf hello-2.10.tar.gz
diff -urq hello-2.10 hello-2.10-pristine && echo "Before build, directories are identical."
cd hello-2.10
}
Parte genérica: reutilícela en su proyecto
Esta parte se puede usar con otros proyectos basados en autoconf. Simplemente cd en su proyecto antes de ejecutar. Cuidado: esto funciona rm
, si juegas con variantes ten cuidado, eres responsable en cualquier caso.
export MYPREFIX="${PWD}.installtree"
(
set -eu # abort on error
ls configure # make sure it aborts if not in correct directory
export SRCTREE="${PWD}"
export BUILDTREE="${PWD}.buildtree"
rm -rf "$BUILDTREE" "$MYPREFIX"
mkdir "$BUILDTREE" "$MYPREFIX"
cd "$BUILDTREE"
"${SRCTREE}"/configure --prefix="${MYPREFIX?}"
time make -k || time make
time make install
)
Comprobar parte
Esto comprueba si la compilación está perfectamente fuera de la fuente.
{
ls "$MYPREFIX"/bin/hello && echo "Okay, build generated the target."
cd "$MYPREFIX"/..
diff -urq hello-2.10 hello-2.10-pristine && echo "No change at all. Perfect out-of-source build success."
}
Aquí da salida a esto:
/tmp/hello-2.10.installtree/bin/hello
Okay, build generated the target.
No change at all. Perfect out-of-source build success.
Bonificación: instalación no root
La --prefix="${MYPREFIX?}"
parte de arriba es opcional. Permite hacer una "instalación de instalación" que es local para su cuenta. Si desea la tradicional "sudo make install" en una ubicación de todo el sistema, puede eliminarla --prefix="${MYPREFIX?}"
.