Fix hash table usage for XLC
[charm.git] / build
blobc0a156e3239111dc74f87116c8c6c0bb7e10b089
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 echo "Selected Options: $BOPTS"
505 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
506 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
507 for i in $BOPTS_WITHCOMPILER
509 VERSION=$VERSION-$i
510 done
513 #echo "|$DESTINATION|$DESTINATION_SUFFIX|"
515 if [ -z "$DESTINATION" ]
516 then
517 DESTINATION="$VERSION"
520 if [ $(dirname $DESTINATION) != "." ]
521 then
522 srcbaseabs="$(cd $srcbaseabs; pwd)"
523 srcbase=$srcbaseabs
524 src="$srcbaseabs/arch/"
527 if [ -n "$DESTINATION_SUFFIX" ]
528 then
529 DESTINATION="$DESTINATION-$DESTINATION_SUFFIX"
532 [ -d $DESTINATION ] || Echo "Creating dir: $DESTINATION"
533 [ -d $DESTINATION ] || mkdir $DESTINATION
534 [ -d $DESTINATION/tmp ] || Echo "Creating dir: $DESTINATION/tmp"
535 [ -d $DESTINATION/tmp ] || mkdir $DESTINATION/tmp
537 Echo "Copying src/scripts/Makefile to $DESTINATION/tmp"
538 rm -f $DESTINATION/tmp/Makefile
539 rm -f $DESTINATION/tmp/Make.depends
540 rm -f $DESTINATION/tmp/Make.cidepends
541 rm -f $DESTINATION/tmp/Make.lb
542 rm -f $DESTINATION/tmp/Make.machine
543 rm -f $DESTINATION/tmp/Make.extlib
546 # Create the bin, lib, include, etc. links:
547 WINNAME=`echo $VERSION | awk -F- '{print $2}'`
548 if [ "x_$WINNAME" = "x_win32" -o "x_$WINNAME" = "x_win64" -o "x_$WINNAME" = "x_win" ]
549 then
550 #Win32/64 version needs special compilers and *copied* (not linked)
551 # source files.
552 cp $src/win32/system_ln $DESTINATION/tmp
553 cp $src/win32/unistd.h $DESTINATION/tmp
554 echo "Compiling createlink.cpp ..."
555 (cd $src/win32; ../$WINNAME/unix2nt_cc -c createlink.cpp -o createlink.o -D_WIN32_WINNT=0x0500; ../$WINNAME/unix2nt_cc createlink.o)
557 if test ! -x $src/win32/createlink.exe
558 then
559 echo "VC++ is not properly installed!"
560 exit 1
562 chmod +x $DESTINATION/tmp/system_ln
563 cp $src/win32/gathertree.local $DESTINATION/tmp
564 cp $src/win32/gatherflat.local $DESTINATION/tmp
565 else
566 cat > $DESTINATION/tmp/system_ln <<EOF
567 #!/bin/sh
568 ln -f -s \$@
570 chmod +x $DESTINATION/tmp/system_ln
571 for newdir in `echo bin lib lib_so include tmp`
573 Echo "Soft-linking over $newdir"
574 if [ -r $newdir ]
575 then
576 rm -fr $newdir || exit 1
578 $DESTINATION/tmp/system_ln $DESTINATION/$newdir $newdir
579 done
580 rm -f VERSION
581 $DESTINATION/tmp/system_ln $DESTINATION/include/VERSION VERSION
584 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.depends" $DESTINATION/tmp/Make.depends
585 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.cidepends" $DESTINATION/tmp/Make.cidepends
586 if test -f "$srcbaseabs/ck-ldb/Make.lb"
587 then
588 $DESTINATION/tmp/system_ln "$srcbase/ck-ldb/Make.lb" $DESTINATION/tmp/Make.lb
589 else
590 touch $DESTINATION/tmp/Make.lb
592 $DESTINATION/tmp/system_ln "$srcbase/scripts/Makefile" $DESTINATION/tmp/Makefile
593 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.tau" $DESTINATION/tmp/Make.tau
594 touch $DESTINATION/tmp/Makefile.machine
595 touch $DESTINATION/tmp/Make.extlib
597 ConvUsr="$DESTINATION/tmp/conv-mach-pre.sh"
598 Echo "Generating $ConvUsr"
599 echo > $ConvUsr
600 if test -n "$LIBDIR"
601 then
602 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
603 echo 'USER_OPTS_LDXX="$USER_OPTS_LDXX '$LIBDIR'"' >> $ConvUsr
605 if test -n "$INCDIR"
606 then
607 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
608 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
610 chmod +x $ConvUsr
612 # Create conv-mach-opt headers with special build-time options
613 ConvHeader="$DESTINATION/tmp/conv-mach-opt.h"
614 ConvSh="$DESTINATION/tmp/conv-mach-opt.sh"
615 if [ ! -f $ConvSh -o ! -f $ConvHeader ]
616 then
617 Echo "Generating $ConvHeader, conv-mach-opt.sh"
618 echo '/* Build-time options header, automatically generated by charm/build*/'> $ConvHeader
619 echo '# Built-time options header, automatically generated by charm/build'> $ConvSh
620 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
622 if test -n "$COMPILER"
623 then
624 i="$COMPILER"
625 echo '#include "'cc-$i.h'"' >> $ConvHeader
626 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
627 elif test `echo "$BASEVERSION" | grep -c "bluegeneq"` -gt 0
628 then
629 i="xlc"
630 echo '#include "'cc-$i.h'"' >> $ConvHeader
631 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
633 if test -n "$BOPTS"
634 then
635 # pxshm+smp note: When combining the 'smp' and 'pxshm' directives, it is
636 # important that they be included in $ConvHeader in that
637 # exact order. See bug #717.
638 TMP=""
639 HAS_PXSHM=0
640 HAS_SMP=0
641 for i in $BOPTS; do
642 if [ "$i" = "smp" ]; then
643 HAS_SMP=1
644 elif [ "$i" = "pxshm" ]; then
645 HAS_PXSHM=1
646 elif [ "$i" = "omp" ]; then
647 BUILD_OMP=1
648 TMP="$TMP $i"
649 else
650 TMP="$TMP $i"
652 done
653 if [ $HAS_PXSHM -eq 1 ]; then
654 TMP="pxshm $TMP"
656 if [ $HAS_SMP -eq 1 ]; then
657 TMP="smp $TMP"
658 elif [ $BUILD_OMP -eq 1 ]; then
659 BUILD_OMP=2 #this means omp keyword inserted without smp keyword"
662 BOPTS=$TMP
663 for i in $BOPTS
665 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
666 if [ $BUILD_CUDA -eq 1 ]; then
667 echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
669 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
670 done
673 if test "$BUILD_SHARED" = "-build-shared"
674 then
675 echo "CMK_NO_BUILD_SHARED=false" >> $ConvSh
676 else
677 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
680 if test -n "$WITH_ROMIO"
681 then
682 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
685 if test -n "$WITH_PRODUCTION"
686 then
687 echo '#define CMK_OPTIMIZE 1' >> $ConvHeader
688 # Prepend optimize so that an explicit -no-optimize still works
689 OPTS="-optimize -production $OPTS"
690 CONFIG_OPTS="--disable-controlpoint --disable-tracing --disable-tracing-commthread --disable-charmdebug --disable-replay --disable-error-checking --disable-stats $CONFIG_OPTS"
693 # build with Tau
694 WITH_TAU=0
695 if [ "$PROGRAM" = "Tau" ]
696 then
697 Echo "TAU>>>> makefile config option: $TAU_MAKEFILE"
698 if [ -n "$TAU_MAKEFILE" -a -f $TAU_MAKEFILE ]
699 then
700 #Setting up TAU trace library:
701 Echo "TAU>>>> configuring with this TAU makefile: $TAU_MAKEFILE"
703 WITH_TAU=1
704 else
705 Echo "TAU>>>> ERROR could not find Makefile: $TAU_MAKEFILE, ignored"
706 TAU_MAKEFILE=""
710 if test $WITH_TAU -eq 1
711 then
712 [ -z "$TAU_MAKEFILE" ] && TAU_MAKEFILE="Make.tau"
713 SED_CHARMC="s@TAU_MAKEFILE=\(.*\)@TAU_MAKEFILE=$TAU_MAKEFILE@"
715 sed -e $SED_CHARMC $srcbaseabs/scripts/Makefile > .Makefile.$$ && cp .Makefile.$$ $srcbaseabs/scripts/Makefile && rm -f .Makefile.$$
716 sed -e $SED_CHARMC $srcbaseabs/scripts/charmc > .charmc.$$ && cp .charmc.$$ $srcbaseabs/scripts/charmc && rm -f .charmc.$$
718 echo "#define CMK_WITH_TAU 1" >> $ConvHeader
719 echo "#define pthread_create tau_pthread_create" >> $ConvHeader
720 echo "#define pthread_exit tau_pthread_exit" >> $ConvHeader
722 echo "CMK_WITH_TAU=\"true\"" >> $ConvSh
725 if [ "$PROGRAM" = "ChaNGa" ]
726 then
727 #Setting lbuserdata when the build is ChaNGa
728 CONFIG_OPTS="--enable-lbuserdata $CONFIG_OPTS"
731 echo $BASEVERSION > $DESTINATION/tmp/.vdir
732 echo $BASEVERSION | sed -e 's@-.*@@' > $DESTINATION/tmp/.gdir
734 if test $BUILD_EMULATOR = 1
735 then
736 PROGRAM="$PROGRAM bigsim"
737 # CONFIG_OPTS="--disable-charmdebug $CONFIG_OPTS"
741 if [ $BUILD_OMP = 2 ]
742 then
743 case $DESTINATION in
744 "multicore"*)
745 BUILD_OMP=1
748 echo "OpenMP support should be built in SMP mode"
749 exit 1
751 esac
754 printError()
756 Echo "-------------------------------------------------"
757 Echo "Charm++ NOT BUILT. Either cd into $DESTINATION/tmp and try"
758 Echo "to resolve the problems yourself, visit"
759 Echo " http://charm.cs.illinois.edu/"
760 Echo "for more information. Otherwise, email the developers at charm@cs.illinois.edu"
761 exit $MAKEEXIT
764 echo 'BUILDOPTS="'$OPTS'"' >> $ConvSh
765 echo "SRCBASE=$srcbase" > $DESTINATION/tmp/charmpath.mk
767 Echo "Performing '$MAKE $MAKEOPTS basics OPTS="$OPTS" QUIET="$QUIET" CONFIG_OPTS="$CONFIG_OPTS"' in $DESTINATION/tmp"
768 cd $DESTINATION/tmp
769 echo "CONFIG_OPTS=\"$CONFIG_OPTS\"" > config_opts.sh
770 chmod +x config_opts.sh
771 echo "OPTSATBUILDTIME += $OPTS" > buildopts.mk
772 $MAKE $MAKEOPTS basics OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
773 MAKEEXIT=$?
774 [ $MAKEEXIT -ne 0 ] && printError
776 Echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS" QUIET="$QUIET"' in $DESTINATION/tmp"
777 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
778 MAKEEXIT=$?
779 if [ $MAKEEXIT -eq 0 ]
780 then
781 if [ $BUILD_OMP = 1 ];
782 then
783 $MAKE MFLAGS="$MAKEOPTS" openmp_llvm OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
785 Echo "-------------------------------------------------"
786 Echo "$PROGRAM built successfully."
787 Echo "Next, try out a sample program like" \
788 "$DESTINATION/tests/charm++/simplearrayhello"
789 else
790 printError