Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=xfcetesting.git;a=commitdiff;h=909e865896b30e644668d45f5923c1618b170029

commit 909e865896b30e644668d45f5923c1618b170029
Author: Michel Hermier <[email protected]>
Date:   Wed May 2 22:10:09 2012 +0200

util.sh

* Refactor configure and make as build system, as single utility
functions.
* This is the first patch of a series that will isolate various
build systems into functions. The aim is to have a single function
convention/API, so we can add easily new build system
(Cmake/waf/nant/...) transparently when using Fbuild.
And ultimately remove some build system out of util.sh.

diff --git a/source/include/util.sh b/source/include/util.sh
index fa9e790..f3df8d7 100644
--- a/source/include/util.sh
+++ b/source/include/util.sh
@@ -761,6 +761,35 @@ Fpatchall() {
done
}

+Fbuildsystem_make() {
+       local command="$1"
+       shift
+
+       case "$command" in
+       'probe')
+               test -f GNUmakefile -o -f makefile -o -f Makefile
+               return $?
+               ;;
+       'make')
+               Fexec make $_F_make_opts "$@"
+               return $?
+               ;;
+       'install')
+               if make -p -q DESTDIR="@FDESTDIR@" "$@" install 2>/dev/null | 
grep -v 'DESTDIR\s*=' | \
+                       grep -q 
"@FDESTDIR@\\|\$DESTDIR\\|\$(DESTDIR)\\|\${DESTDIR}" 2>/dev/null; then
+                       _F_make_opts="$_F_make_opts DESTDIR=$Fdestdir"
+               else
+                       _F_make_opts="$_F_make_opts prefix=$Fdestdir/$Fprefix"
+               fi
+               Fexec make $_F_make_opts "$@" install
+               return $?
+               ;;
+       *)
+               return -1
+               ;;
+       esac
+}
+
###
# * Fconfoptstryset(): A utility function that try to append an option to
# $Fconfopts if $_F_conf_configure supports it and is not already used in
@@ -787,19 +816,10 @@ Fconfoptstryset() {
return 0
}

-###
-# * Fconf(): A wrapper to ./configure. It will try to run ./configure,
-# Makefile.PL, extconf.rb and configure.rb, respectively. It will automatically
-# add the --prefix=$Fprefix (defaults to /usr), --sysconfdir=$Fsysconfdir
-# (defaults to /etc) and the --localstatedir=$Flocalstatedir (defaults to /var)
-# switches. The two later will be added only if the configure script support
-# it. If you want to pre-set a switch (i.e. add a switch only on a certain arch
-# or so) append the $Fconfopts variable. Parameter: switch(es) to pass to the
-# configure script.
-###
-Fconf() {
-       Fcd
-       Fmessage "Configuring..."
+Fbuildsystem_configure() {
+       local command="$1"
+       shift
+
if [ -z "$_F_conf_configure" ]; then
_F_conf_configure="./configure"
if [ ! -x "$_F_conf_configure" -a -n "$_F_conf_outsource" ]; then
@@ -807,11 +827,19 @@ Fconf() {
fi
fi

-       if [ ! -e "$_F_conf_configure" ]; then
-               Fautogen
-       fi
-
-       if [ -x "$_F_conf_configure" ]; then
+       case "$command" in
+       'probe')
+               test -x "$_F_conf_configure" -o -f "$_F_conf_configure.ac" -o 
-f "$_F_conf_configure.in"
+               return $?
+               ;;
+       'prepare')
+               if [ ! -e "$_F_conf_configure" ]; then
+                       Fautogen
+                       return $?
+               fi
+               return 0
+               ;;
+       'configure')
Fconfoptstryset "prefix" "$Fprefix"
Fconfoptstryset "sysconfdir" "$Fsysconfdir"
Fconfoptstryset "localstatedir" "$Flocalstatedir"
@@ -819,7 +847,32 @@ Fconf() {
Fconfoptstryset "infodir" "$Finfodir"
Fconfoptstryset "mandir" "$Fmandir"
Fconfoptstryset "build" "$Fbuildchost"
-               Fexec $_F_conf_configure $Fconfopts "$@" || Fdie
+               Fexec $_F_conf_configure $Fconfopts "$@"
+               return $?
+               ;;
+       *)
+               return -1
+               ;;
+       esac
+}
+
+###
+# * Fconf(): A wrapper to ./configure. It will try to run ./configure,
+# Makefile.PL, extconf.rb and configure.rb, respectively. It will automatically
+# add the --prefix=$Fprefix (defaults to /usr), --sysconfdir=$Fsysconfdir
+# (defaults to /etc) and the --localstatedir=$Flocalstatedir (defaults to /var)
+# switches. The two later will be added only if the configure script support
+# it. If you want to pre-set a switch (i.e. add a switch only on a certain arch
+# or so) append the $Fconfopts variable. Parameter: switch(es) to pass to the
+# configure script.
+###
+Fconf() {
+       Fcd
+       Fmessage "Configuring..."
+
+       if Fbuildsystem_configure 'probe'; then
+               Fbuildsystem_configure 'prepare' || Fdie
+               Fbuildsystem_configure 'configure' "$@" || Fdie
elif [ -f Makefile.PL ]; then
if [ -z "$_F_conf_perl_pipefrom" ]; then
Fexec perl Makefile.PL DESTDIR=$Fdestdir "$@" || Fdie
@@ -844,8 +897,8 @@ Fconf() {
Fmake() {
Fconf "$@"
Fmessage "Compiling..."
-       if [ -f GNUmakefile -o -f makefile -o -f Makefile ]; then
-               Fexec make $_F_make_opts || Fdie
+       if Fbuildsystem_make 'probe'; then
+               Fbuildsystem_make 'make' || Fdie
elif [ -f setup.py ]; then
python setup.py build "$@" || Fdie
elif [ -f setup.rb ]; then
@@ -889,14 +942,8 @@ Fnant() {
###
Fmakeinstall() {
Fmessage "Installing to the package directory..."
-       if [ -f GNUmakefile -o -f makefile -o -f Makefile ]; then
-               if make -p -q DESTDIR="@FDESTDIR@" "$@" install 2>/dev/null | 
grep -v 'DESTDIR\s*=' | \
-                       grep -q 
"@FDESTDIR@\\|\$DESTDIR\\|\$(DESTDIR)\\|\${DESTDIR}" 2>/dev/null; then
-                       _F_make_opts="$_F_make_opts DESTDIR=$Fdestdir"
-               else
-                       _F_make_opts="$_F_make_opts prefix=$Fdestdir/$Fprefix"
-               fi
-               Fexec make $_F_make_opts "$@" install || Fdie
+       if Fbuildsystem_make 'probe'; then
+               Fbuildsystem_make 'install' "$@" || Fdie
elif [ -f setup.py ]; then
Fexec python setup.py install --prefix "$Fprefix" --root "$Fdestdir" "$@" || 
Fdie
elif [ -f setup.rb ]; then
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to