Advertisement
Guest User

configure.sh

a guest
Feb 16th, 2011
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.37 KB | None | 0 0
  1. #!/bin/bash -x
  2. BASE_APPS_PREFIX='/opt'
  3.  
  4. slf="$0"
  5. if [ $# -eq 1 -a "$1" = '--help' -o "$1" = '-h' ]; then
  6.  cat <<-"EOHELP"
  7. This is a smplest frontend to standart GNU configure script
  8. Usage: $slf PROGRAM VERSION [new] [noinst] [srclnk] [<configure-parameters>]
  9. Where:
  10. * PROGRAM is a program name and at the same time - name
  11. of subdirectory in $BASE_APPS_PREFIX (so root directory of a newely
  12. installed software will be $BASE_APPS_PREFIX/PROGRAM)
  13. * VERSION is a version of program that will be installed
  14. Keyword 'new' is used to tell this script that it is
  15. necessary to recreate symlink 'current' to point it to
  16. this VERSION of PROGRAM
  17. EOHELP
  18.  ./configure --help
  19.  exit 0
  20. fi
  21.  
  22. { (($#>=2)) && [[ -x ./configure ]]; } || exit 1
  23.  
  24. prg="$1"; shift
  25. ver="$1"; shift
  26. pfx="${BASE_APPS_PREFIX}/$prg/$ver"
  27.  
  28. if (($(id -u)==0)) && make install; then
  29.  while [[ $# > 0 ]]; do
  30.   case "$1" in
  31.   new)
  32.    rm -f    "${BASE_APPS_PREFIX}/$prg"/current
  33.    ln -s $ver   "${BASE_APPS_PREFIX}/$prg"/current
  34.   ;;
  35.   srclnk)
  36.    { [ -d $pfx/Development ] || mkdir -p $pfx/Development; } && \
  37.     { rm -f $pfx/Development/build; ln -s "`pwd`" $pfx/Development/build; }
  38.   ;;
  39.   *) :
  40.   ;;
  41.   esac
  42.   shift  
  43.  done
  44. else
  45.  args="$@"
  46.  cmds="${args%%--*}"
  47.  cfgoption=(
  48.     prefix:${pfx}
  49.     bindir:${pfx}/Binaries/exe
  50.     sbindir:${pfx}/Binaries/exe/sys
  51.     libexecdir:${pfx}/Binaries/exe/sys
  52.     sysconfdir:${pfx}/Configuration
  53.     sharedstatedir:${pfx}/Binaries/com
  54.     localstatedir:${pfx}/DataFiles/dyn
  55.     libdir:${pfx}/Binaries/lib
  56.     includedir:${pfx}/Development/headers
  57.     oldincludedir:${pfx}/Development/headers/old-compilers
  58.     datarootdir:${pfx}/DataFiles/stat
  59.     infodir:${pfx}/Documentation/info
  60.     mandir:${pfx}/Documentation/man-pages
  61.     localedir:${pfx}/DataFiles/stat/locale
  62.     docdir:${pfx}/Documentation/misc
  63.     htmldir:${pfx}/Documentation/html
  64.     dvidir:${pfx}/Documentation/dvi
  65.     pdfdir:${pfx}/Documentation/pdf
  66.     psdir:${pfx}/Documentation/PostScript
  67.  )
  68.  configure_help=$(./configure --help | fgrep -- -- | tr -d '\n')
  69.  
  70.  # datarootdir infodir mandir localedir docdir htmldir dvidir pdfdir psdir
  71.  configure_options=$(
  72.   for ((i=0; i<${#cfgoption[@]}; i++)); do
  73.    opt="${cfgoption[$i]}"
  74.    [[ $configure_help =~ \-\-${opt%%:*} ]] && \
  75.     echo -n '--'"${opt%%:*}=${opt#*:} "
  76.   done
  77.  )
  78.  
  79.  if ./configure $configure_options ${args:${#cmds}} && make && ! [[ $cmds =~ noinst ]]; then
  80.   sudo $0 "$prg" "$ver" $cmds
  81.  fi
  82. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement