Refactoring of configure scripts.

* Move default values to auto/default
 * Get configuration from environment
 * Add --quiet switch to hide summary
This commit is contained in:
Mateusz Hromada 2009-06-06 13:08:46 +02:00
parent f7b30b9fc6
commit 63a5739817
4 changed files with 107 additions and 56 deletions

38
auto/defaults Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
DEFAULT_PROJECT_NAME='utt'
DEFAULT_PROJECT_FULLNAME='UAM Text Tools'
DEFAULT_PROJECT_COPYRIGHT='Copyright (C) UTT Team'
DEFAULT_PROJECT_VERSION='0.9.3'
DEFAULT_PROJECT_PAGE='http://utt.wmi.amu.edu.pl'
DEFAULT_PROJECT_MAIL='utt@wmid.amu.edu.pl'
DEFAULT_SHELL='/bin/sh'
DEFAULT_CC='/usr/bin/gcc'
DEFAULT_BISON='/usr/bin/bison'
DEFAULT_RM='/bin/rm -f'
DEFAULT_RMDIR='/bin/rm -rf'
DEFAULT_TEST='/usr/bin/test'
DEFAULT_MAKE='/usr/bin/make'
DEFAULT_GREP='/bin/grep'
DEFAULT_CUT='/usr/bin/cut'
DEFAULT_SORT='/usr/bin/sort'
DEFAULT_PR='/usr/bin/pr'
DEFAULT_CFLAGS='-g -O2 -Wall'
DEFAULT_LDFLAGS=''
DEFAULT_LDLIBS=''
DEFAULT_BFLAGS=''
DEFAULT_DESTDIR=
DEFAULT_prefix='/usr/local'
DEFAULT_exec_prefix='$(prefix)'
DEFAULT_bindir='$(exec_prefix)/bin'
DEFAULT_sbindir='$(exec_prefix)/sbin'
DEFAULT_datarootdir='$(prefix)/share'
DEFAULT_datadir='$(datarootdir)'
DEFAULT_sysconfdir='$(prefix)/etc'
DEFAULT_sharedstatedir='$(prefix)/com'
DEFAULT_localstatedir='$(prefix)/var'

View File

