#!/bin/bash # # This script will generate a Makefile according to the options one requests. # The Makefile will then allow one to build and install the FastJet contrib. # # See # configure --help # for information about how to use this script #------------------------------------------------------------------------ # the list of contribs supported by this script #------------------------------------------------------------------------ all_contribs=`find . -mindepth 2 -maxdepth 2 -name VERSION -not -print \ | sed 's/\.\///g;s/\/.*$//g' | grep -v "Template"` #------------------------------------------------------------------------ # default values prior to the arg parsing #------------------------------------------------------------------------ only_contribs="" excluded_contribs="" fjconfig="fastjet-config" #------------------------------------------------------------------------ # print a usage message and exit #------------------------------------------------------------------------ # exit code passed as argument: # 0 if it is a normal call # 1 if it is due to a misusage. usage(){ cat 1>&2 <> $makefileinc echo "# $0 $*" >> $makefileinc for arg do case "$arg" in --help|-h) usage 0 ;; --list) echo $all_contribs exit 0 ;; --*=*) arg_name=`option_name $arg` arg_value=`option_value $arg` case $arg_name in prefix) prefix="$arg_value" ;; fastjet_config) fjconfig="$arg_value" ;; only) only_contribs="${arg_value//,/ /}" ;; exclude) excluded_contribs="${arg_value//,/ /}" ;; *) write_error "$arg: unrecognised argument" ;; esac ;; [A-Z]*=*) # variables that go into the $makefileinc echo "$arg" >> $makefileinc ;; *) write_error "$arg is not a recognised argument. Aborting" ;; esac done #------------------------------------------------------------------------ # check for fastjet-config and set up prefix #------------------------------------------------------------------------ # exit if fastjet-config is not found (bad file name or not in path) if ! [ `command -v $fjconfig` ]; then echo $fjconfig" has not been found. Exiting."; exit 1 fi # if prefix has not been set explicitly from command line, set it to # the one returned by 'fastjet-config --prefix' if [ "x"$prefix == "x" ] ; then prefix=`$fjconfig --prefix` fi # generate the rest of $makefileinc echo "FASTJETCONFIG=$fjconfig" >> $makefileinc echo "PREFIX=$prefix" >> $makefileinc echo 'install_script = $(SHELL) ../utils/install-sh' >> $makefileinc echo 'check_script = ../utils/check.sh' >> $makefileinc #------------------------------------------------------------------------ # construct the list of directories to recurse into #------------------------------------------------------------------------ included_contribs="" if [ "x${only_contribs}" == "x" ] ; then included_contribs="$all_contribs" else included_contribs="$only_contribs" fi built_contribs="" if [ "x${excluded_contribs}" == "x" ] ; then built_contribs="$included_contribs" else built_contribs="" for contrib in $included_contribs; do if ! is_in_list $contrib ${excluded_contribs} ; then built_contribs="$built_contribs $contrib" fi done fi #------------------------------------------------------------------------ # create the Makefile #------------------------------------------------------------------------ TAB="$(printf '\t')" # cat >Makefile <Makefile < Makefile #------------------------------------------------------------------------ # write output and config.log file #------------------------------------------------------------------------ echo echo "Configuring fjcontrib version" `cat VERSION` echo echo -e "Enabled contribs: " for contrib in $built_contribs do printf " %-20s v%s\n" $contrib `cat $contrib/VERSION` done echo echo -e "Installation prefix: "$prefix echo "--------------------------------------------------" echo -e "Now run 'make', optionally 'make check', and 'make install'\n" echo -e "This file was created by the fastjet contrib configure on "`date`"\n" > config.log echo -e "The command line invocation was\n" >> config.log echo -e " $0 $@\n" >> config.log for contrib in $built_contribs do printf " %-20s v%s\n" $contrib `cat $contrib/VERSION` >> config.log done echo -e "Installation prefix: "$prefix"\n" >> config.log