// -------------------------------------------------------------------------
cpPlugins::ParametersQtDialog::
-ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
+ParametersQtDialog( QWidget* parent, Qt::WindowFlags f, bool manual )
: QDialog( parent, f ),
m_ProcessObject( NULL ),
- m_WidgetsUpdated( false )
+ m_WidgetsUpdated( false ),
+ m_Manual( manual )
{
- this->m_Title = new QLabel( this );
- this->m_Title->setText( "Parameters dialog title" );
+ if( !this->m_Manual )
+ {
+ this->m_Title = new QLabel( this );
+ this->m_Title->setText( "Parameters dialog title" );
+ this->m_MainLayout = new QGridLayout( this );
+ this->m_ToolsLayout = new QVBoxLayout( );
+ this->m_ToolsLayout->addWidget( this->m_Title );
+ this->m_MainLayout->addLayout( this->m_ToolsLayout, 0, 0, 1, 1 );
- this->m_MainLayout = new QGridLayout( this );
- this->m_ToolsLayout = new QVBoxLayout( );
- this->m_ToolsLayout->addWidget( this->m_Title );
- this->m_MainLayout->addLayout( this->m_ToolsLayout, 0, 0, 1, 1 );
+ } // fi
}
// -------------------------------------------------------------------------
cpPlugins::ParametersQtDialog::
~ParametersQtDialog( )
{
- delete this->m_Title;
- delete this->m_ToolsLayout;
- delete this->m_MainLayout;
+ if( !this->m_Manual )
+ {
+ delete this->m_Title;
+ delete this->m_ToolsLayout;
+ delete this->m_MainLayout;
+
+ } // fi
}
// -------------------------------------------------------------------------
{
if( this->m_ProcessObject == NULL )
return;
+ if( this->m_Manual )
+ return;
// Put values
auto parameters = this->m_ProcessObject->GetParameters( );
{
if( this->m_ProcessObject == NULL )
return;
+ if( this->m_Manual )
+ return;
// Put values
auto parameters = this->m_ProcessObject->GetParameters( );
void cpPlugins::ParametersQtDialog::
_addButtons( )
{
+ if( this->m_Manual )
+ return;
+
// Add buttons
this->m_Buttons = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel
{
if( this->m_WidgetsUpdated || this->m_ProcessObject == NULL )
return;
+ if( !this->m_Manual )
+ return;
// Set dialog title
std::stringstream title;
Q_OBJECT;
public:
- ParametersQtDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
+ ParametersQtDialog(
+ QWidget* parent = 0, Qt::WindowFlags f = 0, bool manual = false
+ );
virtual ~ParametersQtDialog( );
ProcessObject* getProcessObject( ) const;
protected:
ProcessObject* m_ProcessObject;
bool m_WidgetsUpdated;
+ bool m_Manual;
QLabel* m_Title;
QGridLayout* m_MainLayout;
QVBoxLayout* m_ToolsLayout;
popd > /dev/null
}
-## Some configuration variables
-number_of_processes="-j4"
+function get_file_extension
+{
+ valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
+ actual_file=`abspath $1`
+ actual_ext=""
+ for ext in ${valid_extensions[@]}; do
+ test_str=`dirname $actual_file`/`basename $actual_file $ext`
+ if [ $test_str != $actual_file ]; then
+ actual_ext=$ext
+ fi
+ done
+ echo "$actual_ext"
+}
-# Locate qmake executable
-qmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
-qmake_exec=""
-for loc in ${qmake_locations[@]}; do
- qmake_file="$loc/qmake"
- if [ -x $qmake_file ]; then
- version=`$qmake_file --version | grep Using\ Qt\ version | cut -d ' ' -f 4`
- if [ "${version:0:3}" == "4.8" ]; then
- qmake_exec=$qmake_file
+function print_help()
+{
+ echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-p=instalation_prefix] [-q=qmake_executable]"
+}
+
+## Analyze command-line arguments
+if [ $# -eq 0 ]; then
+ print_help
+ exit 1
+fi
+prefix="${HOME}/local"
+for i in "$@"; do
+ case $i in
+ -f=*|--file=*)
+ source_file="${i#*=}"
+ shift
+ ;;
+ -c=*|--source_dir=*)
+ source_dir="${i#*=}"
+ shift
+ ;;
+ -b=*|--build_dir=*)
+ build_dir="${i#*=}"
+ shift
+ ;;
+ -p=*|--prefix=*)
+ prefix="${i#*=}"
+ shift
+ ;;
+ -q=*|--qmake=*)
+ qmake_exec="${i#*=}"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+done
+
+## Check command line arguments
+if [ "x$source_dir" == "x" ]; then
+ if [ "x$source_file" != "x" ]; then
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ base_dir=`dirname $base_path`
+ if [ "x$base_ext" != "x" ]; then
+ source_dir="$base_dir"/`basename $base_path .$base_ext`
+ else
+ echo "Error: Input compressed file extension not recognized."
+ exit 1
fi
+ else
+ print_help
+ exit 1
fi
-done
+fi
+if [ "x$build_dir" == "x" ]; then
+ if [ "x$source_dir" != "x" ]; then
+ base_dir=$source_dir
+ if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then
+ base_dir=`echo $source_dir | rev | cut -c 2- | rev`
+ fi
+ build_dir="$base_dir-build"
+ else
+ print_help
+ exit 1
+ fi
+fi
+# Locate qmake executable
+if [ "x$qmake_exec" == "x" ]; then
+ qmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
+ for loc in ${qmake_locations[@]}; do
+ qmake_file="$loc/qmake"
+ if [ -x $qmake_file ]; then
+ version=`$qmake_file --version | grep Using\ Qt\ version | cut -d ' ' -f 4`
+ if [ "${version:0:3}" == "4.8" ]; then
+ qmake_exec=$qmake_file
+ fi
+ fi
+ done
+fi
+qmake_exec=`abspath $qmake_exec`
if [ -x $qmake_exec ]; then
qt_options="--qt-gui --qt-qmake=$qmake_exec"
else
qt_options="--no-qt-gui"
fi
-## Check input parameters and process inputs (if needed)
-if [ "$#" -eq 1 ]; then
- valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
- actual_ext=""
- for ext in ${valid_extensions[@]}; do
- if [ `basename $1 $ext` != $1 ]; then
- actual_ext=$ext
- fi
- done
- if [ "x$actual_ext" == "x" ]; then
- echo "$0: Invalid file type."
- exit 1
- fi
- canonical_path=`abspath $1`
- source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
- build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
- echo -n "Cleaning directories... "
+## Other configuration variables
+platform=`uname`
+number_of_cores=`grep -c ^processor /proc/cpuinfo`
+number_of_threads=`expr $number_of_cores / 2`
+if [ "x$source_file" != "x" ]; then
+ source_file=`abspath $source_file`
+fi
+source_dir=`abspath $source_dir`
+build_dir=`abspath $build_dir`
+
+echo "====================================================================="
+echo "==> Source file : $source_file"
+echo "==> Source dir : $source_dir"
+echo "==> Build dir : $build_dir"
+echo "==> Prefix : $prefix"
+echo "==> qmake : $qmake_exec"
+echo "==> Qt options : $qt_options"
+echo "==> Platform : $platform"
+echo "==> Number of cores : $number_of_cores"
+echo "==> Number of threads : $number_of_threads"
+echo "====================================================================="
+
+## Create paths
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Cleaning directories... "
rm -rf $source_dir
rm -rf $build_dir
echo "done."
- echo -n "Creating directories... "
+ echo -n "==> Creating directories... "
mkdir -p $source_dir
mkdir -p $build_dir
echo "done."
- echo -n "Extracting sources... "
- if [ "$actual_ext" == "zip" ]; then
- echo unzip $canonical_path
- elif [ "$actual_ext" == "tar" ]; then
- tar xf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.gz" ]; then
- tar xzf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.bz2" ]; then
- tar xjf $canonical_path -C $source_dir --strip-components=1
- else
- echo "$0: Invalid file type."
- exit 1
- fi
- echo "done!"
-elif [ "$#" -eq 2 ]; then
- source_dir=`dirname $1`
- build_dir=`dirname $2`
-else
- echo "Usage: [cmake_package] or [cmake_source_dir cmake_build_dir]"
fi
-echo "Given source dir : \"$source_dir\""
-echo "Given build dir : \"$build_dir\""
+## Extract source code
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Extracting sources... "
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ if [ "$base_ext" == "zip" ]; then
+ echo unzip $base_path
+ elif [ "$base_ext" == "tar" ]; then
+ tar xf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.gz" ]; then
+ tar xzf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.bz2" ]; then
+ tar xjf $base_path -C $source_dir --strip-components=1
+ fi
+ echo "done."
+fi
-echo "Configuring sources... "
+echo "==> Configuring sources... "
cd $build_dir
-$source_dir/bootstrap --prefix=${HOME}/local $qt_options
-echo "Configuring sources... done."
+$source_dir/bootstrap --prefix=$prefix $qt_options
+echo "==> Configuring sources... done."
-echo "Compiling sources..."
+echo "==> Compiling sources..."
cd $build_dir
-make $number_of_processes
-echo "Compiling sources... done."
+make -j$number_of_threads
+echo "==> Compiling sources... done."
-echo "Installing package..."
+echo "==> Installing package..."
cd $build_dir
make -j install
-echo "Installing package... done."
+echo "==> Installing package... done."
## eof - $RCSfile$
popd > /dev/null
}
-## Some configuration variables
-number_of_processes="-j4"
-
-## Locate cmake executable
-cmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
-cmake_exec=""
-cmake_ver=""
-for loc in ${cmake_locations[@]}; do
- cmake_file="$loc/cmake"
- if [ -x $cmake_file ]; then
- str=`$cmake_file --version | grep version`
- version=${str:14}
- if [ "$cmake_ver" \< "$version" ]; then
- cmake_ver=$version
- cmake_exec=$cmake_file
- fi
- fi
-done
-if [ ! -x $cmake_exec ]; then
- echo "$0: modify this script to put the correct location of cmake."
- exit 1
-fi
-
-## Check input parameters and process inputs (if needed)
-if [ "$#" -eq 2 ]; then
+function get_file_extension
+{
valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
+ actual_file=`abspath $1`
actual_ext=""
for ext in ${valid_extensions[@]}; do
- if [ `basename $1 $ext` != $1 ]; then
+ test_str=`dirname $actual_file`/`basename $actual_file $ext`
+ if [ $test_str != $actual_file ]; then
actual_ext=$ext
fi
done
- if [ "x$actual_ext" == "x" ]; then
- echo "$0: Invalid file type."
+ echo "$actual_ext"
+}
+
+function print_help()
+{
+ echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-p=instalation_prefix] [-m=cmake_executable] [-t=build_type[MinSizeRel/Debug/Release]]"
+}
+
+## Analyze command-line arguments
+if [ $# -eq 0 ]; then
+ print_help
+ exit 1
+fi
+prefix="${HOME}/local"
+build_type="MinSizeRel"
+for i in "$@"; do
+ case $i in
+ -f=*|--file=*)
+ source_file="${i#*=}"
+ shift
+ ;;
+ -c=*|--source_dir=*)
+ source_dir="${i#*=}"
+ shift
+ ;;
+ -b=*|--build_dir=*)
+ build_dir="${i#*=}"
+ shift
+ ;;
+ -t=*|--build_type=*)
+ build_type="${i#*=}"
+ shift
+ ;;
+ -p=*|--prefix=*)
+ prefix="${i#*=}"
+ shift
+ ;;
+ -m=*|--cmake=*)
+ cmake_exec="${i#*=}"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+done
+
+## Check command line arguments
+if [ "x$source_dir" == "x" ]; then
+ if [ "x$source_file" != "x" ]; then
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ base_dir=`dirname $base_path`
+ if [ "x$base_ext" != "x" ]; then
+ source_dir="$base_dir"/`basename $base_path .$base_ext`
+ else
+ echo "Error: Input compressed file extension not recognized."
+ exit 1
+ fi
+ else
+ print_help
+ exit 1
+ fi
+fi
+if [ "x$build_dir" == "x" ]; then
+ if [ "x$source_dir" != "x" ]; then
+ base_dir=$source_dir
+ if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then
+ base_dir=`echo $source_dir | rev | cut -c 2- | rev`
+ fi
+ build_dir="$base_dir-build"
+ else
+ print_help
exit 1
fi
- canonical_path=`abspath $1`
- source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
- build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
- echo -n "Cleaning directories... "
+fi
+
+## Locate cmake executable
+if [ "x$cmake_exec" == "x" ]; then
+ cmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
+ cmake_ver=""
+ for loc in ${cmake_locations[@]}; do
+ cmake_file="$loc/cmake"
+ if [ -x $cmake_file ]; then
+ str=`$cmake_file --version | grep version`
+ version=${str:14}
+ if [ "$cmake_ver" \< "$version" ]; then
+ cmake_ver=$version
+ cmake_exec=$cmake_file
+ fi
+ fi
+ done
+fi
+if [ ! -x $cmake_exec ]; then
+ echo "ERROR: no valid cmake found."
+ exit 1
+fi
+cmake_exec=`abspath $cmake_exec`
+
+## Other configuration variables
+platform=`uname`
+number_of_cores=`grep -c ^processor /proc/cpuinfo`
+number_of_threads=`expr $number_of_cores / 2`
+if [ "x$source_file" != "x" ]; then
+ source_file=`abspath $source_file`
+fi
+source_dir=`abspath $source_dir`
+build_dir=`abspath $build_dir`
+
+echo "====================================================================="
+echo "==> Source file : $source_file"
+echo "==> Source dir : $source_dir"
+echo "==> Build dir : $build_dir"
+echo "==> Build type : $build_type"
+echo "==> Prefix : $prefix"
+echo "==> cmake : $cmake_exec"
+echo "==> Platform : $platform"
+echo "==> Number of cores : $number_of_cores"
+echo "==> Number of threads : $number_of_threads"
+echo "====================================================================="
+
+## Create paths
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Cleaning directories... "
rm -rf $source_dir
rm -rf $build_dir
echo "done."
- echo -n "Creating directories... "
+ echo -n "==> Creating directories... "
mkdir -p $source_dir
mkdir -p $build_dir
echo "done."
- echo -n "Extracting sources... "
- if [ "$actual_ext" == "zip" ]; then
- echo unzip $canonical_path
- elif [ "$actual_ext" == "tar" ]; then
- tar xf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.gz" ]; then
- tar xzf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.bz2" ]; then
- tar xjf $canonical_path -C $source_dir --strip-components=1
- else
- echo "$0: Invalid file type."
- exit 1
- fi
- echo "done!"
- build_type=$2
-elif [ "$#" -eq 3 ]; then
- source_dir=`dirname $1`
- build_dir=`dirname $2`
- build_type=$3
-else
- echo "Usage: [itk_package] or [itk_source_dir itk_build_dir] [build_type]"
fi
-echo "Given source dir : \"$source_dir\""
-echo "Given build dir : \"$build_dir\""
+## Extract source code
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Extracting sources... "
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ if [ "$base_ext" == "zip" ]; then
+ echo unzip $base_path
+ elif [ "$base_ext" == "tar" ]; then
+ tar xf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.gz" ]; then
+ tar xzf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.bz2" ]; then
+ tar xjf $base_path -C $source_dir --strip-components=1
+ fi
+ echo "done."
+fi
-echo "Configuring sources... "
+echo "==> Configuring sources... "
cd $build_dir
$cmake_exec \
-DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
-DCMAKE_BUILD_TYPE:STRING=$build_type \
-DModule_ITKReview:BOOL=ON \
-DModule_ITKVtkGlue:BOOL=OFF \
- -DCMAKE_INSTALL_PREFIX:PATH=${HOME}/local \
+ -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
${source_dir}
-echo "Configuring sources... done."
+echo "==> Configuring sources... done."
-echo "Compiling sources..."
+echo "==> Compiling sources..."
cd $build_dir
-make $number_of_processes
-echo "Compiling sources... done."
+make -j$number_of_threads
+echo "==> Compiling sources... done."
-echo "Installing package..."
+echo "==> Installing package..."
cd $build_dir
make -j install
-echo "Installing package... done."
+echo "==> Installing package... done."
## eof - $RCSfile$
popd > /dev/null
}
-## Some configuration variables
-number_of_processes="-j4"
+function get_file_extension
+{
+ valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
+ actual_file=`abspath $1`
+ actual_ext=""
+ for ext in ${valid_extensions[@]}; do
+ test_str=`dirname $actual_file`/`basename $actual_file $ext`
+ if [ $test_str != $actual_file ]; then
+ actual_ext=$ext
+ fi
+ done
+ echo "$actual_ext"
+}
+
+function print_help()
+{
+ echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-t=build_type[release/debug]] [-p=instalation_prefix] [--full]"
+}
+
+## Analyze command-line arguments
+if [ $# -eq 0 ]; then
+ print_help
+ exit 1
+fi
+full_compile="0"
+prefix="${HOME}/local"
+build_type="release"
+for i in "$@"; do
+ case $i in
+ -f=*|--file=*)
+ source_file="${i#*=}"
+ shift
+ ;;
+ -c=*|--source_dir=*)
+ source_dir="${i#*=}"
+ shift
+ ;;
+ -b=*|--build_dir=*)
+ build_dir="${i#*=}"
+ shift
+ ;;
+ -t=*|--build_type=*)
+ build_type="${i#*=}"
+ shift
+ ;;
+ -p=*|--prefix=*)
+ prefix="${i#*=}"
+ shift
+ ;;
+ --full)
+ full_compile="1"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+done
+
+## Check command line arguments
+if [ "x$source_dir" == "x" ]; then
+ if [ "x$source_file" != "x" ]; then
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ base_dir=`dirname $base_path`
+ if [ "x$base_ext" != "x" ]; then
+ source_dir="$base_dir"/`basename $base_path .$base_ext`
+ else
+ echo "Error: Input compressed file extension not recognized."
+ exit 1
+ fi
+ else
+ print_help
+ exit 1
+ fi
+fi
+if [ "x$build_dir" == "x" ]; then
+ if [ "x$source_dir" != "x" ]; then
+ base_dir=$source_dir
+ if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then
+ base_dir=`echo $source_dir | rev | cut -c 2- | rev`
+ fi
+ build_dir="$base_dir-build"
+ else
+ print_help
+ exit 1
+ fi
+fi
+
+## Other configuration variables
platform=`uname`
particular_options=""
patch_file=""
bash_dir=`dirname $bash_path`
patch_file=$bash_dir/qt-4.8.6.patch
fi
+number_of_cores=`grep -c ^processor /proc/cpuinfo`
+number_of_threads=`expr $number_of_cores / 2`
+if [ "x$source_file" != "x" ]; then
+ source_file=`abspath $source_file`
+fi
+source_dir=`abspath $source_dir`
+build_dir=`abspath $build_dir`
-## Check input parameters and process inputs (if needed)
-if [ "$#" -eq 3 ]; then
- valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
- actual_ext=""
- for ext in ${valid_extensions[@]}; do
- if [ `basename $1 $ext` != $1 ]; then
- actual_ext=$ext
- fi
- done
- if [ "x$actual_ext" == "x" ]; then
- echo "$0: Invalid file type."
- exit 1
- fi
- canonical_path=`abspath $1`
- source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
- build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
- echo -n "Cleaning directories... "
+echo "====================================================================="
+echo "==> Source file : $source_file"
+echo "==> Source dir : $source_dir"
+echo "==> Build dir : $build_dir"
+echo "==> Build type : $build_type"
+echo "==> Prefix : $prefix"
+echo "==> Full compile : $full_compile"
+echo "==> Platform : $platform"
+echo "==> Number of cores : $number_of_cores"
+echo "==> Number of threads : $number_of_threads"
+echo "==> Patch file : $patch_file"
+echo "====================================================================="
+
+## Create paths
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Cleaning directories... "
rm -rf $source_dir
rm -rf $build_dir
echo "done."
- echo -n "Creating directories... "
+ echo -n "==> Creating directories... "
mkdir -p $source_dir
mkdir -p $build_dir
echo "done."
- echo -n "Extracting sources... "
- if [ "$actual_ext" == "zip" ]; then
- echo unzip $canonical_path
- elif [ "$actual_ext" == "tar" ]; then
- tar xf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.gz" ]; then
- tar xzf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.bz2" ]; then
- tar xjf $canonical_path -C $source_dir --strip-components=1
- else
- echo "$0: Invalid file type."
- exit 1
+fi
+
+## Extract source code
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Extracting sources... "
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ if [ "$base_ext" == "zip" ]; then
+ echo unzip $base_path
+ elif [ "$base_ext" == "tar" ]; then
+ tar xf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.gz" ]; then
+ tar xzf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.bz2" ]; then
+ tar xjf $base_path -C $source_dir --strip-components=1
fi
- echo "done!"
- build_type=$2
- full_compil=$3
-elif [ "$#" -eq 4 ]; then
- source_dir=`dirname $1`
- build_dir=`dirname $2`
- build_type=$3
- full_compil=$4
-else
- echo "Usage: [qt4_package] or [qt4_source_dir qt4_build_dir] [build_type] [min/full]"
+ echo "done."
fi
# Apply patch
if [ "x$patch_file" != "x" ]; then
- echo -n "Applying patch... "
+ echo -n "==> Applying patch... "
cd $source_dir
patch -p0 < $patch_file
echo "done."
fi
-echo "Given source dir : \"$source_dir\""
-echo "Given build dir : \"$build_dir\""
-
-echo "Configuring sources... "
+echo "==> Configuring sources... "
cd $build_dir
-if [ "x$full_compil" == "xfull" ]; then
+if [ "x$full_compile" == "xfull" ]; then
$source_dir/configure \
- -prefix ${HOME}/local \
- $build_type \
+ -prefix $prefix \
+ -$build_type \
-opensource -shared -fast \
-no-webkit \
-optimized-qmake \
-confirm-license
else
$source_dir/configure \
- -prefix ${HOME}/local \
- $build_type \
+ -prefix $prefix \
+ -$build_type \
-opensource -shared -fast \
-no-phonon \
-no-phonon-backend \
$particular_options \
-confirm-license
fi
-echo "Configuring sources... done."
+echo "==> Configuring sources... done."
-echo "Compiling sources..."
+echo "==> Compiling sources..."
cd $build_dir
-make $number_of_processes
-echo "Compiling sources... done."
+make -j$number_of_threads
+echo "==> Compiling sources... done."
-echo "Installing package..."
+echo "==> Installing package..."
cd $build_dir
make -j install
-echo "Installing package... done."
+echo "==> Installing package... done."
## eof - $RCSfile$
popd > /dev/null
}
-## Some configuration variables
-number_of_processes="-j4"
+function get_file_extension
+{
+ valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
+ actual_file=`abspath $1`
+ actual_ext=""
+ for ext in ${valid_extensions[@]}; do
+ test_str=`dirname $actual_file`/`basename $actual_file $ext`
+ if [ $test_str != $actual_file ]; then
+ actual_ext=$ext
+ fi
+ done
+ echo "$actual_ext"
+}
-## Locate cmake executable
-cmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
-cmake_exec=""
-cmake_ver=""
-for loc in ${cmake_locations[@]}; do
- cmake_file="$loc/cmake"
- if [ -x $cmake_file ]; then
- str=`$cmake_file --version | grep version`
- version=${str:14}
- if [ "$cmake_ver" \< "$version" ]; then
- cmake_ver=$version
- cmake_exec=$cmake_file
+function print_help()
+{
+ echo "Usage: `basename $0` -f=compressed_code -c=source_dir -b=build_dir [-p=instalation_prefix] [-q=qmake_executable] [-m=cmake_executable] [-t=build_type[MinSizeRel/Debug/Release]]"
+}
+
+## Analyze command-line arguments
+if [ $# -eq 0 ]; then
+ print_help
+ exit 1
+fi
+prefix="${HOME}/local"
+build_type="MinSizeRel"
+for i in "$@"; do
+ case $i in
+ -f=*|--file=*)
+ source_file="${i#*=}"
+ shift
+ ;;
+ -c=*|--source_dir=*)
+ source_dir="${i#*=}"
+ shift
+ ;;
+ -b=*|--build_dir=*)
+ build_dir="${i#*=}"
+ shift
+ ;;
+ -t=*|--build_type=*)
+ build_type="${i#*=}"
+ shift
+ ;;
+ -p=*|--prefix=*)
+ prefix="${i#*=}"
+ shift
+ ;;
+ -m=*|--cmake=*)
+ cmake_exec="${i#*=}"
+ shift
+ ;;
+ -q=*|--qmake=*)
+ qmake_exec="${i#*=}"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+done
+
+## Check command line arguments
+if [ "x$source_dir" == "x" ]; then
+ if [ "x$source_file" != "x" ]; then
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ base_dir=`dirname $base_path`
+ if [ "x$base_ext" != "x" ]; then
+ source_dir="$base_dir"/`basename $base_path .$base_ext`
+ else
+ echo "Error: Input compressed file extension not recognized."
+ exit 1
fi
+ else
+ print_help
+ exit 1
fi
-done
-if [ ! -x $cmake_exec ]; then
- echo "$0: modify this script to put the correct location of cmake."
- exit 1
fi
-
-# Locate qmake executable
-qmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
-qmake_exec=""
-for loc in ${qmake_locations[@]}; do
- qmake_file="$loc/qmake"
- if [ -x $qmake_file ]; then
- version=`$qmake_file --version | grep Using\ Qt\ version | cut -d ' ' -f 4`
- if [ "${version:0:3}" == "4.8" ]; then
- qmake_exec=$qmake_file
+if [ "x$build_dir" == "x" ]; then
+ if [ "x$source_dir" != "x" ]; then
+ base_dir=$source_dir
+ if [ "${source_dir:$((${#str}-1)):1}" == "/" ]; then
+ base_dir=`echo $source_dir | rev | cut -c 2- | rev`
fi
+ build_dir="$base_dir-build"
+ else
+ print_help
+ exit 1
fi
-done
+fi
-if [ ! -x $qmake_exec ]; then
- echo "$0: modify this script to put the correct location of qmake."
+## Locate cmake executable
+if [ "x$cmake_exec" == "x" ]; then
+ cmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
+ cmake_ver=""
+ for loc in ${cmake_locations[@]}; do
+ cmake_file="$loc/cmake"
+ if [ -x $cmake_file ]; then
+ str=`$cmake_file --version | grep version`
+ version=${str:14}
+ if [ "$cmake_ver" \< "$version" ]; then
+ cmake_ver=$version
+ cmake_exec=$cmake_file
+ fi
+ fi
+ done
+fi
+if [ ! -x $cmake_exec ]; then
+ echo "ERROR: no valid cmake found."
exit 1
fi
+cmake_exec=`abspath $cmake_exec`
-## Check input parameters and process inputs (if needed)
-if [ "$#" -eq 2 ]; then
- valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
- actual_ext=""
- for ext in ${valid_extensions[@]}; do
- if [ `basename $1 $ext` != $1 ]; then
- actual_ext=$ext
+# Locate qmake executable
+if [ "x$qmake_exec" == "x" ]; then
+ qmake_locations=("/usr/bin" "/usr/local/bin" "${HOME}/local/bin")
+ for loc in ${qmake_locations[@]}; do
+ qmake_file="$loc/qmake"
+ if [ -x $qmake_file ]; then
+ version=`$qmake_file --version | grep Using\ Qt\ version | cut -d ' ' -f 4`
+ if [ "${version:0:3}" == "4.8" ]; then
+ qmake_exec=$qmake_file
+ fi
fi
done
- if [ "x$actual_ext" == "x" ]; then
- echo "$0: Invalid file type."
- exit 1
- fi
- canonical_path=`abspath $1`
- source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
- build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
- echo -n "Cleaning directories... "
+fi
+qmake_exec=`abspath $qmake_exec`
+if [ -x $qmake_exec ]; then
+ use_qt="1"
+else
+ use_qt="0"
+fi
+
+## Other configuration variables
+platform=`uname`
+number_of_cores=`grep -c ^processor /proc/cpuinfo`
+number_of_threads=`expr $number_of_cores / 2`
+if [ "x$source_file" != "x" ]; then
+ source_file=`abspath $source_file`
+fi
+source_dir=`abspath $source_dir`
+build_dir=`abspath $build_dir`
+
+echo "====================================================================="
+echo "==> Source file : $source_file"
+echo "==> Source dir : $source_dir"
+echo "==> Build dir : $build_dir"
+echo "==> Build type : $build_type"
+echo "==> Prefix : $prefix"
+echo "==> cmake : $cmake_exec"
+echo "==> qmake : $qmake_exec"
+echo "==> Use Qt : $use_qt"
+echo "==> Platform : $platform"
+echo "==> Number of cores : $number_of_cores"
+echo "==> Number of threads : $number_of_threads"
+echo "====================================================================="
+
+## Create paths
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Cleaning directories... "
rm -rf $source_dir
rm -rf $build_dir
echo "done."
- echo -n "Creating directories... "
+ echo -n "==> Creating directories... "
mkdir -p $source_dir
mkdir -p $build_dir
echo "done."
- echo -n "Extracting sources... "
- if [ "$actual_ext" == "zip" ]; then
- echo unzip $canonical_path
- elif [ "$actual_ext" == "tar" ]; then
- tar xf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.gz" ]; then
- tar xzf $canonical_path -C $source_dir --strip-components=1
- elif [ "$actual_ext" == "tar.bz2" ]; then
- tar xjf $canonical_path -C $source_dir --strip-components=1
- else
- echo "$0: Invalid file type."
- exit 1
- fi
- echo "done!"
- build_type=$2
-elif [ "$#" -eq 3 ]; then
- source_dir=`dirname $1`
- build_dir=`dirname $2`
- build_type=$3
-else
- echo "Usage: [vtk_package] or [vtk_source_dir vtk_build_dir] [build_type]"
fi
-echo "Given source dir : \"$source_dir\""
-echo "Given build dir : \"$build_dir\""
+## Extract source code
+if [ "x$source_file" != "x" ]; then
+ echo -n "==> Extracting sources... "
+ base_path=`abspath $source_file`
+ base_ext=`get_file_extension $base_path`
+ if [ "$base_ext" == "zip" ]; then
+ echo unzip $base_path
+ elif [ "$base_ext" == "tar" ]; then
+ tar xf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.gz" ]; then
+ tar xzf $base_path -C $source_dir --strip-components=1
+ elif [ "$base_ext" == "tar.bz2" ]; then
+ tar xjf $base_path -C $source_dir --strip-components=1
+ fi
+ echo "done."
+fi
-echo "Configuring sources... "
+echo "==> Configuring sources... "
cd $build_dir
-$cmake_exec \
- -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
- -DBUILD_DOCUMENTATION:BOOL=OFF \
- -DBUILD_EXAMPLES:BOOL=OFF \
- -DBUILD_SHARED_LIBS:BOOL=ON \
- -DBUILD_TESTING:BOOL=OFF \
- -DQT_QMAKE_EXECUTABLE:PATH=$qmake_exec \
- -DCMAKE_BUILD_TYPE:STRING=$build_type \
- -DModule_vtkGUISupportQt:BOOL=ON \
- -DModule_vtkGUISupportQtOpenGL:BOOL=ON \
- -DModule_vtkGUISupportQtSQL:BOOL=OFF \
- -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
- -DCMAKE_INSTALL_PREFIX:PATH=${HOME}/local \
- ${source_dir}
-echo "Configuring sources... done."
+if [ "$use_qt" == "1" ]; then
+ $cmake_exec \
+ -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+ -DBUILD_DOCUMENTATION:BOOL=OFF \
+ -DBUILD_EXAMPLES:BOOL=OFF \
+ -DBUILD_SHARED_LIBS:BOOL=ON \
+ -DBUILD_TESTING:BOOL=OFF \
+ -DQT_QMAKE_EXECUTABLE:PATH=$qmake_exec \
+ -DCMAKE_BUILD_TYPE:STRING=$build_type \
+ -DModule_vtkGUISupportQt:BOOL=ON \
+ -DModule_vtkGUISupportQtOpenGL:BOOL=ON \
+ -DModule_vtkGUISupportQtSQL:BOOL=OFF \
+ -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
+ -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
+ ${source_dir}
+else
+ $cmake_exec \
+ -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+ -DBUILD_DOCUMENTATION:BOOL=OFF \
+ -DBUILD_EXAMPLES:BOOL=OFF \
+ -DBUILD_SHARED_LIBS:BOOL=ON \
+ -DBUILD_TESTING:BOOL=OFF \
+ -DCMAKE_BUILD_TYPE:STRING=$build_type \
+ -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
+ ${source_dir}
+fi
+echo "==> Configuring sources... done."
-echo "Compiling sources..."
+echo "==> Compiling sources..."
cd $build_dir
-make $number_of_processes
-echo "Compiling sources... done."
+make -j$number_of_threads
+echo "==> Compiling sources... done."
-echo "Installing package..."
+echo "==> Installing package..."
cd $build_dir
make -j install
-echo "Installing package... done."
+echo "==> Installing package... done."
## eof - $RCSfile$