Update year in README and charmc to 2018
[charm.git] / build
blob3a442a0fcbff88491dafa632c1fe696b34f3d6cb
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$)|(^netlrts?$)|(^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 ' flang Flang Fortran compiler'
58 echo ' xlf IBM XL Fortran compiler'
59 echo ' ifort Intel Fortran compiler'
60 echo " pgf90 Portland Group Fortran compiler"
61 echo ''
62 echo 'Platform specific options (choose multiple if apply):'
63 echo ' smp support for SMP, multithreaded charm on each node'
64 echo ' omp support for the integrated LLVM OpenMP runtime'
65 echo ' ibverbs use Infiniband Verbs for communication (only for netlrts-linux-x86_64; prefer verbs-*)'
66 echo ' tcp use TCP sockets for communication (only for netlrts)'
67 echo ' pthreads compile with pthreads Converse threads'
68 echo ''
69 echo 'Advanced options:'
70 echo ' bigemulator compile for BigSim simulator'
71 echo ' ooc compile with out of core support'
72 echo ' syncft compile with Charm++ fault tolerance support'
73 echo ' mlogft compile with Charm++ message logging fault tolerance support'
74 echo ' papi compile with PAPI performance counter support (if any)'
75 echo ''
76 echo "Charm++ dynamic libraries:"
77 echo " --no-build-shared don't build Charm++'s shared libraries (default)"
78 echo " --build-shared build Charm++ dynamic libraries (.so) "
79 echo ''
80 echo 'Enable/disable features:'
81 $srcbaseabs/scripts/configure --help | grep enable-
82 $srcbaseabs/scripts/configure --help | grep with-
83 echo " --with-production build Charm++ with all optimizations for maximum performance, and disabling all above features"
84 echo ''
85 echo 'Miscellaneous options:'
86 echo ' --incdir=DIR specify additional include path for compiler'
87 echo ' --libdir=DIR specify additional lib path for compiler'
88 echo ' --basedir=DIR shortcut for the above two - DIR/include and DIR/lib'
89 echo ' -j[N] parallel make, N is the number of paralle make jobs'
90 echo " --with-lbtime-type specify real type for the load balancing timers"
91 echo " --destination=DIR build Charm++ inside DIR, by default the destination is <version>"
92 echo " --suffix=DIR append DIR to the destination directory of the Charm++ build"
93 echo " --tau-makefile=FILE Specify which TAU stub makefile to use"
95 echo ''
96 echo '<charmc-options>: normal compiler options e.g. -g -optimize -save -verbose'
97 if test $more = 1
98 then
99 echo ''
100 echo 'Examples:'
101 echo "1. display all supported options for netlrts-linux-x86_64 using 'help':"
102 echo ' ./build charm++ netlrts-linux-x86_64 help'
103 echo '2. compile Charm++ on Linux with all available tuning:'
104 echo ' ./build charm++ netlrts-linux-x86_64 --with-production'
105 echo '3. compile Charm++ for Linux with Intel compiler and optimizations:'
106 echo ' ./build charm++ netlrts-linux-x86_64 icc -optimize'
107 echo '4. compile Charm++ for Windows with VC++:'
108 echo ' ./build charm++ netlrts-win-x86_64 -optimize'
109 echo '5. compile Charm++ with MPI that is installed at /usr/local/mpich:'
110 echo ' ./build charm++ mpi-linux-x86_64 --incdir /usr/local/mpich/include --libdir /usr/local/mpich/lib -optimize'
111 echo ' or in short,'
112 echo ' ./build charm++ mpi-linux-x86_64 --basedir /usr/local/mpich -optimize'
113 echo ' ./build Tau --tau-makefile=/usr/local/packages/TAU/x86_64/lib/Makefile.tau-mpi'
114 echo ''
115 echo 'Note: This script:'
116 echo ' 1. Creates directories <destination> and <destination>/tmp'
117 echo ' 2. Copies src/scripts/Makefile into <destination>/tmp'
118 echo ' 3. Does a "make basics" in <destination>/tmp.'
119 echo ' 3. Does a "make -jN <target> <version> OPTS=<charmc-options>" in <destination>/tmp.'
120 echo "That's all build does. The rest is handled by the Makefile."
121 echo ''
122 echo 'Thank you for using Charm++, please send questions or comments to '
123 echo 'Parallel Programming Lab at University of Illinois at Urbana-Champaign'
124 echo '(email: charm@cs.illinois.edu).'
126 else
127 echo ''
128 echo "To get more detailed help, run ./build --help"
132 Echo() {
133 [ "x$QUIET" = "x--quiet" ] || echo $*
136 printOption() {
137 for prefix in cc conv-mach
139 str="Supported compilers:"
140 [ "$prefix" = "conv-mach" ] && str="Supported options:"
141 opts=""
142 for dir in $OPT_DIRS
144 # echo "Checking for $prefix in $dir"
145 files=`cd $dir; ls $prefix-*.h 2>/dev/null`
146 opts="$opts "`echo $files | sed 's/'$prefix'-\([^.]*\).h/\1/g'`
147 done
148 tmp=.tmp.$$
149 rm -f $tmp; touch $tmp
150 for o in $opts
152 echo $o >> $tmp
153 done
154 opts=`sort $tmp | uniq`
155 rm -f $tmp
156 echo $str $opts
157 done
158 exit 1
161 CheckDir() {
162 for d in $*
164 if test ! -d $d
165 then
166 echo Error: cannot find $d!
167 exit 1
169 done
172 TestIfCompiler() {
173 for dir in $OPT_DIRS
175 [ -f $dir/cc-$1.sh ] && return 1
176 done
177 return 0
180 TestIfOption() {
181 for dir in $OPT_DIRS
183 [ -f $dir/conv-mach-$1.h ] && return 1
184 done
186 echo "Error> option: $1 is not supported in this version!";
187 printOption
191 # start
193 BUILD_CUDA=0
194 MAKEOPTS=""
195 OPTS=""
196 BOPTS=""
197 MORE=""
198 COMPILER=""
199 BASEDIR=
200 LIBDIR=
201 INCDIR=
202 ARCH=
203 BUILD_SHARED="" # default no shared lib
204 WITH_ROMIO="true" # default to building ROMIO on AMPI
205 WITH_PRODUCTION=
206 BUILD_EMULATOR=0
207 DESTINATION=""
208 DESTINATION_SUFFIX=""
209 TAU_MAKEFILE=""
210 QUIET=""
211 BUILD_OMP=0
213 [ "$1" = '--help' -o "$1" = '-h' ] && more=1 && syntax | ( less || more ) && exit 1
214 [ $# -lt 2 ] && $(dirname "$0")/smart-build.pl && exit 1
215 PROGRAM=$1
216 shift
218 # find longest prefix of version argument that exists as a directory in $src
219 VERSION=$1
220 VERSOPTS=""
221 testversion=""
222 oldifs=$IFS
223 IFS=-
224 for w in $1; do
225 IFS=$oldifs
226 if [ -z "$testversion" ]; then
227 testversion=$w
228 else
229 testversion="$testversion-$w"
231 if [ -d $src/$testversion ]; then
232 VERSION=$testversion
233 VERSOPTS=""
234 else
235 VERSOPTS="$VERSOPTS $w"
237 done
238 if [ $VERSION = $1 ]; then VERSOPTS=""; fi
240 BASEVERSION=$VERSION;
241 if test -f $src/$BASEVERSION/vdir_link
242 then
243 BASEVERSION=`cat $src/$BASEVERSION/vdir_link`
245 ARCH=`echo $BASEVERSION | sed -e 's@-.*@@'`
246 shift
248 #echo $src
249 #echo $BASEVERSION
250 #echo $ARCH
252 OPT_DIRS="$src/$BASEVERSION $src/$ARCH $src/common"
254 # process remainder of version argument as options, copied from below
255 for w in $VERSOPTS; do
256 # This has to be a build-time option (like "smp")
257 TestIfCompiler $w
258 if [ $? -eq 1 ]
259 then
260 # It specifies a compiler:
261 if [ ! -z "$COMPILER" ]
262 then
263 echo "Error> Tried to specify two compilers: $COMPILER and $w"
264 printOption
266 COMPILER=$w
267 else
268 # It specifies some other option:
269 TestIfOption $w
270 BOPTS="$BOPTS $w"
271 [ $w = "bigemulator" ] && BUILD_EMULATOR=1
272 [ $w = "bigsim" ] && BUILD_EMULATOR=1
273 [ $w = "cuda" ] && BUILD_CUDA=1
275 done
277 while [ ! $# -eq 0 ]
279 case "$1" in
280 "--basedir")
281 shift;
282 for dir in $1
284 CheckDir $dir/include $dir/lib
285 LIBDIR="$LIBDIR -L$dir/lib";
286 INCDIR="$INCDIR -I$dir/include"
287 done
288 shift
290 --basedir=*)
291 basedir=`echo $1 | awk -F= '{print $2}'`
292 for dir in $basedir
294 CheckDir $dir/include $dir/lib
295 LIBDIR="$LIBDIR -L$dir/lib";
296 INCDIR="$INCDIR -I$dir/include"
297 done
298 shift
300 "--libdir")
301 shift; CheckDir $1
302 for dir in $1
304 LIBDIR="$LIBDIR -L$dir";
305 done
306 shift
308 --libdir=*)
309 libdir=`echo $1 | awk -F= '{print $2}'`
310 CheckDir $libdir
311 for dir in $libdir
313 LIBDIR="$LIBDIR -L$dir";
314 done
315 shift
317 "--incdir")
318 shift; CheckDir $1
319 for dir in $1
321 INCDIR="$INCDIR -I$dir";
322 done
323 shift
325 --incdir=*)
326 incdir=`echo $1 | awk -F= '{print $2}'`
327 CheckDir $incdir
328 for dir in $incdir
330 INCDIR="$INCDIR -I$dir";
331 done
332 shift
334 --no-build-shared|--no-shared)
335 #BUILD_SHARED="-no-build-shared";
336 shift
338 --build-shared)
339 BUILD_SHARED="-build-shared";
340 shift
342 --with-romio)
343 WITH_ROMIO="true"; shift
345 --without-romio)
346 WITH_ROMIO=""; shift
348 --with-production)
349 WITH_PRODUCTION="true"
350 shift
352 --with-*)
353 CONFIG_OPTS="$CONFIG_OPTS $1"
354 shift
356 --without-*)
357 CONFIG_OPTS="$CONFIG_OPTS $1"
358 shift
360 --destination)
361 shift
362 DESTINATION="$1"
363 shift
365 --destination=*)
366 DESTINATION="`echo $1 | awk -F= '{print $2}'`"
367 shift
369 --suffix)
370 shift
371 DESTINATION_SUFFIX="$1"
372 shift
374 --suffix=*)
375 DESTINATION_SUFFIX="`echo $1 | awk -F= '{print $2}'`"
376 shift
378 --tau-makefile)
379 TAU_MAKEFILE=$1
380 shift
382 --tau-makefile=*)
383 TAU_MAKEFILE=`echo $1 | awk -F= '{print $2}'`
384 shift
386 --quiet)
387 MAKEOPTS="$MAKEOPTS --quiet"
388 QUIET="--quiet"
389 shift;
391 --enable-tracing|--enable-tracing=*)
392 CONFIG_OPTS="$CONFIG_OPTS $1"
393 ENABLE_TRACING=yes
394 shift
396 --enable-*)
397 CONFIG_OPTS="$CONFIG_OPTS $1"
398 shift
400 --disable-*)
401 CONFIG_OPTS="$CONFIG_OPTS $1"
402 shift
404 -j*)
405 PMAKENUM=`echo $1 | awk -Fj '{print $2}'`
406 MAKEOPTS="$MAKEOPTS -j $PMAKENUM"
407 shift;
409 -k|--keep-going)
410 MAKEOPTS="$MAKEOPTS $1"
411 shift;
413 -*)
414 # We hit a real compiler option (like -g, or -Dfoo),
415 # so just copy over all remaining options
416 while [ ! $# -eq 0 ]
418 OPTS="$OPTS $1"; shift
419 done
421 "help")
422 printOption
425 # This has to be a build-time option (like "smp")
426 TestIfCompiler $1
427 if [ $? -eq 1 ]
428 then
429 # It specifies a compiler:
430 if [ ! -z "$COMPILER" ]
431 then
432 echo "Error> Tried to specify two compilers: $COMPILER and $1"
433 printOption
435 COMPILER=$1
436 else
437 # It specifies some other option:
438 TestIfOption $1
439 BOPTS="$BOPTS $1"
440 [ $1 = "bigemulator" ] && BUILD_EMULATOR=1
441 [ $1 = "bigsim" ] && BUILD_EMULATOR=1
442 [ $1 = "cuda" ] && BUILD_CUDA=1
444 shift
446 esac
447 done
449 if [ $BUILD_CUDA -eq 1 ]; then
450 HAVE_CUDA="no"
451 echo "checking for CUDA toolkit directory"
452 CUDA_PRESET_DIRS="/usr/local/cuda /usr/lib/nvidia-cuda-toolkit"
453 CUDA_CANDIDATE_DIRS="$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
454 for dir in $CUDA_CANDIDATE_DIRS; do
455 if test -d "$dir"; then
456 CUDA_DIR="$dir"
457 HAVE_CUDA="yes"
458 echo "CUDA_DIR=$CUDA_DIR"
459 break
461 done
462 if [ "$HAVE_CUDA" = "no" ]; then
463 echo "Error> no CUDA toolkit found, searched \$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
464 exit 1
468 [ "x$VERSION" = "x" ] && syntax && exit 1
470 if [ "x_$ARCH" = "x_net" ]; then
471 echo "Error: net-* has been removed, please use netlrts or verbs.";
472 exit 1;
475 #Check if building verbs on Omni-Path
476 if [ "x_$ARCH" = "x_verbs" ] && type /usr/sbin/opafabricinfo >/dev/null 2>&1; then
477 echo "WARNING: Detected Omni-Path diagnostic tools.";
478 echo "Verbs on Omni-Path architectures is not well supported: please use an OFI build instead.";
481 if test -n "$WITH_PRODUCTION" -a $BUILD_EMULATOR -eq 1 -a -z "$ENABLE_TRACING"
482 then
483 echo "Error: bigemulator requires tracing modules, --with-production must be used with --enable-tracing"
484 exit 1
487 if [ -z "$MAKE" ]
488 then
489 # prefer gmake
490 MAKE=`which gmake 2>/dev/null`
491 [ -z "$MAKE" -o ! -x "$MAKE" ] && MAKE='make'
494 if [ ! -f $src/$BASEVERSION/conv-mach.h ]
495 then
496 echo "Error> build can not find arch: $BASEVERSION!"
497 exit 1
500 #generate header for uFcontext for the target VERSION
501 UFCONTEXT_HEADER_NAME=
502 if test `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
503 then
504 UFCONTEXT_HEADER_NAME="macho_gas"
505 elif test `echo "$BASEVERSION" | grep -c "win"` -gt 0
506 then
507 UFCONTEXT_HEADER_NAME="windows"
508 else
509 UFCONTEXT_HEADER_NAME="elf_gas"
512 if test `echo "$BASEVERSION" | grep -c "arm"` -gt 0
513 then
514 UFCONTEXT_HEADER_NAME="arm_aapcs_${UFCONTEXT_HEADER_NAME}"
515 elif test `echo "$BASEVERSION" | grep -c "mips"` -gt 0
516 then
517 UFCONTEXT_HEADER_NAME="mips32_o32_${UFCONTEXT_HEADER_NAME}"
518 elif test `echo "$BASEVERSION" | grep -c "bluegene\|pami\|ppc"` -gt 0
519 then
520 UFCONTEXT_HEADER_NAME="ppc64_sysv_${UFCONTEXT_HEADER_NAME}"
521 elif test `echo "$BASEVERSION" | grep -c "cray\|x86_64\|linux64\|amd64"` -gt 0
522 then
523 UFCONTEXT_HEADER_NAME="x86_64_sysv_${UFCONTEXT_HEADER_NAME}"
524 else
525 UFCONTEXT_HEADER_NAME="i386_sysv_${UFCONTEXT_HEADER_NAME}"
528 #generate VERSION name combining all the build-time options.
529 if [ -n "$BOPTS" -o -n "$COMPILER" ]
530 then
531 echo "Selected Compiler: $COMPILER"
533 if test -n "$COMPILER" -a `echo "$BASEVERSION" | grep -c "cray\|gni\|gemini"` -gt 0
534 then
535 echo "Inserted explicit compiler options on Cray systems. Use compiler wrappers by loading PrgEnv-*"
536 echo "e.g.) module load PrgEnv-* (e.g. cray for cce, gnu for gcc, intel for icc, and pgi for pgcc)"
537 echo " ./build charm++ $BASEVERSION <other build options>"
538 echo "Charm++ uses the compiler wrapper 'CC' specified by the Cray system. Don't use explicit compiler options on Cray systems."
539 exit 1
542 if test `echo "$BOPTS" | grep -c "omp"` -gt 0 -a `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
543 then
544 if test -z "$COMPILER" -o "$COMPILER" != "gcc"
545 then
546 echo "The integrated OpenMP runtime library is supported on Mac only with the normal gcc"
547 echo "You need to install this normal (non-clang) gcc via MacPorts or Homebrew"
548 echo "Read the instructions on the Charm++ manual."
549 exit 1
552 echo "Selected Options: $BOPTS"
553 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
554 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
555 for i in $BOPTS_WITHCOMPILER
557 VERSION=$VERSION-$i
558 done
561 #echo "|$DESTINATION|$DESTINATION_SUFFIX|"
563 if [ -z "$DESTINATION" ]
564 then
565 DESTINATION="$VERSION"
568 if [ $(dirname $DESTINATION) != "." ]
569 then
570 srcbaseabs="$(cd $srcbaseabs; pwd)"
571 srcbase=$srcbaseabs
572 src="$srcbaseabs/arch/"
575 if [ -n "$DESTINATION_SUFFIX" ]
576 then
577 DESTINATION="$DESTINATION-$DESTINATION_SUFFIX"
580 [ -d $DESTINATION ] || Echo "Creating dir: $DESTINATION"
581 [ -d $DESTINATION ] || mkdir $DESTINATION
582 [ -d $DESTINATION/tmp ] || Echo "Creating dir: $DESTINATION/tmp"
583 [ -d $DESTINATION/tmp ] || mkdir $DESTINATION/tmp
585 Echo "Copying src/scripts/Makefile to $DESTINATION/tmp"
586 rm -f $DESTINATION/tmp/Makefile
587 rm -f $DESTINATION/tmp/Make.depends
588 rm -f $DESTINATION/tmp/Make.cidepends
589 rm -f $DESTINATION/tmp/Make.lb
590 rm -f $DESTINATION/tmp/Make.gpu
591 rm -f $DESTINATION/tmp/Makefile.machine
592 rm -f $DESTINATION/tmp/Make.extlib
594 echo "TARGET=${UFCONTEXT_HEADER_NAME}" > $DESTINATION/tmp/uFcontext.mk
596 # Create the bin, lib, include, etc. links:
597 WINNAME=`echo $VERSION | awk -F- '{print $2}'`
598 if [ "x_$WINNAME" = "x_win64" -o "x_$WINNAME" = "x_win" ]
599 then
600 #Win64 version needs special compilers and *copied* (not linked)
601 # source files.
602 cp $src/win/system_ln $DESTINATION/tmp
603 cp $src/win/unistd.h $DESTINATION/tmp
604 echo "Compiling createlink.cpp ..."
605 (cd $src/win; ./unix2nt_cc -c createlink.cpp -o createlink.o -D_WIN32_WINNT=0x0500; ./unix2nt_cc createlink.o)
607 if test ! -x $src/win/createlink.exe
608 then
609 echo "VC++ is not properly installed!"
610 exit 1
612 chmod +x $DESTINATION/tmp/system_ln
613 cp $src/win/gathertree.local $DESTINATION/tmp
614 cp $src/win/gatherflat.local $DESTINATION/tmp
615 else
616 cat > $DESTINATION/tmp/system_ln <<EOF
617 #!/bin/sh
618 ln -f -s \$@
620 chmod +x $DESTINATION/tmp/system_ln
621 for newdir in `echo bin lib lib_so include tmp`
623 Echo "Soft-linking over $newdir"
624 if [ -r $newdir ]
625 then
626 rm -fr $newdir || exit 1
628 $DESTINATION/tmp/system_ln $DESTINATION/$newdir $newdir
629 done
630 rm -f VERSION
631 $DESTINATION/tmp/system_ln $DESTINATION/include/VERSION VERSION
634 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.depends" $DESTINATION/tmp/Make.depends
635 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.cidepends" $DESTINATION/tmp/Make.cidepends
636 if test -f "$srcbaseabs/ck-ldb/Make.lb"
637 then
638 $DESTINATION/tmp/system_ln "$srcbase/ck-ldb/Make.lb" $DESTINATION/tmp/Make.lb
639 else
640 touch $DESTINATION/tmp/Make.lb
642 $DESTINATION/tmp/system_ln "$srcbase/scripts/Makefile" $DESTINATION/tmp/Makefile
643 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.tau" $DESTINATION/tmp/Make.tau
644 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.gpu" $DESTINATION/tmp/Make.gpu
645 touch $DESTINATION/tmp/Makefile.machine
646 touch $DESTINATION/tmp/Make.extlib
648 ConvUsr="$DESTINATION/tmp/conv-mach-pre.sh"
649 Echo "Generating $ConvUsr"
650 echo > $ConvUsr
651 if test -n "$LIBDIR"
652 then
653 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
654 echo 'USER_OPTS_LDXX="$USER_OPTS_LDXX '$LIBDIR'"' >> $ConvUsr
656 if test -n "$INCDIR"
657 then
658 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
659 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
661 chmod +x $ConvUsr
663 # Create conv-mach-opt headers with special build-time options
664 ConvHeader="$DESTINATION/tmp/conv-mach-opt.h"
665 ConvSh="$DESTINATION/tmp/conv-mach-opt.sh"
666 if [ ! -f $ConvSh -o ! -f $ConvHeader ]
667 then
668 Echo "Generating $ConvHeader, conv-mach-opt.sh"
669 echo '/* Build-time options header, automatically generated by charm/build*/'> $ConvHeader
670 echo '# Built-time options header, automatically generated by charm/build'> $ConvSh
671 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
673 if test -n "$COMPILER"
674 then
675 i="$COMPILER"
676 echo '#include "'cc-$i.h'"' >> $ConvHeader
677 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
678 elif test `echo "$BASEVERSION" | grep -c "bluegeneq"` -gt 0
679 then
680 i="clang"
681 bgclang++11 --version
682 if [ $? -ne 0 ]; then
683 echo "ERROR: bgclang C/C++ compiler missing. Please load bgclang compilers, i.e. 'soft add +mpiwrapper-bgclang'."
684 exit 1
686 echo '#include "'cc-$i.h'"' >> $ConvHeader
687 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
689 if test -n "$BOPTS"
690 then
691 # pxshm+smp note: When combining the 'smp' and 'pxshm' directives, it is
692 # important that they be included in $ConvHeader in that
693 # exact order. See bug #717.
694 TMP=""
695 HAS_PXSHM=0
696 HAS_SMP=0
697 for i in $BOPTS; do
698 if [ "$i" = "smp" ]; then
699 HAS_SMP=1
700 elif [ "$i" = "pxshm" ]; then
701 HAS_PXSHM=1
702 elif [ "$i" = "omp" ]; then
703 BUILD_OMP=1
704 TMP="$TMP $i"
705 else
706 TMP="$TMP $i"
708 done
709 if [ $HAS_PXSHM -eq 1 ]; then
710 TMP="pxshm $TMP"
712 if [ $HAS_SMP -eq 1 ]; then
713 TMP="smp $TMP"
714 elif [ $BUILD_OMP -eq 1 ]; then
715 BUILD_OMP=2 #this means omp keyword inserted without smp keyword"
718 BOPTS=$TMP
719 for i in $BOPTS
721 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
722 if [ $BUILD_CUDA -eq 1 ]; then
723 echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
725 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
726 done
729 if test "$BUILD_SHARED" = "-build-shared"
730 then
731 echo "CMK_NO_BUILD_SHARED=false" >> $ConvSh
732 else
733 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
736 if test -n "$WITH_ROMIO"
737 then
738 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
741 if test -n "$WITH_PRODUCTION"
742 then
743 echo '#define CMK_OPTIMIZE 1' >> $ConvHeader
744 # Prepend optimize so that an explicit -no-optimize still works
745 OPTS="-optimize -production $OPTS"
746 CONFIG_OPTS="--disable-controlpoint --disable-tracing --disable-tracing-commthread --disable-charmdebug --disable-replay --disable-error-checking --disable-stats $CONFIG_OPTS"
749 # build with Tau
750 WITH_TAU=0
751 if [ "$PROGRAM" = "Tau" ]
752 then
753 Echo "TAU>>>> makefile config option: $TAU_MAKEFILE"
754 if [ -n "$TAU_MAKEFILE" -a -f $TAU_MAKEFILE ]
755 then
756 #Setting up TAU trace library:
757 Echo "TAU>>>> configuring with this TAU makefile: $TAU_MAKEFILE"
759 WITH_TAU=1
760 else
761 Echo "TAU>>>> ERROR could not find Makefile: $TAU_MAKEFILE, ignored"
762 TAU_MAKEFILE=""
766 if test $WITH_TAU -eq 1
767 then
768 [ -z "$TAU_MAKEFILE" ] && TAU_MAKEFILE="Make.tau"
769 SED_CHARMC="s@TAU_MAKEFILE=\(.*\)@TAU_MAKEFILE=$TAU_MAKEFILE@"
771 sed -e $SED_CHARMC $srcbaseabs/scripts/Makefile > .Makefile.$$ && cp .Makefile.$$ $srcbaseabs/scripts/Makefile && rm -f .Makefile.$$
772 sed -e $SED_CHARMC $srcbaseabs/scripts/charmc > .charmc.$$ && cp .charmc.$$ $srcbaseabs/scripts/charmc && rm -f .charmc.$$
774 echo "#define CMK_WITH_TAU 1" >> $ConvHeader
775 echo "#define pthread_create tau_pthread_create" >> $ConvHeader
776 echo "#define pthread_exit tau_pthread_exit" >> $ConvHeader
778 echo "CMK_WITH_TAU=\"true\"" >> $ConvSh
781 if [ "$PROGRAM" = "ChaNGa" ]
782 then
783 #Setting lbuserdata when the build is ChaNGa
784 CONFIG_OPTS="--enable-lbuserdata $CONFIG_OPTS"
787 echo $BASEVERSION > $DESTINATION/tmp/.vdir
788 echo $BASEVERSION | sed -e 's@-.*@@' > $DESTINATION/tmp/.gdir
790 if test $BUILD_EMULATOR = 1
791 then
792 # export BIGSIM so that make targets can depend on it
793 MAKEOPTS="$MAKEOPTS BIGSIM=bigsim"
794 PROGRAM="$PROGRAM bigsim"
798 if [ $BUILD_OMP = 2 ]
799 then
800 case $DESTINATION in
801 "multicore"*)
802 BUILD_OMP=1
805 echo "OpenMP support should be built in SMP mode"
806 exit 1
808 esac
811 printError()
813 Echo "-------------------------------------------------"
814 Echo "Charm++ NOT BUILT. Either cd into $DESTINATION/tmp and try"
815 Echo "to resolve the problems yourself, visit"
816 Echo " http://charm.cs.illinois.edu/"
817 Echo "for more information. Otherwise, email the developers at charm@cs.illinois.edu"
818 exit $MAKEEXIT
821 echo 'BUILDOPTS="'$OPTS'"' >> $ConvSh
822 echo "SRCBASE=$srcbase" > $DESTINATION/tmp/charmpath.mk
824 Echo "Performing '$MAKE $MAKEOPTS basics OPTS="$OPTS" QUIET="$QUIET" CONFIG_OPTS="$CONFIG_OPTS"' in $DESTINATION/tmp"
825 cd $DESTINATION/tmp
826 echo "CONFIG_OPTS=\"$CONFIG_OPTS\"" > config_opts.sh
827 chmod +x config_opts.sh
828 echo "OPTSATBUILDTIME += $OPTS" > buildopts.mk
829 $MAKE $MAKEOPTS basics OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
830 MAKEEXIT=$?
831 [ $MAKEEXIT -ne 0 ] && printError
833 Echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS" QUIET="$QUIET"' in $DESTINATION/tmp"
834 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
835 MAKEEXIT=$?
836 if [ $MAKEEXIT -eq 0 ]
837 then
838 if [ $BUILD_OMP = 1 ];
839 then
840 $MAKE MFLAGS="$MAKEOPTS" openmp_llvm OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
842 Echo "-------------------------------------------------"
843 Echo "$PROGRAM built successfully."
844 Echo "Next, try out a sample program like" \
845 "$DESTINATION/tests/charm++/simplearrayhello"
846 else
847 printError