# This file is part of the src2pkg program: # Copyright 2005-2008 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ### configure_source configure_source() { if [[ "$FAILED" = "" ]] ; then if [[ "$CONFIG_COMMAND" = "skip" ]] ; then echo $BLUE"Skipped configure_source - "$NORMAL CONFIG_DIR=$SRC_DIR else # find the main configuration directory if [[ $CONFIG_SUBDIR ]] ; then CONFIG_DIR=$SRC_DIR/$CONFIG_SUBDIR else for keydir in $SRC_DIR $SRC_DIR/src $SRC_DIR/Src $SRC_DIR/source $SRC_DIR/$NAME-$VERSION $SRC_DIR/$NAME $SRC_DIR/$NAMElib $SRC_DIR/lib$NAME $SRC_DIR/$VERSION $SRC_DIR/abi ; do for keyfile in configure CMakeLists.txt Makefile configure.in configure.ac Makefile.in Makefile.am autogen.sh bootstrap.sh GNUmakefile GNUmakefile.in GNUmakefile.am Imakefile imakefile SConstruct makefile Jamfile install.sh setup.py Makefile.PL ; do if [[ -e $keydir/$keyfile ]] ; then CONFIG_SUBDIR=$keydir KEYFILE="$keyfile" break ; fi done if [[ $CONFIG_SUBDIR ]] ; then CONFIG_DIR=$keydir break ; fi if [[ $CONFIG_DIR ]] ; then CONFIG_DIR=$keydir break ; fi done fi [[ $DEBUG ]] && echo $BLUE"Using keyfile: "$NORMAL"$KEYFILE" ! [[ "$CONFIG_DIR" ]] && CONFIG_DIR=$SRC_DIR if [[ "$CONFIG_DIR" != "$SRC_DIR" ]] ; then FUNNY_SUBDIR=$(basename $CONFIG_DIR) echo $BLUE"Notice - "$NORMAL"The configuration files are in a subdirectory: $FUNNY_SUBDIR" ! [[ $USE_OBJ_DIR ]] && OBJ_DIR=$CONFIG_DIR fi ! [[ $USE_OBJ_DIR ]] && [[ ! $OBJ_DIR ]] && OBJ_DIR=$CONFIG_DIR # If there are GNUmakefile.in or GNUmakefile.am files *and* a Makefile we have to get # rid of the Makefile as it would take precedence over the generated GNUmakefile if [[ -e $CONFIG_DIR/GNUmakefile.in ]] && [[ -e $CONFIG_DIR/Makefile ]] ; then echo $BLUE"Notice - "$NORMAL"This packages uses GNUmakefiles, instead of Makefiles." if ! [[ $USE_DEFAULT_MAKEFILES = "YES" ]] ; then MAKEFILE="GNUmakefile" #if [[ -e $CONFIG_DIR/Makefile ]] ; then echo "We rename the Makefile to Makefile.found and start fresh." echo "If not, the Makefile would be used instead of the new GNUmakefile." mv $CONFIG_DIR/Makefile $CONFIG_DIR/Makefile.found #fi fi elif [[ -e $CONFIG_DIR/Makefile.in ]] && [[ -e $CONFIG_DIR/GNUmakefile ]] ; then # If there are Makefile.in or Makefile.am files *and* a GNUmakefile we have to get # rid of the GNUmakefile as it might take precedence over the generated Makefile echo $BLUE"Notice - "$NORMAL"This packages contains both a Makefile.in and a GNUmakefile." if ! [[ $USE_DEFAULT_MAKEFILES = "YES" ]] ; then MAKEFILE="Makefile" #if [[ -e $CONFIG_DIR/Makefile ]] ; then echo "We rename the GNUmakefile to GNUmakefile.found and start fresh." echo "If not, the GNUmakefile might be used instead of the new Makefile." mv $CONFIG_DIR/GNUmakefile $CONFIG_DIR/GNUmakefile.found #fi fi fi if [[ -e $CONFIG_DIR/makefile ]] ; then MAKEFILE="makefile" elif [[ -e $CONFIG_DIR/GNUmakefile ]] || [[ -e $CONFIG_DIR/GNUmakefile.am ]] || [[ -e $CONFIG_DIR/GNUmakefile.in ]] ; then MAKEFILE="GNUmakefile" elif [[ -e $CONFIG_DIR/Makefile ]] || [[ -e $CONFIG_DIR/Makefile.am ]] || [[ -e $CONFIG_DIR/Makefile.in ]] ; then MAKEFILE="Makefile" fi # moved here from compile_source. Some sources will be 'de-configured' if 'make clean' is run after configuration make clean &> /dev/null if [[ $PATCHES_APPLIED ]] && [[ $SHOULD_AUTORECONF ]] && [[ "$AUTORECONF" != "NO" ]] ; then echo $CYAN"NOTICE - "$NORMAL"'.am', '.ac' or '.in' config files were patched" #echo " You can disable this with AUTORECONF=NO if necessary." cd $CONFIG_DIR ; if [[ -f autogen.sh ]] ; then echo -n $BLUE"Regenerating config files - "$NORMAL"Using: autogen.sh" sh ./autogen.sh &> /dev/null echo $GREEN"Done!"$NORMAL else echo -n $BLUE"Regenerating config files - "$NORMAL"Using: autoreconf -if " autoreconf --install --force &> /dev/null autoconf &> /dev/null echo $GREEN"Done!"$NORMAL fi fi if ! [[ -x $CONFIG_DIR/configure ]] ; then if [[ -e $CONFIG_DIR/configure.in ]] || [[ -e $CONFIG_DIR/configure.ac ]] ; then if [[ -e $CONFIG_DIR/$MAKEFILE.in ]] || [[ -e $CONFIG_DIR/$MAKEFILE.am ]] ; then echo $BLUE"Found incomplete autoconf sources - "$NORMAL if [[ -e $CONFIG_DIR/autogen.sh ]] ; then echo -n $BLUE"Found an autogen.sh script - "$NORMAL "We'll try running that - " cd $CONFIG_DIR ; sh ./autogen.sh &> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL echo -n $BLUE"Now we'll try running autoconf - "$NORMAL autoconf 2> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL elif [[ -e $CONFIG_DIR/bootstrap.sh ]] ; then echo -n $BLUE"Found a bootstrap.sh script - "$NORMAL" We'll try running that - " cd $CONFIG_DIR ; sh ./bootstrap.sh &> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL echo -n $BLUE"Now we'll try running autoconf - "$NORMAL autoconf 2> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL elif [[ -e $CONFIG_DIR/bootstrap ]] ; then echo -n $BLUE"Found a bootstrap script - "$NORMAL" We'll try running that - " cd $CONFIG_DIR ; sh ./bootstrap &> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL echo -n $BLUE"Now we'll try running autoconf - "$NORMAL autoconf 2> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL elif [[ -e $CONFIG_DIR/$MAKEFILE.in ]] && [[ -e $CONFIG_DIR/$MAKEFILE.am ]] ; then echo -n $BLUE"Found autoconf files. "$NORMAL"We'll try running autoconf - " cd $CONFIG_DIR ; autoconf 2> /dev/null && echo $GREEN"Done"$NORMAL || echo $YELLOW"FAILED!"$NORMAL elif [[ -e $CONFIG_DIR/$MAKEFILE.am ]] ; then echo -n $BLUE"Generating autoconf files - "$NORMAL"Running 'autoreconf -if' " cd $CONFIG_DIR ; autoreconf -if &> /dev/null autoconf &> /dev/null echo $GREEN"Done!"$NORMAL fi fi fi fi # if all else fails try this generic routine. if ! [[ -x $CONFIG_DIR/configure ]] && [[ -e $CONFIG_DIR/$MAKEFILE.am ]] && [[ -e $CONFIG_DIR/$MAKEFILE.in ]] ; then if [[ -e $CONFIG_DIR/configure.ac ]] || [[ -e $CONFIG_DIR/configure.in ]] ; then echo $BLUE"Found Makefile.am and configure.in. "$NORMAL"We'll try with these generic commands:" echo "aclocal -I. ; autoheader ; automake -a --force --copy --foreign ; autoconf" [[ -d $CONFIG_DIR/autom4te.cache ]] && rm -rf $CONFIG_DIR/autom4te.cache [[ -d $CONFIG_DIR/.deps ]] && rm -rf $CONFIG_DIR/.deps [[ -f $CONFIG_DIR/.deps ]] && rm -f $CONFIG_DIR/.deps [[ -f $CONFIG_DIR/config.status ]] && rm -f $CONFIG_DIR/config.status [[ -f $CONFIG_DIR/config.cache ]] && rm -f $CONFIG_DIR/config.cache cd $CONFIG_DIR ; # automake aclocal -I . 2> /dev/null 1> /dev/null autoheader 2> /dev/null 1> /dev/null # automake --add-missing --copy --foreign 2> /dev/null 1> /dev/null automake -a --force --copy --foreign 2> /dev/null 1> /dev/null autoconf 2> /dev/null fi if ! [[ -x $CONFIG_DIR/configure ]] ; then echo $YELLOW"WARNING! "$NORMAL"This looks like a non-working autoconf package or maybe needs automake-1.4." if [[ -e $CONFIG_DIR/$MAKEFILE ]] ; then echo "But we have a Makefile, so we'll proceed anyway. Maybe it's your lucky day." else echo $YELLOW"WARNING! "$NORMAL"No Makefile and no configure script found. "$BLUE"Skipping..."$NORMAL fi fi fi if [[ -x $CONFIG_DIR/configure ]] ; then trap safe_user_cancel 2 echo $BLUE"Found configure script - "$NORMAL if [[ $USE_OBJ_DIR = "YES" ]] ; then echo "" echo $BLUE"Using OBJ_DIR: "$NORMAL "$(basename ${OBJ_DIR})" if [[ -e $CONFIG_DIR/$MAKEFILE ]] ; then echo $BLUE"NOTICE - "$NORMAL"Stale Makefile found. Running 'make distclean' - " cd $CONFIG_DIR && make distclean &> /dev/null && echo $GREEN"Okay"$NORMAL fi if ! [[ $CONFIG_COMMAND ]] ; then CONFIG_COMMAND="../$SRC_DIR_NAME/configure" ; else CONFIG_COMMAND="../$SRC_DIR_NAME/$CONFIG_COMMAND" ; fi fi if ! [[ $CONFIG_COMMAND ]] ; then CONFIG_COMMAND="$CONFIG_DIR/configure" else CONFIG_COMMAND="$CONFIG_DIR/$CONFIG_COMMAND" fi # create a configure-help.txt file -but only if there appears to be a '--help' option if [[ "$(grep "\-\-help" $CONFIG_DIR/configure &> /dev/null)" ]] ; then $CONFIG_DIR/configure --help > $CONFIG_DIR/configure-help.txt 2> /dev/null fi if [[ -e $CONFIG_DIR/configure-help.txt ]] && [[ $(cat $CONFIG_DIR/configure-help.txt 2> /dev/null) != "" ]] ;then if [[ $(grep "help=short" $CONFIG_DIR/configure-help.txt) ]] ; then $CONFIG_COMMAND --help=short > $CONFIG_DIR/configure-help-short.txt 2> /dev/null fi if [[ -f $CONFIG_DIR/configure-help-short.txt ]] ; then SHORTHELPFILE=$CONFIG_DIR/configure-help-short.txt fi if [[ -f $CONFIG_DIR/configure-help.txt ]] ; then HELPFILE=$CONFIG_DIR/configure-help.txt fi fi # if no EXTRA_CONFIGS were given and we are in AUTO_SCRIPT mode, # look for defaults in an rpm spec file or debian 'rules', if one is present if [[ $EXTRA_CONFIGS = "" ]] && [[ $AUTO_SCRIPT ]] ; then if [[ -e $SRC_DIR/debian/rules ]] ; then SPECFILE=$SRC_DIR/debian/rules FOREIGN_CONFIGS=$(get_deb_config $SPECFILE) elif [[ -e $SRC_DIR/$NAME.spec ]] ; then SPECFILE=$SRC_DIR/$NAME.spec FOREIGN_CONFIGS=$(get_rpm_config $SPECFILE) elif [[ -e $SRC_DIR/$NAME.spec.in ]] ; then SPECFILE=$SRC_DIR/$NAME.spec.in FOREIGN_CONFIGS=$(get_rpm_config $SPECFILE) fi if [[ $FOREIGN_CONFIGS != "" ]] ; then echo"" echo $BLUE"Found default configuration options in: "$NORMAL"$(basename $SPECFILE)" fi if [[ $HELPFILE ]] ; then if [[ $(grep "sysconfdir" $HELPFILE) ]] || [[ $(grep "localstatedir" $HELPFILE) ]] ; then echo "" echo -n $BLUE"Adding default system directories: "$NORMAL if [[ $(grep "sysconfdir" $HELPFILE) ]] ; then if [[ "$(echo $FOREIGN_CONFIGS |grep 'sysconfdir')" = "" ]] ; then FOREIGN_CONFIGS="$FOREIGN_CONFIGS --sysconfdir=$sysconfdir" echo -n "sysconfdir " fi fi if [[ $(grep "localstatedir" $HELPFILE) ]] ; then if [[ "$(echo $FOREIGN_CONFIGS |grep 'localstatedir')" = "" ]] ; then FOREIGN_CONFIGS="$FOREIGN_CONFIGS --localstatedir=$localstatedir" echo -n "localstatedir " fi fi echo "" fi fi #FOREIGN_CONFIGS=${FOREIGN_CONFIGS/libdir/libdir$LIBDIRSUFFIX} EXTRA_CONFIGS=${FOREIGN_CONFIGS} fi # if using interactive mode, pause and get config options from the user. Use the FOREIGN_CONFIGS from above if available if [[ "$QUERY_FOR_EXTRA_CONFIGS" = "YES" ]] ; then echo "" echo $BLUE"Running interactive configuration - "$NORMAL cd $CONFIG_DIR ; # show the configure options show_config_help # show this prompt again since the --help command throws the first one way off the screen if [[ $FOREIGN_CONFIGS != "" ]] ; then DEFAULT_CONFIGS="$FOREIGN_CONFIGS" echo $BLUE"Possible default options were found in:"$NORMAL $(basename $SPECFILE) #echo $FOREIGN_CONFIGS echo $BLUE"Interactive mode: "$NORMAL"If you want change the arguments to the configure script" echo " you can do so now. Don't pass the '--prefix=??' as it is supplied separately." echo " Type in options and press ENTER, or press ENTER to accept the default of:" echo " $FOREIGN_CONFIGS" else echo $BLUE"Interactive mode: "$NORMAL"If you need to pass extra arguments to the configure script" echo " you can do so now. Don't pass the '--prefix=??' as it is supplied separately." echo " Just press ENTER to leave blank, or type in options and then press ENTER" fi read -e NEW_CONFIGS if [[ $NEW_CONFIGS != "" ]] ; then EXTRA_CONFIGS=$NEW_CONFIGS fi echo "" fi #STD_CONFIGS=${STD_CONFIGS/libdir/libdir$LIBDIRSUFFIX} #EXTRA_CONFIGS=${EXTRA_CONFIGS/libdir/libdir$LIBDIRSUFFIX} # put all the configure options together and remove white space CONFIG_ARGS="$(echo --prefix=/$PRE_FIX $STD_CONFIGS $EXTRA_CONFIGS| white_out)" # if FLAG_LINE is not already set from src2pkg command line, set it and remove white space if ! [[ $FLAG_LINE ]] ; then FLAG_LINE="$(echo $STD_FLAGS $EXTRA_FLAGS |white_out)" fi # try this by default -remove stale files -probably should use find for .deps [[ -d $CONFIG_DIR/autom4te.cache ]] && rm -rf $CONFIG_DIR/autom4te.cache #[[ -d $CONFIG_DIR/.deps ]] && rm -rf $CONFIG_DIR/.deps #[[ -f $CONFIG_DIR/.deps ]] && rm -f $CONFIG_DIR/.deps find $CONFIG_DIR -name .deps -exec rm -rf {} \; [[ -f $CONFIG_DIR/config.status ]] && rm -f $CONFIG_DIR/config.status [[ -f $CONFIG_DIR/config.cache ]] && rm -f $CONFIG_DIR/config.cache # run the configure script if [[ $QUIET = "YES" ]] ; then cd $OBJ_DIR ; echo $BLUE"Configuring sources using:"$NORMAL echo " CFLAGS=$FLAG_LINE ./$(basename $CONFIG_COMMAND) $CONFIG_ARGS" export CFLAGS=$FLAG_LINE # export CXXFLAGS=$FLAG_LINE export LDFLAGS $CONFIG_COMMAND $CONFIG_ARGS &> /dev/null else cd $OBJ_DIR ; echo $BLUE"Configuring sources using:"$NORMAL echo " CFLAGS=$FLAG_LINE ./$(basename $CONFIG_COMMAND) $CONFIG_ARGS" echo "Messages from configure:" export CFLAGS=$FLAG_LINE # export CXXFLAGS=$FLAG_LINE export LDFLAGS $CONFIG_COMMAND $CONFIG_ARGS fi if [[ $? -eq 0 ]] ; then echo $BLUE"Configuration has been - "$GREEN"Successful!"$NORMAL if [[ "$CONFIRM_BUILD" = "YES" ]] ; then echo -n $BLUE"Continue with the build? [ y or n ] > "$NORMAL read ANSWER if [ $ANSWER == "n" ]; then echo $RED"CANCELLED! "$NORMAL"Quitting at users request." FAILED="CANCELLED interactively" exit 0 fi fi elif [[ $USER_CANCELLED ]] ; then echo $RED"STOPPED! "$NORMAL"Operation cancelled during configuration!" FAILED="CANCELLED" else FAILED="configure_source" echo $RED"ERROR! "$NORMAL"Configuring sources has failed!"$NORMAL echo "This usually happens because of missing libraries, or you" echo "may need to pass extra options to configure using EXTRA_CONFIGS." if [[ $REPLAY_ERRORS = "YES" ]] && [[ $QUIET = "YES" ]] ; then if [[ $DISPLAY ]] ; then cd $CONFIG_DIR ; echo $CYAN"NOTICE-"$NORMAL"Replaying failed configuration in a separate xterm:" export CFLAGS=$STD_FLAGS$EXTRA_FLAGS ( xterm -hold -e "$CONFIG_COMMAND" "$CONFIG_ARGS" & ) else cd $CONFIG_DIR ; echo $CYAN"NOTICE-"$NORMAL"Replaying failed configuration:" export CFLAGS=$STD_FLAGS$EXTRA_FLAGS $CONFIG_COMMAND $CONFIG_ARGS fi else show_requires show_config_help #exit fi fi elif [[ -f $CONFIG_DIR/Imakefile ]] || [[ -f $CONFIG_DIR/imakefile ]] ; then if ! [[ $USE_DEFAULT_MAKEFILES = "YES" ]] ; then echo -n $BLUE"Found Imakefile - "$NORMAL"Configuring using: 'xmkmf -a' - " cd $CONFIG_DIR ; xmkmf -a 2> /dev/null 1> /dev/null MAKEFILE="Makefile" echo $GREEN"Done"$NORMAL fi elif [[ -f $CONFIG_DIR/SConstruct ]] ; then echo -n $BLUE"Found SConstruct file - "$NORMAL"Configuring using: 'scons configure' - " cd $CONFIG_DIR ; if [[ $QUIET = "YES" ]] ; then scons configure prefix=$PRE_FIX 2> /dev/null 1> /dev/null else scons configure prefix=$PRE_FIX fi MAKEFILE="SConstruct" echo $GREEN"Done"$NORMAL elif [[ -f $CONFIG_DIR/setup.py ]] ; then #MAKEFILE="setup.py" MAKE_COMMAND="./setup.py build" INSTALL_LINE="./setup.py install" elif [[ -f $CONFIG_DIR/CMakeLists.txt ]] ; then echo $BLUE"Found 'cmake' configuration - "$NORMAL"Configuring using:" echo " cmake -DCMAKE_INSTALL_PREFIX=${PKG_DIR}/${PRE_FIX}" # make a build dir in the sources and use it as the OBJ_DIR if [[ $USE_OBJ_DIR ]] || [[ -d $CONFIG_DIR/build ]] ; then mkdir -p $CONFIG_DIR/build # Delete the normal OBJ_DIR which got created in 03-make_dirs if [[ $OBJ_DIR_NAME != "" ]] && [[ -d $SRC_BUILDS_DIR/$OBJ_DIR_NAME ]] ; then [[ "$QUIET" = "NO" ]] && echo $BLUE"Removing existing object build directory from previous build - "$NORMAL ( cd $SRC_BUILDS_DIR && rm -rf $OBJ_DIR_NAME 2> /dev/null 1> /dev/null ) fi # now reset the OBJ_DIR for cmake OBJ_DIR=$CONFIG_DIR/build else OBJ_DIR=$CONFIG_DIR fi INSTALL_TYPE=DESTDIR cd $OBJ_DIR if ! [[ $(which cmake) ]] ; then echo $RED"FAILED! "$NORMAL"No cmake found in path. "$RED"Exiting..."$NORMAL FAILED="CONFIGURATION - Missing cmake" elif [[ "$PRE_FIX" != "usr/local" ]] ; then if [[ $QUIET = "YES" ]] ; then # this is what you need to change the default PREFIX for cmake non-interactively if [[ $USE_OBJ_DIR ]] ; then cmake .. -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} &> /dev/null else cmake . -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} &> /dev/null fi else if [[ $USE_OBJ_DIR ]] ; then cmake .. -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} else cmake . -DCMAKE_INSTALL_PREFIX=/${PKG_DIR}/${PRE_FIX} fi fi else if [[ $QUIET = "YES" ]] ; then if [[ $USE_OBJ_DIR ]] ; then cmake .. &> /dev/null else cmake . &> /dev/null fi else if [[ $USE_OBJ_DIR ]] ; then cmake .. else cmake . fi fi fi elif [[ -f $CONFIG_DIR/Makefile.PL ]] ; then echo $BLUE"Found perl Makefile.PL - "$NORMAL"Running perl Makefile.PL -n" cd $CONFIG_DIR; perl Makefile.PL -n # set this because perl modules usually conatin empty place-holder files FORCE_ZERO_LENGTH=YES elif [[ $(find $CONFIG_DIR -name "$MAKEFILE" |wc -l) -ge 1 ]] ; then # We have at least one Makfile so we continue echo $BLUE"Skipping autoconf configuration:"$NORMAL echo $BLUE"Continuing - "$NORMAL"We found at least one "$BLUE"$MAKEFILE"$NORMAL else echo $BLUE"Skipping configure_source - "$NORMAL fi # Some Makefiles have hard-coded installation paths to /usr/local and some configure routines # also fail to set prefix properly because the variable is called PREFIX, DEST or INSTALLROOT # We try to correct these here unless the user is using PRE_FIX under /usr/local or /opt in which # case CORRECT_MAKEFILES will have been set to NO in pre_process if [[ $FAILED = "" ]] && [[ "$MAKEFILE" != "" ]] ; then if [[ "$CORRECT_MAKEFILES" != "NO" ]] && [[ "$(find . -name "$MAKEFILE" |wc -l)" = "1" ]] ; then if [[ "${PRE_FIX:0:9}" != "usr/local" ]] && [[ $(grep 'usr/local' $CONFIG_DIR/$MAKEFILE) ]] ; then echo $CYAN"NOTICE - "$NORMAL"Correcting $MAKEFILE(s) with incorrect hard-coded prefix." find . -name "$MAKEFILE" |xargs sed -i -e s:"/usr/local":"/$PRE_FIX": fi fi fi fi fi } get_rpm_config() { INPUT=$1 RPM_OPT_FLAGS="" RPM_BUILD_ROOT="" FOUND_FIRST_LINE="" FOUND_LAST_LINE="" BUILT_LINE="" while read LINE ; do (( LINE_COUNT++ )) CHUNK=${LINE} # whittle off any leading spaces until we have FOUND_FIRST_LINE if ! [[ $FOUND_FIRST_LINE ]] ; then while [[ ${CHUNK:0:1} = " " ]] ; do CHUNK=${CHUNK:1} done fi # Then, check for leading string matches and skip over them if [[ ${CHUNK:0:10} = "%configure" ]] ; then CHUNK=${CHUNK#* } FOUND_FIRST_LINE=1 elif [[ ${CHUNK:0:11} = "./configure" ]] ; then CHUNK=${CHUNK:12} FOUND_FIRST_LINE=1 elif [[ ${CHUNK:0:17} = "sh -c ./configure" ]] ; then CHUNK=${CHUNK:17} FOUND_FIRST_LINE=1 elif [[ ${CHUNK:0:7} = "CFLAGS=" ]] ; then CHUNK=${CHUNK#* } FOUND_FIRST_LINE=1 if [[ ${CHUNK:0:11} = "./configure" ]] ; then CHUNK=${CHUNK:11} fi fi # if [[ $FOUND_FIRST_LINE ]] && ! [[ $FOUND_LAST_LINE ]] ; then # && ! [[ $FOUND_LAST_LINE ]] ; then # strip leading spaces while [[ ${CHUNK:0:1} = " " ]] ; do CHUNK=${CHUNK:1} done if [[ "${CHUNK:0:1}" = "%" ]] || [[ "$CHUNK" = "" ]] ; then ! [[ $FOUND_LAST_LINE ]] && FOUND_LAST_LINE=1 elif ! [[ $FOUND_LAST_LINE ]] ; then BUILT_LINE="$BUILT_LINE $CHUNK" #BUILT_LINE=$CHUNK FOUND_LAST_LINE=1 fi fi done <$INPUT for CHUNK in "$BUILT_LINE" ; do while [[ ${CHUNK:0:1} = " " ]] ; do CHUNK=${CHUNK:1} done if [[ ${CHUNK:0:9} = "--prefix=" ]] ; then CHUNK=${CHUNK#* } fi # get rid of prefix -the above should skip over it CHUNK=${CHUNK/--prefix=/} CHUNK=${CHUNK/\%\{_prefix\}/} CHUNK=${CHUNK/\%\{prefix\}/} CHUNK=${CHUNK/\%\{/} ; CHUNK=${CHUNK/\}/} # this should also be better if [[ ${CHUNK:0:13} = "RPM_OPT_FLAGS" ]] ; then CHUNK=${CHUNK#* } fi # get rid of RPM_OPT_FLAGS CHUNK=${CHUNK/RPM_OPT_FLAGS=/} # Change LSB compliance to Slackware compliance CHUNK=${CHUNK/usr\/share\/man/usr\/man} CHUNK=${CHUNK/usr\/share\/info/usr\/info} CHUNK=${CHUNK/_bindir/$bindir} CHUNK=${CHUNK/_sbindir/$sbindir} CHUNK=${CHUNK/_libexecdir/$libexecdir} CHUNK=${CHUNK/_sysconfdir/$sysconfdir} CHUNK=${CHUNK/_sharedstatedir/$sharedstatedir} CHUNK=${CHUNK/_localstatedir/$localstatedir} CHUNK=${CHUNK/_libdir/$libdir} CHUNK=${CHUNK/_includedir/$includedir} CHUNK=${CHUNK/_oldincludedir/$oldincludedir} CHUNK=${CHUNK/_datarootdir/$datarootdir} CHUNK=${CHUNK/_datadir/$datadir} CHUNK=${CHUNK/_infodir/$infodir} CHUNK=${CHUNK/_localedir/$localedir} CHUNK=${CHUNK/_mandir/$mandir} CHUNK=${CHUNK/_docdir/$docdir} CHUNK=${CHUNK/_htmldir/$htmldir} CHUNK=${CHUNK/_dvidir/$dvidir} CHUNK=${CHUNK/_pdfdir/$pdfdir} CHUNK=${CHUNK/_psidir/$psidir} CHUNK=${CHUNK/_gamesbindir/$gamesbindir} CHUNK=${CHUNK/_gamesdatadir/$gamesdatadir} if [[ $REBUILT_LINE = "" ]] ; then REBUILT_LINE="$CHUNK" else REBUILT_LINE="$REBUILT_LINE $CHUNK" fi done echo $REBUILT_LINE } get_deb_config() { INPUT=$1 FOUND_LINE=0 while read LINE ; do (( LINE_COUNT++ )) CHUNK=$LINE #get rid of leading while [[ ${CHUNK:0:1} = " " ]] ; do CHUNK=${CHUNK:1} done if [[ ${CHUNK:0:11} = "./configure" ]] ; then FOUND_FIRST_LINE=1 BUILT_LINE=$CHUNK elif [[ ${CHUNK:0:1} = "#" ]] ; then continue elif ! [[ $FOUND_LAST_LINE ]] ; then if [[ "$CHUNK" = "" ]] ; then FOUND_LAST_LINE=1 else BUILT_LINE=$BUILT_LINE$CHUNK fi fi done <$INPUT for CHUNK in $BUILT_LINE ; do [[ ${CHUNK:0:1} = " " ]] && CHUNK=${CHUNK:1} # we want to skip over all of these: if [[ ${CHUNK:0:11} = "./configure" ]] ; then CHUNK_SIZE=${#CHUNK} && CHUNK=${CHUNK:$CHUNK_SIZE} elif [[ ${CHUNK:0:6} = "--host" ]] ; then CHUNK_SIZE=${#CHUNK} && CHUNK=${CHUNK:$CHUNK_SIZE} elif [[ ${CHUNK:0:7} = "--build" ]] ; then CHUNK_SIZE=${#CHUNK} && CHUNK=${CHUNK:$CHUNK_SIZE} elif [[ ${CHUNK:0:8} = "--target" ]] ; then CHUNK_SIZE=${#CHUNK} && CHUNK=${CHUNK:$CHUNK_SIZE} elif [[ ${CHUNK:0:8} = "--prefix" ]] ; then CHUNK_SIZE=${#CHUNK} && CHUNK=${CHUNK:$CHUNK_SIZE} fi # change all the occurences of "$${prefix}" to our $PRE_FIX CHUNK=$(echo ${CHUNK/\$\$\{prefix\}/$PRE_FIX}) # Change the debian standard /usr/share/man and /usr/share/info CHUNK=$(echo ${CHUNK/usr\/share\/man/$mandir}) CHUNK=$(echo ${CHUNK/usr\/share\/info/$infodir}) # if the CHUNK is not NULL add it to the rebuilt line [[ "$CHUNK" != "" ]] && REBUILT_LINE="$REBUILT_LINE $CHUNK" done echo $REBUILT_LINE } show_config_help() { if [[ $DISPLAY ]] ; then if [[ $SHORTHELPFILE ]] ; then echo $CYAN"NOTICE: "$NORMAL"Showing short options in a separate xterm." ( xterm -hold -e cat $SHORTHELPFILE & ) elif [[ $HELPFILE ]] ; then echo $CYAN"NOTICE: "$NORMAL"Showing all available options in a separate xterm." ( xterm -hold -e cat $HELPFILE & ) fi else if [[ $SHORTHELPFILE ]] ; then echo $CYAN"NOTICE: "$NORMAL"Showing short package-specific options:" cat $SHORTHELPFILE elif [[ $HELPFILE ]] ; then echo $CYAN"NOTICE: "$NORMAL"Showing all available configure options:" cat $HELPFILE fi fi }