Bug #1621: Fix unpacking code in closure structure for rdmawrappers on non-rdma platforms
[charm.git] / build
blob71a4e8d7c882517c1ef88c3f6eeaf67499760f70
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$)|(^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 ] && ./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 -*)
409 # We hit a real compiler option (like -g, or -Dfoo),
410 # so just copy over all remaining options
411 while [ ! $# -eq 0 ]
413 OPTS="$OPTS $1"; shift
414 done
416 "help")
417 printOption
420 # This has to be a build-time option (like "smp")
421 TestIfCompiler $1
422 if [ $? -eq 1 ]
423 then
424 # It specifies a compiler:
425 if [ ! -z "$COMPILER" ]
426 then
427 echo "Error> Tried to specify two compilers: $COMPILER and $1"
428 printOption
430 COMPILER=$1
431 else
432 # It specifies some other option:
433 TestIfOption $1
434 BOPTS="$BOPTS $1"
435 [ $1 = "bigemulator" ] && BUILD_EMULATOR=1
436 [ $1 = "bigsim" ] && BUILD_EMULATOR=1
437 [ $1 = "cuda" ] && BUILD_CUDA=1
439 shift
441 esac
442 done
444 if [ $BUILD_CUDA -eq 1 ]; then
445 HAVE_CUDA="no"
446 echo "checking for CUDA toolkit directory"
447 CUDA_PRESET_DIRS="/usr/local/cuda /usr/lib/nvidia-cuda-toolkit"
448 CUDA_CANDIDATE_DIRS="$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
449 for dir in $CUDA_CANDIDATE_DIRS; do
450 if test -d "$dir"; then
451 CUDA_DIR="$dir"
452 HAVE_CUDA="yes"
453 echo "CUDA_DIR=$CUDA_DIR"
454 break
456 done
457 if [ "$HAVE_CUDA" = "no" ]; then
458 echo "Error> no CUDA toolkit found, searched \$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
459 exit 1
463 [ "x$VERSION" = "x" ] && syntax && exit 1
465 #Check if building verbs on OmniPath
466 if [ "x_$ARCH" = "x_verbs" ] && type /usr/sbin/opafabricinfo >/dev/null 2>&1; then
467 echo "WARNING: Verbs on OmniPath architectures is not well supported, please use an MPI build instead.";
468 exit 1;
471 if test -n "$WITH_PRODUCTION" -a $BUILD_EMULATOR -eq 1 -a -z "$ENABLE_TRACING"
472 then
473 echo "Error: bigemulator requires tracing modules, --with-production must be used with --enable-tracing"
474 exit 1
477 if [ -z "$MAKE" ]
478 then
479 # prefer gmake
480 MAKE=`which gmake 2>/dev/null`
481 [ -z "$MAKE" -o ! -x "$MAKE" ] && MAKE='make'
484 if [ ! -f $src/$BASEVERSION/conv-mach.h ]
485 then
486 echo "Error> build can not find arch: $BASEVERSION!"
487 exit 1
490 #generate VERSION name combining all the build-time options.
491 if [ -n "$BOPTS" -o -n "$COMPILER" ]
492 then
493 echo "Selected Compiler: $COMPILER"
495 if test -n "$COMPILER" -a `echo "$BASEVERSION" | grep -c "cray\|gni\|gemini"` -gt 0
496 then
497 echo "Inserted explicit compiler options on Cray systems. Use compiler wrappers by loading PrgEnv-*"
498 echo "e.g.) module load PrgEnv-* (e.g. cray for cce, gnu for gcc, intel for icc, and pgi for pgcc)"
499 echo " ./build charm++ $BASEVERSION <other build options>"
500 echo "Charm++ uses the compiler wrapper 'CC' specified by the Cray system. Don't use explicit compiler options on Cray systems."
501 exit 1
504 if test `echo "$BOPTS" | grep -c "omp"` -gt 0 -a `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
505 then
506 if test -z "$COMPILER" -o "$COMPILER" != "gcc"
507 then
508 echo "The integrated OpenMP runtime library is supported on Mac only with the normal gcc"
509 echo "You need to install this normal(non-clang) gcc via MacPorts or HomeBrew"
510 echo "Read the instructions on the Charm++ manual."
511 exit 1
514 echo "Selected Options: $BOPTS"
515 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
516 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
517 for i in $BOPTS_WITHCOMPILER
519 VERSION=$VERSION-$i
520 done
523 #echo "|$DESTINATION|$DESTINATION_SUFFIX|"
525 if [ -z "$DESTINATION" ]
526 then
527 DESTINATION="$VERSION"
530 if [ $(dirname $DESTINATION) != "." ]
531 then
532 srcbaseabs="$(cd $srcbaseabs; pwd)"
533 srcbase=$srcbaseabs
534 src="$srcbaseabs/arch/"
537 if [ -n "$DESTINATION_SUFFIX" ]
538 then
539 DESTINATION="$DESTINATION-$DESTINATION_SUFFIX"
542 [ -d $DESTINATION ] || Echo "Creating dir: $DESTINATION"
543 [ -d $DESTINATION ] || mkdir $DESTINATION
544 [ -d $DESTINATION/tmp ] || Echo "Creating dir: $DESTINATION/tmp"
545 [ -d $DESTINATION/tmp ] || mkdir $DESTINATION/tmp
547 Echo "Copying src/scripts/Makefile to $DESTINATION/tmp"
548 rm -f $DESTINATION/tmp/Makefile
549 rm -f $DESTINATION/tmp/Make.depends
550 rm -f $DESTINATION/tmp/Make.cidepends
551 rm -f $DESTINATION/tmp/Make.lb
552 rm -f $DESTINATION/tmp/Make.machine
553 rm -f $DESTINATION/tmp/Make.extlib
556 # Create the bin, lib, include, etc. links:
557 WINNAME=`echo $VERSION | awk -F- '{print $2}'`
558 if [ "x_$WINNAME" = "x_win32" -o "x_$WINNAME" = "x_win64" -o "x_$WINNAME" = "x_win" ]
559 then
560 #Win32/64 version needs special compilers and *copied* (not linked)
561 # source files.
562 cp $src/win32/system_ln $DESTINATION/tmp
563 cp $src/win32/unistd.h $DESTINATION/tmp
564 echo "Compiling createlink.cpp ..."
565 (cd $src/win32; ../$WINNAME/unix2nt_cc -c createlink.cpp -o createlink.o -D_WIN32_WINNT=0x0500; ../$WINNAME/unix2nt_cc createlink.o)
567 if test ! -x $src/win32/createlink.exe
568 then
569 echo "VC++ is not properly installed!"
570 exit 1
572 chmod +x $DESTINATION/tmp/system_ln
573 cp $src/win32/gathertree.local $DESTINATION/tmp
574 cp $src/win32/gatherflat.local $DESTINATION/tmp
575 else
576 cat > $DESTINATION/tmp/system_ln <<EOF
577 #!/bin/sh
578 ln -f -s \$@
580 chmod +x $DESTINATION/tmp/system_ln
581 for newdir in `echo bin lib lib_so include tmp`
583 Echo "Soft-linking over $newdir"
584 if [ -r $newdir ]
585 then
586 rm -fr $newdir || exit 1
588 $DESTINATION/tmp/system_ln $DESTINATION/$newdir $newdir
589 done
590 rm -f VERSION
591 $DESTINATION/tmp/system_ln $DESTINATION/include/VERSION VERSION
594 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.depends" $DESTINATION/tmp/Make.depends
595 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.cidepends" $DESTINATION/tmp/Make.cidepends
596 if test -f "$srcbaseabs/ck-ldb/Make.lb"
597 then
598 $DESTINATION/tmp/system_ln "$srcbase/ck-ldb/Make.lb" $DESTINATION/tmp/Make.lb
599 else
600 touch $DESTINATION/tmp/Make.lb
602 $DESTINATION/tmp/system_ln "$srcbase/scripts/Makefile" $DESTINATION/tmp/Makefile
603 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.tau" $DESTINATION/tmp/Make.tau
604 touch $DESTINATION/tmp/Makefile.machine
605 touch $DESTINATION/tmp/Make.extlib
607 ConvUsr="$DESTINATION/tmp/conv-mach-pre.sh"
608 Echo "Generating $ConvUsr"
609 echo > $ConvUsr
610 if test -n "$LIBDIR"
611 then
612 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
613 echo 'USER_OPTS_LDXX="$USER_OPTS_LDXX '$LIBDIR'"' >> $ConvUsr
615 if test -n "$INCDIR"
616 then
617 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
618 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
620 chmod +x $ConvUsr
622 # Create conv-mach-opt headers with special build-time options
623 ConvHeader="$DESTINATION/tmp/conv-mach-opt.h"
624 ConvSh="$DESTINATION/tmp/conv-mach-opt.sh"
625 if [ ! -f $ConvSh -o ! -f $ConvHeader ]
626 then
627 Echo "Generating $ConvHeader, conv-mach-opt.sh"
628 echo '/* Build-time options header, automatically generated by charm/build*/'> $ConvHeader
629 echo '# Built-time options header, automatically generated by charm/build'> $ConvSh
630 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
632 if test -n "$COMPILER"
633 then
634 i="$COMPILER"
635 echo '#include "'cc-$i.h'"' >> $ConvHeader
636 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
637 elif test `echo "$BASEVERSION" | grep -c "bluegeneq"` -gt 0
638 then
639 i="xlc"
640 echo '#include "'cc-$i.h'"' >> $ConvHeader
641 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
643 if test -n "$BOPTS"
644 then
645 # pxshm+smp note: When combining the 'smp' and 'pxshm' directives, it is
646 # important that they be included in $ConvHeader in that
647 # exact order. See bug #717.
648 TMP=""
649 HAS_PXSHM=0
650 HAS_SMP=0
651 for i in $BOPTS; do
652 if [ "$i" = "smp" ]; then
653 HAS_SMP=1
654 elif [ "$i" = "pxshm" ]; then
655 HAS_PXSHM=1
656 elif [ "$i" = "omp" ]; then
657 BUILD_OMP=1
658 TMP="$TMP $i"
659 else
660 TMP="$TMP $i"
662 done
663 if [ $HAS_PXSHM -eq 1 ]; then
664 TMP="pxshm $TMP"
666 if [ $HAS_SMP -eq 1 ]; then
667 TMP="smp $TMP"
668 elif [ $BUILD_OMP -eq 1 ]; then
669 BUILD_OMP=2 #this means omp keyword inserted without smp keyword"
672 BOPTS=$TMP
673 for i in $BOPTS
675 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
676 if [ $BUILD_CUDA -eq 1 ]; then
677 echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
679 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
680 done
683 if test "$BUILD_SHARED" = "-build-shared"
684 then
685 echo "CMK_NO_BUILD_SHARED=false" >> $ConvSh
686 else
687 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
690 if test -n "$WITH_ROMIO"
691 then
692 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
695 if test -n "$WITH_PRODUCTION"
696 then
697 echo '#define CMK_OPTIMIZE 1' >> $ConvHeader
698 # Prepend optimize so that an explicit -no-optimize still works
699 OPTS="-optimize -production $OPTS"
700 CONFIG_OPTS="--disable-controlpoint --disable-tracing --disable-tracing-commthread --disable-charmdebug --disable-replay --disable-error-checking --disable-stats $CONFIG_OPTS"
703 # build with Tau
704 WITH_TAU=0
705 if [ "$PROGRAM" = "Tau" ]
706 then
707 Echo "TAU>>>> makefile config option: $TAU_MAKEFILE"
708 if [ -n "$TAU_MAKEFILE" -a -f $TAU_MAKEFILE ]
709 then
710 #Setting up TAU trace library:
711 Echo "TAU>>>> configuring with this TAU makefile: $TAU_MAKEFILE"
713 WITH_TAU=1
714 else
715 Echo "TAU>>>> ERROR could not find Makefile: $TAU_MAKEFILE, ignored"
716 TAU_MAKEFILE=""
720 if test $WITH_TAU -eq 1
721 then
722 [ -z "$TAU_MAKEFILE" ] && TAU_MAKEFILE="Make.tau"
723 SED_CHARMC="s@TAU_MAKEFILE=\(.*\)@TAU_MAKEFILE=$TAU_MAKEFILE@"
725 sed -e $SED_CHARMC $srcbaseabs/scripts/Makefile > .Makefile.$$ && cp .Makefile.$$ $srcbaseabs/scripts/Makefile && rm -f .Makefile.$$
726 sed -e $SED_CHARMC $srcbaseabs/scripts/charmc > .charmc.$$ && cp .charmc.$$ $srcbaseabs/scripts/charmc && rm -f .charmc.$$
728 echo "#define CMK_WITH_TAU 1" >> $ConvHeader
729 echo "#define pthread_create tau_pthread_create" >> $ConvHeader
730 echo "#define pthread_exit tau_pthread_exit" >> $ConvHeader
732 echo "CMK_WITH_TAU=\"true\"" >> $ConvSh
735 if [ "$PROGRAM" = "ChaNGa" ]
736 then
737 #Setting lbuserdata when the build is ChaNGa
738 CONFIG_OPTS="--enable-lbuserdata $CONFIG_OPTS"
741 echo $BASEVERSION > $DESTINATION/tmp/.vdir
742 echo $BASEVERSION | sed -e 's@-.*@@' > $DESTINATION/tmp/.gdir
744 if test $BUILD_EMULATOR = 1
745 then
746 PROGRAM="$PROGRAM bigsim"
747 # CONFIG_OPTS="--disable-charmdebug $CONFIG_OPTS"
751 if [ $BUILD_OMP = 2 ]
752 then
753 case $DESTINATION in
754 "multicore"*)
755 BUILD_OMP=1
758 echo "OpenMP support should be built in SMP mode"
759 exit 1
761 esac
764 printError()
766 Echo "-------------------------------------------------"
767 Echo "Charm++ NOT BUILT. Either cd into $DESTINATION/tmp and try"
768 Echo "to resolve the problems yourself, visit"
769 Echo " http://charm.cs.illinois.edu/"
770 Echo "for more information. Otherwise, email the developers at charm@cs.illinois.edu"
771 exit $MAKEEXIT
774 echo 'BUILDOPTS="'$OPTS'"' >> $ConvSh
775 echo "SRCBASE=$srcbase" > $DESTINATION/tmp/charmpath.mk
777 Echo "Performing '$MAKE $MAKEOPTS basics OPTS="$OPTS" QUIET="$QUIET" CONFIG_OPTS="$CONFIG_OPTS"' in $DESTINATION/tmp"
778 cd $DESTINATION/tmp
779 echo "CONFIG_OPTS=\"$CONFIG_OPTS\"" > config_opts.sh
780 chmod +x config_opts.sh
781 echo "OPTSATBUILDTIME += $OPTS" > buildopts.mk
782 $MAKE $MAKEOPTS basics OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
783 MAKEEXIT=$?
784 [ $MAKEEXIT -ne 0 ] && printError
786 Echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS" QUIET="$QUIET"' in $DESTINATION/tmp"
787 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
788 MAKEEXIT=$?
789 if [ $MAKEEXIT -eq 0 ]
790 then
791 if [ $BUILD_OMP = 1 ];
792 then
793 $MAKE MFLAGS="$MAKEOPTS" openmp_llvm OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
795 Echo "-------------------------------------------------"
796 Echo "$PROGRAM built successfully."
797 Echo "Next, try out a sample program like" \
798 "$DESTINATION/tests/charm++/simplearrayhello"
799 else
800 printError