+++ /dev/null
-#!/usr/bin/python
-
-import glob, multiprocessing, os, platform, readline
-from distutils import spawn
-
-## --------------------
-## -- Various values --
-## --------------------
-
-system_name = platform.system( )
-process_count = multiprocessing.cpu_count( ) / 2
-home_dir = os.environ[ "HOME" ]
-
-## ------------------------
-## -- Filename completer --
-## ------------------------
-
-def filename_completer( text, state ):
- return ( glob.glob( text + '*' ) + [ None ] )[ state ]
-# fed
-
-def get_filepath( message ):
- readline.set_completer_delims( ' \t\n;' )
- readline.parse_and_bind( "tab: complete" )
- readline.set_completer( filename_completer )
- return os.path.abspath( raw_input( message ) )
-# fed
-
-## --------------------
-## -- File extractor --
-## --------------------
-
-def file_extract( filename, outdir ):
- real_ext = None
- for ext in [ ".zip", ".tar", ".tar.gz", ".tar.bz2" ]:
- if filename[ len( filename ) - len( ext ) : ] == ext:
- real_ext = ext
- # fi
- # rof
- command = None
- if real_ext == ".zip":
- command = "unzip " + filename + " -d " + outdir
- elif real_ext == ".tar":
- command = "tar xf " + filename + " -C " + outdir + " --strip-components=1"
- elif real_ext == ".tar.gz":
- command = "tar xzf " + filename + " -C " + outdir + " --strip-components=1"
- elif real_ext == ".tar.bz2":
- command = "tar xjf " + filename + " -C " + outdir + " --strip-components=1"
- # fi
- if command <> None:
- print( "\tExtracting " + filename + "..." )
- res = os.system( "mkdir -p " + outdir + " && " + command )
- print( "\t\tdone." )
- if res == 0:
- return True
- else:
- return False
- else:
- return False
- # fi
-# fed
-
-## ------------------
-## -- Look for Qt4 --
-## ------------------
-
-qmake_locations = []
-qmake_progs = []
-if system_name == "Linux":
- qmake_locations = [
- "/usr/bin",
- "/usr/local/bin",
- home_dir + "/bin",
- home_dir + "/local/bin"
- ]
- qmake_progs = [ "qmake", "qmake-qt4" ]
-# fi
-
-qmake_paths = []
-for prog in qmake_progs:
- for loc in qmake_locations:
- path = spawn.find_executable( loc + "/" + prog )
- if path <> None:
- qmake_paths.append( path )
- # rof
-# rof
-
-print( "Please choose one configuration for Qt4:" )
-for i in range( len( qmake_paths ) ):
- print( "\t" + str( i ) + ": " + qmake_paths[ i ] )
-# rof
-print( "\t" + str( len( qmake_paths ) + 0 ) + ": Give another installation path (path to qmake)." )
-print( "\t" + str( len( qmake_paths ) + 1 ) + ": Build from scratch." )
-qmake_opt = -1
-while qmake_opt == -1:
- qmake_opt = int( raw_input( "\t---> " ) )
- if qmake_opt < 0 or qmake_opt > len( qmake_paths ) + 1:
- qmake_opt = -1
- # fi
-# elihw
-
-qmake_exec = None
-qmake_src = None
-if qmake_opt == len( qmake_paths ):
- qmake_exec = get_filepath( "Choose your own Qt4 installation: " )
- while not os.path.isfile( qmake_exec ):
- qmake_exec = get_filepath( "Choose your own Qt4 installation: " )
- # elihw
-elif qmake_opt == len( qmake_paths ) + 1:
- qmake_src = get_filepath( "Choose your own Qt4 source file: " )
- while not os.path.isfile( qmake_src ):
- qmake_src = get_filepath( "Choose your own Qt4 source file: " )
- # elihw
-else:
- qmake_exec = qmake_paths[ qmake_opt ]
-# fi
-
-## --------------------
-## -- Look for CMake --
-## --------------------
-
-cmake_locations = []
-cmake_progs = []
-if system_name == "Linux":
- cmake_locations = [
- "/usr/bin",
- "/usr/local/bin",
- home_dir + "/bin",
- home_dir + "/local/bin"
- ]
- cmake_progs = [ "cmake" ]
-# fi
-
-cmake_paths = []
-for prog in cmake_progs:
- for loc in cmake_locations:
- path = spawn.find_executable( loc + "/" + prog )
- if path <> None:
- cmake_paths.append( path )
- # rof
-# rof
-
-print( "Please choose one configuration for CMake:" )
-for i in range( len( cmake_paths ) ):
- print( "\t" + str( i ) + ": " + cmake_paths[ i ] )
-# rof
-print( "\t" + str( len( cmake_paths ) + 0 ) + ": Give another installation path (path to cmake)." )
-print( "\t" + str( len( cmake_paths ) + 1 ) + ": Build from scratch." )
-cmake_opt = -1
-while cmake_opt == -1:
- cmake_opt = int( raw_input( "\t---> " ) )
- if cmake_opt < 0 or cmake_opt > len( cmake_paths ) + 1:
- cmake_opt = -1
- # fi
-# elihw
-
-cmake_exec = None
-cmake_src = None
-if cmake_opt == len( cmake_paths ):
- cmake_exec = get_filepath( "Choose your own CMake installation: " )
- while not os.path.isfile( cmake_exec ):
- cmake_exec = get_filepath( "Choose your own CMake installation: " )
- # elihw
-elif cmake_opt == len( cmake_paths ) + 1:
- cmake_src = get_filepath( "Choose your own CMake source file: " )
- while not os.path.isfile( cmake_src ):
- cmake_src = get_filepath( "Choose your own CMake source file: " )
- # elihw
-else:
- cmake_exec = cmake_paths[ cmake_opt ]
-# fi
-
-## ------------------
-## -- Look for ITK --
-## ------------------
-
-itk_src = get_filepath( "Choose your own ITK source file: " )
-while not os.path.isfile( itk_src ):
- itk_src = get_filepath( "Choose your own ITK source file: " )
-# elihw
-
-## ------------------
-## -- Look for VTK --
-## ------------------
-
-vtk_src = get_filepath( "Choose your own VTK source file: " )
-while not os.path.isfile( vtk_src ):
- vtk_src = get_filepath( "Choose your own VTK source file: " )
-# elihw
-
-## --------------------------
-## -- Miscelaneous options --
-## --------------------------
-
-build_prefix = get_filepath( "Build prefix: " )
-install_prefix = get_filepath( "Installation prefix: " )
-build_type = raw_input( "Build type [release/debug]: " ).lower( )
-
-os.system( "mkdir -p " + build_prefix )
-os.system( "mkdir -p " + install_prefix )
-
-## -------------------
-## -- Extract files --
-## -------------------
-
-print( "Extracting source code... " )
-if qmake_src <> None:
- file_extract( qmake_src, build_prefix + "/qt4-source" )
-# fi
-if cmake_src <> None:
- file_extract( cmake_src, build_prefix + "/cmake-source" )
-# fi
-file_extract( itk_src, build_prefix + "/itk-source" )
-file_extract( vtk_src, build_prefix + "/vtk-source" )
-print( " done!" )
-
-## ---------------
-## -- Build Qt4 --
-## ---------------
-
-if qmake_src <> None:
- full = raw_input( "\tWould you like to perform a full Qt4 build [y/n]? " )
- full.lower( )
-
- qt4_source = os.path.abspath( build_prefix + "/qt4-source" )
- qt4_build = os.path.abspath( build_prefix + "/qt4-build" )
- os.system( "mkdir -p " + qt4_build )
-
- config_command = qt4_source + "/configure"
- config_command += " -prefix " + install_prefix
- config_command += " -" + build_type
- config_command += " -opensource -shared -fast -no-webkit -optimized-qmake -confirm-license"
- if full[ 0 ] == "n":
- config_command += " -no-phonon -no-phonon-backend -no-openvg -nomake demos -nomake examples"
- # fi
- ## MACOS: -no-framework
-
- ## Build and install
- res = os.system( "cd " + qt4_build + " && " + config_command )
- if res <> 0:
- print( "Error configuring Qt4." )
- exit( 1 )
- # fi
- res = os.system( "cd " + qt4_build + " && make -j" + str( process_count ) )
- if res <> 0:
- print( "Error compiling Qt4." )
- exit( 1 )
- # fi
- res = os.system( "cd " + qt4_build + " && make -j install" )
- if res <> 0:
- print( "Error installing Qt4." )
- exit( 1 )
- # fi
- qmake_exec = install_prefix + "/bin/qmake"
-# fi
-
-## -----------------
-## -- Build CMake --
-## -----------------
-
-if cmake_src <> None:
- cmake_source = os.path.abspath( build_prefix + "/cmake-source" )
- cmake_build = os.path.abspath( build_prefix + "/cmake-build" )
- os.system( "mkdir -p " + cmake_build )
-
- config_command = cmake_source + "/bootstrap"
- config_command += " --prefix " + install_prefix
- if qmake_exec <> None:
- config_command += " --qt-gui --qt-qmake=" + qmake_exec
- else:
- config_command += " --no-qt-gui"
- # fi
-
- ## Build and install
- res = os.system( "cd " + cmake_build + " && " + config_command )
- if res <> 0:
- print( "Error configuring CMake." )
- exit( 1 )
- # fi
- res = os.system( "cd " + cmake_build + " && make -j" + str( process_count ) )
- if res <> 0:
- print( "Error compiling CMake." )
- exit( 1 )
- # fi
- res = os.system( "cd " + cmake_build + " && make -j install" )
- if res <> 0:
- print( "Error installing CMake." )
- exit( 1 )
- # fi
- cmake_exec = install_prefix + "/bin/cmake"
-# fi
-
-## ---------------
-## -- Build VTK --
-## ---------------
-
-vtk_source = os.path.abspath( build_prefix + "/vtk-source" )
-vtk_build = os.path.abspath( build_prefix + "/vtk-build" )
-os.system( "mkdir -p " + vtk_build )
-
-kitware_build = "MinSizeRel"
-if build_type == "debug":
- kitware_build = "Debug"
-# fi
-
-vtk_configure = cmake_exec
-vtk_configure += " -DCMAKE_CXX_FLAGS:STRING=-std=c++11"
-vtk_configure += " -DBUILD_DOCUMENTATION:BOOL=OFF"
-vtk_configure += " -DBUILD_EXAMPLES:BOOL=OFF"
-vtk_configure += " -DBUILD_SHARED_LIBS:BOOL=ON"
-vtk_configure += " -DBUILD_TESTING:BOOL=OFF"
-vtk_configure += " -DCMAKE_BUILD_TYPE:STRING=" + kitware_build
-if qmake_exec <> None:
- vtk_configure += " -DQT_QMAKE_EXECUTABLE:PATH=" + qmake_exec
- vtk_configure += " -DModule_vtkGUISupportQt:BOOL=ON"
- vtk_configure += " -DModule_vtkGUISupportQtOpenGL:BOOL=ON"
- vtk_configure += " -DModule_vtkGUISupportQtSQL:BOOL=OFF"
- vtk_configure += " -DModule_vtkGUISupportQtWebkit:BOOL=OFF"
-# fi
-vtk_configure += " -DCMAKE_INSTALL_PREFIX:PATH=" + install_prefix
-vtk_configure += " " + vtk_source
-
-## Build and install
-res = os.system( "cd " + vtk_build + " && " + vtk_configure )
-if res <> 0:
- print( "Error configuring VTK." )
- exit( 1 )
-# fi
-res = os.system( "cd " + vtk_build + " && make -j" + str( process_count ) )
-if res <> 0:
- print( "Error compiling VTK." )
- exit( 1 )
-# fi
-res = os.system( "cd " + vtk_build + " && make -j install" )
-if res <> 0:
- print( "Error installing VTK." )
- exit( 1 )
-# fi
-
-## ---------------
-## -- Build ITK --
-## ---------------
-
-itk_source = os.path.abspath( build_prefix + "/itk-source" )
-itk_build = os.path.abspath( build_prefix + "/itk-build" )
-os.system( "mkdir -p " + itk_build )
-
-kitware_build = "MinSizeRel"
-if build_type == "debug":
- kitware_build = "Debug"
-# fi
-
-itk_configure = cmake_exec
-itk_configure += " -DCMAKE_CXX_FLAGS:STRING=-std=c++11"
-itk_configure += " -DBUILD_DOCUMENTATION:BOOL=OFF"
-itk_configure += " -DBUILD_EXAMPLES:BOOL=OFF"
-itk_configure += " -DBUILD_SHARED_LIBS:BOOL=ON"
-itk_configure += " -DBUILD_TESTING:BOOL=OFF"
-itk_configure += " -DCMAKE_BUILD_TYPE:STRING=" + kitware_build
-itk_configure += " -DModule_ITKReview:BOOL=ON"
-itk_configure += " -DModule_ITKVtkGlue:BOOL=OFF"
-itk_configure += " -DModule_ParabolicMorphology:BOOL=ON"
-itk_configure += " -DCMAKE_INSTALL_PREFIX:PATH=" + install_prefix
-itk_configure += " " + itk_source
-
-## Build and install
-res = os.system( "cd " + itk_build + " && " + itk_configure )
-if res <> 0:
- print( "Error configuring ITK." )
- exit( 1 )
-# fi
-res = os.system( "cd " + itk_build + " && make -j" + str( process_count ) )
-if res <> 0:
- print( "Error compiling ITK." )
- exit( 1 )
-# fi
-res = os.system( "cd " + itk_build + " && make -j install" )
-if res <> 0:
- print( "Error installing ITK." )
- exit( 1 )
-# fi
-
-## eof - $RCSfile$