Fix pthread_exit on pami/pamilrts
[charm.git] / build
blob595632b667dd758127b99b167e0678c213a3bb90
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 charmpy 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 ' charmpy compile shared library version of Charm++ for Charmpy'
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 ' ibverbs use Infiniband Verbs for communication (only for netlrts-linux-x86_64; prefer verbs-*)'
67 echo ' tcp use TCP sockets for communication (only for netlrts)'
68 echo ' pthreads compile with pthreads Converse threads'
69 echo ''
70 echo 'Advanced options:'
71 echo ' bigemulator compile for BigSim simulator'
72 echo ' ooc compile with out of core support'
73 echo ' syncft compile with Charm++ fault tolerance support'
74 echo ' mlogft compile with Charm++ message logging fault tolerance support'
75 echo ' papi compile with PAPI performance counter support (if any)'
76 echo ''
77 echo "Charm++ dynamic libraries:"
78 echo " --no-build-shared don't build Charm++'s shared libraries (default)"
79 echo " --build-shared build Charm++ dynamic libraries (.so) "
80 echo ''
83 echo 'Enable/disable features:'
84 configure_ac="$srcbaseabs/scripts/configure.ac"
85 parameter_regex='\([-A-Za-z0-9_=/ ]*\)'
86 description_regex='\([-A-Za-z0-9_=/ ()\\]*\)'
88 # 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.
89 # 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.
90 help_string_source="$(sed -n "/AS_HELP_STRING(\[${parameter_regex}\],/,/ *\[${description_regex}\])/p" "$configure_ac")"
92 # This regex matches the AS_HELP_STRING entries in configure.ac.
93 # 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).
94 help_item_regex=" *\[AS_HELP_STRING(\[${parameter_regex}\],\n *\[${description_regex}\]) *\]*[, []*[a-z=_]*\]*[, ]*"
95 # "\1" is the parameter and "\2" is the description; use printf to left-justify the parameter.
96 help_output_print='printf " %-30s \2\\\\n" "\1"'
97 # The remaining sed syntax allows us to perform a substitution over two successive lines instead of only one.
98 help_items="$(echo "$help_string_source" | sed -n "1h; 1!H; \${ g; s:${help_item_regex}:${help_output_print}:g p; }")"
99 # With the AS_HELP_STRING entries replaced with printf commands, evaluate the result.
100 eval "$help_items"
101 printf " %-30s %s\n" "--with-production" "build Charm++ with all optimizations for maximum performance, and disabling all above features"
103 # Test that the above regular expressions are sufficient to capture all help strings.
104 num_help_strings="$(grep -c AS_HELP_STRING "$configure_ac")"
105 num_help_items="$(echo "$help_items" | wc -l)"
106 if [ $num_help_strings != $num_help_items ]; then
107 echo '<Warning>: Not all parameters were able to be displayed. Please notify the Charm++ developers at charm@cs.illinois.edu.'
111 echo ''
112 echo 'Miscellaneous options:'
113 echo ' --incdir=DIR specify additional include path for compiler'
114 echo ' --libdir=DIR specify additional lib path for compiler'
115 echo ' --basedir=DIR shortcut for the above two - DIR/include and DIR/lib'
116 echo ' -j[N] parallel make, N is the number of paralle make jobs'
117 echo " --with-lbtime-type specify real type for the load balancing timers"
118 echo " --destination=DIR build Charm++ inside DIR, by default the destination is <version>"
119 echo " --suffix=DIR append DIR to the destination directory of the Charm++ build"
120 echo " --tau-makefile=FILE Specify which TAU stub makefile to use"
122 echo ''
123 echo '<charmc-options>: normal compiler options e.g. -g -optimize -save -verbose'
124 if test $more = 1
125 then
126 echo ''
127 echo 'Examples:'
128 echo "1. display all supported options for netlrts-linux-x86_64 using 'help':"
129 echo ' ./build charm++ netlrts-linux-x86_64 help'
130 echo '2. compile Charm++ on Linux with all available tuning:'
131 echo ' ./build charm++ netlrts-linux-x86_64 --with-production'
132 echo '3. compile Charm++ for Linux with Intel compiler and optimizations:'
133 echo ' ./build charm++ netlrts-linux-x86_64 icc -optimize'
134 echo '4. compile Charm++ for Windows with VC++:'
135 echo ' ./build charm++ netlrts-win-x86_64 -optimize'
136 echo '5. compile Charm++ with MPI that is installed at /usr/local/mpich:'
137 echo ' ./build charm++ mpi-linux-x86_64 --incdir /usr/local/mpich/include --libdir /usr/local/mpich/lib -optimize'
138 echo ' or in short,'
139 echo ' ./build charm++ mpi-linux-x86_64 --basedir /usr/local/mpich -optimize'
140 echo ' ./build Tau --tau-makefile=/usr/local/packages/TAU/x86_64/lib/Makefile.tau-mpi'
141 echo ''
142 echo 'Note: This script:'
143 echo ' 1. Creates directories <destination> and <destination>/tmp'
144 echo ' 2. Copies src/scripts/Makefile into <destination>/tmp'
145 echo ' 3. Does a "make basics" in <destination>/tmp.'
146 echo ' 3. Does a "make -jN <target> <version> OPTS=<charmc-options>" in <destination>/tmp.'
147 echo "That's all build does. The rest is handled by the Makefile."
148 echo ''
149 echo 'Thank you for using Charm++, please send questions or comments to '
150 echo 'Parallel Programming Lab at University of Illinois at Urbana-Champaign'
151 echo '(email: charm@cs.illinois.edu).'
153 else
154 echo ''
155 echo "To get more detailed help, run ./build --help"
159 Echo() {
160 [ "x$QUIET" = "x--quiet" ] || echo $*
163 printOption() {
164 for prefix in cc conv-mach
166 str="Supported compilers:"
167 [ "$prefix" = "conv-mach" ] && str="Supported options:"
168 opts=""
169 for dir in $OPT_DIRS
171 # echo "Checking for $prefix in $dir"
172 files=`cd $dir; ls $prefix-*.h 2>/dev/null`
173 opts="$opts "`echo $files | sed 's/'$prefix'-\([^.]*\).h/\1/g'`
174 done
175 tmp=.tmp.$$
176 rm -f $tmp; touch $tmp
177 for o in $opts
179 echo $o >> $tmp
180 done
181 opts=`sort $tmp | uniq`
182 rm -f $tmp
183 echo $str $opts
184 done
185 exit 1
188 CheckDir() {
189 for d in $*
191 if test ! -d $d
192 then
193 echo Error: cannot find $d!
194 exit 1
196 done
199 TestIfCompiler() {
200 compilerName=`echo $1 | sed 's/-[0-9\.][0-9\.]*$//'`
201 for dir in $OPT_DIRS
203 [ -f $dir/cc-$compilerName.sh ] && return 1
204 done
205 return 0
208 TestIfOption() {
209 for dir in $OPT_DIRS
211 [ -f $dir/conv-mach-$1.h ] && return 1
212 done
214 echo "Error> option: $1 is not supported in this version!";
215 printOption
219 # start
221 BUILD_CUDA=0
222 MAKEOPTS=""
223 OPTS=""
224 BOPTS=""
225 MORE=""
226 COMPILER=""
227 BASEDIR=
228 LIBDIR=
229 INCDIR=
230 ARCH=
231 BUILD_SHARED="" # default no shared lib
232 WITH_ROMIO="true" # default to building ROMIO on AMPI
233 WITH_PRODUCTION=
234 BUILD_EMULATOR=0
235 DESTINATION=""
236 DESTINATION_SUFFIX=""
237 TAU_MAKEFILE=""
238 QUIET=""
239 BUILD_OMP=0
240 ONLY_CONFIGURE=
242 [ "$1" = '--help' -o "$1" = '-h' ] && more=1 && syntax | ( less || more ) && exit 1
243 [ $# -lt 2 ] && $(dirname "$0")/smart-build.pl && exit 1
244 PROGRAM=$1
245 shift
247 # find longest prefix of version argument that exists as a directory in $src
248 VERSION="$1"
249 VERSOPTS=""
250 testversion=""
251 oldifs="$IFS"
252 IFS="-"
253 for w in $1; do
254 IFS="$oldifs"
255 if [ -z "$testversion" ]; then
256 testversion="$w"
257 else
258 testversion="$testversion-$w"
260 if [ -d $src/$testversion ]; then
261 VERSION="$testversion"
262 VERSOPTS=""
263 else
264 VERSOPTS="$VERSOPTS $w"
266 done
267 if [ "$VERSION" = "$1" ]; then VERSOPTS=""; fi
269 BASEVERSION="$VERSION"
270 if test -f $src/$BASEVERSION/vdir_link
271 then
272 BASEVERSION=`cat $src/$BASEVERSION/vdir_link`
274 ARCH=`echo $BASEVERSION | sed -e 's@-.*@@'`
275 shift
277 #echo $src
278 #echo $BASEVERSION
279 #echo $ARCH
281 OPT_DIRS="$src/$BASEVERSION $src/$ARCH $src/common"
283 # process remainder of version argument as options, copied from below
284 for w in $VERSOPTS; do
285 # This has to be a build-time option (like "smp")
286 TestIfCompiler $w
287 if [ $? -eq 1 ]
288 then
289 # It specifies a compiler:
290 if [ ! -z "$COMPILER" ]
291 then
292 echo "Error> Tried to specify two compilers: $COMPILER and $w"
293 printOption
295 COMPILER=$w
296 else
297 # It specifies some other option:
298 TestIfOption $w
299 BOPTS="$BOPTS $w"
300 [ $w = "bigemulator" ] && BUILD_EMULATOR=1
301 [ $w = "bigsim" ] && BUILD_EMULATOR=1
302 [ $w = "cuda" ] && BUILD_CUDA=1
304 done
306 while [ ! $# -eq 0 ]
308 case "$1" in
309 "--basedir")
310 shift;
311 for dir in $1
313 CheckDir $dir/include $dir/lib
314 LIBDIR="$LIBDIR -L$dir/lib";
315 INCDIR="$INCDIR -I$dir/include"
316 done
317 shift
319 --basedir=*)
320 basedir=`echo $1 | awk -F= '{print $2}'`
321 for dir in $basedir
323 CheckDir $dir/include $dir/lib
324 LIBDIR="$LIBDIR -L$dir/lib";
325 INCDIR="$INCDIR -I$dir/include"
326 done
327 shift
329 "--libdir")
330 shift; CheckDir $1
331 for dir in $1
333 LIBDIR="$LIBDIR -L$dir";
334 done
335 shift
337 --libdir=*)
338 libdir=`echo $1 | awk -F= '{print $2}'`
339 CheckDir $libdir
340 for dir in $libdir
342 LIBDIR="$LIBDIR -L$dir";
343 done
344 shift
346 "--incdir")
347 shift; CheckDir $1
348 for dir in $1
350 INCDIR="$INCDIR -I$dir";
351 done
352 shift
354 --incdir=*)
355 incdir=`echo $1 | awk -F= '{print $2}'`
356 CheckDir $incdir
357 for dir in $incdir
359 INCDIR="$INCDIR -I$dir";
360 done
361 shift
363 --no-build-shared|--no-shared)
364 #BUILD_SHARED="-no-build-shared";
365 shift
367 --build-shared)
368 BUILD_SHARED="-build-shared";
369 shift
371 --with-romio)
372 WITH_ROMIO="true"; shift
374 --without-romio)
375 WITH_ROMIO=""; shift
377 --with-production)
378 WITH_PRODUCTION="true"
379 shift
381 --with-*)
382 CONFIG_OPTS="$CONFIG_OPTS $1"
383 shift
385 --without-*)
386 CONFIG_OPTS="$CONFIG_OPTS $1"
387 shift
389 --destination)
390 shift
391 DESTINATION="$1"
392 shift
394 --destination=*)
395 DESTINATION="`echo $1 | awk -F= '{print $2}'`"
396 shift
398 --suffix)
399 shift
400 DESTINATION_SUFFIX="$1"
401 shift
403 --suffix=*)
404 DESTINATION_SUFFIX="`echo $1 | awk -F= '{print $2}'`"
405 shift
407 --tau-makefile)
408 TAU_MAKEFILE=$1
409 shift
411 --tau-makefile=*)
412 TAU_MAKEFILE=`echo $1 | awk -F= '{print $2}'`
413 shift
415 --quiet)
416 MAKEOPTS="$MAKEOPTS --quiet"
417 QUIET="--quiet"
418 shift;
420 --only-configure)
421 ONLY_CONFIGURE="true"
422 shift
424 --enable-tracing|--enable-tracing=*)
425 CONFIG_OPTS="$CONFIG_OPTS $1"
426 ENABLE_TRACING=yes
427 shift
429 --enable-*)
430 CONFIG_OPTS="$CONFIG_OPTS $1"
431 shift
433 --disable-*)
434 CONFIG_OPTS="$CONFIG_OPTS $1"
435 shift
437 -j*)
438 PMAKENUM=`echo $1 | awk -Fj '{print $2}'`
439 MAKEOPTS="$MAKEOPTS -j $PMAKENUM"
440 shift;
442 -k|--keep-going)
443 MAKEOPTS="$MAKEOPTS $1"
444 shift;
446 -*)
447 # Compiler option (like -g or -Dfoo), copy it over
448 OPTS="$OPTS $1"
449 shift
451 "help")
452 printOption
455 # This has to be a build-time option (like "smp")
456 TestIfCompiler $1
457 if [ $? -eq 1 ]
458 then
459 # It specifies a compiler:
460 if [ ! -z "$COMPILER" ]
461 then
462 echo "Error> Tried to specify two compilers: $COMPILER and $1"
463 printOption
465 COMPILER=$1
466 else
467 # It specifies some other option:
468 TestIfOption $1
469 BOPTS="$BOPTS $1"
470 [ $1 = "bigemulator" ] && BUILD_EMULATOR=1
471 [ $1 = "bigsim" ] && BUILD_EMULATOR=1
472 [ $1 = "cuda" ] && BUILD_CUDA=1
474 shift
476 esac
477 done
479 if [ $BUILD_CUDA -eq 1 ]; then
480 HAVE_CUDA="no"
481 echo "checking for CUDA toolkit directory"
482 CUDA_PRESET_DIRS="/usr/local/cuda /usr/lib/nvidia-cuda-toolkit"
483 CUDA_CANDIDATE_DIRS="$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
484 for dir in $CUDA_CANDIDATE_DIRS; do
485 if test -d "$dir"; then
486 CUDA_DIR="$dir"
487 HAVE_CUDA="yes"
488 echo "CUDA_DIR=$CUDA_DIR"
489 break
491 done
492 if [ "$HAVE_CUDA" = "no" ]; then
493 echo "Error> no CUDA toolkit found, searched \$CUDATOOLKIT_HOME $CUDA_PRESET_DIRS"
494 exit 1
498 [ "x$VERSION" = "x" ] && syntax && exit 1
500 if [ "x_$ARCH" = "x_net" ]; then
501 echo "Error: net-* has been removed, please use netlrts or verbs.";
502 exit 1;
505 #Check if building verbs on Omni-Path
506 if [ "x_$ARCH" = "x_verbs" ] && type /usr/sbin/opafabricinfo >/dev/null 2>&1; then
507 echo "WARNING: Detected Omni-Path diagnostic tools.";
508 echo "Verbs on Omni-Path architectures is not well supported: please use an OFI build instead.";
511 if test -n "$WITH_PRODUCTION" -a $BUILD_EMULATOR -eq 1 -a -z "$ENABLE_TRACING"
512 then
513 echo "Error: bigemulator requires tracing modules, --with-production must be used with --enable-tracing"
514 exit 1
517 if [ -z "$MAKE" ]
518 then
519 # prefer gmake
520 MAKE=`which gmake 2>/dev/null`
521 [ -z "$MAKE" -o ! -x "$MAKE" ] && MAKE='make'
524 if [ ! -f $src/$BASEVERSION/conv-mach.h ]
525 then
526 echo "Error> build can not find arch: $BASEVERSION!"
527 exit 1
530 if [ ! -f "$srcbaseabs/scripts/configure" ]
531 then
532 if ! command -v autoreconf >/dev/null 2>&1 || ! command -v aclocal >/dev/null 2>&1
533 then
534 echo "Error> autoconf and automake are not installed."
535 exit 1
539 #generate header for uFcontext for the target VERSION
540 UFCONTEXT_HEADER_NAME=
541 if test `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
542 then
543 UFCONTEXT_HEADER_NAME="macho_gas"
544 elif test `echo "$BASEVERSION" | grep -c "win"` -gt 0
545 then
546 UFCONTEXT_HEADER_NAME="windows"
547 else
548 UFCONTEXT_HEADER_NAME="elf_gas"
551 if test `echo "$BASEVERSION" | grep -c "arm7"` -gt 0
552 then
553 UFCONTEXT_HEADER_NAME="arm_aapcs_${UFCONTEXT_HEADER_NAME}"
554 elif test `echo "$BASEVERSION" | grep -c "arm8"` -gt 0
555 then
556 UFCONTEXT_HEADER_NAME="arm64_aapcs_${UFCONTEXT_HEADER_NAME}"
557 elif test `echo "$BASEVERSION" | grep -c "mips"` -gt 0
558 then
559 UFCONTEXT_HEADER_NAME="mips32_o32_${UFCONTEXT_HEADER_NAME}"
560 elif test `echo "$BASEVERSION" | grep -c "bluegene\|pami\|ppc"` -gt 0
561 then
562 UFCONTEXT_HEADER_NAME="ppc64_sysv_${UFCONTEXT_HEADER_NAME}"
563 elif test `echo "$BASEVERSION" | grep -c "cray\|x86_64\|linux64\|amd64"` -gt 0
564 then
565 UFCONTEXT_HEADER_NAME="x86_64_sysv_${UFCONTEXT_HEADER_NAME}"
566 else
567 UFCONTEXT_HEADER_NAME="i386_sysv_${UFCONTEXT_HEADER_NAME}"
570 #generate VERSION name combining all the build-time options.
571 if [ -n "$BOPTS" -o -n "$COMPILER" ]
572 then
573 echo "Selected Compiler: $COMPILER"
575 if test -n "$COMPILER" -a `echo "$BASEVERSION" | grep -c "cray\|gni\|gemini"` -gt 0
576 then
577 echo "Inserted explicit compiler options on Cray systems. Use compiler wrappers by loading PrgEnv-*"
578 echo "e.g.) module load PrgEnv-* (e.g. cray for cce, gnu for gcc, intel for icc, and pgi for pgcc)"
579 echo " ./build charm++ $BASEVERSION <other build options>"
580 echo "Charm++ uses the compiler wrapper 'CC' specified by the Cray system. Don't use explicit compiler options on Cray systems."
581 exit 1
584 if test `echo "$BOPTS" | grep -c "omp"` -gt 0 -a `echo "$BASEVERSION" | grep -c "darwin"` -gt 0
585 then
586 if test -z "$COMPILER" -o "$COMPILER" != "gcc"
587 then
588 echo "The integrated OpenMP runtime library is supported on Mac only with the normal gcc"
589 echo "You need to install this normal (non-clang) gcc via MacPorts or Homebrew"
590 echo "Read the instructions on the Charm++ manual."
591 exit 1
594 echo "Selected Options: $BOPTS"
595 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
596 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
597 for i in $BOPTS_WITHCOMPILER
599 VERSION=$VERSION-$i
600 done
603 #echo "|$DESTINATION|$DESTINATION_SUFFIX|"
605 if [ -z "$DESTINATION" ]
606 then
607 DESTINATION="$VERSION"
610 if [ $(dirname $DESTINATION) != "." ]
611 then
612 srcbaseabs="$(cd $srcbaseabs; pwd)"
613 srcbase=$srcbaseabs
614 src="$srcbaseabs/arch/"
617 if [ -n "$DESTINATION_SUFFIX" ]
618 then
619 DESTINATION="$DESTINATION-$DESTINATION_SUFFIX"
622 # make sure $DESTINATION is more than '/' characters, because we `rm -rf` it
623 if [ -z "${DESTINATION#"${DESTINATION%%[!/]*}"}" ]
624 then
625 echo 'Error: $DESTINATION is the filesystem root.'
626 exit 1
629 if test -n "$BOPTS"
630 then
631 # pxshm+smp note: When combining the 'smp' and 'pxshm' directives, it is
632 # important that they be included in $ConvHeader in that
633 # exact order. See bug #717.
634 MYTMP=""
635 HAS_PXSHM=0
636 HAS_SMP=0
637 for i in $BOPTS; do
638 if [ "$i" = "smp" ]; then
639 HAS_SMP=1
640 elif [ "$i" = "pxshm" ]; then
641 HAS_PXSHM=1
642 elif [ "$i" = "omp" ]; then
643 BUILD_OMP=1
644 MYTMP="$MYTMP $i"
645 else
646 MYTMP="$MYTMP $i"
648 done
649 if [ $HAS_PXSHM -eq 1 ]; then
650 MYTMP="pxshm $MYTMP"
652 if [ $HAS_SMP -eq 1 ]; then
653 MYTMP="smp $MYTMP"
654 elif [ $BUILD_OMP -eq 1 ]; then
655 BUILD_OMP=2 #this means omp keyword inserted without smp keyword"
659 # build for Charmpy
660 if [ "$PROGRAM" = "charmpy" ]; then
661 if [ -n "$BOPTS" ] && [ "$HAS_SMP" -eq 1 ]; then
662 echo "Error: SMP mode is currently not supported with charmpy. Choose a non-smp version."
663 exit 1
666 if [ `echo "$BASEVERSION" | grep -c "multicore"` -gt 0 ]; then
667 echo "Error: multicore is currently not supported with charmpy. Choose a non-smp version."
668 exit 1
671 if test `echo "$CONFIG_OPTS" | grep -c "\--enable-charmpy"` -eq 0
672 then
673 CONFIG_OPTS="$CONFIG_OPTS --enable-charmpy"
676 if test `echo "$BASEVERSION" | grep -c "win"` -gt 0
677 then
678 BUILD_SHARED=""
679 else
680 BUILD_SHARED="-build-shared"
684 if test -n "$WITH_PRODUCTION"
685 then
686 # Prepend optimize so that an explicit -no-optimize still works
687 OPTS="-optimize -production $OPTS"
688 CONFIG_OPTS="--disable-controlpoint --disable-tracing --disable-tracing-commthread --disable-charmdebug --disable-replay --disable-error-checking --disable-stats $CONFIG_OPTS"
691 # build with Tau
692 WITH_TAU=0
693 if [ "$PROGRAM" = "Tau" ]
694 then
695 Echo "TAU>>>> makefile config option: $TAU_MAKEFILE"
696 if [ -n "$TAU_MAKEFILE" -a -f $TAU_MAKEFILE ]
697 then
698 #Setting up TAU trace library:
699 Echo "TAU>>>> configuring with this TAU makefile: $TAU_MAKEFILE"
701 WITH_TAU=1
702 else
703 Echo "TAU>>>> ERROR could not find Makefile: $TAU_MAKEFILE, ignored"
704 TAU_MAKEFILE=""
708 if [ "$PROGRAM" = "ChaNGa" ]
709 then
710 #Setting lbuserdata when the build is ChaNGa
711 CONFIG_OPTS="--enable-lbuserdata $CONFIG_OPTS"
714 if test $BUILD_EMULATOR = 1
715 then
716 # export BIGSIM so that make targets can depend on it
717 MAKEOPTS="$MAKEOPTS BIGSIM=bigsim"
718 PROGRAM="$PROGRAM bigsim"
721 if [ $BUILD_OMP = 2 ]
722 then
723 case $DESTINATION in
724 "multicore"*)
725 BUILD_OMP=1
728 echo "OpenMP support should be built in SMP mode"
729 exit 1
731 esac
734 # ===================================================
735 # ---------- begin file structure creation ----------
736 # ===================================================
738 if [ -f "$DESTINATION/tmp/basics" ]
739 then
740 Echo "File structure already created; skipping directly to make"
741 else
743 for d in bin doc examples include lib lib_so tests tmp; do
744 rm -rf "$DESTINATION/$d"
745 done
747 Echo "Creating dir: $DESTINATION"
748 Echo "Creating dir: $DESTINATION/tmp"
749 mkdir -p "$DESTINATION/tmp"
751 echo "TARGET=${UFCONTEXT_HEADER_NAME}" > $DESTINATION/tmp/uFcontext.mk
753 # Create the bin, lib, include, etc. links:
754 WINNAME=`echo $VERSION | awk -F- '{print $2}'`
755 if [ "x_$WINNAME" = "x_win64" -o "x_$WINNAME" = "x_win" ]
756 then
757 #Win64 version needs special compilers and *copied* (not linked)
758 # source files.
759 cp $src/win/system_ln $DESTINATION/tmp
760 cp $src/win/unistd.h $DESTINATION/tmp
761 echo "Compiling createlink.cpp ..."
762 case "$COMPILER" in
763 gcc*|clang*)
764 createlinkcc="$COMPILER"
767 createlinkcc="./unix2nt_cc"
769 esac
770 (cd $src/win; $createlinkcc -c createlink.cpp -o createlink.o -D_WIN32_WINNT=0x0500; $createlinkcc createlink.o -o createlink.exe)
772 if test ! -x $src/win/createlink.exe
773 then
774 echo "VC++ is not properly installed!"
775 exit 1
777 chmod +x $DESTINATION/tmp/system_ln
778 cp $src/win/gathertree.local $DESTINATION/tmp
779 cp $src/win/gatherflat.local $DESTINATION/tmp
780 else
781 cat > $DESTINATION/tmp/system_ln <<EOF
782 #!/bin/sh
783 ln -f -s \$@
785 chmod +x $DESTINATION/tmp/system_ln
786 for newdir in `echo bin lib lib_so include tmp`
788 Echo "Soft-linking over $newdir"
789 if [ -r $newdir ]
790 then
791 rm -fr $newdir || exit 1
793 $DESTINATION/tmp/system_ln $DESTINATION/$newdir $newdir
794 done
795 rm -f VERSION
796 $DESTINATION/tmp/system_ln $DESTINATION/include/VERSION VERSION
799 Echo "Copying src/scripts/Makefile to $DESTINATION/tmp"
800 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.depends" $DESTINATION/tmp/Make.depends
801 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.cidepends" $DESTINATION/tmp/Make.cidepends
802 if test -f "$srcbaseabs/ck-ldb/Make.lb"
803 then
804 $DESTINATION/tmp/system_ln "$srcbase/ck-ldb/Make.lb" $DESTINATION/tmp/Make.lb
805 else
806 touch $DESTINATION/tmp/Make.lb
808 $DESTINATION/tmp/system_ln "$srcbase/scripts/Makefile" $DESTINATION/tmp/Makefile
809 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.tau" $DESTINATION/tmp/Make.tau
810 $DESTINATION/tmp/system_ln "$srcbase/scripts/Make.gpu" $DESTINATION/tmp/Make.gpu
811 touch $DESTINATION/tmp/Makefile.machine
812 touch $DESTINATION/tmp/Make.extlib
814 ConvUsr="$DESTINATION/tmp/conv-mach-pre.sh"
815 Echo "Generating $ConvUsr"
816 echo > $ConvUsr
817 if test -n "$LIBDIR"
818 then
819 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
821 if test -n "$INCDIR"
822 then
823 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
824 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
826 chmod +x $ConvUsr
828 # Create conv-mach-opt headers with special build-time options
829 ConvHeader="$DESTINATION/tmp/conv-mach-opt.h"
830 ConvSh="$DESTINATION/tmp/conv-mach-opt.sh"
831 if [ ! -f $ConvSh -o ! -f $ConvHeader ]
832 then
833 Echo "Generating $ConvHeader, conv-mach-opt.sh"
834 echo '/* Build-time options header, automatically generated by charm/build*/'> $ConvHeader
835 echo '# Built-time options header, automatically generated by charm/build'> $ConvSh
836 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
838 if test -n "$COMPILER"
839 then
840 i=`echo $COMPILER | sed 's/-[0-9\.][0-9\.]*$//'`
841 echo "CMK_COMPILER_SUFFIX=${COMPILER#$i}" >> $ConvSh
842 echo '#include "'cc-$i.h'"' >> $ConvHeader
843 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
844 elif test `echo "$BASEVERSION" | grep -c "bluegeneq"` -gt 0
845 then
846 i="clang"
847 bgclang++11 --version
848 if [ $? -ne 0 ]; then
849 echo "ERROR: bgclang C/C++ compiler missing. Please load bgclang compilers, i.e. 'soft add +mpiwrapper-bgclang'."
850 exit 1
852 echo '#include "'cc-$i.h'"' >> $ConvHeader
853 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
855 if test -n "$MYTMP"
856 then
857 BOPTS=$MYTMP
858 for i in $BOPTS
860 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
861 if [ $BUILD_CUDA -eq 1 ]; then
862 echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
864 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
865 done
868 if test "$BUILD_SHARED" = "-build-shared"
869 then
870 echo "CMK_NO_BUILD_SHARED=false" >> $ConvSh
871 else
872 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
875 if test -n "$WITH_ROMIO"
876 then
877 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
880 if test -n "$WITH_PRODUCTION"
881 then
882 echo '#define CMK_OPTIMIZE 1' >> $ConvHeader
885 if test $WITH_TAU -eq 1
886 then
887 [ -z "$TAU_MAKEFILE" ] && TAU_MAKEFILE="Make.tau"
888 SED_CHARMC="s@TAU_MAKEFILE=\(.*\)@TAU_MAKEFILE=$TAU_MAKEFILE@"
890 sed -e $SED_CHARMC $srcbaseabs/scripts/Makefile > .Makefile.$$ && cp .Makefile.$$ $srcbaseabs/scripts/Makefile && rm -f .Makefile.$$
891 sed -e $SED_CHARMC $srcbaseabs/scripts/charmc > .charmc.$$ && cp .charmc.$$ $srcbaseabs/scripts/charmc && rm -f .charmc.$$
893 echo "#define CMK_WITH_TAU 1" >> $ConvHeader
894 echo "#define pthread_create tau_pthread_create" >> $ConvHeader
895 echo "#define pthread_exit tau_pthread_exit" >> $ConvHeader
897 echo "CMK_WITH_TAU=\"true\"" >> $ConvSh
900 echo $BASEVERSION > $DESTINATION/tmp/.vdir
901 echo $BASEVERSION | sed -e 's@-.*@@' > $DESTINATION/tmp/.gdir
903 echo 'BUILDOPTS="'$OPTS'"' >> $ConvSh
904 echo "SRCBASE=$srcbase" > $DESTINATION/tmp/charmpath.mk
906 echo "CONFIG_OPTS=\"$CONFIG_OPTS\"" > "$DESTINATION/tmp/config_opts.sh"
907 chmod +x "$DESTINATION/tmp/config_opts.sh"
908 echo "OPTSATBUILDTIME += $OPTS" > "$DESTINATION/tmp/buildopts.mk"
912 # ===================================================
913 # ----------- end file structure creation -----------
914 # ===================================================
916 printError()
918 Echo "-------------------------------------------------"
919 Echo "Charm++ NOT BUILT. Either cd into $DESTINATION/tmp and try"
920 Echo "to resolve the problems yourself, visit"
921 Echo " http://charm.cs.illinois.edu/"
922 Echo "for more information. Otherwise, email the developers at charm@cs.illinois.edu"
923 exit $MAKEEXIT
926 Echo "Performing '$MAKE $MAKEOPTS basics OPTS="$OPTS" QUIET="$QUIET" CONFIG_OPTS="$CONFIG_OPTS"' in $DESTINATION/tmp"
927 cd $DESTINATION/tmp
928 $MAKE $MAKEOPTS basics OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
929 MAKEEXIT=$?
930 [ $MAKEEXIT -ne 0 ] && printError
932 if test -n "$ONLY_CONFIGURE"
933 then
934 exit 0
937 Echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS" QUIET="$QUIET"' in $DESTINATION/tmp"
938 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
939 MAKEEXIT=$?
940 if [ $MAKEEXIT -eq 0 ]
941 then
942 if [ $BUILD_OMP = 1 ];
943 then
944 $MAKE MFLAGS="$MAKEOPTS" openmp_llvm OPTS="$OPTS $BUILD_SHARED" QUIET="$QUIET"
946 Echo "-------------------------------------------------"
947 Echo "$PROGRAM built successfully."
948 Echo "Next, try out a sample program like" \
949 "$DESTINATION/tests/charm++/simplearrayhello"
950 else
951 printError