44    if not os.path.exists(args.build_dir):
 
   45        os.mkdir(args.build_dir)
 
   46    elif args.clean_build:
 
   47        shutil.rmtree(args.build_dir)
 
   48        os.mkdir(args.build_dir)
 
   50    root_dir = os.path.split(__file__)[0]
 
   51    makefile = os.path.join(args.build_dir, 
'Makefile')
 
   52    on_darwin = platform.system() == 
'Darwin' 
   53    libext = 
'.dylib' if on_darwin 
else '.so' 
   55    if not os.path.exists(makefile):
 
   56        rtn = subprocess.call([
'which', 
'cmake'], shell=(os.name == 
'nt'))
 
   58            sys.exit(
"CMake could not be found, " 
   59                     "please install CMake before developing Cyclus.")
 
   60        cmake_cmd = [
'cmake', os.path.abspath(root_dir)]
 
   62            cmake_cmd += [
'-DCMAKE_INSTALL_PREFIX=' +
 
   64        if args.cmake_prefix_path:
 
   65            cmake_cmd += [
'-DCMAKE_PREFIX_PATH=' +
 
   67        if cmake_cmd 
is not None:
 
   68            cmake_cmd += [
'-DDEFAULT_ALLOW_MILPS=' +
 
   69                          (
'TRUE' if args.allow_milps 
else 'FALSE')]
 
   71            cmake_cmd += [
'-DDEPS_ROOT_DIR=' + 
absexpanduser(args.deps_root)]
 
   73            cmake_cmd += [
'-DCOIN_ROOT_DIR=' + 
absexpanduser(args.coin_root)]
 
   75            cmake_cmd += [
'-DBOOST_ROOT=' + 
absexpanduser(args.boost_root)]
 
   77            cmake_cmd += [
'-DCYCLUS_ROOT_DIR='+
absexpanduser(args.cyclus_root)]
 
   80            cmake_cmd += [
'-DHDF5_ROOT=' + h5root,
 
   81                          '-DHDF5_LIBRARIES={0}/lib/libhdf5{1};{0}/lib/libhdf5_hl{1}'.format(h5root, libext),
 
   82                          '-DHDF5_LIBRARY_DIRS=' + h5root + 
'/lib',
 
   83                          '-DHDF5_INCLUDE_DIRS=' + h5root + 
'/include',
 
   86            cmake_cmd += [
'-DCMAKE_BUILD_TYPE=' + args.build_type]
 
   87        if args.D 
is not None:
 
   88            cmake_cmd += [
'-D' + x 
for x 
in args.D]
 
   90            cmake_cmd += [
'-Wdev', 
'--debug-output']
 
   92        rtn = subprocess.check_call(cmake_cmd, cwd=args.build_dir,
 
   93                                    shell=(os.name == 
'nt'))
 
  103        make_cmd += [
'-j' + str(args.threads)]
 
  104    rtn = subprocess.check_call(make_cmd, cwd=args.build_dir,
 
  105                                shell=(os.name == 
'nt'))
 
  109    elif not args.build_only:
 
  110        make_cmd += [
'install']
 
  112    rtn = subprocess.check_call(make_cmd, cwd=args.build_dir,
 
  113                                shell=(os.name == 
'nt'))
 
 
  126    description = 
"A Cyclus installation helper script. " +\
 
  127        "For more information, please see cyclus.github.com." 
  128    parser = ap.ArgumentParser(description=description)
 
  130    build_dir = 
'where to place the build directory' 
  131    parser.add_argument(
'--build_dir', help=build_dir, default=
'build')
 
  134    parser.add_argument(
'--uninstall', action=
'store_true', help=uninst, default=
False)
 
  136    noupdate = 
'do not update the hash in version.cc' 
  137    parser.add_argument(
'--no-update', dest=
'update', action=
'store_false',
 
  138                        help=noupdate, default=
True)
 
  140    clean = 
'attempt to remove the build directory before building' 
  141    parser.add_argument(
'--clean-build', action=
'store_true', help=clean)
 
  143    threads = 
"the number of threads to use in the make step" 
  144    parser.add_argument(
'-j', 
'--threads', type=int, help=threads)
 
  146    prefix = 
"the relative path to the installation directory" 
  147    parser.add_argument(
'--prefix', help=prefix, default=localdir)
 
  149    config_only = 
'only configure the package, do not build or install' 
  150    parser.add_argument(
'--config-only', action=
'store_true', help=config_only)
 
  152    build_only = 
'only build the package, do not install' 
  153    parser.add_argument(
'--build-only', action=
'store_true', help=build_only)
 
  155    test = 
'run tests after building' 
  156    parser.add_argument(
'--test', action=
'store_true', help=test)
 
  158    parser.add_argument(
'--allow-milps', action=
'store_true',
 
  159                        dest=
'allow_milps', default=
None,
 
  160                        help=
'Allows mixed integer linear programs by default')
 
  161    parser.add_argument(
'--dont-allow-milps', action=
'store_false',
 
  163                        help=
"Don't Allows mixed integer linear programs " 
  166    deps = 
"the path to the directory containing all dependencies" 
  167    parser.add_argument(
'--deps-root', 
'--deps_root', help=deps,
 
  168                        default=
None, dest=
'deps_root')
 
  170    coin = 
"the relative path to the Coin-OR libraries directory" 
  171    parser.add_argument(
'--coin-root', 
'--coin_root', help=coin)
 
  173    boost = 
"the relative path to the Boost libraries directory" 
  174    parser.add_argument(
'--boost_root', help=boost)
 
  176    hdf5 = 
"the path to the HDF5 libraries directory" 
  177    parser.add_argument(
'--hdf5_root', help=hdf5)
 
  179    cyclus = 
"the relative path to Cyclus installation directory" 
  180    parser.add_argument(
'--cyclus-root', 
'--cyclus_root', help=cyclus)
 
  182    cmake_prefix_path = 
"the cmake prefix path for use with FIND_PACKAGE, " + \
 
  183        "FIND_PATH, FIND_PROGRAM, or FIND_LIBRARY macros" 
  184    parser.add_argument(
'--cmake_prefix_path', help=cmake_prefix_path)
 
  186    build_type = 
"the CMAKE_BUILD_TYPE" 
  187    parser.add_argument(
'--build-type', 
'--build_type', help=build_type,
 
  190    parser.add_argument(
'-D', metavar=
'VAR', action=
'append',
 
  191                        help=
'Set enviornment variable(s).')
 
  192    parser.add_argument(
'--cmake-debug', action=
'store_true', default=
False,
 
  193                        dest=
'cmake_debug', help=
'puts CMake itself in a debug mode ' 
  194                                                 'when dealing with build system issues.')
 
  196    args = parser.parse_args()
 
  198    if args.deps_root 
is not None:
 
  199        roots = [
'coin_root', 
'boost_root', 
'hdf5_root', 
'cyclus_root']
 
  201            if not getattr(args, name, 
None):
 
  202                setattr(args, name, args.deps_root)