Geant4 Cross Reference |
1 #!/bin/sh 2 3 #----------------------------------------------------------------------- 4 # sh config query script for Geant4 @Geant4_VERSION@ on UNIX platforms 5 # Autogenerated by CMake DO NOT EDIT 6 #----------------------------------------------------------------------- 7 8 #----------------------------------------------------------------------- 9 # Determine location of this script. 10 # NB, we don't always use the result of this calculation, but it does not 11 # hurt to do it. Only possible error is if too long a chain of symbolic 12 # links are used to point to the physical script. 13 # 14 # Resolve symbolic links to script - we should end up with a physical file 15 script="$0" 16 calldir=`pwd` 17 loopcount="" 18 19 while [ "x`readlink $script`" != "x" ] ; do 20 preloc=`dirname $script` 21 script=`readlink $script` 22 23 if [ ${script##/} = ${script##~} ] ; then 24 # The symbolic link was relative... 25 script="$preloc/$script" 26 fi 27 loopcount="l$loopcount" 28 29 if [ ${#loopcount} -gt 10 ] ; then 30 echo "error: more than 10 symbolic links to geant4-config traversed." 31 exit 1 32 fi 33 done 34 35 # If we still have a relative path, then it must be relative to the 36 # calling dir. NB we don't attempt to resolve directory symbolic 37 # links or remove '.' or '..' 38 if [ ${script##/} = ${script##~} ] ; then 39 script="$calldir/$script" 40 fi 41 42 #----------------------------------------------------------------------- 43 # Finally, grab the directory in which the script is located 44 # Used below should we be setup to be relocatable. 45 scriptloc=`dirname $script` 46 47 #----------------------------------------------------------------------- 48 # Expansion and calculation of all needed variables 49 # 50 prefix=@GEANT4_CONFIG_INSTALL_PREFIX@ 51 # canonicalize path 52 prefix=`cd "$prefix" 2>/dev/null; pwd -P` 53 54 exec_prefix=@GEANT4_CONFIG_EXECPREFIX@ 55 libdir=@GEANT4_CONFIG_LIBDIR@ 56 includedirs="@GEANT4_CONFIG_INCLUDE_DIRS@" 57 58 name="geant4" 59 description="Geant4 toolkit for the simulation of the passage of particles through matter" 60 version="@Geant4_VERSION@" 61 62 # 'Requires' that may affect cflags and libs. 63 # Basic flags and libraries for visualization 64 vis_cflags="-DG4UI_USE_TCSH" 65 66 vis_libs="-lG4Tree \ 67 -lG4FR \ 68 -lG4GMocren \ 69 -lG4visHepRep \ 70 -lG4RayTracer \ 71 -lG4VRML \ 72 -lG4ToolsSG \ 73 -lG4vis_management \ 74 -lG4modeling" 75 76 #----------------------------------------------------------------------- 77 # Core setup... 78 # 79 cflags="@CMAKE_CXX_FLAGS@ @GEANT4_CXXSTD_FLAGS@" 80 feature_list="" 81 82 # - CXX Standard 83 geant4_cxx_std="@CMAKE_CXX_STANDARD@" 84 85 # - static libs 86 have_staticlibs="@G4_BUILTWITH_STATICLIBS@" 87 feature_list="${feature_list} staticlibs[${have_staticlibs}]" 88 # No action as yet 89 90 # - multithreading 91 have_multithreading="@G4_BUILTWITH_MULTITHREADING@" 92 feature_list="${feature_list} multithreading[${have_multithreading}]" 93 if test "x${have_multithreading}" = "xyes" ; then 94 geant4_tls_model="@GEANT4_BUILD_TLS_MODEL@" 95 if test "x${geant4_tls_model}" = "xauto" ; then 96 geant4_tls_model="" 97 fi 98 else 99 geant4_tls_model="" 100 fi 101 102 # - smart stacking 103 have_smartstack="@G4_BUILTWITH_SMARTSTACK@" 104 feature_list="${feature_list} smartstack[${have_smartstack}]" 105 if test "x${have_smartstack}" = "xyes" ; then 106 cflags="-DG4_USESMARTSTACK ${cflags}" 107 fi 108 109 # - ParticleHP was built as HP. Pure feature 110 have_php_as_hp="@G4_BUILTWITH_PHP_AS_HP@" 111 feature_list="${feature_list} php_as_hp[${have_php_as_hp}]" 112 113 # - Includes and Libs 114 for g4incdir in ${includedirs} ; do 115 cflags="${cflags} -I${g4incdir}" 116 done 117 118 libs="-lG4interfaces \ 119 -lG4geomtext \ 120 -lG4mctruth \ 121 -lG4analysis \ 122 -lG4error_propagation \ 123 -lG4readout \ 124 -lG4physicslists \ 125 -lG4run \ 126 -lG4event \ 127 -lG4tracking \ 128 -lG4parmodels \ 129 -lG4processes \ 130 -lG4digits_hits \ 131 -lG4track \ 132 -lG4particles \ 133 -lG4geometry \ 134 -lG4materials \ 135 -lG4graphics_reps \ 136 -lG4intercoms \ 137 -lG4global \ 138 @G4_LINK_CXX_FILESYSTEM@" 139 140 #----------------------------------------------------------------------- 141 # - Extra optional features that were enabled. 142 # - ALL 143 geant4_uses_opengl="no" 144 geant4_uses_x11="no" 145 146 # - CLHEP 147 have_clhep="@G4_BUILTWITH_CLHEP@" 148 feature_list="${feature_list} clhep[${have_clhep}]" 149 150 if test "x${have_clhep}" = "xno" ; then 151 cflags="${cflags} -I@G4_SYSTEM_CLHEP_INCLUDE_DIR@" 152 libs="${libs} @G4_SYSTEM_CLHEP_LIBRARIES@" 153 fi 154 if test "x${have_clhep}" = "xyes" ; then 155 libs="${libs} -lG4clhep" 156 fi 157 158 # - EXPAT 159 have_expat="@G4_BUILTWITH_EXPAT@" 160 feature_list="${feature_list} expat[${have_expat}]" 161 162 if test "x${have_expat}" = "xyes" ; then 163 libs="${libs} -lG4expat" 164 fi 165 166 # - ZLIB 167 have_zlib="@G4_BUILTWITH_ZLIB@" 168 feature_list="${feature_list} zlib[${have_zlib}]" 169 170 if test "x${have_zlib}" = "xyes" ; then 171 libs="${libs} -lG4zlib" 172 fi 173 174 # - GDML 175 have_gdml="@G4_BUILTWITH_GDML@" 176 feature_list="${feature_list} gdml[${have_gdml}]" 177 178 if test "x${have_gdml}" = "xyes" ; then 179 cflags="${cflags} @G4_XERCESC_CFLAGS@" 180 libs="-lG4gdml ${libs}" 181 fi 182 183 # - PTL 184 have_ptl="@G4_BUILTWITH_PTL@" 185 feature_list="${feature_list} ptl[${have_ptl}]" 186 187 if test "x${have_ptl}" = "xyes" ; then 188 libs="${libs} -lG4ptl" 189 fi 190 191 # - USolids 192 have_usolids="@G4_BUILTWITH_USOLIDS@" 193 feature_list="${feature_list} usolids[${have_usolids}]" 194 if test "x${have_usolids}" = "xyes" ; then 195 cflags="${cflags} @G4_USOLIDS_CFLAGS@" 196 fi 197 198 # - Freetype 199 have_freetype="@G4_BUILTWITH_FREETYPE@" 200 feature_list="${feature_list} freetype[${have_freetype}]" 201 202 # - HDF5 203 have_hdf5="@G4_BUILTWITH_HDF5@" 204 feature_list="${feature_list} hdf5[${have_hdf5}]" 205 206 # - G3toG4 207 have_g3tog4="@G4_BUILTWITH_G3TOG4@" 208 feature_list="${feature_list} g3tog4[${have_g3tog4}]" 209 210 if test "x${have_g3tog4}" = "xyes" ; then 211 libs="-lG3toG4 ${libs}" 212 fi 213 214 # - Qt 215 have_qt="@G4_BUILTWITH_QT@" 216 feature_list="${feature_list} qt[${have_qt}]" 217 218 if test "x${have_qt}" = "xyes" ; then 219 vis_cflags="${vis_cflags} \ 220 -DG4UI_USE_QT -DG4VIS_USE_OPENGLQT -DG4VIS_USE_TOOLSSG_QT_GLES @G4_QT_CFLAGS@" 221 geant4_uses_opengl="yes" 222 fi 223 224 # - QT3D 225 have_qt3d="@G4_BUILTWITH_QT3D@" 226 feature_list="${feature_list} qt3d[${have_qt3d}]" 227 228 if test "x${have_qt3d}" = "xyes" ; then 229 vis_libs="-lG4visQt3D ${vis_libs}" 230 vis_cflags="${vis_cflags} -DG4UI_USE_QT3D" 231 fi 232 233 # - Motif 234 have_motif="@G4_BUILTWITH_MOTIF@" 235 feature_list="${feature_list} motif[${have_motif}]" 236 237 if test "x${have_motif}" = "xyes" ; then 238 vis_cflags="${vis_cflags} -DG4UI_USE_XM -DG4VIS_USE_OPENGLXM -DG4VIS_USE_TOOLSSG_XT_GLES" 239 geant4_uses_x11="yes" 240 geant4_uses_opengl="yes" 241 fi 242 243 # - RayTracerX11 244 have_raytracerx11="@G4_BUILTWITH_RAYTRACERX11@" 245 feature_list="${feature_list} raytracer-x11[${have_raytracerx11}]" 246 247 if test "x${have_raytracerx11}" = "xyes" ; then 248 vis_cflags="${vis_cflags} -DG4VIS_USE_RAYTRACERX" 249 geant4_uses_x11="yes" 250 fi 251 252 # - OpenGL with X11 253 have_openglx11="@G4_BUILTWITH_OPENGLX11@" 254 feature_list="${feature_list} opengl-x11[${have_openglx11}]" 255 256 if test "x${have_openglx11}" = "xyes" ; then 257 vis_cflags="${vis_cflags} -DG4VIS_USE_OPENGLX -DG4VIS_USE_TOOLSSG_X11_GLES" 258 geant4_uses_opengl="yes" 259 geant4_uses_x11="yes" 260 fi 261 262 # - OpenInventor 263 # Whilst it *is* an Xt based driver, don't *think* Xt or X11 appear 264 # in the public interface, nor do the Inventor headers... 265 have_openinventor="@G4_BUILTWITH_INVENTOR@" 266 feature_list="${feature_list} openinventor[${have_openinventor}]" 267 268 if test "x${have_openinventor}" = "xyes" ; then 269 vis_cflags="${vis_cflags} -DG4VIS_USE_OI -DG4VIS_USE_OIX" 270 vis_libs="-lG4OpenInventor ${vis_libs}" 271 fi 272 273 # - VTK 274 have_vtk="@G4_BUILTWITH_VTK@" 275 feature_list="${feature_list} vtk[${have_vtk}]" 276 277 278 # - If we have any OpenGL based feature, then we need to add in the 279 # OpenGL global define and the G4OpenGL libraries. 280 if test "x${geant4_uses_opengl}" = "xyes" ; then 281 vis_cflags="-DG4VIS_USE_OPENGL ${vis_cflags}" 282 vis_libs="-lG4OpenGL ${vis_libs}" 283 fi 284 285 # - If we have any X11 based feature, then we *may* need the X11 includes 286 if test "x${geant4_uses_x11}" = "xyes" ; then 287 vis_cflags="@G4_X11_CFLAGS@ ${vis_cflags}" 288 fi 289 290 #----------------------------------------------------------------------- 291 # Datasets 292 # - List creation for sh compatibility, see: 293 # https://wiki.ubuntu.com/DashAsBinSh 294 # Note however that the guide in the link uses the GNU awk extension 295 # 'length' to find the number of elements in the array. This will fail 296 # on other awk implementations. Use standard feature of split function 297 # returning number of elements. 298 dataset_url="@GEANT4_DATASETS_URL@" 299 dataset_timeout="@GEANT4_INSTALL_DATA_TIMEOUT@" 300 dataset_list=$(awk 'BEGIN { n = split( "@GEANT4_CONFIG_DATASET_DESCRIPTIONS@", array, ";"); for (i=1;i<=n;i++) { print array[i]; } }') 301 302 #----------------------------------------------------------------------- 303 # function print_datasets 304 # print dataset information with one line per dataset and each 305 # line in the format 306 # <NAME> <ENVVARNAME> <PATH> 307 print_datasets() 308 { 309 for ds in ${dataset_list} ; do 310 dataset_name=$(echo $ds | cut -d "|" -f1) 311 dataset_envvar=$(echo $ds | cut -d "|" -f2) 312 dataset_path=$(echo $ds | cut -d "|" -f3) 313 echo ${dataset_name} ${dataset_envvar} ${dataset_path} 314 done 315 exit 0 316 } 317 318 #----------------------------------------------------------------------- 319 # function print_datasets_sh 320 # print dataset information with one line per dataset and each 321 # line in the format 322 # export <ENVVARNAME>="<PATH>" 323 print_datasets_sh() 324 { 325 for ds in ${dataset_list} ; do 326 dataset_envvar=$(echo $ds | cut -d "|" -f2) 327 dataset_path=$(echo $ds | cut -d "|" -f3) 328 echo "export ${dataset_envvar}=\"${dataset_path}\"" 329 done 330 exit 0 331 } 332 333 #----------------------------------------------------------------------- 334 # function print_datasets_csh 335 # print dataset information with one line per dataset and each 336 # line in the format 337 # setenv <ENVVARNAME> "<PATH>"; 338 print_datasets_csh() 339 { 340 for ds in ${dataset_list} ; do 341 dataset_envvar=$(echo $ds | cut -d "|" -f2) 342 dataset_path=$(echo $ds | cut -d "|" -f3) 343 echo "setenv ${dataset_envvar} \"${dataset_path}\";" 344 done 345 exit 0 346 } 347 348 #----------------------------------------------------------------------- 349 # function check_datasets 350 # Check whether datasets exist as directories at the expected 351 # location. Print dataset name, path and install status 352 # 353 check_datasets() 354 { 355 for ds in ${dataset_list} ; do 356 dataset_name=$(echo $ds | cut -d "|" -f1) 357 dataset_path=$(echo $ds | cut -d "|" -f3) 358 dataset_status="NOTFOUND" 359 if test -d ${dataset_path} ; then 360 dataset_status="INSTALLED" 361 fi 362 echo ${dataset_name} ${dataset_status} ${dataset_path} 363 done 364 } 365 366 #----------------------------------------------------------------------- 367 # function install_datasets 368 # Download and install datasets if they are not already installed 369 # 370 install_datasets() 371 { 372 G4CURL=$(which curl) 373 if test "x${G4CURL}" = "x" ; then 374 echo "- error: no curl executable found" 375 exit 1 376 fi 377 378 G4OPENSSL=$(which openssl) 379 if test "x${G4OPENSSL}" = "x" ; then 380 G4MD5SUM=$(which md5sum) 381 if test "x${G4MD5SUM}" = "x" ; then 382 echo "- error: no openssl or md5sum executable found" 383 exit 1 384 else 385 G4MD5CMD="${G4MD5SUM}" 386 fi 387 else 388 G4MD5CMD="${G4OPENSSL} dgst -md5 -r" 389 fi 390 391 G4TAR=$(which tar) 392 if test "x${G4TAR}" = "x" ; then 393 echo "- error: no tar executable found" 394 exit 1 395 fi 396 397 datasets_to_install='' 398 for ds in ${dataset_list} ; do 399 dataset_path=$(echo $ds | cut -d "|" -f3) 400 if test ! -d ${dataset_path} ; then 401 datasets_to_install="${datasets_to_install} ${ds}" 402 fi 403 done 404 405 dataset_install="ok" 406 if test "x${datasets_to_install}" != "x" ; then 407 # - Create download cache 408 g4downloaddir=$(mktemp -d -t g4dlcXXXXXXXXXX) 409 if test -d ${g4downloaddir} ; then 410 echo "+ created download cache" 411 else 412 echo "- error : failed to create '${g4downloaddir}'" 413 dataset_install="fail" 414 break 415 fi 416 417 # - Download/install loop 418 for ds in ${datasets_to_install} ; do 419 # Create base path (repetitive) 420 dataset_path=$(echo $ds | cut -d "|" -f3) 421 mkdir -p $(dirname ${dataset_path}) 422 if [ "$?" != "0" ] || [ ! -w $(dirname ${dataset_path}) ] ; then 423 echo "- error : failed to create base directory '$(dirname ${dataset_path})'" 424 dataset_install="fail" 425 break 426 fi 427 428 # - Download bundle to cache 429 dataset_file=$(echo $ds | cut -d "|" -f4) 430 echo "+ downloading ${dataset_file}" 431 ${G4CURL} -L -f -m ${dataset_timeout} -o ${g4downloaddir}/${dataset_file} ${dataset_url}/${dataset_file} 432 curl_status="$?" 433 if [ "$curl_status" != "0" ] ; then 434 echo "- download of '${dataset_file}' failed : CURL error $?" 435 dataset_install="fail" 436 break 437 fi 438 439 # Validate bundle hash (basic) 440 dataset_md5=$(echo $ds | cut -d "|" -f5) 441 actual_md5=$(${G4MD5CMD} ${g4downloaddir}/${dataset_file} | cut -d ' ' -f1) 442 echo "+ checking md5 of ${dataset_file}" 443 if [ "${actual_md5}" != "${dataset_md5}" ] ; then 444 echo "- md5 mismatch for '${dataset_file}' : ${actual_md5}(actual) != ${dataset_md5}(expected)" 445 dataset_install="fail" 446 break 447 fi 448 449 # Unpack bundle 450 echo "+ untar ${dataset_file}" 451 ${G4TAR} -C ${g4downloaddir} -xf ${g4downloaddir}/${dataset_file} 452 tar_status="$?" 453 if [ "$tar_status" != "0" ] ; then 454 echo "- untar of '${dataset_file}' failed : tar error $?" 455 dataset_install="fail" 456 break 457 fi 458 459 # Install bundle 460 echo "+ installing $(basename ${dataset_path})" 461 cp -R ${g4downloaddir}/$(basename ${dataset_path}) $(dirname ${dataset_path}) 462 cp_status="$?" 463 if [ "$cp_status" != "0" ] ; then 464 echo "- copy of '$(basename ${dataset_path})' failed : cp error $?" 465 # Extra task - remove anything copied... 466 rm -Rf ${dataset_path} 467 dataset_install="fail" 468 break 469 fi 470 done 471 472 # - Clean up download cache 473 rm -Rf ${g4downloaddir} 474 if test -d ${g4downloaddir} ; then 475 echo "- failed to remove '${g4downloaddir}'" 476 else 477 echo "+ cleaned download cache" 478 fi 479 fi 480 481 if [ "${dataset_install}" = "ok" ] ; then 482 echo "+ all datasets installed" 483 exit 0 484 else 485 echo "- dataset installation failed" 486 exit 1 487 fi 488 exit 1 489 } 490 491 #----------------------------------------------------------------------- 492 # function list_features 493 # print list of enabled and disabled features. 494 # 495 list_features() 496 { 497 cat<<EOF 498 Known Features: 499 EOF 500 for f in ${feature_list} ; do 501 echo " $f" 502 done 503 exit 0 504 } 505 506 #----------------------------------------------------------------------- 507 # function help 508 # print help on available command line arguments and enabled 509 # and disabled features of the toolkit 510 # 511 help() 512 { 513 cat<<EOF 514 Usage: geant4-config [OPTION...] 515 --prefix output installation prefix of Geant4 516 --version output version for Geant4 517 --cxxstd C++ Standard compiled against 518 --tls-model Thread Local Storage model used 519 --libs output all linker flags 520 --cflags output all preprocessor 521 and compiler flags 522 523 --libs-without-gui output linker flags without 524 GUI components 525 --cflags-without-gui output preprocessor and compiler 526 flags without GUI components 527 528 --has-feature FEATURE output yes if FEATURE is supported, 529 or no if not supported 530 531 --features print list of features 532 533 --sh print shell commands required to set environment 534 variables for Geant4, which can be evaluated in 535 the calling shell with "eval \$(geant4-config --sh)" 536 537 --csh print C shell commands required to set environment 538 variables for Geant4, which can be evaluated in 539 the calling shell with "eval \`geant4-config --csh\`" 540 541 --datasets output dataset name, environment variable 542 and path, with one line per dataset 543 544 --check-datasets output dataset name, installation status and 545 expected installation location, with one line 546 per dataset 547 548 --install-datasets download and install any missing datasets, 549 requires a network connection and for the dataset 550 path to be user writable 551 552 Known Features: 553 EOF 554 for f in ${feature_list} ; do 555 echo " $f" 556 done 557 558 cat<<EOF 559 560 Help options: 561 -?, --help show this help message 562 --usage display brief usage message 563 EOF 564 565 exit 1 566 } 567 568 #----------------------------------------------------------------------- 569 # function usage 570 # print basic usage message 571 # 572 usage() 573 { 574 cat<<EOF 575 Usage: geant4-config [--prefix] [--version] [--libs] [--cflags] 576 EOF 577 exit 1 578 } 579 580 #----------------------------------------------------------------------- 581 # Process arguments 582 # 583 if test $# -eq 0 ; then 584 usage 585 fi 586 587 while test $# -gt 0 ; do 588 case "$1" in 589 -*=*) 590 optflag=`echo "$1" | sed 's/=[-_a-zA-Z0-9]*//'` 591 optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` 592 ;; 593 *) 594 optflag=$1 595 optarg= 596 ;; 597 esac 598 599 case "$optflag" in 600 --prefix) 601 echo ${prefix} 602 ;; 603 604 --version) 605 echo ${version} 606 ;; 607 608 --cxxstd) 609 echo ${geant4_cxx_std} 610 ;; 611 612 --tls-model) 613 echo ${geant4_tls_model} 614 ;; 615 616 --libs) 617 echo "-L${libdir}" ${vis_libs} ${libs} 618 ;; 619 620 --cflags) 621 echo ${vis_cflags} ${cflags} 622 ;; 623 624 --libs-without-gui) 625 echo "-L${libdir}" ${libs} 626 ;; 627 628 --cflags-without-gui) 629 echo ${cflags} 630 ;; 631 632 --has-feature) 633 if [ x$optarg = x ]; then 634 if [ $# -gt 1 ]; then 635 shift 636 optarg=$1 637 else 638 echo "$optflag - missing parameter" 639 exit 1 640 fi 641 fi 642 643 case "$optarg" in 644 static) 645 echo ${have_staticlibs} 646 ;; 647 multithreading) 648 echo ${have_multithreading} 649 ;; 650 smartstack) 651 echo ${have_smartstack} 652 ;; 653 clhep) 654 echo ${have_clhep} 655 ;; 656 expat) 657 echo ${have_expat} 658 ;; 659 zlib) 660 echo ${have_zlib} 661 ;; 662 gdml) 663 echo ${have_gdml} 664 ;; 665 usolids) 666 echo ${have_usolids} 667 ;; 668 freetype) 669 echo ${have_freetype} 670 ;; 671 hdf5) 672 echo ${have_hdf5} 673 ;; 674 g3tog4) 675 echo ${have_g3tog4} 676 ;; 677 qt) 678 echo ${have_qt} 679 ;; 680 qt3d) 681 echo ${have_qt3d} 682 ;; 683 vtk) 684 echo ${have_vtk} 685 ;; 686 motif) 687 echo ${have_motif} 688 ;; 689 raytracer-x11) 690 echo ${have_raytracerx11} 691 ;; 692 opengl-x11) 693 echo ${have_openglx11} 694 ;; 695 openinventor) 696 echo ${have_openinventor} 697 ;; 698 php_as_hp) 699 echo ${have_php_as_hp} 700 ;; 701 *) 702 echo "no" 703 ;; 704 esac 705 ;; 706 707 --features) 708 list_features 709 ;; 710 711 --datasets) 712 print_datasets 713 ;; 714 715 --check-datasets) 716 check_datasets 717 ;; 718 719 --install-datasets) 720 install_datasets 721 ;; 722 723 --sh) 724 print_datasets_sh 725 ;; 726 727 --csh) 728 print_datasets_csh 729 ;; 730 731 -?) 732 help 733 ;; 734 735 --help) 736 help 737 ;; 738 739 --usage) 740 usage 741 ;; 742 743 *) 744 usage 745 ;; 746 esac 747 748 shift 749 done 750 751 # Finally... 752 exit 0