# This file is part of the src2pkg program: # Copyright 2005-2009 Gilbert Ashley # src2pkg is released under the GNU General Public License Version 2 ### configure_source configure_source() { if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any pre-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/06.pre ]] && . "$HOME"/.src2pkg/extensions/06.pre fi 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 "$SRC_DIR"/build "$SRC_DIR"/dist ; 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 Build.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 $CYAN"Notice - "$NORMAL"These sources use GNUmakefiles, instead of Makefiles." if ! [[ $USE_DEFAULT_MAKEFILES = "YES" ]] ; then MAKEFILE="GNUmakefile" 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 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 $CYAN"Notice - "$NORMAL"These sources contain both a Makefile.in and a GNUmakefile." if ! [[ $USE_DEFAULT_MAKEFILES = "YES" ]] ; then MAKEFILE="Makefile" 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 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"/genconf.sh ]] ; then echo -n $BLUE"Found a genconf.sh script - "$NORMAL" We'll try running that - " cd "$CONFIG_DIR" ; sh ./genconf.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 # check to see of --prefix option is present if ! [[ $(grep "\-\-prefix" "$CONFIG_DIR"/configure 2> /dev/null) ]] ; then # check to make sure prefix hasn't been given in EXTRA_CONFIGS # manedit and other pconf sources are weird if [[ $(echo $EXTRA_CONFIGS |grep prefix) = "" ]] ; then echo $CYAN"Notice: "$NORMAL"No '--prefix' option found in configure script." echo $CYAN"Notice: "$NORMAL"Activating interactive mode so you can fix that." QUERY_FOR_EXTRA_CONFIGS=YES fi else HAVE_PREFIX_OPTION=1 fi # create a configure-help.txt file -but only if there appears to be a '--help' option if [[ $(grep "\-\-help" "$CONFIG_DIR"/configure 2> /dev/null) ]] ; then "$CONFIG_DIR"/configure --help > "$CONFIG_DIR"/configure-help.txt 2> /dev/null else # a program called openttd has all the --help stuff in a separate file which is sourced :-( ( "$CONFIG_DIR"/configure --help > "$CONFIG_DIR"/configure-help.txt 2> /dev/null ) & fi # need to sleep for a second for the file creation above to register sleep 1 if [[ -f "$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 AUTO_CONFIG is enabled if [[ $EXTRA_CONFIGS = "" ]] ; then # if AUTO_CONFIG=FOREIGN look for defaults in an rpm spec file or debian 'rules', if one is present if [[ $AUTO_CONFIG = "FOREIGN" ]] ; 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"/$ORIG_NAME.spec ]] ; then SPECFILE="$SRC_DIR"/$ORIG_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") elif [[ -e "$SRC_DIR"/$ORIG_NAME.spec.in ]] ; then SPECFILE="$SRC_DIR"/$ORIG_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 AUTO_CONFIG=NATIVE then compose options by detecting them in the configure script elif [[ $AUTO_CONFIG = "NATIVE" ]] ; then if [[ "$HELPFILE" ]] ; then for option in $AUTO_CONFIG_OPTIONS ; do if [[ $(grep "\-\-$option" "$HELPFILE") ]] ; then HAVE_CONFIG_OPTIONS=1 SPECFILE="configure" fi done if [[ $HAVE_CONFIG_OPTIONS = 1 ]] ; then echo -n $BLUE"Adding default options: "$NORMAL for option in $AUTO_CONFIG_OPTIONS ; do if [[ $(grep "\-\-$option" "$HELPFILE") ]] ; then FOREIGN_CONFIGS="$FOREIGN_CONFIGS --$option=${!option}" echo -n "$option " fi done echo "" fi fi fi 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 $BLUE"Interactive mode: "$NORMAL"Change arguments to the configure script now, if needed" if [[ $HAVE_PREFIX_OPTION = 1 ]] ; then echo " Don't pass the '--prefix=/$PRE_FIX' as it is supplied separately." else echo " No '--prefix' option found in the configure script. Look for other syntax" echo " like -prefix or --prefix-dir and supply that here like: --prefix=/$PRE_FIX" fi echo " Type in options and press ENTER, or press ENTER to accept the default of:" echo " $FOREIGN_CONFIGS" else echo $BLUE"Interactive mode: "$NORMAL"Pass extra arguments to the configure script, if needed." if [[ $HAVE_PREFIX_OPTION = 1 ]] ; then echo " Don't pass the '--prefix=/$PRE_FIX' as it is supplied separately." else echo " No '--prefix' option found in the configure script. Look for other syntax" echo " like -prefix or --prefix-dir and supply that here like: --prefix=/$PRE_FIX" fi if [[ $EXTRA_CONFIGS = "" ]] ; then echo " Just press ENTER to leave blank, or type in options and then press ENTER" else echo " Enter new options or paste and edit the ones shown below. Then press ENTER." echo " $EXTRA_CONFIGS" fi fi read -e -p ">" NEW_CONFIGS if [[ $NEW_CONFIGS != "" ]] ; then # if we have new configs, then let AUTO_SCRIPT clobber the original script DONT_CLOBBER_SCRIPT= EXTRA_CONFIGS="$NEW_CONFIGS" fi fi # put all the configure options together and remove white space if [[ -f "$HELPFILE" ]] && [[ $HAVE_PREFIX_OPTION = 1 ]] ; then CONFIG_ARGS="$(echo --prefix=/$PRE_FIX $STD_CONFIGS $EXTRA_CONFIGS| white_out)" else CONFIG_ARGS="$(echo $STD_CONFIGS $EXTRA_CONFIGS| white_out)" fi # 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 # Remove stale configuration files [[ -d "$CONFIG_DIR"/autom4te.cache ]] && rm -rf "$CONFIG_DIR"/autom4te.cache find "$CONFIG_DIR" -name .deps -exec rm -rf {} \; 2> /dev/null [[ -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 cd "$OBJ_DIR" ; echo $BLUE"Configuring sources using:"$NORMAL echo " CFLAGS=$FLAG_LINE ./${CONFIG_COMMAND##*/} $CONFIG_ARGS" export CFLAGS="$FLAG_LINE" # exporting CXXFLAGS seems like a good idea, but exporting both cause some things to fail # maybe need to figure out how to detect whether the sources are in C or C++ # export CXXFLAGS=$FLAG_LINE export LDFLAGS if [[ $LOG_COMMANDS = "YES" ]] ; then echo $BLUE"Logging configuration output to: "$NORMAL"$NAME-configure.log" "$CONFIG_COMMAND" $CONFIG_ARGS &> $NAME-configure.log elif [[ $QUIET = "YES" ]] ; then "$CONFIG_COMMAND" $CONFIG_ARGS &> /dev/null else echo "Messages from configure:" "$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 -n 1 ANSWER echo "" 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 may be because of some missing libraries, or you may" echo "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 prefix=/$PRE_FIX' " 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" # use JAIL to avoid Makefile failures INSTALL_TYPE=JAIL MAKE_COMMAND="python ./setup.py build" INSTALL_LINE="python ./setup.py install" elif [[ -f "$CONFIG_DIR"/CMakeLists.txt ]] ; then echo $BLUE"Found 'cmake' configuration - "$NORMAL"Configuring using:" echo " cmake -DCMAKE_INSTALL_PREFIX:PATH=${PKG_DIR}/${PRE_FIX} $EXTRA_CONFIGS" # 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:PATH=/"${PKG_DIR}/${PRE_FIX}" "${EXTRA_CONFIGS}" &> /dev/null else cmake . -DCMAKE_INSTALL_PREFIX:PATH=/"${PKG_DIR}/${PRE_FIX}" "${EXTRA_CONFIGS}" &> /dev/null fi else if [[ $USE_OBJ_DIR ]] ; then cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/"${PKG_DIR}/${PRE_FIX}" "${EXTRA_CONFIGS}" else cmake . -DCMAKE_INSTALL_PREFIX:PATH=/"${PKG_DIR}/${PRE_FIX}" "${EXTRA_CONFIGS}" fi fi else # cmake defaults to prefix /usr/local so we don't need the prefix part here if [[ $QUIET = "YES" ]] ; then if [[ $USE_OBJ_DIR ]] ; then cmake .. "${EXTRA_CONFIGS}" &> /dev/null else cmake . "${EXTRA_CONFIGS}" &> /dev/null fi else if [[ $USE_OBJ_DIR ]] ; then cmake .. "${EXTRA_CONFIGS}" else cmake . "${EXTRA_CONFIGS}" fi fi fi elif [[ -f "$CONFIG_DIR"/Makefile.PL ]] || [[ -f "$CONFIG_DIR"/Build.PL ]] ; then if [[ -f "$CONFIG_DIR"/Makefile.PL ]] ; then MAKEFILE=Makefile.PL else MAKEFILE=Build.PL fi echo $BLUE"Found perl $MAKEFILE - "$NORMAL"Running perl $MAKEFILE" cd "$CONFIG_DIR" ; if [[ "$MAKE_COMMAND" != "" ]] ; then echo $BLUE"Compiling perl module using: $NORMAL $MAKE_COMMAND" "$MAKE_COMMAND" else echo $BLUE"Compiling perl module using: $NORMAL perl $MAKEFILE $EXTRA_CONFIGS" perl $MAKEFILE "$EXTRA_CONFIGS" fi INSTALL_TYPE=JAIL elif [[ $(find "$CONFIG_DIR" -name "$MAKEFILE" |wc -l) -ge 1 ]] ; then # We have at least one Makefile so we continue echo $BLUE"Skipping configuration: "$NORMAL"Nothing to be done" 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 conflicting hard-coded prefix." find . -name "$MAKEFILE" |xargs -r sed -i -e s:"/usr/local":"/$PRE_FIX":g fi fi fi fi fi if [[ $ALLOW_USER_EXTENSIONS = "YES" ]] ; then # check if the user has any post-execution extensions to this file and run them, if so. [[ -f "$HOME"/.src2pkg/extensions/06.post ]] && . "$HOME"/.src2pkg/extensions/06.post fi } # end configure_source 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 [[ $HAVE_PREFIX_OPTION != 1 ]] || [[ $QUERY_FOR_EXTRA_CONFIGS = "YES" ]] ; then echo $CYAN"NOTICE: "$NORMAL"Showing long options in a separate xterm." ( xterm -hold -e cat "$HELPFILE" & ) elif [[ $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 [[ $HAVE_PREFIX_OPTION != 1 ]] || [[ $QUERY_FOR_EXTRA_CONFIGS = "YES" ]] ; then echo $CYAN"NOTICE: "$NORMAL"Showing long configure options:" cat "$HELPFILE" elif [[ $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 }