@ -1,42 +1,43 @@
#!/bin/sh #!/bin/sh
help=no help=no
quiet=no
PROJECT_NAME='utt' if [ -z "$PROJECT_NAME" ]; then PROJECT_NAME=$DEFAULT_PROJECT_NAME; fi
PROJECT_FULLNAME='UAM Text Tools' if [ -z "$PROJECT_FULLNAME" ]; then PROJECT_FULLNAME=$DEFAULT_PROJECT_FULLNAME; fi
PROJECT_COPYRIGHT='Copyright (C) UTT Team' if [ -z "$PROJECT_COPYRIGHT" ]; then PROJECT_COPYRIGHT=$DEFAULT_PROJECT_COPYRIGHT; fi
PROJECT_VERSION='0.9.3' if [ -z "$PROJECT_VERSION" ]; then PROJECT_VERSION=$DEFAULT_PROJECT_VERSION; fi
PROJECT_PAGE='http://utt.wmi.amu.edu.pl' if [ -z "$PROJECT_PAGE" ]; then PROJECT_PAGE=$DEFAULT_PROJECT_PAGE; fi
PROJECT_MAIL='utt@wmid.amu.edu.pl' if [ -z "$PROJECT_MAIL" ]; then PROJECT_MAIL=$DEFAULT_PROJECT_MAIL; fi
SHELL='/bin/sh' if [ -z "$SHELL" ]; then SHELL=$DEFAULT_SHELL; fi
CC='/usr/bin/gcc' if [ -z "$CC" ]; then CC=$DEFAULT_CC; fi
BISON='/usr/bin/bison' if [ -z "$BISON" ]; then BISON=$DEFAULT_BISON; fi
RM='/bin/rm -f' if [ -z "$RM" ]; then RM=$DEFAULT_RM; fi
RMDIR='/bin/rm -rf' if [ -z "$RMDIR" ]; then RMDIR=$DEFAULT_RMDIR; fi
TEST='/usr/bin/test' if [ -z "$TEST" ]; then TEST=$DEFAULT_TEST; fi
MAKE='/usr/bin/make' if [ -z "$MAKE" ]; then MAKE=$DEFAULT_MAKE; fi
GREP='/bin/grep' if [ -z "$GREP" ]; then GREP=$DEFAULT_GREP; fi
CUT='/usr/bin/cut' if [ -z "$CUT" ]; then CUT=$DEFAULT_CUT; fi
SORT='/usr/bin/sort' if [ -z "$SORT" ]; then SORT=$DEFAULT_SORT; fi
PR='/usr/bin/pr' if [ -z "$PR" ]; then PR=$DEFAULT_PR; fi
CFLAGS='-g -O2 -Wall' if [ -z "$CFLAGS" ]; then CFLAGS=$DEFAULT_CFLAGS; fi
LDFLAGS='' if [ -z "$LDFLAGS" ]; then LDFLAGS=$DEFAULT_LDFLAGS; fi
LDLIBS='' if [ -z "$LDLIBS" ]; then LDLIBS=$DEFAULT_LDLIBS; fi
BFLAGS='' if [ -z "$BFLAGS" ]; then BFLAGS=$DEFAULT_BFLAGS; fi
DESTDIR= if [ -z "$DESTDIR" ]; then DESTDIR=$DEFAULT_DESTDIR; fi
prefix='/usr/local' if [ -z "$prefix" ]; then prefix=$DEFAULT_prefix; fi
exec_prefix='$(prefix)' if [ -z "$exec_prefix" ]; then exec_prefix=$DEFAULT_exec_prefix; fi
bindir='$(exec_prefix)/bin' if [ -z "$bindir" ]; then bindir=$DEFAULT_bindir; fi
sbindir='$(exec_prefix)/sbin' if [ -z "$sbindir" ]; then sbindir=$DEFAULT_sbindir; fi
datarootdir='$(prefix)/share' if [ -z "$datarootdir" ]; then datarootdir=$DEFAULT_datarootdir; fi
datadir='$(datarootdir)' if [ -z "$datadir" ]; then datadir=$DEFAULT_datadir; fi
sysconfdir='$(prefix)/etc' if [ -z "$sysconfdir" ]; then sysconfdir=$DEFAULT_sysconfdir; fi
sharedstatedir='$(prefix)/com' if [ -z "$sharedstatedir" ]; then sharedstatedir=$DEFAULT_sharedstatedir; fi
localstatedir='$(prefix)/var' if [ -z "$localstatedir" ]; then localstatedir=$DEFAULT_localstatedir; fi
for option for option
do do
@ -48,6 +49,7 @@ do
case "$option" in case "$option" in
--help) help=yes ;; --help) help=yes ;;
--quiet) quiet=yes ;;
--prefix=*) prefix="$value" ;; --prefix=*) prefix="$value" ;;
--exec-prefix=*) exec_prefix="$value" ;; --exec-prefix=*) exec_prefix="$value" ;;

View File

@ -1,35 +1,45 @@
#!/bin/sh #!/bin/sh
if [ "$quiet" = "yes" ]; then return; fi
cat << SUMMARY_END cat << SUMMARY_END
Project name : $PROJECT_NAME
Project fullname : $PROJECT_FULLNAME
Project copyright : $PROJECT_COPYRIGHT
Project version : $PROJECT_VERSION
Project page : $PROJECT_PAGE
Project mail : $PROJECT_MAIL
Configuration summary Configuration summary
prefix : $prefix DESTDIR : $DESTDIR
exec-prefix : $exec_prefix
bindir : $bindir
sbindir : $sbindir
datarootdir : $datarootdir
datadir : $datadir
sysconfdir : $sysconfdir
sharedstatedir : $sharedstatedir
localstatedir : $localstatedir
SHELL : $SHELL prefix : $prefix
CC : $CC exec_prefix : $exec_prefix
BISON : $BISON bindir : $bindir
RM : $RM sbindir : $sbindir
RMDIR : $RMDIR datarootdir : $datarootdir
TEST : $TEST datadir : $datadir
MAKE : $MAKE sysconfdir : $sysconfdir
GREP : $GREP sharedstatedir : $sharedstatedir
CUT : $CUT localstatedir : $localstatedir
SORT : $SORT
PR : $PR
CFLAGS : $CFLAGS SHELL : $SHELL
LDFLAGS : $LDFLAGS CC : $CC
LDLIBS : $LDLIBS BISON : $BISON
BFLAGS : $BFLAGS RM : $RM
RMDIR : $RMDIR
TEST : $TEST
MAKE : $MAKE
GREP : $GREP
CUT : $CUT
SORT : $SORT
PR : $PR
CFLAGS : $CFLAGS
LDFLAGS : $LDFLAGS
LDLIBS : $LDLIBS
BFLAGS : $BFLAGS
SUMMARY_END SUMMARY_END

1
configure vendored
View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
. ./auto/defaults
. ./auto/options . ./auto/options
if [ -f ./src/config.h ]; then if [ -f ./src/config.h ]; then