build: fix travis MPI/SMP build
[charm.git] / build
blob9cd34424e0503d92763e57d39d334fcf98d8fdc2
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 charm4py bigemulator msa'
21 if test $more = 1
22 then
23 echo ''
24 echo ' charm++ compile Charm++ core only'
25 echo ' AMPI compile Adaptive MPI on top of Charm++'
26 echo ' LIBS compile additional parallel libraries with Charm++ core'
27 echo ' charm4py compile shared library version of Charm++ for charm4py'
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 ' tcp use TCP sockets for communication (only for netlrts)'
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 ''
81 echo 'Enable/disable features:'
82 configure_ac="$srcbaseabs/scripts/configure.ac"
83 parameter_regex='\([-A-Za-z0-9_=/ ]*\)'
84 description_regex='\([-A-Za-z0-9_=/ ()\\]*\)'
86 # Isolate the sections of configure.ac on which we want to operate. This command uses sed's p command which gives a result similar to grep.
87 # This is because grep cannot operate on multiple lines. GNU grep can do this using "-z", but it is not portable to BSD grep as found on macOS.
88 help_string_source="$(sed -n "/AS_HELP_STRING(\[${parameter_regex}\],/,/ *\[${description_regex}\])/p" "$configure_ac")"
90 # This regex matches the AS_HELP_STRING entries in configure.ac.
91 # It looks messy at the end due to matching square brackets (which must be escaped), commas, and an unrelated token on the same line (a BSD sed concession).
92 help_item_regex=" *\[AS_HELP_STRING(\[${parameter_regex}\],\n *\[${description_regex}\]) *\]*[, []*[a-z=_]*\]*[, ]*"
93 # "\1" is the parameter and "\2" is the description; use printf to left-justify the parameter.
94 help_output_print='printf " %-30s \2\\\\n" "\1"'
95 # The remaining sed syntax allows us to perform a substitution over two successive lines instead of only one.
96 help_items="$(echo "$help_string_source" | sed -n "1h; 1!H; \${ g; s:${help_item_regex}:${help_output_print}:g p; }")"
97 # With the AS_HELP_STRING entries replaced with printf commands, evaluate the result.
98 eval "$help_items"
99 printf " %-30s %s\n" "--with-production" "build Charm++ with all optimizations for maximum performance, and disabling all above features"
101 # Test that the above regular expressions are sufficient to capture all help strings.
102 num_help_strings="$(grep -c AS_HELP_STRING "$configure_ac")"
103 num_help_items="$(echo "$help_items" | wc -l)"
104 if [ $num_help_strings != $num_help_items ]; then
105 echo '<Warning>: Not all parameters were able to be displayed. Please notify the Charm++ developers at charm@cs.illinois.edu.'
109 echo ''
110 echo 'Miscellaneous options:'
111 echo ' --incdir=DIR specify additional include path for compiler'
112 echo ' --libdir=DIR specify additional lib path for compiler'
113 echo ' --basedir=DIR shortcut for the above two - DIR/include and DIR/lib'
114 echo ' -j[N] parallel make, N is the number of parallel make jobs'
115 echo " --with-lbtime-type specify real type for the load balancing timers"
116 echo " --destination=DIR build Charm++ inside DIR, by default the destination is <version>"
117 echo " --suffix=DIR append DIR to the destination directory of the Charm++ build"
118 echo " --tau-makefile=FILE Specify which TAU stub makefile to use"
120 echo ''
121 echo '<charmc-options>: normal compiler options e.g. -g -optimize -save -verbose'
122 if test $more = 1
123 then
124 echo ''
125 echo 'Examples:'
126 echo "1. display all supported options for netlrts-linux-x86_64 using 'help':"
127 echo ' ./build charm++ netlrts-linux-x86_64 help'
128 echo '2. compile Charm++ on Linux with all available tuning:'
129 echo ' ./build charm++ netlrts-linux-x86_64 --with-production'
130 echo '3. compile Charm++ for Linux with Intel compiler and optimizations:'
131 echo ' ./build charm++ netlrts-linux-x86_64 icc -optimize'
132 echo '4. compile Charm++ for Windows with VC++:'
133 echo ' ./build charm++ netlrts-win-x86_64 -optimize'
134 echo '5. compile Charm++ with MPI that is installed at /usr/local/mpich:'
135 echo ' ./build charm++ mpi-linux-x86_64 --incdir /usr/local/mpich/include --libdir /usr/local/mpich/lib -optimize'
136 echo ' or in short,'
137 echo ' ./build charm++ mpi-linux-x86_64 --basedir /usr/local/mpich -optimize'
138 echo ' ./build Tau --tau-makefile=/usr/local/packages/TAU/x86_64/lib/Makefile.tau-mpi'
139 echo ''
140 echo 'Note: This script:'
141 echo ' 1. Creates directories <destination> and <destination>/tmp'
142 echo ' 2. Copies src/scripts/Makefile into <destination>/tmp'
143 echo ' 3. Does a "make basics" in <destination>/tmp.'
144 echo ' 3. Does a "make -jN <target> <version> OPTS=<charmc-options>" in <destination>/tmp.'
145 echo "That's all build does. The rest is handled by the Makefile."
146 echo ''
147 echo 'Thank you for using Charm++, please send questions or comments to '
148 echo 'Parallel Programming Lab at University of Illinois at Urbana-Champaign'
149 echo '(email: charm@cs.illinois.edu).'
151 else
152 echo ''
153 echo "To get more detailed help, run ./build --help"
157 Echo() {
158 [ "x$QUIET" = "x--quiet" ] || echo $*
161 printOption() {
162 for prefix in cc conv-mach
164 str="Supported compilers:"
165 [ "$prefix" = "conv-mach" ] && str="Supported options:"
166 opts=""
167 for dir in $OPT_DIRS
169 # echo "Checking for $prefix in $dir"
170 files=`cd $dir; ls $prefix-*.h 2>/dev/null`
171 opts="$opts "`echo $files | sed 's/'$prefix'-\([^.]*\).h/\1/g'`
172 done
173 tmp=.tmp.$$
174 rm -f $tmp; touch $tmp
175 for o in $opts
177 echo $o >> $tmp
178 done
179 opts=`sort $tmp | uniq`
180 rm -f $tmp
181 echo $str $opts
182 done
183 exit 1
186 CheckDir() {
187 for d in $*
189 if test ! -d $d
190 then
191 echo Error: cannot find $d!
192 exit 1
194 done
197 TestIfCompiler() {
198 compilerName=`echo $1 | sed 's/-[0-9\.][0-9\.]*$//'`
199 for dir in $OPT_DIRS
201 [ -f $dir/cc-$compilerName.sh ] && return 1
202 done
203 return 0
206 TestIfOption() {
207 for dir in $OPT_DIRS
209 [ -f $dir/conv-mach-$1.h ] && return 1
210 done
212 echo "Error> option: $1 is not supported in this version!";
213 printOption
217 # start
219 BUILD_CUDA=0
220 MAKEOPTS=""
221 OPTS=""
222 BOPTS=""
223 MORE=""
224 COMPILER=""
225 BASEDIR=
226 LIBDIR=
227 INCDIR=
228 ARCH=
229 BUILD_SHARED="" # default no shared lib
230 WITH_ROMIO="true" # default to building ROMIO on AMPI
231 WITH_PRODUCTION=
232 BUILD_EMULATOR=0
233 DESTINATION=""
234 DESTINATION_SUFFIX=""
235 TAU_MAKEFILE=""
236 QUIET=""
237 BUILD_OMP=0
238 ONLY_CONFIGURE=
240 [ "$1" = '--help' -o "$1" = '-h' ] && more=1 && syntax | ( less || more ) && exit 1
241 [ $# -lt 2 ] && $(dirname "$0")/smart-build.pl && exit 1
242 PROGRAM=$1
243 shift
245 # find longest prefix of version argument that exists as a directory in $src
246 VERSION="$1"
247 VERSOPTS=""
248 testversion=""
249 oldifs="$IFS"
250 IFS="-"
251 for w in $1; do
252 IFS="$oldifs"
253 if [ -z "$testversion" ]; then
254 testversion="$w"
255 else
256 testversion="$testversion-$w"
258 if [ -d $src/$testversion ]; then
259 VERSION="$testversion"
260 VERSOPTS=""
261 else
262 VERSOPTS="$VERSOPTS $w"
264 done
265 if [ "$VERSION" = "$1" ]; then VERSOPTS=""; fi
267 BASEVERSION="$VERSION"
268 if test -f $src/$BASEVERSION/vdir_link
269 then
270 BASEVERSION=`cat $src/$BASEVERSION/vdir_link`
272 ARCH=`echo $BASEVERSION | sed -e 's@-.*@@'`
273 shift
275 #echo $src
276 #echo $BASEVERSION
277 #echo $ARCH
279 OPT_DIRS="$src/$BASEVERSION $src/$ARCH $src/common"
281 # process remainder of version argument as options, copied from below
282 for w in $VERSOPTS; do
283 # This has to be a build-time option (like "smp")
284 TestIfCompiler $w
285 if [ $? -eq 1 ]
286 then
287 # It specifies a compiler:
288 if [ ! -z "$COMPILER" ]
289 then
290 echo "Error> Tried to specify two compilers: $COMPILER and $w"
291 printOption
293 COMPILER=$w
294 else
295 # It specifies some other option:
296 TestIfOption $w
297 BOPTS="$BOPTS $w"
298 [ $w = "bigemulator" ] && BUILD_EMULATOR=1
299 [ $w = "bigsim" ] && BUILD_EMULATOR=1
300 [ $w = "cuda" ] && BUILD_CUDA=1
302 done
304 while [ ! $# -eq 0 ]
306 case "$1" in
307 "--basedir")
308 shift;
309 for dir in $1
311 CheckDir $dir/include $dir/lib
312 LIBDIR="$LIBDIR -L$dir/lib";
313 INCDIR="$INCDIR -I$dir/include"
314 done
315 shift
317 --basedir=*)
318 basedir=`echo $1 | awk -F= '{print $2}'`
319 for dir in $basedir
321 CheckDir $dir/include $dir/lib
322 LIBDIR="$LIBDIR -L$dir/lib";
323 INCDIR="$INCDIR -I$dir/include"
324 done
325 shift
327 "--libdir")
328 shift; CheckDir $1
329 for dir in $1
331 LIBDIR="$LIBDIR -L$dir";
332 done
333 shift
335 --libdir=*)
336 libdir=`echo $1 | awk -F= '{print $2}'`
337 CheckDir $libdir
338 for dir in $libdir
340 LIBDIR="$LIBDIR -L$dir";
341 done
342 shift
344 "--incdir")
345 shift; CheckDir $1
346 for dir in $1
348 INCDIR="$INCDIR -I$dir";
349 done
350 shift
352 --incdir=*)
353 incdir=`echo $1 | awk -F= '{print $2}'`
354 CheckDir $incdir
355 for dir in $incdir
357 INCDIR="$INCDIR -I$dir";
358 done
359 shift
361 --no-build-shared|--no-shared)
362 BUILD_SHARED='';
363 shift
365 --build-shared)
366 BUILD_SHARED="-build-shared";
367 shift
369 --with-romio)
370 WITH_ROMIO="true"; shift
372 --without-romio)
373 WITH_ROMIO=""; shift
375 --with-production)
376 WITH_PRODUCTION="true"
377 shift
379 --with-*)
380 CONFIG_OPTS="$CONFIG_OPTS $1"
381 shift
383 --without-*)
384 CONFIG_OPTS="$CONFIG_OPTS $1"
385 shift
387 --destination)
388 shift
389 DESTINATION="$1"
390 shift
392 --destination=*)
393 DESTINATION="`echo $1 | awk -F= '{print $2}'`"
394 shift
396 --suffix)
397 shift
398 DESTINATION_SUFFIX="$1"
399 shift
401 --suffix=*)
402 DESTINATION_SUFFIX="`echo $1 | awk -F= '{print $2}'`"
403 shift
405 --tau-makefile)
406 TAU_MAKEFILE=$1
407 shift
409 --tau-makefile=*)
410 TAU_MAKEFILE=`echo $1 | awk -F= '{print $2}'`
411 shift
413 --quiet)
414 MAKEOPTS="$MAKEOPTS --quiet"
415 QUIET="--quiet"
416 shift;
418 --only-configure)
419 ONLY_CONFIGURE="true"
420 shift
422 --enable-tracing|--enable-tracing=*)
423 CONFIG_OPTS="$CONFIG_OPTS $1"
424 ENABLE_TRACING=yes
425 shift
427 --enable-*)
428 CONFIG_OPTS="$CONFIG_OPTS $1"
429 shift
431 --disable-*)
432 CONFIG_OPTS="$CONFIG_OPTS $1"
433 shift
435 -j*)
436 PMAKENUM=`echo $1 | awk -Fj '{print $2}'`
437 MAKEOPTS="$MAKEOPTS -j $PMAKENUM"
438 shift;
440 -k|--keep-going)
441 MAKEOPTS="$MAKEOPTS $1"
442 shift;
444 -*)
445 # Compiler option (like -g or -Dfoo), copy it over
446 OPTS="$OPTS $1"
447 shift
449 "help")
450 printOption
453 # This has to be a build-time option (like "smp")
454 TestIfCompiler $1
455 if [ $? -eq 1 ]
456 then
457 # It specifies a compiler:
458 if [ ! -z "$COMPILER" ]
459 then
460 echo "Error> Tried to specify two compilers: $COMPILER and $1"
461 printOption
463 COMPILER=$1
464 else
465 # It specifies some other option:
466 TestIfOption $1
467 BOPTS="$BOPTS $1"
468 [ $1 = "bigemulator" ] && BUILD_EMULATOR=1
469 [ $1 = "bigsim" ] && BUILD_EMULATOR=1
470 [ $1 = "cuda" ] && BUILD_CUDA=1
472 shift
474 esac
475 done
477 if [ $BUILD_CUDA -eq 1 ]; then
478 HAVE_CUDA="no"
479 echo "checking for CUDA toolkit directory"
480 CUDA_PRESET_DIRS="/usr/local/cuda /usr/lib/nvidia-cuda-toolkit"
481 CUDA_CANDIDATE_DIRS="$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
482 for dir in $CUDA_CANDIDATE_DIRS; do
483 if test -d "$dir"; then
484 CUDA_DIR="$dir"
485 HAVE_CUDA="yes"
486 echo "CUDA_DIR=$CUDA_DIR"
487 break
489 done
490 if [ "$HAVE_CUDA" = "no" ]; then
491 echo "Error> no CUDA toolkit found, searched \$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
492 exit 1
496 [ "x$VERSION" = "x" ] && syntax && exit 1
498 if [ "x_$ARCH" = "x_net" ]; then
499 echo "Error: net-* has been removed, please use netlrts or verbs.";
500 exit 1;
503 #Check if building verbs on Omni-Path
504 if [ "x_$ARCH" = "x_verbs" ] && type /usr/sbin/opafabricinfo >/dev/null 2>&1; then
505 echo "WARNING: Detected Omni-Path diagnostic tools.";
506 echo "Verbs on Omni-Path architectures is not well supported: please use an OFI build instead.";
509 if test -n "$WITH_PRODUCTION" -a $BUILD_EMULATOR -eq 1 -a -z "$ENABLE_TRACING"
510 then
511 echo "Error: bigemulator requires tracing modules, --with-production must be used with --enable-tracing"
512 exit 1
515 if [ -z "$MAKE" ]
516 then
517 # prefer gmake
518 MAKE=`which gmake 2>/dev/null`
519 [ -z "$MAKE" -o ! -x "$MAKE" ] && MAKE='make'
522 if [ ! -f $src/$BASEVERSION/conv-mach.h ]
523 then
524 echo "Error> build can not find arch: $BASEVERSION!"
525 exit 1
528 if [ ! -f "$srcbaseabs/scripts/configure" ]
529 then
530 if ! command -v autoreconf >/dev/null 2>&1 || ! command -v aclocal >/dev/null 2>&1
531 then
532 echo "Error> autoconf and automake are not installed."
533 exit 1
537 #generate header for uFcontext for the target VERSION
538 UFCONTEXT_HEADER_NAME=
539 if test `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
540 then
541 UFCONTEXT_HEADER_NAME="macho_gas"
542 elif test `echo "$BASEVERSION" | grep -c "win"` -gt 0
543 then
544 UFCONTEXT_HEADER_NAME="windows"
545 else
546 UFCONTEXT_HEADER_NAME="elf_gas"
549 if test `echo "$BASEVERSION" | grep -c "arm7"` -gt 0
550 then
551 UFCONTEXT_HEADER_NAME="arm_aapcs_${UFCONTEXT_HEADER_NAME}"
552 elif test `echo "$BASEVERSION" | grep -c "arm8"` -gt 0
553 then
554 UFCONTEXT_HEADER_NAME="arm64_aapcs_${UFCONTEXT_HEADER_NAME}"
555 elif test `echo "$BASEVERSION" | grep -c "mips"` -gt 0
556 then
557 UFCONTEXT_HEADER_NAME="mips32_o32_${UFCONTEXT_HEADER_NAME}"
558 elif test `echo "$BASEVERSION" | grep -c "bluegene\|pami\|ppc"` -gt 0
559 then
560 UFCONTEXT_HEADER_NAME="ppc64_sysv_${UFCONTEXT_HEADER_NAME}"
561 elif test `echo "$BASEVERSION" | grep -c "cray\|x86_64\|linux64\|amd64"` -gt 0
562 then
563 UFCONTEXT_HEADER_NAME="x86_64_sysv_${UFCONTEXT_HEADER_NAME}"
564 else
565 UFCONTEXT_HEADER_NAME="i386_sysv_${UFCONTEXT_HEADER_NAME}"
568 #generate VERSION name combining all the build-time options.
569 if [ -n "$BOPTS" -o -n "$COMPILER" ]
570 then
571 echo "Selected Compiler: $COMPILER"
573 if test -n "$COMPILER" -a `echo "$BASEVERSION" | grep -c "cray\|gni\|gemini"` -gt 0
574 then
575 echo "Inserted explicit compiler options on Cray systems. Use compiler wrappers by loading PrgEnv-*"
576 echo "e.g.) module load PrgEnv-* (e.g. cray for cce, gnu for gcc, intel for icc, and pgi for pgcc)"
577 echo " ./build charm++ $BASEVERSION <other build options>"
578 echo "Charm++ uses the compiler wrapper 'CC' specified by the Cray system. Don't use explicit compiler options on Cray systems."
579 exit 1
582 if test `echo "$BOPTS" | grep -c "omp"` -gt 0 -a `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
583 then
584 if test -z "$COMPILER" -o "$COMPILER" != "gcc"
585 then
586 echo "The integrated OpenMP runtime library is supported on Mac only with the normal gcc"
587 echo "You need to install this normal (non-clang) gcc via MacPorts or Homebrew"
588 echo "Read the instructions on the Charm++ manual."
589 exit 1
592 echo "Selected Options: $BOPTS"
593 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
594 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
595 for i in $BOPTS_WITHCOMPILER
597 VERSION=$VERSION-$i
598 done
601 #echo "|$DESTINATION|$DESTINATION_SUFFIX|"
603 if [ -z "$DESTINATION" ]
604 then
605 DESTINATION="$VERSION"
608 if [ $(dirname $DESTINATION) != "." ]
609 then
610 srcbaseabs="$(cd $srcbaseabs; pwd)"
611 srcbase=$srcbaseabs
612 src="$srcbaseabs/arch/"
615 if [ -n "$DESTINATION_SUFFIX" ]
616 then
617 DESTINATION="$DESTINATION-$DESTINATION_SUFFIX"
620 # make sure $DESTINATION is more than '/' characters, because we `rm -rf` it
621 if [ -z "${DESTINATION#"${DESTINATION%%[!/]*}"}" ]
622 then
623 echo 'Error: $DESTINATION is the filesystem root.'
624 exit 1
627 if test -n "$BOPTS"
628 then
629 # pxshm+smp note: When combining the 'smp' and 'pxshm' directives, it is
630 # important that they be included in $ConvHeader in that
631 # exact order. See bug #717.
632 MYTMP=""
633 HAS_PXSHM=0
634 HAS_SMP=0
635 for i in $BOPTS; do
636 if [ "$i" = "smp" ]; then
637 HAS_SMP=1
638 elif [ "$i" = "pxshm" ]; then
639 HAS_PXSHM=1
640 elif [ "$i" = "omp" ]; then
641 BUILD_OMP=1
642 MYTMP="$MYTMP $i"
643 else
644 MYTMP="$MYTMP $i"
646 done
647 if [ $HAS_PXSHM -eq 1 ]; then
648 MYTMP="pxshm $MYTMP"
650 if [ $HAS_SMP -eq 1 ]; then
651 MYTMP="smp $MYTMP"
652 if [ $BUILD_OMP -eq 1 ]; then
653 CONFIG_OPTS="--enable-task-queue $CONFIG_OPTS"
655 elif [ $BUILD_OMP -eq 1 ]; then
656 BUILD_OMP=2 #this means omp keyword inserted without smp keyword"
660 # build for Charm4py
661 if [ "$PROGRAM" = "charmpy" ] || [ "$PROGRAM" = "charm4py" ]; then
663 if [ -n "$BOPTS" ] && [ "$HAS_SMP" -eq 1 ]; then
664 echo "Error: SMP mode is currently not supported with charm4py. Choose a non-smp version."
665 exit 1
668 if [ `echo "$BASEVERSION" | grep -c "multicore"` -gt 0 ]; then
669 echo "Error: multicore is currently not supported with charm4py. Choose a non-smp version."
670 exit 1
673 if test `echo "$CONFIG_OPTS" | grep -c "\--enable-charmpy"` -eq 0
674 then
675 CONFIG_OPTS="$CONFIG_OPTS --enable-charmpy"
678 if test `echo "$BASEVERSION" | grep -c "win"` -gt 0
679 then
680 BUILD_SHARED=""
681 else
682 BUILD_SHARED="-build-shared"
686 if test -n "$WITH_PRODUCTION"
687 then
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 [ "$PROGRAM" = "ChaNGa" ]
711 then
712 #Setting lbuserdata when the build is ChaNGa
713 CONFIG_OPTS="--enable-lbuserdata $CONFIG_OPTS"
716 if test $BUILD_EMULATOR = 1
717 then
718 # export BIGSIM so that make targets can depend on it
719 MAKEOPTS="$MAKEOPTS BIGSIM=bigsim"
720 PROGRAM="$PROGRAM bigsim"
723 if [ $BUILD_OMP = 2 ]
724 then
725 case $DESTINATION in
726 "multicore"*)
727 BUILD_OMP=1
730 echo "OpenMP support should be built in SMP mode"
731 exit 1
733 esac
736 # ===================================================
737 # ---------- begin file structure creation ----------
738 # ===================================================
740 if [ -f "$DESTINATION/tmp/basics" ]
741 then
742 Echo "File structure already created; skipping directly to make"
743 else
745 for d in benchmarks bin examples include lib lib_so tests tmp; do
746 rm -rf "$DESTINATION/$d"
747 done
749 Echo "Creating dir: $DESTINATION"
750 Echo "Creating dir: $DESTINATION/tmp"
751 mkdir -p "$DESTINATION/tmp"
753 echo "TARGET=${UFCONTEXT_HEADER_NAME}" > $DESTINATION/tmp/uFcontext.mk
755 # Create the bin, lib, include, etc. links:
756 WINNAME=`echo $VERSION | awk -F- '{print $2}'`
757 if [ "x_$WINNAME" = "x_win64" -o "x_$WINNAME" = "x_win" ]
758 then
759 #Win64 version needs special compilers and *copied* (not linked)
760 # source files.
761 cp $src/win/system_ln $DESTINATION/tmp
762 cp $src/win/unistd.h $DESTINATION/tmp
763 echo "Compiling createlink.cpp ..."
764 case "$COMPILER" in
765 gcc*|clang*)
766 createlinkcc="$COMPILER"
769 createlinkcc="./unix2nt_cc"
771 esac
772 (cd $src/win; $createlinkcc -c createlink.cpp -o createlink.o -D_WIN32_WINNT=0x0500; $createlinkcc createlink.o -o createlink.exe)
774 if test ! -x $src/win/createlink.exe
775 then
776 echo "VC++ is not properly installed!"
777 exit 1
779 chmod +x $DESTINATION/tmp/system_ln
780 cp $src/win/gathertree.local $DESTINATION/tmp
781 cp $src/win/gatherflat.local $DESTINATION/tmp
782 else
783 cat > $DESTINATION/tmp/system_ln <<EOF
784 #!/bin/sh
785 ln -f -s \$@
787 chmod +x $DESTINATION/tmp/system_ln
788 newdirlist='bin lib'
789 [ -n "$BUILD_SHARED" ] && newdirlist="$newdirlist lib_so"
790 newdirlist="$newdirlist include tmp"
791 for newdir in $newdirlist
793 Echo "Soft-linking over $newdir"
794 if [ -r $newdir ]
795 then
796 rm -fr $newdir || exit 1
798 $DESTINATION/tmp/system_ln $DESTINATION/$newdir $newdir
799 done
800 rm -f VERSION
801 $DESTINATION/tmp/system_ln $DESTINATION/include/VERSION VERSION
804 Echo "Copying src/scripts/Makefile to $DESTINATION/tmp"
805 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.depends" $DESTINATION/tmp/Make.depends
806 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.cidepends" $DESTINATION/tmp/Make.cidepends
807 if test -f "$srcbaseabs/ck-ldb/Make.lb"
808 then
809 $DESTINATION/tmp/system_ln "$srcbase/ck-ldb/Make.lb" $DESTINATION/tmp/Make.lb
810 else
811 touch $DESTINATION/tmp/Make.lb
813 $DESTINATION/tmp/system_ln "$srcbase/scripts/Makefile" $DESTINATION/tmp/Makefile
814 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.tau" $DESTINATION/tmp/Make.tau
815 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.gpu" $DESTINATION/tmp/Make.gpu
816 touch $DESTINATION/tmp/Makefile.machine
817 touch $DESTINATION/tmp/Make.extlib
819 ConvUsr="$DESTINATION/tmp/conv-mach-pre.sh"
820 Echo "Generating $ConvUsr"
821 echo > $ConvUsr
822 if test -n "$LIBDIR"
823 then
824 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
826 if test -n "$INCDIR"
827 then
828 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
829 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
831 chmod +x $ConvUsr
833 # Create conv-mach-opt headers with special build-time options
834 ConvHeader="$DESTINATION/tmp/conv-mach-opt.h"
835 ConvSh="$DESTINATION/tmp/conv-mach-opt.sh"
836 ConvMak="$DESTINATION/tmp/conv-mach-opt.mak"
837 if [ ! -f "$ConvSh" -o ! -f "$ConvHeader" -o ! -f "$ConvMak" ]
838 then
839 Echo "Generating $ConvHeader, conv-mach-opt.sh, conv-mach-opt.mak"
840 echo '/* Build-time options header, automatically generated by charm/build */' > $ConvHeader
841 echo '# Build-time options header, automatically generated by charm/build' > $ConvSh
842 echo '# Build-time options header, automatically generated by charm/build' > $ConvMak
843 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
845 if test -n "$COMPILER"
846 then
847 i=`echo $COMPILER | sed 's/-[0-9\.][0-9\.]*$//'`
848 echo "CMK_COMPILER_SUFFIX=${COMPILER#$i}" >> $ConvSh
849 echo '#include "'cc-$i.h'"' >> $ConvHeader
850 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
851 elif test `echo "$BASEVERSION" | grep -c "bluegeneq"` -gt 0
852 then
853 i="clang"
854 bgclang++11 --version
855 if [ $? -ne 0 ]; then
856 echo "ERROR: bgclang C/C++ compiler missing. Please load bgclang compilers, i.e. 'soft add +mpiwrapper-bgclang'."
857 exit 1
859 echo '#include "'cc-$i.h'"' >> $ConvHeader
860 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
862 if test -n "$MYTMP"
863 then
864 BOPTS=$MYTMP
865 for i in $BOPTS
867 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
868 if [ $BUILD_CUDA -eq 1 ]; then
869 echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
870 echo "CUDA_DIR:=$CUDA_DIR" >> $ConvMak
872 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
873 done
876 if test "$BUILD_SHARED" = "-build-shared"
877 then
878 echo "CMK_NO_BUILD_SHARED=false" >> $ConvSh
879 echo "CMK_NO_BUILD_SHARED:=false" >> $ConvMak
880 else
881 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
882 echo "CMK_NO_BUILD_SHARED:=true" >> $ConvMak
885 if test -n "$WITH_ROMIO"
886 then
887 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
888 echo "CMK_AMPI_WITH_ROMIO:=true" >> $ConvMak
891 if test -n "$WITH_PRODUCTION"
892 then
893 echo '#define CMK_OPTIMIZE 1' >> $ConvHeader
896 if test $WITH_TAU -eq 1
897 then
898 [ -z "$TAU_MAKEFILE" ] && TAU_MAKEFILE="Make.tau"
899 SED_CHARMC="s@TAU_MAKEFILE=\(.*\)@TAU_MAKEFILE=$TAU_MAKEFILE@"
901 sed -e $SED_CHARMC $srcbaseabs/scripts/Makefile > .Makefile.$$ && cp .Makefile.$$ $srcbaseabs/scripts/Makefile && rm -f .Makefile.$$
902 sed -e $SED_CHARMC $srcbaseabs/scripts/charmc > .charmc.$$ && cp .charmc.$$ $srcbaseabs/scripts/charmc && rm -f .charmc.$$
904 echo "#define CMK_WITH_TAU 1" >> $ConvHeader
905 echo "#define pthread_create tau_pthread_create" >> $ConvHeader
906 echo "#define pthread_exit tau_pthread_exit" >> $ConvHeader
908 echo "CMK_WITH_TAU=\"true\"" >> $ConvSh
911 CMK_VDIR="$BASEVERSION"
912 echo "$CMK_VDIR" > $DESTINATION/tmp/.vdir
913 echo 'CMK_VDIR="'$CMK_VDIR'"' >> $ConvSh
914 echo "CMK_VDIR:=$CMK_VDIR" >> $ConvMak
915 CMK_GDIR="`echo $BASEVERSION | sed -e 's@-.*@@'`"
916 echo "$CMK_GDIR" > $DESTINATION/tmp/.gdir
917 echo 'CMK_GDIR="'$CMK_GDIR'"' >> $ConvSh
918 echo "CMK_GDIR:=$CMK_GDIR" >> $ConvMak
920 echo 'BUILDOPTS="'$OPTS'"' >> $ConvSh
921 echo "SRCBASE=$srcbase" > $DESTINATION/tmp/charmpath.mk
923 echo "CONFIG_OPTS=\"$CONFIG_OPTS\"" > "$DESTINATION/tmp/config_opts.sh"
924 chmod +x "$DESTINATION/tmp/config_opts.sh"
925 echo "OPTSATBUILDTIME:=$OPTS" >> $ConvMak
929 # ===================================================
930 # ----------- end file structure creation -----------
931 # ===================================================
933 printError()
935 Echo "-------------------------------------------------"
936 Echo "Charm++ NOT BUILT. Either cd into $DESTINATION/tmp and try"
937 Echo "to resolve the problems yourself, visit"
938 Echo " http://charm.cs.illinois.edu/"
939 Echo "for more information. Otherwise, email the developers at charm@cs.illinois.edu"
940 exit $MAKEEXIT
943 Echo "Performing '$MAKE $MAKEOPTS basics OPTS="$OPTS" QUIET="$QUIET" CONFIG_OPTS="$CONFIG_OPTS"' in $DESTINATION/tmp"
944 cd $DESTINATION/tmp
945 $MAKE $MAKEOPTS basics OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
946 MAKEEXIT=$?
947 [ $MAKEEXIT -ne 0 ] && printError
949 if test -n "$ONLY_CONFIGURE"
950 then
951 exit 0
954 Echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS" QUIET="$QUIET"' in $DESTINATION/tmp"
955 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
956 MAKEEXIT=$?
957 if [ $MAKEEXIT -eq 0 ]
958 then
959 if [ $BUILD_OMP = 1 ];
960 then
961 $MAKE MFLAGS="$MAKEOPTS" openmp_llvm OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
963 Echo "-------------------------------------------------"
964 Echo "$PROGRAM built successfully."
965 Echo "Next, try out a sample program like" \
966 "$DESTINATION/tests/charm++/simplearrayhello"
967 else
968 printError