Fix warnings and errors in ampi_noimpl.C
[charm.git] / build
blob2a207c107ea5e72b1f69610c584ec0bac26b979a
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 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 ' charm4py compile shared library version of Charm++ for charm4py'
29 echo ' bigemulator build additional BigSim libraries'
30 echo ' msa build Multiphase Shared Arrays(MSA) library'
31 echo ' Tau build the TAU tracing library for generating TAU performance data'
32 echo ' ChaNGa compile Charm++ core and necessary libraries for ChaNGa'
33 echo ' everylb compile EveryLB suite of load balancing strategies'
34 echo ''
36 echo '<versions>: '
37 ( 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 )
38 echo ''
39 echo '<options>: compiler and platform specific options'
40 echo 'icc iccstatic xlc xlc64 gcc clang pgcc cc mpicxx'
41 echo 'help smp omp tcp bigemulator ooc syncft mlogft causalft papi pthreads'
42 echo '--incdir --libdir --basedir --build-shared --destination --suffix -j'
43 if test $more = 1
44 then
45 echo ''
46 echo 'For platform specific options, use help option:'
47 echo ' help platform specific help, e.g. ./build charm++ netlrts-linux-x86_64 help'
48 echo ''
49 echo 'Choose a compiler (only one option is allowed from this section):'
50 echo ' icc, iccstatic Intel compilers (default or static linking)'
51 echo ' xlc, xlc64 IBM XL compilers (with 64-bit option on architectures with 32-bit modes)'
52 echo ' gcc GNU compiler collection (on platforms where the default differs)'
53 echo ' clang Clang C/C++ compiler (including bgclang)'
54 echo ' pgcc Portland Group compilers'
55 echo ''
56 echo 'Choose an alternative fortran compiler (only one option is allowed from this section):'
57 echo ' gfortran GNU Fortran compiler'
58 echo ' flang Flang Fortran compiler'
59 echo ' xlf IBM XL Fortran compiler'
60 echo ' ifort Intel Fortran compiler'
61 echo " pgf90 Portland Group Fortran compiler"
62 echo ''
63 echo 'Platform specific options (choose multiple if apply):'
64 echo ' smp support for SMP, multithreaded charm on each node'
65 echo ' omp support for the integrated LLVM OpenMP runtime'
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 ''
82 echo 'Enable/disable features:'
83 configure_ac="$srcbaseabs/scripts/configure.ac"
84 parameter_regex='\([-A-Za-z0-9_=/ ]*\)'
85 description_regex='\([-A-Za-z0-9_=/ ()\\]*\)'
87 # 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.
88 # 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.
89 help_string_source="$(sed -n "/AS_HELP_STRING(\[${parameter_regex}\],/,/ *\[${description_regex}\])/p" "$configure_ac")"
91 # This regex matches the AS_HELP_STRING entries in configure.ac.
92 # 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).
93 help_item_regex=" *\[AS_HELP_STRING(\[${parameter_regex}\],\n *\[${description_regex}\]) *\]*[, []*[a-z=_]*\]*[, ]*"
94 # "\1" is the parameter and "\2" is the description; use printf to left-justify the parameter.
95 help_output_print='printf " %-30s \2\\\\n" "\1"'
96 # The remaining sed syntax allows us to perform a substitution over two successive lines instead of only one.
97 help_items="$(echo "$help_string_source" | sed -n "1h; 1!H; \${ g; s:${help_item_regex}:${help_output_print}:g p; }")"
98 # With the AS_HELP_STRING entries replaced with printf commands, evaluate the result.
99 eval "$help_items"
100 printf " %-30s %s\n" "--with-production" "build Charm++ with all optimizations for maximum performance, and disabling all above features"
102 # Test that the above regular expressions are sufficient to capture all help strings.
103 num_help_strings="$(grep -c AS_HELP_STRING "$configure_ac")"
104 num_help_items="$(echo "$help_items" | wc -l)"
105 if [ $num_help_strings != $num_help_items ]; then
106 echo '<Warning>: Not all parameters were able to be displayed. Please notify the Charm++ developers at charm@cs.illinois.edu.'
110 echo ''
111 echo 'Miscellaneous options:'
112 echo ' --incdir=DIR specify additional include path for compiler'
113 echo ' --libdir=DIR specify additional lib path for compiler'
114 echo ' --basedir=DIR shortcut for the above two - DIR/include and DIR/lib'
115 echo ' -j[N] parallel make, N is the number of parallel make jobs'
116 echo " --with-lbtime-type specify real type for the load balancing timers"
117 echo " --destination=DIR build Charm++ inside DIR, by default the destination is <version>"
118 echo " --suffix=DIR append DIR to the destination directory of the Charm++ build"
119 echo " --tau-makefile=FILE Specify which TAU stub makefile to use"
121 echo ''
122 echo '<charmc-options>: normal compiler options e.g. -g -optimize -save -verbose'
123 if test $more = 1
124 then
125 echo ''
126 echo 'Examples:'
127 echo "1. display all supported options for netlrts-linux-x86_64 using 'help':"
128 echo ' ./build charm++ netlrts-linux-x86_64 help'
129 echo '2. compile Charm++ on Linux with all available tuning:'
130 echo ' ./build charm++ netlrts-linux-x86_64 --with-production'
131 echo '3. compile Charm++ for Linux with Intel compiler and optimizations:'
132 echo ' ./build charm++ netlrts-linux-x86_64 icc -optimize'
133 echo '4. compile Charm++ for Windows with VC++:'
134 echo ' ./build charm++ netlrts-win-x86_64 -optimize'
135 echo '5. compile Charm++ with MPI that is installed at /usr/local/mpich:'
136 echo ' ./build charm++ mpi-linux-x86_64 --incdir /usr/local/mpich/include --libdir /usr/local/mpich/lib -optimize'
137 echo ' or in short,'
138 echo ' ./build charm++ mpi-linux-x86_64 --basedir /usr/local/mpich -optimize'
139 echo ' ./build Tau --tau-makefile=/usr/local/packages/TAU/x86_64/lib/Makefile.tau-mpi'
140 echo ''
141 echo 'Note: This script:'
142 echo ' 1. Creates directories <destination> and <destination>/tmp'
143 echo ' 2. Copies src/scripts/Makefile into <destination>/tmp'
144 echo ' 3. Does a "make basics" in <destination>/tmp.'
145 echo ' 3. Does a "make -jN <target> <version> OPTS=<charmc-options>" in <destination>/tmp.'
146 echo "That's all build does. The rest is handled by the Makefile."
147 echo ''
148 echo 'Thank you for using Charm++, please send questions or comments to '
149 echo 'Parallel Programming Lab at University of Illinois at Urbana-Champaign'
150 echo '(email: charm@cs.illinois.edu).'
152 else
153 echo ''
154 echo "To get more detailed help, run ./build --help"
158 Echo() {
159 [ "x$QUIET" = "x--quiet" ] || echo $*
162 printOption() {
163 for prefix in cc conv-mach
165 str="Supported compilers:"
166 [ "$prefix" = "conv-mach" ] && str="Supported options:"
167 opts=""
168 for dir in $OPT_DIRS
170 # echo "Checking for $prefix in $dir"
171 files=`cd $dir; ls $prefix-*.h 2>/dev/null`
172 opts="$opts "`echo $files | sed 's/'$prefix'-\([^.]*\).h/\1/g'`
173 done
174 tmp=.tmp.$$
175 rm -f $tmp; touch $tmp
176 for o in $opts
178 echo $o >> $tmp
179 done
180 opts=`sort $tmp | uniq`
181 rm -f $tmp
182 echo $str $opts
183 done
184 exit 1
187 CheckDir() {
188 for d in $*
190 if test ! -d $d
191 then
192 echo Error: cannot find $d!
193 exit 1
195 done
198 TestIfCompiler() {
199 compilerName=`echo $1 | sed 's/-[0-9\.][0-9\.]*$//'`
200 for dir in $OPT_DIRS
202 [ -f $dir/cc-$compilerName.sh ] && return 1
203 done
204 return 0
207 TestIfOption() {
208 for dir in $OPT_DIRS
210 [ -f $dir/conv-mach-$1.h ] && return 1
211 done
213 echo "Error> option: $1 is not supported in this version!";
214 printOption
218 # start
220 BUILD_CUDA=0
221 MAKEOPTS=""
222 OPTS=""
223 BOPTS=""
224 MORE=""
225 COMPILER=""
226 BASEDIR=
227 LIBDIR=
228 INCDIR=
229 ARCH=
230 BUILD_SHARED="" # default no shared lib
231 WITH_ROMIO="true" # default to building ROMIO on AMPI
232 WITH_PRODUCTION=
233 BUILD_EMULATOR=0
234 DESTINATION=""
235 DESTINATION_SUFFIX=""
236 TAU_MAKEFILE=""
237 QUIET=""
238 BUILD_OMP=0
239 ONLY_CONFIGURE=
241 [ "$1" = '--help' -o "$1" = '-h' ] && more=1 && syntax | ( less || more ) && exit 1
242 [ $# -lt 2 ] && $(dirname "$0")/smart-build.pl && exit 1
243 PROGRAM=$1
244 shift
246 # find longest prefix of version argument that exists as a directory in $src
247 VERSION="$1"
248 VERSOPTS=""
249 testversion=""
250 oldifs="$IFS"
251 IFS="-"
252 for w in $1; do
253 IFS="$oldifs"
254 if [ -z "$testversion" ]; then
255 testversion="$w"
256 else
257 testversion="$testversion-$w"
259 if [ -d $src/$testversion ]; then
260 VERSION="$testversion"
261 VERSOPTS=""
262 else
263 VERSOPTS="$VERSOPTS $w"
265 done
266 if [ "$VERSION" = "$1" ]; then VERSOPTS=""; fi
268 BASEVERSION="$VERSION"
269 if test -f $src/$BASEVERSION/vdir_link
270 then
271 BASEVERSION=`cat $src/$BASEVERSION/vdir_link`
273 ARCH=`echo $BASEVERSION | sed -e 's@-.*@@'`
274 shift
276 #echo $src
277 #echo $BASEVERSION
278 #echo $ARCH
280 OPT_DIRS="$src/$BASEVERSION $src/$ARCH $src/common"
282 # process remainder of version argument as options, copied from below
283 for w in $VERSOPTS; do
284 # This has to be a build-time option (like "smp")
285 TestIfCompiler $w
286 if [ $? -eq 1 ]
287 then
288 # It specifies a compiler:
289 if [ ! -z "$COMPILER" ]
290 then
291 echo "Error> Tried to specify two compilers: $COMPILER and $w"
292 printOption
294 COMPILER=$w
295 else
296 # It specifies some other option:
297 TestIfOption $w
298 BOPTS="$BOPTS $w"
299 [ $w = "bigemulator" ] && BUILD_EMULATOR=1
300 [ $w = "bigsim" ] && BUILD_EMULATOR=1
301 [ $w = "cuda" ] && BUILD_CUDA=1
303 done
305 while [ ! $# -eq 0 ]
307 case "$1" in
308 "--basedir")
309 shift;
310 for dir in $1
312 CheckDir $dir/include $dir/lib
313 LIBDIR="$LIBDIR -L$dir/lib";
314 INCDIR="$INCDIR -I$dir/include"
315 done
316 shift
318 --basedir=*)
319 basedir=`echo $1 | awk -F= '{print $2}'`
320 for dir in $basedir
322 CheckDir $dir/include $dir/lib
323 LIBDIR="$LIBDIR -L$dir/lib";
324 INCDIR="$INCDIR -I$dir/include"
325 done
326 shift
328 "--libdir")
329 shift; CheckDir $1
330 for dir in $1
332 LIBDIR="$LIBDIR -L$dir";
333 done
334 shift
336 --libdir=*)
337 libdir=`echo $1 | awk -F= '{print $2}'`
338 CheckDir $libdir
339 for dir in $libdir
341 LIBDIR="$LIBDIR -L$dir";
342 done
343 shift
345 "--incdir")
346 shift; CheckDir $1
347 for dir in $1
349 INCDIR="$INCDIR -I$dir";
350 done
351 shift
353 --incdir=*)
354 incdir=`echo $1 | awk -F= '{print $2}'`
355 CheckDir $incdir
356 for dir in $incdir
358 INCDIR="$INCDIR -I$dir";
359 done
360 shift
362 --no-build-shared|--no-shared)
363 BUILD_SHARED='';
364 shift
366 --build-shared)
367 BUILD_SHARED="-build-shared";
368 shift
370 --with-romio)
371 WITH_ROMIO="true"; shift
373 --without-romio)
374 WITH_ROMIO=""; shift
376 --with-production)
377 WITH_PRODUCTION="true"
378 shift
380 --with-*)
381 CONFIG_OPTS="$CONFIG_OPTS $1"
382 shift
384 --without-*)
385 CONFIG_OPTS="$CONFIG_OPTS $1"
386 shift
388 --destination)
389 shift
390 DESTINATION="$1"
391 shift
393 --destination=*)
394 DESTINATION="`echo $1 | awk -F= '{print $2}'`"
395 shift
397 --suffix)
398 shift
399 DESTINATION_SUFFIX="$1"
400 shift
402 --suffix=*)
403 DESTINATION_SUFFIX="`echo $1 | awk -F= '{print $2}'`"
404 shift
406 --tau-makefile)
407 TAU_MAKEFILE=$1
408 shift
410 --tau-makefile=*)
411 TAU_MAKEFILE=`echo $1 | awk -F= '{print $2}'`
412 shift
414 --quiet)
415 MAKEOPTS="$MAKEOPTS --quiet"
416 QUIET="--quiet"
417 shift;
419 --only-configure)
420 ONLY_CONFIGURE="true"
421 shift
423 --enable-tracing|--enable-tracing=*)
424 CONFIG_OPTS="$CONFIG_OPTS $1"
425 ENABLE_TRACING=yes
426 shift
428 --enable-*)
429 CONFIG_OPTS="$CONFIG_OPTS $1"
430 shift
432 --disable-*)
433 CONFIG_OPTS="$CONFIG_OPTS $1"
434 shift
436 -j*)
437 PMAKENUM=`echo $1 | awk -Fj '{print $2}'`
438 MAKEOPTS="$MAKEOPTS -j $PMAKENUM"
439 shift;
441 -k|--keep-going)
442 MAKEOPTS="$MAKEOPTS $1"
443 shift;
445 -*)
446 # Compiler option (like -g or -Dfoo), copy it over
447 OPTS="$OPTS $1"
448 shift
450 "help")
451 printOption
454 # This has to be a build-time option (like "smp")
455 TestIfCompiler $1
456 if [ $? -eq 1 ]
457 then
458 # It specifies a compiler:
459 if [ ! -z "$COMPILER" ]
460 then
461 echo "Error> Tried to specify two compilers: $COMPILER and $1"
462 printOption
464 COMPILER=$1
465 else
466 # It specifies some other option:
467 TestIfOption $1
468 BOPTS="$BOPTS $1"
469 [ $1 = "bigemulator" ] && BUILD_EMULATOR=1
470 [ $1 = "bigsim" ] && BUILD_EMULATOR=1
471 [ $1 = "cuda" ] && BUILD_CUDA=1
473 shift
475 esac
476 done
478 if [ $BUILD_CUDA -eq 1 ]; then
479 HAVE_CUDA="no"
480 echo "checking for CUDA toolkit directory"
481 CUDA_PRESET_DIRS="/usr/local/cuda /usr/lib/nvidia-cuda-toolkit"
482 CUDA_CANDIDATE_DIRS="$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
483 for dir in $CUDA_CANDIDATE_DIRS; do
484 if test -d "$dir"; then
485 CUDA_DIR="$dir"
486 HAVE_CUDA="yes"
487 echo "CUDA_DIR=$CUDA_DIR"
488 break
490 done
491 if [ "$HAVE_CUDA" = "no" ]; then
492 echo "Error> no CUDA toolkit found, searched \$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
493 exit 1
497 [ "x$VERSION" = "x" ] && syntax && exit 1
499 if [ "x_$ARCH" = "x_net" ]; then
500 echo "Error: net-* has been removed, please use netlrts or verbs.";
501 exit 1;
504 #Check if building verbs on Omni-Path
505 if [ "x_$ARCH" = "x_verbs" ] && type /usr/sbin/opafabricinfo >/dev/null 2>&1; then
506 echo "WARNING: Detected Omni-Path diagnostic tools.";
507 echo "Verbs on Omni-Path architectures is not well supported: please use an OFI build instead.";
510 if test -n "$WITH_PRODUCTION" -a $BUILD_EMULATOR -eq 1 -a -z "$ENABLE_TRACING"
511 then
512 echo "Error: bigemulator requires tracing modules, --with-production must be used with --enable-tracing"
513 exit 1
516 if [ -z "$MAKE" ]
517 then
518 # prefer gmake
519 MAKE=`which gmake 2>/dev/null`
520 [ -z "$MAKE" -o ! -x "$MAKE" ] && MAKE='make'
523 if [ ! -f $src/$BASEVERSION/conv-mach.h ]
524 then
525 echo "Error> build can not find arch: $BASEVERSION!"
526 exit 1
529 if [ ! -f "$srcbaseabs/scripts/configure" ]
530 then
531 if ! command -v autoreconf >/dev/null 2>&1 || ! command -v aclocal >/dev/null 2>&1
532 then
533 echo "Error> autoconf and automake are not installed."
534 exit 1
538 #generate header for uFcontext for the target VERSION
539 UFCONTEXT_HEADER_NAME=
540 if test `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
541 then
542 UFCONTEXT_HEADER_NAME="macho_gas"
543 elif test `echo "$BASEVERSION" | grep -c "win"` -gt 0
544 then
545 UFCONTEXT_HEADER_NAME="windows"
546 else
547 UFCONTEXT_HEADER_NAME="elf_gas"
550 if test `echo "$BASEVERSION" | grep -c "arm7"` -gt 0
551 then
552 UFCONTEXT_HEADER_NAME="arm_aapcs_${UFCONTEXT_HEADER_NAME}"
553 elif test `echo "$BASEVERSION" | grep -c "arm8"` -gt 0
554 then
555 UFCONTEXT_HEADER_NAME="arm64_aapcs_${UFCONTEXT_HEADER_NAME}"
556 elif test `echo "$BASEVERSION" | grep -c "mips"` -gt 0
557 then
558 UFCONTEXT_HEADER_NAME="mips32_o32_${UFCONTEXT_HEADER_NAME}"
559 elif test `echo "$BASEVERSION" | grep -c "bluegene\|pami\|ppc"` -gt 0
560 then
561 UFCONTEXT_HEADER_NAME="ppc64_sysv_${UFCONTEXT_HEADER_NAME}"
562 elif test `echo "$BASEVERSION" | grep -c "cray\|x86_64\|linux64\|amd64"` -gt 0
563 then
564 UFCONTEXT_HEADER_NAME="x86_64_sysv_${UFCONTEXT_HEADER_NAME}"
565 else
566 UFCONTEXT_HEADER_NAME="i386_sysv_${UFCONTEXT_HEADER_NAME}"
569 #generate VERSION name combining all the build-time options.
570 if [ -n "$BOPTS" -o -n "$COMPILER" ]
571 then
572 echo "Selected Compiler: $COMPILER"
574 if test -n "$COMPILER" -a `echo "$BASEVERSION" | grep -c "cray\|gni\|gemini"` -gt 0
575 then
576 echo "Inserted explicit compiler options on Cray systems. Use compiler wrappers by loading PrgEnv-*"
577 echo "e.g.) module load PrgEnv-* (e.g. cray for cce, gnu for gcc, intel for icc, and pgi for pgcc)"
578 echo " ./build charm++ $BASEVERSION <other build options>"
579 echo "Charm++ uses the compiler wrapper 'CC' specified by the Cray system. Don't use explicit compiler options on Cray systems."
580 exit 1
583 if test `echo "$BOPTS" | grep -c "omp"` -gt 0 -a `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
584 then
585 if test -z "$COMPILER" -o "$COMPILER" != "gcc"
586 then
587 echo "The integrated OpenMP runtime library is supported on Mac only with the normal gcc"
588 echo "You need to install this normal (non-clang) gcc via MacPorts or Homebrew"
589 echo "Read the instructions on the Charm++ manual."
590 exit 1
593 echo "Selected Options: $BOPTS"
594 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
595 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
596 for i in $BOPTS_WITHCOMPILER
598 VERSION=$VERSION-$i
599 done
602 #echo "|$DESTINATION|$DESTINATION_SUFFIX|"
604 if [ -z "$DESTINATION" ]
605 then
606 DESTINATION="$VERSION"
609 if [ $(dirname $DESTINATION) != "." ]
610 then
611 srcbaseabs="$(cd $srcbaseabs; pwd)"
612 srcbase=$srcbaseabs
613 src="$srcbaseabs/arch/"
616 if [ -n "$DESTINATION_SUFFIX" ]
617 then
618 DESTINATION="$DESTINATION-$DESTINATION_SUFFIX"
621 # make sure $DESTINATION is more than '/' characters, because we `rm -rf` it
622 if [ -z "${DESTINATION#"${DESTINATION%%[!/]*}"}" ]
623 then
624 echo 'Error: $DESTINATION is the filesystem root.'
625 exit 1
628 if test -n "$BOPTS"
629 then
630 # pxshm+smp note: When combining the 'smp' and 'pxshm' directives, it is
631 # important that they be included in $ConvHeader in that
632 # exact order. See bug #717.
633 MYTMP=""
634 HAS_PXSHM=0
635 HAS_SMP=0
636 for i in $BOPTS; do
637 if [ "$i" = "smp" ]; then
638 HAS_SMP=1
639 elif [ "$i" = "pxshm" ]; then
640 HAS_PXSHM=1
641 elif [ "$i" = "omp" ]; then
642 BUILD_OMP=1
643 MYTMP="$MYTMP $i"
644 else
645 MYTMP="$MYTMP $i"
647 done
648 if [ $HAS_PXSHM -eq 1 ]; then
649 MYTMP="pxshm $MYTMP"
651 if [ $HAS_SMP -eq 1 ]; then
652 MYTMP="smp $MYTMP"
653 if [ $BUILD_OMP -eq 1 ]; then
654 CONFIG_OPTS="--enable-task-queue $CONFIG_OPTS"
656 elif [ $BUILD_OMP -eq 1 ]; then
657 BUILD_OMP=2 #this means omp keyword inserted without smp keyword"
661 # build for Charm4py
662 if [ "$PROGRAM" = "charmpy" ] || [ "$PROGRAM" = "charm4py" ]; then
664 if [ -n "$BOPTS" ] && [ "$HAS_SMP" -eq 1 ]; then
665 echo "Error: SMP mode is currently not supported with charm4py. Choose a non-smp version."
666 exit 1
669 if [ `echo "$BASEVERSION" | grep -c "multicore"` -gt 0 ]; then
670 echo "Error: multicore is currently not supported with charm4py. Choose a non-smp version."
671 exit 1
674 if test `echo "$CONFIG_OPTS" | grep -c "\--enable-charmpy"` -eq 0
675 then
676 CONFIG_OPTS="$CONFIG_OPTS --enable-charmpy"
679 if test `echo "$BASEVERSION" | grep -c "win"` -gt 0
680 then
681 BUILD_SHARED=""
682 else
683 BUILD_SHARED="-build-shared"
687 if test -n "$WITH_PRODUCTION"
688 then
689 # Prepend optimize so that an explicit -no-optimize still works
690 OPTS="-optimize -production $OPTS"
691 CONFIG_OPTS="--disable-controlpoint --disable-tracing --disable-tracing-commthread --disable-charmdebug --disable-replay --disable-error-checking --disable-stats $CONFIG_OPTS"
694 # build with Tau
695 WITH_TAU=0
696 if [ "$PROGRAM" = "Tau" ]
697 then
698 Echo "TAU>>>> makefile config option: $TAU_MAKEFILE"
699 if [ -n "$TAU_MAKEFILE" -a -f $TAU_MAKEFILE ]
700 then
701 #Setting up TAU trace library:
702 Echo "TAU>>>> configuring with this TAU makefile: $TAU_MAKEFILE"
704 WITH_TAU=1
705 else
706 Echo "TAU>>>> ERROR could not find Makefile: $TAU_MAKEFILE, ignored"
707 TAU_MAKEFILE=""
711 if [ "$PROGRAM" = "ChaNGa" ]
712 then
713 #Setting lbuserdata when the build is ChaNGa
714 CONFIG_OPTS="--enable-lbuserdata $CONFIG_OPTS"
717 if test $BUILD_EMULATOR = 1
718 then
719 # export BIGSIM so that make targets can depend on it
720 MAKEOPTS="$MAKEOPTS BIGSIM=bigsim"
721 PROGRAM="$PROGRAM bigsim"
724 if [ $BUILD_OMP = 2 ]
725 then
726 case $DESTINATION in
727 "multicore"*)
728 BUILD_OMP=1
731 echo "OpenMP support should be built in SMP mode"
732 exit 1
734 esac
737 # ===================================================
738 # ---------- begin file structure creation ----------
739 # ===================================================
741 if [ -f "$DESTINATION/tmp/basics" ]
742 then
743 Echo "File structure already created; skipping directly to make"
744 else
746 for d in bin doc examples include lib lib_so tests tmp; do
747 rm -rf "$DESTINATION/$d"
748 done
750 Echo "Creating dir: $DESTINATION"
751 Echo "Creating dir: $DESTINATION/tmp"
752 mkdir -p "$DESTINATION/tmp"
754 echo "TARGET=${UFCONTEXT_HEADER_NAME}" > $DESTINATION/tmp/uFcontext.mk
756 # Create the bin, lib, include, etc. links:
757 WINNAME=`echo $VERSION | awk -F- '{print $2}'`
758 if [ "x_$WINNAME" = "x_win64" -o "x_$WINNAME" = "x_win" ]
759 then
760 #Win64 version needs special compilers and *copied* (not linked)
761 # source files.
762 cp $src/win/system_ln $DESTINATION/tmp
763 cp $src/win/unistd.h $DESTINATION/tmp
764 echo "Compiling createlink.cpp ..."
765 case "$COMPILER" in
766 gcc*|clang*)
767 createlinkcc="$COMPILER"
770 createlinkcc="./unix2nt_cc"
772 esac
773 (cd $src/win; $createlinkcc -c createlink.cpp -o createlink.o -D_WIN32_WINNT=0x0500; $createlinkcc createlink.o -o createlink.exe)
775 if test ! -x $src/win/createlink.exe
776 then
777 echo "VC++ is not properly installed!"
778 exit 1
780 chmod +x $DESTINATION/tmp/system_ln
781 cp $src/win/gathertree.local $DESTINATION/tmp
782 cp $src/win/gatherflat.local $DESTINATION/tmp
783 else
784 cat > $DESTINATION/tmp/system_ln <<EOF
785 #!/bin/sh
786 ln -f -s \$@
788 chmod +x $DESTINATION/tmp/system_ln
789 newdirlist='bin lib'
790 [ -n "$BUILD_SHARED" ] && newdirlist="$newdirlist lib_so"
791 newdirlist="$newdirlist include tmp"
792 for newdir in $newdirlist
794 Echo "Soft-linking over $newdir"
795 if [ -r $newdir ]
796 then
797 rm -fr $newdir || exit 1
799 $DESTINATION/tmp/system_ln $DESTINATION/$newdir $newdir
800 done
801 rm -f VERSION
802 $DESTINATION/tmp/system_ln $DESTINATION/include/VERSION VERSION
805 Echo "Copying src/scripts/Makefile to $DESTINATION/tmp"
806 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.depends" $DESTINATION/tmp/Make.depends
807 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.cidepends" $DESTINATION/tmp/Make.cidepends
808 if test -f "$srcbaseabs/ck-ldb/Make.lb"
809 then
810 $DESTINATION/tmp/system_ln "$srcbase/ck-ldb/Make.lb" $DESTINATION/tmp/Make.lb
811 else
812 touch $DESTINATION/tmp/Make.lb
814 $DESTINATION/tmp/system_ln "$srcbase/scripts/Makefile" $DESTINATION/tmp/Makefile
815 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.tau" $DESTINATION/tmp/Make.tau
816 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.gpu" $DESTINATION/tmp/Make.gpu
817 touch $DESTINATION/tmp/Makefile.machine
818 touch $DESTINATION/tmp/Make.extlib
820 ConvUsr="$DESTINATION/tmp/conv-mach-pre.sh"
821 Echo "Generating $ConvUsr"
822 echo > $ConvUsr
823 if test -n "$LIBDIR"
824 then
825 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
827 if test -n "$INCDIR"
828 then
829 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
830 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
832 chmod +x $ConvUsr
834 # Create conv-mach-opt headers with special build-time options
835 ConvHeader="$DESTINATION/tmp/conv-mach-opt.h"
836 ConvSh="$DESTINATION/tmp/conv-mach-opt.sh"
837 ConvMak="$DESTINATION/tmp/conv-mach-opt.mak"
838 if [ ! -f "$ConvSh" -o ! -f "$ConvHeader" -o ! -f "$ConvMak" ]
839 then
840 Echo "Generating $ConvHeader, conv-mach-opt.sh, conv-mach-opt.mak"
841 echo '/* Build-time options header, automatically generated by charm/build */' > $ConvHeader
842 echo '# Build-time options header, automatically generated by charm/build' > $ConvSh
843 echo '# Build-time options header, automatically generated by charm/build' > $ConvMak
844 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
846 if test -n "$COMPILER"
847 then
848 i=`echo $COMPILER | sed 's/-[0-9\.][0-9\.]*$//'`
849 echo "CMK_COMPILER_SUFFIX=${COMPILER#$i}" >> $ConvSh
850 echo '#include "'cc-$i.h'"' >> $ConvHeader
851 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
852 elif test `echo "$BASEVERSION" | grep -c "bluegeneq"` -gt 0
853 then
854 i="clang"
855 bgclang++11 --version
856 if [ $? -ne 0 ]; then
857 echo "ERROR: bgclang C/C++ compiler missing. Please load bgclang compilers, i.e. 'soft add +mpiwrapper-bgclang'."
858 exit 1
860 echo '#include "'cc-$i.h'"' >> $ConvHeader
861 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
863 if test -n "$MYTMP"
864 then
865 BOPTS=$MYTMP
866 for i in $BOPTS
868 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
869 if [ $BUILD_CUDA -eq 1 ]; then
870 echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
871 echo "CUDA_DIR:=$CUDA_DIR" >> $ConvMak
873 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
874 done
877 if test "$BUILD_SHARED" = "-build-shared"
878 then
879 echo "CMK_NO_BUILD_SHARED=false" >> $ConvSh
880 echo "CMK_NO_BUILD_SHARED:=false" >> $ConvMak
881 else
882 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
883 echo "CMK_NO_BUILD_SHARED:=true" >> $ConvMak
886 if test -n "$WITH_ROMIO"
887 then
888 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
889 echo "CMK_AMPI_WITH_ROMIO:=true" >> $ConvMak
892 if test -n "$WITH_PRODUCTION"
893 then
894 echo '#define CMK_OPTIMIZE 1' >> $ConvHeader
897 if test $WITH_TAU -eq 1
898 then
899 [ -z "$TAU_MAKEFILE" ] && TAU_MAKEFILE="Make.tau"
900 SED_CHARMC="s@TAU_MAKEFILE=\(.*\)@TAU_MAKEFILE=$TAU_MAKEFILE@"
902 sed -e $SED_CHARMC $srcbaseabs/scripts/Makefile > .Makefile.$$ && cp .Makefile.$$ $srcbaseabs/scripts/Makefile && rm -f .Makefile.$$
903 sed -e $SED_CHARMC $srcbaseabs/scripts/charmc > .charmc.$$ && cp .charmc.$$ $srcbaseabs/scripts/charmc && rm -f .charmc.$$
905 echo "#define CMK_WITH_TAU 1" >> $ConvHeader
906 echo "#define pthread_create tau_pthread_create" >> $ConvHeader
907 echo "#define pthread_exit tau_pthread_exit" >> $ConvHeader
909 echo "CMK_WITH_TAU=\"true\"" >> $ConvSh
912 CMK_VDIR="$BASEVERSION"
913 echo "$CMK_VDIR" > $DESTINATION/tmp/.vdir
914 echo 'CMK_VDIR="'$CMK_VDIR'"' >> $ConvSh
915 echo "CMK_VDIR:=$CMK_VDIR" >> $ConvMak
916 CMK_GDIR="`echo $BASEVERSION | sed -e 's@-.*@@'`"
917 echo "$CMK_GDIR" > $DESTINATION/tmp/.gdir
918 echo 'CMK_GDIR="'$CMK_GDIR'"' >> $ConvSh
919 echo "CMK_GDIR:=$CMK_GDIR" >> $ConvMak
921 echo 'BUILDOPTS="'$OPTS'"' >> $ConvSh
922 echo "SRCBASE=$srcbase" > $DESTINATION/tmp/charmpath.mk
924 echo "CONFIG_OPTS=\"$CONFIG_OPTS\"" > "$DESTINATION/tmp/config_opts.sh"
925 chmod +x "$DESTINATION/tmp/config_opts.sh"
926 echo "OPTSATBUILDTIME:=$OPTS" >> $ConvMak
930 # ===================================================
931 # ----------- end file structure creation -----------
932 # ===================================================
934 printError()
936 Echo "-------------------------------------------------"
937 Echo "Charm++ NOT BUILT. Either cd into $DESTINATION/tmp and try"
938 Echo "to resolve the problems yourself, visit"
939 Echo " http://charm.cs.illinois.edu/"
940 Echo "for more information. Otherwise, email the developers at charm@cs.illinois.edu"
941 exit $MAKEEXIT
944 Echo "Performing '$MAKE $MAKEOPTS basics OPTS="$OPTS" QUIET="$QUIET" CONFIG_OPTS="$CONFIG_OPTS"' in $DESTINATION/tmp"
945 cd $DESTINATION/tmp
946 $MAKE $MAKEOPTS basics OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
947 MAKEEXIT=$?
948 [ $MAKEEXIT -ne 0 ] && printError
950 if test -n "$ONLY_CONFIGURE"
951 then
952 exit 0
955 Echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS" QUIET="$QUIET"' in $DESTINATION/tmp"
956 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
957 MAKEEXIT=$?
958 if [ $MAKEEXIT -eq 0 ]
959 then
960 if [ $BUILD_OMP = 1 ];
961 then
962 $MAKE MFLAGS="$MAKEOPTS" openmp_llvm OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
964 Echo "-------------------------------------------------"
965 Echo "$PROGRAM built successfully."
966 Echo "Next, try out a sample program like" \
967 "$DESTINATION/tests/charm++/simplearrayhello"
968 else
969 printError