_autosetup 4.27 KB
Newer Older
1
#!/bin/sh
2 3
## $Id$

4 5 6 7
## ---------- some portability checks/adjustments [stolen from configure] ----------
## 'echo -n' is not portable..
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
  *c*,-n*) ECHO_N= ECHO_C='
8
' ECHO_T='	' ;;
9 10 11 12
  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
esac
##----------
13

14
## ----------------------------------------------------------------------
15 16
## Check that given command $1 has version >= $2
## Full path $3 may be specified in order to skip command search.
17 18 19
## return 0 if ok, 1 too old or not found  (-> shell conventions).
## ----------------------------------------------------------------------
check_version()
20
{
21 22 23
    dir=`pwd`
    cd /tmp
    foundit=
24
    ## get current version of $1
David Anderson's avatar
David Anderson committed
25
    desired=`echo $2 | awk -F. '{print $1*100+$2}'`
26 27
    echo $ECHO_N "Checking version of '$1' >= $desired... $ECHO_C"
    name=$1
28
    fullpath=${3:-`command -v "$name"`};
29
    if [ -x "$fullpath" ]; then
30
        foundit=yes;
31 32
    fi

33
    if [ "$foundit" != yes ]; then
34 35 36
        echo "Didn't find application";
        version=0
        success=no
37
    else
38 39 40 41 42 43 44 45 46 47 48 49 50 51
        cmdline="$fullpath --version";
        if version=`($cmdline 2>/dev/null)` 2>/dev/null; then
            echo >/dev/null
        else
            version="0";
        fi
        if [ -n "${version}" ]; then
            version=`echo $version | awk '{ for (i=1;i<=NF;i++) { split($i,j,"."); m=j[1]*100+j[2] ; if ((m*1)>0) { print m ; break; } } }'`
            if [ -z "$version" ]; then version=0; fi
            success=`echo "$version" "$desired" | awk '{ if ($1 >= $2) { print "yes";} else {print "no";}} '`
        else
            version=0
            success=no
        fi
52
    fi
53
    cd $dir
54

55 56 57
    if [ $success = "yes" ] ; then
      echo "succeeded. ($version)"
      return 0;
58
    else
59 60
      echo "failed. ($version)"
      return 1;
61 62 63 64
    fi
} ## check_version()


65
  ## --------------------------------------------------------------------------------
66
  ## 'MAIN' starts here
67 68
  ## --------------------------------------------------------------------------------
  echo "Bootstrapping configure script and makefiles:"
69

70
  ## ---------- first check santity of the installed versions of the build-system
71
  ## in case there's GNU drop-in tools available, set these
72

73
  ## some sorry systems don't have proper GNU-make...
74 75 76 77
  if ! check_version make 3.79 "$MAKE"; then
      echo "Couldn't find a new-enough version of GNU 'make', please install one!";
      echo "If you have a newer version, set the environment variable 'MAKE' to its path";
      exit 1;
78
  fi
79

80
  ## FreeBSD's m4 seems to be broken? Download a fresh one
81 82 83 84
  if ! check_version m4 1.4 "$M4" && [ ! -f /usr/ccs/bin/m4 ] && ! check_version gm4 1.4; then
     echo "Couldn't find a new-enough version of 'm4', please install one!";
     echo "If you have a newer version, set the environment variable 'M4' to its path";
     exit 1;
85
  fi
86

87
  if ! check_version pkg-config 0.15; then
88 89 90 91
      echo "Couldn't find a new-enough version of 'pkg-config', please install one!";
      exit 1;
      # build_lsc_aux "pkgconfig-0.15.0"
  fi
92

93
  if ! check_version autoreconf 2.58; then
94
      echo "Couldn't find a new-enough version of 'autoreconf', please install one!";
95 96 97
      exit 1;
      # build_lsc_aux "autoconf-2.59"
  fi
98
  if ! check_version automake 1.8 "$AUTOMAKE"; then
99
      echo "Couldn't find a new-enough version of 'automake', please install one!";
100
      echo "If you have a newer version, set the environment variable 'AUTOMAKE' and 'ACLOCAL' to its path";
101 102 103
      exit 1;
      # build_lsc_aux "automake-1.8.5"
  fi
104
  if ! check_version libtoolize 1.5 "$LIBTOOLIZE"; then
105 106 107 108
      echo "Couldn't find a new-enough version of 'libtoolize', please install one!";
      echo "If you have a newer version, set the environment variable 'LIBTOOLIZE' to its path";
      exit 1;
  fi
109

110
  ## ---------- now run autoreconf
111
  cmdline="autoreconf -i";
112
  ## -- if _autosetup was invoked with -f run autoreconf with -f to force a recreation of all files
113
  if [ "$1" = "-f" ]; then
114 115
    cmdline="autoreconf -i -f";
  fi
116

117 118 119 120 121
echo "$cmdline"
if eval $cmdline; then
    echo "Done, now run ./configure"
    echo " ./configure -C                         to enable caching"
    exit 0
Karl Chen's avatar
Karl Chen committed
122
else
123 124 125
    echo "Something failed .... please check error-message and re-run when fixed."
    echo "exiting..."
    exit 1
Karl Chen's avatar
Karl Chen committed
126
fi