Enable topology (or physical node) aware spanning tree for array reductions
[charm.git] / build
blobf256b521b85bb32ce8f96f147b81f8ce0844e4cf
1 #!/bin/sh
3 # Silly shorthand, used for source reorganization
4 if [ $(dirname $0) = "." ]
5 then
6 srcbaseabs="./src"
7 srcbase="../../src"
8 else
9 srcbaseabs="$(cd $(dirname $0)/src/; pwd)"
10 srcbase=$srcbaseabs
12 src="$srcbaseabs/arch/"
14 more=0
16 syntax() {
17 echo ''
18 echo 'Usage: build <target> <version> <options> [charmc-options ...]'
19 echo ''
20 echo '<targets>: converse charm++ LIBS AMPI bigemulator msa'
21 echo '<targets>: doc ps-doc pdf-doc html-doc'
22 if test $more = 1
23 then
24 echo ''
25 echo ' charm++ compile Charm++ core only'
26 echo ' AMPI compile Adaptive MPI on top of Charm++'
27 echo ' LIBS compile additional parallel libraries with Charm++ core'
28 echo ' bigemulator build additional BigSim libraries'
29 echo ' msa build Multiphase Shared Arrays(MSA) library'
30 echo ' Tau build the TAU tracing library for generating TAU performance data'
31 echo ' ChaNGa compile Charm++ core and necessary libraries for ChaNGa'
32 echo ' everylb compile EveryLB suite of load balancing strategies'
33 echo ''
35 echo '<versions>: '
36 ( cd $src ; ls -1 | egrep -v '(^shmem$)|(^mpi$)|(^sim$)|(^net(lrts)?$)|(^multicore$)|(^util$)|(^common$)|(^uth$)|(^conv-mach-fix.sh$)|(^win64$)|(^(gemini_)?gni$)|(^pami(lrts)?$)|(^verbs$)|(^ofi$)|(^template$)|(^cuda$)' | pr -3 -t )
37 echo ''
38 echo '<options>: compiler and platform specific options'
39 echo 'icc iccstatic xlc xlc64 gcc clang pgcc cc mpicxx'
40 echo 'help smp omp tcp bigemulator ooc syncft mlogft causalft papi pthreads'
41 echo '--incdir --libdir --basedir --build-shared --destination --suffix -j'
42 if test $more = 1
43 then
44 echo ''
45 echo 'For platform specific options, use help option:'
46 echo ' help platform specific help, e.g. ./build charm++ netlrts-linux-x86_64 help'
47 echo ''
48 echo 'Choose a compiler (only one option is allowed from this section):'
49 echo ' icc, iccstatic Intel compilers (default or static linking)'
50 echo ' xlc, xlc64 IBM XL compilers (with 64-bit option on architectures with 32-bit modes)'
51 echo ' gcc GNU compiler collection (on platforms where the default differs)'
52 echo ' clang Clang C/C++ compiler (including bgclang)'
53 echo ' pgcc Portland Group compilers'
54 echo ''
55 echo 'Choose an alternative fortran compiler (only one option is allowed from this section):'
56 echo ' gfortran GNU Fortran compiler'
57 echo ' xlf IBM XL Fortran compiler'
58 echo ' ifort Intel Fortran compiler'
59 echo " pgf90 Portland Group Fortran compiler"
60 echo ''
61 echo 'Platform specific options (choose multiple if apply):'
62 echo ' smp support for SMP, multithreaded charm on each node'
63 echo ' omp support for the integrated LLVM OpenMP runtime'
64 echo ' ibverbs use Infiniband Verbs for communication (only for netlrts-linux-x86_64; prefer verbs-*)'
65 echo ' tcp use TCP sockets for communication (only for net version)'
66 echo ' pthreads compile with pthreads Converse threads'
67 echo ''
68 echo 'Advanced options:'
69 echo ' bigemulator compile for BigSim simulator'
70 echo ' ooc compile with out of core support'
71 echo ' syncft compile with Charm++ fault tolerance support'
72 echo ' mlogft compile with Charm++ message logging fault tolerance support'
73 echo ' papi compile with PAPI performance counter support (if any)'
74 echo ''
75 echo "Charm++ dynamic libraries:"
76 echo " --no-build-shared don't build Charm++'s shared libraries (default)"
77 echo " --build-shared build Charm++ dynamic libraries (.so) "
78 echo ''
79 echo 'Enable/disable features:'
80 $srcbaseabs/scripts/configure --help | grep enable-
81 $srcbaseabs/scripts/configure --help | grep with-
82 echo " --with-production build Charm++ with all optimizations for maximum performance, and disabling all above features"
83 echo ''
84 echo 'Miscellaneous options:'
85 echo ' --incdir=DIR specify additional include path for compiler'
86 echo ' --libdir=DIR specify additional lib path for compiler'
87 echo ' --basedir=DIR shortcut for the above two - DIR/include and DIR/lib'
88 echo ' -j[N] parallel make, N is the number of paralle make jobs'
89 echo " --with-lbtime-type specify real type for the load balancing timers"
90 echo " --destination=DIR build Charm++ inside DIR, by default the destination is <version>"
91 echo " --suffix=DIR append DIR to the destination directory of the Charm++ build"
92 echo " --tau-makefile=FILE Specify which TAU stub makefile to use"
94 echo ''
95 echo '<charmc-options>: normal compiler options e.g. -g -optimize -save -verbose'
96 if test $more = 1
97 then
98 echo ''
99 echo 'Examples:'
100 echo "1. display all supported options for netlrts-linux-x86_64 using 'help':"
101 echo ' ./build charm++ netlrts-linux-x86_64 help'
102 echo '2. compile Charm++ on Linux with all available tuning:'
103 echo ' ./build charm++ netlrts-linux-x86_64 --with-production'
104 echo '3. compile Charm++ for Linux with Intel compiler and optimizations:'
105 echo ' ./build charm++ netlrts-linux-x86_64 icc -optimize'
106 echo '4. compile Charm++ for Windows with VC++:'
107 echo ' ./build charm++ netlrts-win-x86_64 -optimize'
108 echo '5. compile Charm++ with MPI that is installed at /usr/local/mpich:'
109 echo ' ./build charm++ mpi-linux-x86_64 --incdir /usr/local/mpich/include --libdir /usr/local/mpich/lib -optimize'
110 echo ' or in short,'
111 echo ' ./build charm++ mpi-linux-x86_64 --basedir /usr/local/mpich -optimize'
112 echo ' ./build Tau --tau-makefile=/usr/local/packages/TAU/x86_64/lib/Makefile.tau-mpi'
113 echo ''
114 echo 'Note: This script:'
115 echo ' 1. Creates directories <destination> and <destination>/tmp'
116 echo ' 2. Copies src/scripts/Makefile into <destination>/tmp'
117 echo ' 3. Does a "make basics" in <destination>/tmp.'
118 echo ' 3. Does a "make -jN <target> <version> OPTS=<charmc-options>" in <destination>/tmp.'
119 echo "That's all build does. The rest is handled by the Makefile."
120 echo ''
121 echo 'Thank you for using Charm++, please send questions or comments to '
122 echo 'Parallel Programming Lab at University of Illinois at Urbana-Champaign'
123 echo '(email: charm@cs.illinois.edu).'
125 else
126 echo ''
127 echo "To get more detailed help, run ./build --help"
131 Echo() {
132 [ "x$QUIET" = "x--quiet" ] || echo $*
135 printOption() {
136 for prefix in cc conv-mach
138 str="Supported compilers:"
139 [ "$prefix" = "conv-mach" ] && str="Supported options:"
140 opts=""
141 for dir in $OPT_DIRS
143 # echo "Checking for $prefix in $dir"
144 files=`cd $dir; ls $prefix-*.h 2>/dev/null`
145 opts="$opts "`echo $files | sed 's/'$prefix'-\([^.]*\).h/\1/g'`
146 done
147 tmp=.tmp.$$
148 rm -f $tmp; touch $tmp
149 for o in $opts
151 echo $o >> $tmp
152 done
153 opts=`sort $tmp | uniq`
154 rm -f $tmp
155 echo $str $opts
156 done
157 exit 1
160 CheckDir() {
161 for d in $*
163 if test ! -d $d
164 then
165 echo Error: cannot find $d!
166 exit 1
168 done
171 TestIfCompiler() {
172 for dir in $OPT_DIRS
174 [ -f $dir/cc-$1.sh ] && return 1
175 done
176 return 0
179 TestIfOption() {
180 for dir in $OPT_DIRS
182 [ -f $dir/conv-mach-$1.h ] && return 1
183 done
185 echo "Error> option: $1 is not supported in this version!";
186 printOption
190 # start
192 BUILD_CUDA=0
193 MAKEOPTS=""
194 OPTS=""
195 BOPTS=""
196 MORE=""
197 COMPILER=""
198 BASEDIR=
199 LIBDIR=
200 INCDIR=
201 ARCH=
202 BUILD_SHARED="" # default no shared lib
203 WITH_ROMIO="true" # default to building ROMIO on AMPI
204 WITH_PRODUCTION=
205 BUILD_EMULATOR=0
206 DESTINATION=""
207 DESTINATION_SUFFIX=""
208 TAU_MAKEFILE=""
209 QUIET=""
210 BUILD_OMP=0
212 [ "$1" = '--help' -o "$1" = '-h' ] && more=1 && syntax | ( less || more ) && exit 1
213 [ $# -lt 2 ] && $(dirname "$0")/smart-build.pl && exit 1
214 PROGRAM=$1
215 shift
217 # find longest prefix of version argument that exists as a directory in $src
218 VERSION=$1
219 VERSOPTS=""
220 testversion=""
221 oldifs=$IFS
222 IFS=-
223 for w in $1; do
224 IFS=$oldifs
225 if [ -z "$testversion" ]; then
226 testversion=$w
227 else
228 testversion="$testversion-$w"
230 if [ -d $src/$testversion ]; then
231 VERSION=$testversion
232 VERSOPTS=""
233 else
234 VERSOPTS="$VERSOPTS $w"
236 done
237 if [ $VERSION = $1 ]; then VERSOPTS=""; fi
239 BASEVERSION=$VERSION;
240 if test -f $src/$BASEVERSION/vdir_link
241 then
242 BASEVERSION=`cat $src/$BASEVERSION/vdir_link`
244 ARCH=`echo $BASEVERSION | sed -e 's@-.*@@'`
245 shift
247 #echo $src
248 #echo $BASEVERSION
249 #echo $ARCH
251 OPT_DIRS="$src/$BASEVERSION $src/$ARCH $src/common"
253 # process remainder of version argument as options, copied from below
254 for w in $VERSOPTS; do
255 # This has to be a build-time option (like "smp")
256 TestIfCompiler $w
257 if [ $? -eq 1 ]
258 then
259 # It specifies a compiler:
260 if [ ! -z "$COMPILER" ]
261 then
262 echo "Error> Tried to specify two compilers: $COMPILER and $w"
263 printOption
265 COMPILER=$w
266 else
267 # It specifies some other option:
268 TestIfOption $w
269 BOPTS="$BOPTS $w"
270 [ $w = "bigemulator" ] && BUILD_EMULATOR=1
271 [ $w = "bigsim" ] && BUILD_EMULATOR=1
272 [ $w = "cuda" ] && BUILD_CUDA=1
274 done
276 while [ ! $# -eq 0 ]
278 case "$1" in
279 "--basedir")
280 shift;
281 for dir in $1
283 CheckDir $dir/include $dir/lib
284 LIBDIR="$LIBDIR -L$dir/lib";
285 INCDIR="$INCDIR -I$dir/include"
286 done
287 shift
289 --basedir=*)
290 basedir=`echo $1 | awk -F= '{print $2}'`
291 for dir in $basedir
293 CheckDir $dir/include $dir/lib
294 LIBDIR="$LIBDIR -L$dir/lib";
295 INCDIR="$INCDIR -I$dir/include"
296 done
297 shift
299 "--libdir")
300 shift; CheckDir $1
301 for dir in $1
303 LIBDIR="$LIBDIR -L$dir";
304 done
305 shift
307 --libdir=*)
308 libdir=`echo $1 | awk -F= '{print $2}'`
309 CheckDir $libdir
310 for dir in $libdir
312 LIBDIR="$LIBDIR -L$dir";
313 done
314 shift
316 "--incdir")
317 shift; CheckDir $1
318 for dir in $1
320 INCDIR="$INCDIR -I$dir";
321 done
322 shift
324 --incdir=*)
325 incdir=`echo $1 | awk -F= '{print $2}'`
326 CheckDir $incdir
327 for dir in $incdir
329 INCDIR="$INCDIR -I$dir";
330 done
331 shift
333 --no-build-shared|--no-shared)
334 #BUILD_SHARED="-no-build-shared";
335 shift
337 --build-shared)
338 BUILD_SHARED="-build-shared";
339 shift
341 --with-romio)
342 WITH_ROMIO="true"; shift
344 --without-romio)
345 WITH_ROMIO=""; shift
347 --with-production)
348 WITH_PRODUCTION="true"
349 shift
351 --with-*)
352 CONFIG_OPTS="$CONFIG_OPTS $1"
353 shift
355 --without-*)
356 CONFIG_OPTS="$CONFIG_OPTS $1"
357 shift
359 --destination)
360 shift
361 DESTINATION="$1"
362 shift
364 --destination=*)
365 DESTINATION="`echo $1 | awk -F= '{print $2}'`"
366 shift
368 --suffix)
369 shift
370 DESTINATION_SUFFIX="$1"
371 shift
373 --suffix=*)
374 DESTINATION_SUFFIX="`echo $1 | awk -F= '{print $2}'`"
375 shift
377 --tau-makefile)
378 TAU_MAKEFILE=$1
379 shift
381 --tau-makefile=*)
382 TAU_MAKEFILE=`echo $1 | awk -F= '{print $2}'`
383 shift
385 --quiet)
386 MAKEOPTS="$MAKEOPTS --quiet"
387 QUIET="--quiet"
388 shift;
390 --enable-tracing|--enable-tracing=*)
391 CONFIG_OPTS="$CONFIG_OPTS $1"
392 ENABLE_TRACING=yes
393 shift
395 --enable-*)
396 CONFIG_OPTS="$CONFIG_OPTS $1"
397 shift
399 --disable-*)
400 CONFIG_OPTS="$CONFIG_OPTS $1"
401 shift
403 -j*)
404 PMAKENUM=`echo $1 | awk -Fj '{print $2}'`
405 MAKEOPTS="$MAKEOPTS -j $PMAKENUM"
406 shift;
408 -k|--keep-going)
409 MAKEOPTS="$MAKEOPTS $1"
410 shift;
412 -*)
413 # We hit a real compiler option (like -g, or -Dfoo),
414 # so just copy over all remaining options
415 while [ ! $# -eq 0 ]
417 OPTS="$OPTS $1"; shift
418 done
420 "help")
421 printOption
424 # This has to be a build-time option (like "smp")
425 TestIfCompiler $1
426 if [ $? -eq 1 ]
427 then
428 # It specifies a compiler:
429 if [ ! -z "$COMPILER" ]
430 then
431 echo "Error> Tried to specify two compilers: $COMPILER and $1"
432 printOption
434 COMPILER=$1
435 else
436 # It specifies some other option:
437 TestIfOption $1
438 BOPTS="$BOPTS $1"
439 [ $1 = "bigemulator" ] && BUILD_EMULATOR=1
440 [ $1 = "bigsim" ] && BUILD_EMULATOR=1
441 [ $1 = "cuda" ] && BUILD_CUDA=1
443 shift
445 esac
446 done
448 if [ $BUILD_CUDA -eq 1 ]; then
449 HAVE_CUDA="no"
450 echo "checking for CUDA toolkit directory"
451 CUDA_PRESET_DIRS="/usr/local/cuda /usr/lib/nvidia-cuda-toolkit"
452 CUDA_CANDIDATE_DIRS="$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
453 for dir in $CUDA_CANDIDATE_DIRS; do
454 if test -d "$dir"; then
455 CUDA_DIR="$dir"
456 HAVE_CUDA="yes"
457 echo "CUDA_DIR=$CUDA_DIR"
458 break
460 done
461 if [ "$HAVE_CUDA" = "no" ]; then
462 echo "Error> no CUDA toolkit found, searched \$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
463 exit 1
467 [ "x$VERSION" = "x" ] && syntax && exit 1
469 #Check if building verbs on Omni-Path
470 if [ "x_$ARCH" = "x_verbs" ] && type /usr/sbin/opafabricinfo >/dev/null 2>&1; then
471 echo "WARNING: Verbs on Omni-Path architectures is not well supported, please use an OFI build instead.";
472 exit 1;
475 if test -n "$WITH_PRODUCTION" -a $BUILD_EMULATOR -eq 1 -a -z "$ENABLE_TRACING"
476 then
477 echo "Error: bigemulator requires tracing modules, --with-production must be used with --enable-tracing"
478 exit 1
481 if [ -z "$MAKE" ]
482 then
483 # prefer gmake
484 MAKE=`which gmake 2>/dev/null`
485 [ -z "$MAKE" -o ! -x "$MAKE" ] && MAKE='make'
488 if [ ! -f $src/$BASEVERSION/conv-mach.h ]
489 then
490 echo "Error> build can not find arch: $BASEVERSION!"
491 exit 1
494 #generate VERSION name combining all the build-time options.
495 if [ -n "$BOPTS" -o -n "$COMPILER" ]
496 then
497 echo "Selected Compiler: $COMPILER"
499 if test -n "$COMPILER" -a `echo "$BASEVERSION" | grep -c "cray\|gni\|gemini"` -gt 0
500 then
501 echo "Inserted explicit compiler options on Cray systems. Use compiler wrappers by loading PrgEnv-*"
502 echo "e.g.) module load PrgEnv-* (e.g. cray for cce, gnu for gcc, intel for icc, and pgi for pgcc)"
503 echo " ./build charm++ $BASEVERSION <other build options>"
504 echo "Charm++ uses the compiler wrapper 'CC' specified by the Cray system. Don't use explicit compiler options on Cray systems."
505 exit 1
508 if test `echo "$BOPTS" | grep -c "omp"` -gt 0 -a `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
509 then
510 if test -z "$COMPILER" -o "$COMPILER" != "gcc"
511 then
512 echo "The integrated OpenMP runtime library is supported on Mac only with the normal gcc"
513 echo "You need to install this normal (non-clang) gcc via MacPorts or Homebrew"
514 echo "Read the instructions on the Charm++ manual."
515 exit 1
518 echo "Selected Options: $BOPTS"
519 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
520 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
521 for i in $BOPTS_WITHCOMPILER
523 VERSION=$VERSION-$i
524 done
527 #echo "|$DESTINATION|$DESTINATION_SUFFIX|"
529 if [ -z "$DESTINATION" ]
530 then
531 DESTINATION="$VERSION"
534 if [ $(dirname $DESTINATION) != "." ]
535 then
536 srcbaseabs="$(cd $srcbaseabs; pwd)"
537 srcbase=$srcbaseabs
538 src="$srcbaseabs/arch/"
541 if [ -n "$DESTINATION_SUFFIX" ]
542 then
543 DESTINATION="$DESTINATION-$DESTINATION_SUFFIX"
546 [ -d $DESTINATION ] || Echo "Creating dir: $DESTINATION"
547 [ -d $DESTINATION ] || mkdir $DESTINATION
548 [ -d $DESTINATION/tmp ] || Echo "Creating dir: $DESTINATION/tmp"
549 [ -d $DESTINATION/tmp ] || mkdir $DESTINATION/tmp
551 Echo "Copying src/scripts/Makefile to $DESTINATION/tmp"
552 rm -f $DESTINATION/tmp/Makefile
553 rm -f $DESTINATION/tmp/Make.depends
554 rm -f $DESTINATION/tmp/Make.cidepends
555 rm -f $DESTINATION/tmp/Make.lb
556 rm -f $DESTINATION/tmp/Make.machine
557 rm -f $DESTINATION/tmp/Make.extlib
560 # Create the bin, lib, include, etc. links:
561 WINNAME=`echo $VERSION | awk -F- '{print $2}'`
562 if [ "x_$WINNAME" = "x_win32" -o "x_$WINNAME" = "x_win64" -o "x_$WINNAME" = "x_win" ]
563 then
564 #Win32/64 version needs special compilers and *copied* (not linked)
565 # source files.
566 cp $src/win32/system_ln $DESTINATION/tmp
567 cp $src/win32/unistd.h $DESTINATION/tmp
568 echo "Compiling createlink.cpp ..."
569 (cd $src/win32; ../$WINNAME/unix2nt_cc -c createlink.cpp -o createlink.o -D_WIN32_WINNT=0x0500; ../$WINNAME/unix2nt_cc createlink.o)
571 if test ! -x $src/win32/createlink.exe
572 then
573 echo "VC++ is not properly installed!"
574 exit 1
576 chmod +x $DESTINATION/tmp/system_ln
577 cp $src/win32/gathertree.local $DESTINATION/tmp
578 cp $src/win32/gatherflat.local $DESTINATION/tmp
579 else
580 cat > $DESTINATION/tmp/system_ln <<EOF
581 #!/bin/sh
582 ln -f -s \$@
584 chmod +x $DESTINATION/tmp/system_ln
585 for newdir in `echo bin lib lib_so include tmp`
587 Echo "Soft-linking over $newdir"
588 if [ -r $newdir ]
589 then
590 rm -fr $newdir || exit 1
592 $DESTINATION/tmp/system_ln $DESTINATION/$newdir $newdir
593 done
594 rm -f VERSION
595 $DESTINATION/tmp/system_ln $DESTINATION/include/VERSION VERSION
598 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.depends" $DESTINATION/tmp/Make.depends
599 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.cidepends" $DESTINATION/tmp/Make.cidepends
600 if test -f "$srcbaseabs/ck-ldb/Make.lb"
601 then
602 $DESTINATION/tmp/system_ln "$srcbase/ck-ldb/Make.lb" $DESTINATION/tmp/Make.lb
603 else
604 touch $DESTINATION/tmp/Make.lb
606 $DESTINATION/tmp/system_ln "$srcbase/scripts/Makefile" $DESTINATION/tmp/Makefile
607 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.tau" $DESTINATION/tmp/Make.tau
608 touch $DESTINATION/tmp/Makefile.machine
609 touch $DESTINATION/tmp/Make.extlib
611 ConvUsr="$DESTINATION/tmp/conv-mach-pre.sh"
612 Echo "Generating $ConvUsr"
613 echo > $ConvUsr
614 if test -n "$LIBDIR"
615 then
616 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
617 echo 'USER_OPTS_LDXX="$USER_OPTS_LDXX '$LIBDIR'"' >> $ConvUsr
619 if test -n "$INCDIR"
620 then
621 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
622 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
624 chmod +x $ConvUsr
626 # Create conv-mach-opt headers with special build-time options
627 ConvHeader="$DESTINATION/tmp/conv-mach-opt.h"
628 ConvSh="$DESTINATION/tmp/conv-mach-opt.sh"
629 if [ ! -f $ConvSh -o ! -f $ConvHeader ]
630 then
631 Echo "Generating $ConvHeader, conv-mach-opt.sh"
632 echo '/* Build-time options header, automatically generated by charm/build*/'> $ConvHeader
633 echo '# Built-time options header, automatically generated by charm/build'> $ConvSh
634 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
636 if test -n "$COMPILER"
637 then
638 i="$COMPILER"
639 echo '#include "'cc-$i.h'"' >> $ConvHeader
640 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
641 elif test `echo "$BASEVERSION" | grep -c "bluegeneq"` -gt 0
642 then
643 i="xlc"
644 echo '#include "'cc-$i.h'"' >> $ConvHeader
645 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
647 if test -n "$BOPTS"
648 then
649 # pxshm+smp note: When combining the 'smp' and 'pxshm' directives, it is
650 # important that they be included in $ConvHeader in that
651 # exact order. See bug #717.
652 TMP=""
653 HAS_PXSHM=0
654 HAS_SMP=0
655 for i in $BOPTS; do
656 if [ "$i" = "smp" ]; then
657 HAS_SMP=1
658 elif [ "$i" = "pxshm" ]; then
659 HAS_PXSHM=1
660 elif [ "$i" = "omp" ]; then
661 BUILD_OMP=1
662 TMP="$TMP $i"
663 else
664 TMP="$TMP $i"
666 done
667 if [ $HAS_PXSHM -eq 1 ]; then
668 TMP="pxshm $TMP"
670 if [ $HAS_SMP -eq 1 ]; then
671 TMP="smp $TMP"
672 elif [ $BUILD_OMP -eq 1 ]; then
673 BUILD_OMP=2 #this means omp keyword inserted without smp keyword"
676 BOPTS=$TMP
677 for i in $BOPTS
679 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
680 if [ $BUILD_CUDA -eq 1 ]; then
681 echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
683 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
684 done
687 if test "$BUILD_SHARED" = "-build-shared"
688 then
689 echo "CMK_NO_BUILD_SHARED=false" >> $ConvSh
690 else
691 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
694 if test -n "$WITH_ROMIO"
695 then
696 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
699 if test -n "$WITH_PRODUCTION"
700 then
701 echo '#define CMK_OPTIMIZE 1' >> $ConvHeader
702 # Prepend optimize so that an explicit -no-optimize still works
703 OPTS="-optimize -production $OPTS"
704 CONFIG_OPTS="--disable-controlpoint --disable-tracing --disable-tracing-commthread --disable-charmdebug --disable-replay --disable-error-checking --disable-stats $CONFIG_OPTS"
707 # build with Tau
708 WITH_TAU=0
709 if [ "$PROGRAM" = "Tau" ]
710 then
711 Echo "TAU>>>> makefile config option: $TAU_MAKEFILE"
712 if [ -n "$TAU_MAKEFILE" -a -f $TAU_MAKEFILE ]
713 then
714 #Setting up TAU trace library:
715 Echo "TAU>>>> configuring with this TAU makefile: $TAU_MAKEFILE"
717 WITH_TAU=1
718 else
719 Echo "TAU>>>> ERROR could not find Makefile: $TAU_MAKEFILE, ignored"
720 TAU_MAKEFILE=""
724 if test $WITH_TAU -eq 1
725 then
726 [ -z "$TAU_MAKEFILE" ] && TAU_MAKEFILE="Make.tau"
727 SED_CHARMC="s@TAU_MAKEFILE=\(.*\)@TAU_MAKEFILE=$TAU_MAKEFILE@"
729 sed -e $SED_CHARMC $srcbaseabs/scripts/Makefile > .Makefile.$$ && cp .Makefile.$$ $srcbaseabs/scripts/Makefile && rm -f .Makefile.$$
730 sed -e $SED_CHARMC $srcbaseabs/scripts/charmc > .charmc.$$ && cp .charmc.$$ $srcbaseabs/scripts/charmc && rm -f .charmc.$$
732 echo "#define CMK_WITH_TAU 1" >> $ConvHeader
733 echo "#define pthread_create tau_pthread_create" >> $ConvHeader
734 echo "#define pthread_exit tau_pthread_exit" >> $ConvHeader
736 echo "CMK_WITH_TAU=\"true\"" >> $ConvSh
739 if [ "$PROGRAM" = "ChaNGa" ]
740 then
741 #Setting lbuserdata when the build is ChaNGa
742 CONFIG_OPTS="--enable-lbuserdata $CONFIG_OPTS"
745 echo $BASEVERSION > $DESTINATION/tmp/.vdir
746 echo $BASEVERSION | sed -e 's@-.*@@' > $DESTINATION/tmp/.gdir
748 if test $BUILD_EMULATOR = 1
749 then
750 # export BIGSIM so that make targets can depend on it
751 MAKEOPTS="$MAKEOPTS BIGSIM=bigsim"
752 PROGRAM="$PROGRAM bigsim"
756 if [ $BUILD_OMP = 2 ]
757 then
758 case $DESTINATION in
759 "multicore"*)
760 BUILD_OMP=1
763 echo "OpenMP support should be built in SMP mode"
764 exit 1
766 esac
769 printError()
771 Echo "-------------------------------------------------"
772 Echo "Charm++ NOT BUILT. Either cd into $DESTINATION/tmp and try"
773 Echo "to resolve the problems yourself, visit"
774 Echo " http://charm.cs.illinois.edu/"
775 Echo "for more information. Otherwise, email the developers at charm@cs.illinois.edu"
776 exit $MAKEEXIT
779 echo 'BUILDOPTS="'$OPTS'"' >> $ConvSh
780 echo "SRCBASE=$srcbase" > $DESTINATION/tmp/charmpath.mk
782 Echo "Performing '$MAKE $MAKEOPTS basics OPTS="$OPTS" QUIET="$QUIET" CONFIG_OPTS="$CONFIG_OPTS"' in $DESTINATION/tmp"
783 cd $DESTINATION/tmp
784 echo "CONFIG_OPTS=\"$CONFIG_OPTS\"" > config_opts.sh
785 chmod +x config_opts.sh
786 echo "OPTSATBUILDTIME += $OPTS" > buildopts.mk
787 $MAKE $MAKEOPTS basics OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
788 MAKEEXIT=$?
789 [ $MAKEEXIT -ne 0 ] && printError
791 Echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS" QUIET="$QUIET"' in $DESTINATION/tmp"
792 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
793 MAKEEXIT=$?
794 if [ $MAKEEXIT -eq 0 ]
795 then
796 if [ $BUILD_OMP = 1 ];
797 then
798 $MAKE MFLAGS="$MAKEOPTS" openmp_llvm OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
800 Echo "-------------------------------------------------"
801 Echo "$PROGRAM built successfully."
802 Echo "Next, try out a sample program like" \
803 "$DESTINATION/tests/charm++/simplearrayhello"
804 else
805 printError