2 ##############################################################################
3 # charmc: Compiler for Converse/Charm/Charm++ programs
5 # Converted to Bourne Shell by Orion Sky Lawlor, 10/21/1999
7 # Initialize the main controlling variables, setup error handler
8 # ALL variables used by this script should be initialized here.
10 ##############################################################################
12 #Prepare aliases for the external commands we use--
13 # Note that adding /bin/ to everything breaks Cygwin32.
40 #Generic options, passed to everything
43 #charm internal flag, only pass to c and cxx, not f90
44 OPTS_CPP_INTERNAL
="-D__CHARMC__=1"
60 EXPLICIT_COMPILATION
="no"
94 ROSE_OMP_TLS_GLOBALS
="no"
110 ####################################################################
112 # Utility routines used below
114 ###################################################################
116 # PrintUsage: prints a helpful command-line usage message and quits
117 # Args: any additional messages
121 echo "Usage: charmc [ flags ] <files>"
124 echo " -o <target> -g -O"
125 echo " -D<define> -I<include path> -L<lib path> -l<library> -s"
126 echo " -machine <mach> -seq -host -language <lang> -pg <opt>"
127 echo " -balance <mode> -tracemode <mode> -memory <mode>"
128 echo " -modules <comma-separated list of C++ modules> -thread"
129 echo " -debug-script -count-tokens -default-to-aout -E -S -M"
130 echo " -verbose -save -purify -cp <dest> -cpmod -gen-cpm <pkg>"
131 echo " -swapglobals -tlsglobals -roseomptlsglobals"
132 echo " -use-reliable-cc -use-fastest-cc -use-new-std"
133 echo " -cc <new cc> -c++ <new CC> -ld <new ld> -ld++ <new LD>"
134 echo " -cpp-option <opt> -ldro-option <opt> -cc-option <opt>"
135 echo " -c++-option <opt> -ld-option <opt> -ld++-option <opt>"
136 echo " -f90 <new f90> -f90-option <opt> -fmoddir <f90mod path>"
137 echo " -flibs -rpath <path> -custom-part -touch-on-failure"
138 echo " -mpi -openmp -no-trace-mpi -build-shared -charm-shared"
139 echo " -no-charmrun -no-preprocess-ci -nomain-module -nomain"
140 echo " -nof90main -f90main"
142 echo " Charmc compiles C, C++, f77, f90, AMPI, Converse, Converse++, Charm, "
143 echo "and Charm++ programs. The flags generally match those of cc or f77."
144 echo "Parallel Programming Lab, UIUC, 2017."
149 # End blows away the temporary files (unless SAVE is true) and exits
154 for FILE
in `echo $FILES`
156 #BASE=`stripExtention $FILE`
157 TMP
=`basename $FILE`".TMP"
158 $RM $TMP.P.C
$TMP.cpp
$TMP.space
$TMP.xlat
$TMP.o
159 $RM $TMP.c
$TMP.c
.0.h
$TMP.c
.1.h
$TMP.c
.2.h
160 $RM $TMP.i
$TMP.
$CMK_CPP_SUFFIX
163 if test -n "$modInitObj"
165 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
166 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
172 # Write this error message to stderr
173 # ("1>&2" redirects the echo output to stderr).
178 # This procedure prints an error message and exits.
179 # Args: written to stderr
181 Warning
"Fatal Error by charmc in directory "`pwd`
183 Warning
"charmc exiting..."
188 # Instead of an ECHO_CMD variable, I define a procedure Do,
189 # which (possibly) echos, runs, and tests the errors of the given command.
190 # Args: executed as given
192 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
199 # The UNIX result code better be zero, or we die
200 [ $Do_res -eq 0 -o -n "$NOABORT" ] || Abort
"Command $@ returned error code $Do_res"
203 # This procedure removes the extention (the ".c" in "./main.c") from
204 # its first argument, and prints the result. Unlike the builtin command
205 # basename, it keeps the directory path.
206 # Args: <name to strip>
208 se_base
=`basename $1`
209 # se_base=`echo $1 | awk -F/ '{print $NF}'`
210 se_strip
=`echo $se_base | awk -F. '{ORS="";print $1;for (i=2;i<NF;i++) print "."$i}'`
211 se_ret
=`echo $1 | awk -F/ '{ORS="";for (i=1;i<NF;i++) print $i"/"}'`"$se_strip"
215 # GetExtention returns the extention on the given file name
216 # or "" if none. (e.g. "./bob/snack.c" returns ".c")
217 # Args: <name to find extention of>
219 # se_base=`echo $1 | awk -F/ '{print $NF}'`
220 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
222 se_ret
=`echo $1 | sed -e 's/.*\././'`
223 if test "$se_ret" = $1
232 [ -n "$VERBOSE" ] && echo "charmc>" $@
236 if [ -n "$DEBUG_SCRIPT" ]
239 echo "------- Charmc Debugging info: $* -------"
240 echo "CHARMBIN=$CHARMBIN"
241 echo "CHARMINC=$CHARMINC"
242 echo "CHARMLIB=$CHARMLIB"
244 echo "DELETE=$DELETE"
245 echo "OBJECT=$OBJECT"
246 echo "LANGUAGE=$LANGUAGE"
247 # echo "Working directory="`pwd`
251 # Return success if $1 is not in any of the other arguments
257 if [ "$search" = "$1" ]
259 # It's already in there-- fail
264 # It's missing--succeed
268 # Add arguments to our modules list, avoiding duplicates
272 notInList
$M $MODULES && MODULES
="$MODULES $M"
276 # Add this word to this list, avoiding duplicates
291 # TEMP_BASE is appended with this script's process ID (PID),
292 # so multiple charmcs can run in parallel without overwriting
293 # each other's temporary files.
294 TEMP_BASE
="/tmp/charmc_tmp.$$"
296 # Try to find CHARMBIN by looking in directory where charmc is
298 if [ -z "$CHARMBIN" ]
301 CHARMBIN
=`dirname $SCRIPT`
302 # CHARMBIN=`cd $CHARMBIN; pwd`
303 # NOTE: this script no longer tries to follow soft links
304 # to find the "original" charmc-- if this is bad,
305 # translate these lines to Bourne shell from C shell:
306 # -------------------- Begin C Shell ------------------------->
307 # if ($SCRIPT:h != $SCRIPT:t) then
309 # set SCRIPT=$SCRIPT:t
311 # foreach dir ($path)
312 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
318 # while (x`find $SCRIPT -type l -print` == x$SCRIPT)
319 # set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
320 # if ($SCRIPT:h != $SCRIPT:t) then
322 # set SCRIPT=$SCRIPT:t
326 # <------------------ End C Shell -----------------------------
333 version
=`cat $CHARMBIN/../include/VERSION`
334 echo Charm
++ Version
$version
338 ##############################################################################
340 # The following section identifies CHARMBIN, the charm binary-directory.
342 ##############################################################################
346 # Try to find CHARMBIN by looking in directory where charmc is
351 FIRST_THREE
=`uname -s | awk '{print substr($1,1,3)}' `
352 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
354 # Running on a windows system-- append .exe to file names
358 CHARMLIB
="$CHARMBIN/../lib"
359 CHARMINC
="$CHARMBIN/../include"
361 if test -d "$CHARMBIN/../lib_so"
363 CHARMLIBSO
=`cd $CHARMBIN/../lib_so 2>/dev/null && pwd`
364 #getting absolute path is harder than thought because of symbolic links and ..
365 #ksh needs cd -P to resolve werid symbolic links, however -P is not portable
366 #csh is ok too if it exists
367 test -z "$CHARMLIBSO" && CHARMLIBSO
=`cd -P $CHARMBIN/../lib_so 2>/dev/null && pwd`
368 test -z "$CHARMLIBSO" && CHARMLIBSO
=`csh -c "cd $CHARMBIN/../lib_so >& /dev/null && pwd"`
369 test -z "$CHARMLIBSO" && echo "$CHARMBIN/../lib_so: not found" && exit 1
372 ##############################################################################
374 # Parse the arguments
376 # Don't do any analysis in here, just the parsing.
378 ##############################################################################
380 [ $# -eq 0 ] && printUsage
"Error: No arguments given."
408 # Parse out some fake languages (that are actually modules)
410 "ampi") AddModules tcharmmain ampi
;;
411 "ampif") AddModules tcharmmain ampif
; USE_F90_LIBRARIES
="1" ;;
412 "armci") AddModules tcharmmain armci
;;
413 "armcif") AddModules tcharmmain armci
; USE_F90_LIBRARIES
="1" ;;
414 "fem") AddModules tcharmmain fem
; AMPIMAIN
="femmain";;
415 "femf") AddModules tcharmmain fem
; AMPIMAIN
="femmain"; USE_F90_LIBRARIES
="1" ;;
416 "ParFUM_TOPS") AddModules tcharmmain ParFUM ParFUM_TOPS
; AMPIMAIN
="ParFUMmain";;
417 "ParFUM") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain";;
418 "ParFUMf") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain"; USE_F90_LIBRARIES
="1" ;;
419 "mblock") AddModules tcharmmain mblock
;;
420 "mblockf") AddModules tcharmmain mblock
; USE_F90_LIBRARIES
="1" ;;
430 # Requested support from charmdebug: add some modules and libraries
435 "-module"|
"-modules")
436 AddModules
`echo $1 | sed -e 's/,/ /g'`
441 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
442 BALANCER
="$BALANCER $1"
443 mod
=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
454 Warning
"Warning: -queue currently being ignored."
469 TRACEMODE_NEW
=`AddList $TRACEMODE $1`
470 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
472 Warning
"Warning: Duplicate tracemode $1 ignored"
474 TRACEMODE
=$TRACEMODE_NEW
482 "-swapglobal"|
"-swapglobals")
487 "-tlsglobal"|
"-tlsglobals")
491 "-roseomptlsglobals")
492 ROSE_OMP_TLS_GLOBALS
="yes"
496 echo "Verbose mode set"
505 SPU_EXTRA_LIBS
="$SPU_EXTRA_LIBS -l$1"
514 echo "Will give excessive charmc debugging output..."
560 OPTS_CPP
="$OPTS_CPP $1"
565 OPTS_LDRO
="$OPTS_LDRO $1"
570 OPTS_CC
="$OPTS_CC $1"
575 OPTS_CXX
="$OPTS_CXX $1"
580 OPTS_F90
="$OPTS_F90 $1"
585 OPTS_LD
="$OPTS_LD $1"
590 OPTS_LDXX
="$OPTS_LDXX $1"
595 OPTS_LDXX
="$OPTS_LDXX -rpath $1"
599 "-fortran"|
"-flib"|
"-flibs")
600 USE_F90_LIBRARIES
="1"
605 "-fortran77"|
"-f77lib"|
"-f77libs")
606 USE_F77_LIBRARIES
="1"
609 # Run preprocessor only
615 # Run preprocessor as an extra step, continue after preprocessing
619 # Turn off the preprocessor for ci files
623 # Run preprocessor/assembler only
637 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
643 echo $arg | cut
-d'=' -f2
647 if [ "$EXPLICIT_OBJECT" = "no" ]
651 EXPLICIT_COMPILATION
="yes"
655 EXPLICIT_OBJECT
="yes"
666 MODCOPIES
="$1 $MODCOPIES"
676 OPTS_CPP
="$OPTS_CPP -I$1"
681 if echo "$arg" |
grep ' ' > /dev
/null
2>/dev
/null
683 OPTS_CPP
="$OPTS_CPP "\"$arg\"
685 OPTS_CPP
="$OPTS_CPP $arg"
706 Warning
"passing unrecognized option $arg to all compilers and linkers"
713 OPTS_LD
="$OPTS_LD $arg"
719 # used internally when building Charm++ to create lib_so
723 # used internally not to build Charm++ lib_so
738 PRODUCTION_MODE
=false
742 POST_LIBRARIES
="$POST_LIBRARIES $arg"
750 F90_MODDIR
="$F90_MODDIR $1"
755 if [ -n "$POST_LANGUAGE" ]
757 POST_LIBRARIES
="$POST_LIBRARIES $arg"
759 PRE_LIBRARIES
="$PRE_LIBRARIES $arg"
764 OPTS_LD
="$OPTS_LD $arg"
782 MPI_INTEROPERATE
="yes"
792 CUSTOM_PARTITION
="yes"
804 # Warning "passing unrecognized option $arg to all compilers and linkers"
808 [ -n "$VERBOSE" ] && echo "Adding file $arg..."
813 # printUsage "Error: Unrecognized argument $arg"
814 # Warning "passing unrecognized option $arg to all compilers and linkers"
823 # Process original command-line arguments
824 eval processArgs
"$@"
827 ##############################################################################
829 # Load module dependencies.
831 ##############################################################################
833 Debug
"About to read machine config script"
834 Debug
"Read config script, setting defaults..."
836 [ ! -r $CHARMINC/conv-config.sh
] && Abort
"Cannot find conv-config.sh in $CHARMINC"
837 .
$CHARMINC/conv-config.sh
$CHARMINC
839 Debug
"Setting vars..."
841 if [ "$USE_BUILD_OPTIONS" = "1" ]
843 [ -n "$VERBOSE" ] && echo "Charmc applying build time options: $BUILDOPTS"
844 OPTS
="$OPTS $BUILDOPTS"
847 # If we are debugging, add "-g -O0" to the C/C++ flags
848 if [ -n "$CHARMDEBUG" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]; then
849 if [ -n "$CMK_BUILD_PYTHON" ]; then
850 AddModules PythonCCS charmdebug_python
851 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lpython${CMK_BUILD_PYTHON}`
853 OPTS_CPP
="$OPTS_CPP -O0 -g"
858 if [ "$WERROR" = "1" ]
860 OPTS
="$OPTS $CMK_WARNINGS_ARE_ERRORS"
863 # If the user has asked for the latest language standards (C11 or CPP11)
864 if [ "$USE_NEW_STD" = "1" ]
866 # and if configure confirmed that the underlying compiler knows abt C11, enable it
867 if [ "$CMK_COMPILER_KNOWS_C11" = "1" ]
869 OPTS_CC
="$OPTS $CMK_ENABLE_C11"
871 # and if configure confirmed that the underlying compiler knows abt CPP11, enable it
872 if [ "$CMK_COMPILER_KNOWS_CPP11" = "1" ]
874 OPTS_CXX
="$OPTS $CMK_ENABLE_CPP11"
878 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
883 if [ ! -x "$CMK_ROSE_OMP_TOOL" ]
885 Abort
"The environment variable CMK_ROSE_OMP_TOOL must contain the path to a built binary of the ROSE OpenMP variable privatization tool"
889 if [ "$USE_OPENMP" = "yes" ]
891 [ -n "$VERBOSE" ] && echo OpenMP support enabled
892 OPTS_CC
="$OPTS_CC $CMK_C_OPENMP"
893 OPTS_CXX
="$OPTS_CXX $CMK_C_OPENMP"
894 OPTS_F90
="$OPTS_F90 $CMK_F_OPENMP"
895 OPTS_LD
="$OPTS_LD $CMK_LD_OPENMP"
896 OPTS_LDXX
="$OPTS_LDXX $CMK_LD_OPENMP"
898 [ -n "$VERBOSE" ] && echo OpenMP support not enabled
901 if [ "$TLSGLOBALS" = "1" ]
903 OPTS_CC
="$OPTS_CC -mno-tls-direct-seg-refs"
904 OPTS_CXX
="$OPTS_CXX -mno-tls-direct-seg-refs"
905 OPTS_F90
="$OPTS_F90 -mno-tls-direct-seg-refs"
906 OPTS_LD
="$OPTS_LD -static -Wl,--allow-multiple-definition"
907 OPTS_LDXX
="$OPTS_LDXX -static -Wl,--allow-multiple-definition"
910 # Look up and add the dependencies for module $1
913 notInList
$M $PROCESSED_MODULES ||
return
914 PROCESSED_MODULES
="$PROCESSED_MODULES $M"
915 #PRE_LIBRARIES=`AddList $PRE_LIBRARIES -lmodule$M`
916 PRE_LIBRARIES
=`AddList -lmodule$M $PRE_LIBRARIES`
917 # HACK: add modules to both ends of library list, to avoid
918 # undefined symbol CkRegisterMainModule when it's in a module file.
919 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lmodule$M`
920 if [ "$M" = "PythonCCS" ]
926 # fixme: should search everything in the -L library paths:
927 for dir
in `echo . $CHARMLIB`
929 d
="$dir/libmodule$M.dep"
930 [ -r "$d" ] && dep
=$d
934 # Add the module dependencies in this file
935 # Debugf "Adding module" $M "dependencies from" $dep
937 Debugf
"Module" $M "adds dependencies:" $deps
942 # Repeat the module-dependency search until we find no
945 while [ "$START_MODULES" != "$MODULES" ]
947 Debugf
"----------- Module dependency search ------------"
948 START_MODULES
="$MODULES"
955 Debugf
"----------- Module dependency search complete ------------"
959 ##############################################################################
961 # Load machine-specific configuration data, then handle overrides to it.
963 ##############################################################################
966 if [ x
"$CMK_NO_BUILD_SHARED" = "xfalse" ]
971 if [ "$BUILD_SHARE" = "1" ]
973 if [ x
"$CMK_NO_BUILD_SHARED" = "xtrue" -o -z "$CHARMLIBSO" ]
982 if [ "$USE_PIC" = "1" ]
984 OPTS_CC
="$OPTS_CC $OPTS_PIC"
985 OPTS_CXX
="$OPTS_CXX $OPTS_PIC"
986 OPTS_F90
="$OPTS_F90 $OPTS_PIC"
987 OPTS_LD
="$OPTS_LD $OPTS_PIC"
990 if [ "$BUILD_SHARE" = "1" ]
992 # ignore BUILD_SHARE if the target is not .a or .so
994 *.a|
*.so|
*.so.
*|
*.sl|
*.dylib
)
995 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
1003 if [ -n "$OVERRIDE_CC" ]
1005 CMK_CC
="$OVERRIDE_CC"
1008 if [ -n "$OVERRIDE_CXX" ]
1010 CMK_CXX
="$OVERRIDE_CXX"
1013 if [ -n "$OVERRIDE_F90" ]
1015 CMK_CF90
="$OVERRIDE_F90"
1018 if [ -n "$OVERRIDE_LD" ]
1020 CMK_LD
="$OVERRIDE_LD"
1023 if [ -n "$OVERRIDE_LDXX" ]
1025 CMK_LDXX
="$OVERRIDE_LDXX"
1028 if [ -n "$USE_RELIABLE_CC" ]
1030 CMK_CC
="$CMK_CC_RELIABLE"
1033 if [ -n "$USE_FASTEST_CC" ]
1035 CMK_CC
="$CMK_CC_FASTEST"
1038 if [ -n "$USE_F77" ]
1041 CMK_CF90_FIXED
=$CMK_CF77
1042 CMK_F90LIBS
=$CMK_F77LIBS
1045 if [ -n "$CMK_F90_MODINC" ]
1047 CMK_CF90_MODINC
="$CMK_F90_MODINC"
1049 CMK_CF90_MODINC
="-M"
1052 if [ -n "$F90_MODDIR" ]
1054 for dir
in $F90_MODDIR
1056 OPTS_F90
="$OPTS_F90 $CMK_CF90_MODINC $dir"
1060 if [ -n "$CMK_F90_USE_MODDIR" ]
1062 CMK_CF90
="$CMK_CF90 $CMK_CF90_MODINC $CHARMINC $CMK_SYSINC"
1065 if [ -n "$SEQUENTIAL" ]
1067 CMK_CC
="$CMK_SEQ_CC -DCMK_SEQUENTIAL=1 "
1068 CMK_LD
="$CMK_SEQ_LD"
1069 CMK_CXX
="$CMK_SEQ_CXX -DCMK_SEQUENTIAL=1 "
1070 CMK_CF90
="$CMK_SEQ_F90 "
1071 CMK_LDXX
="$CMK_SEQ_LDXX"
1072 CMK_AR
="$CMK_SEQ_AR"
1073 CMK_RANLIB
="$CMK_SEQ_RANLIB"
1078 CMK_CC
="$CMK_NATIVE_CC "
1079 CMK_LD
="$CMK_NATIVE_LD"
1080 CMK_CXX
="$CMK_NATIVE_CXX "
1081 CMK_LDXX
="$CMK_NATIVE_LDXX"
1084 if [ -n "$PREPROCESS" ]
1091 CMK_LD
="purify $CMK_LD"
1092 CMK_LDXX
="purify $CMK_LDXX"
1096 if [ "$OPTIMIZE_MODE" = "true" ]
1098 OPTS_CC
="$CMK_C_OPTIMIZE $OPTS_CC"
1099 OPTS_CXX
="$CMK_CXX_OPTIMIZE $OPTS_CXX"
1100 OPTS_F90
="$CMK_F90_OPTIMIZE $OPTS_F90"
1101 OPTS_LD
="$CMK_C_OPTIMIZE $OPTS_LD"
1102 OPTS_LDXX
="$CMK_CXX_OPTIMIZE $OPTS_LDXX"
1105 # Pick up per-architecture production mode settings
1106 if [ "$PRODUCTION_MODE" = "true" ]
1108 OPTS_CC
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_CC"
1109 OPTS_CXX
="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_CXX"
1110 OPTS_F90
="$CMK_PRODUCTION $CMK_F90_PRODUCTION $OPTS_F90"
1111 OPTS_LD
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_LD"
1112 OPTS_LDXX
="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_LDXX"
1115 if [ -n "$XI_INTERNAL" ]
1117 CMK_XIOPTS
="$CMK_XIOPTS -intrinsic"
1120 if [ "$GENDEPENDS" = "yes" ]
1122 CMK_XIOPTS
="$CMK_XIOPTS -M"
1125 if [ "$COUNTTOKENS" = "yes" ]
1127 CMK_XIOPTS
="$CMK_XIOPTS -count-tokens"
1130 if test "$CMK_WITH_TAU" = "true"
1132 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1133 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1134 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1135 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1136 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1137 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1138 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1143 #Add generic options to the compiler- and linker-options
1144 OPTS_CC
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CC"
1145 OPTS_CXX
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CXX"
1146 OPTS_F90
="$OPTS $OPTS_F90"
1147 OPTS_LD
="$OPTS $OPTS_LD"
1148 # OPTS_LDXX gets OPTS from OPTS_LD
1150 if [ -n "$F90_MAIN" ]
1152 # for_main needs to be placed at beginning
1153 CMK_LD
="$CMK_LD $CMK_F90MAINLIBS"
1154 CMK_LDXX
="$CMK_LDXX $CMK_F90MAINLIBS"
1157 # There's really no analog for this in the Bourne shell:
1158 # -------- C Shell ------> onintr failure
1159 # Luckily, it's irrelevant as long as nobody sends us a ^Z.
1161 ##############################################################################
1163 # Check for valid choice of LANGUAGE
1165 ##############################################################################
1166 Debug
"Checking language..."
1168 if [ -z "$LANGUAGE" ]
1171 [ -n "$SEQUENTIAL" ] && LANGUAGE
=c
1175 "c"|
"C"|
"c++"|
"C++")
1176 [ -z "$SEQUENTIAL" -a -z "$NATIVE" ] && Abort
"Language $LANGUAGE is for sequential programs"
1180 # update charm to bgcharm
1181 if [ "$LANGUAGE" = "charm++" -a -n "$CMK_BIGSIM" ]
1183 LANGUAGE
="bgcharm++"
1185 if [ "$LANGUAGE" = "converse++" -a -n "$CMK_BIGSIM" ]
1187 LANGUAGE
="bgconverse++"
1189 if [ "$LANGUAGE" = "bgcharm++" ]
1191 TRACEMODE
=`AddList $TRACEMODE bluegene`
1194 ########################################################################
1196 # We've parsed and verified the command-line parameters.
1197 # Now we prepare routines to clean up and exit.
1198 # None of these routines ever returns-- they all just exit.
1200 ########################################################################
1204 if [ "a$COPYTO" != "a" -a "a$COPYTO" != "a$OBJECT" ]
1206 [ -d $COPYTO ] && COPYTO
="$COPYTO/"
1207 if [ "a$PROG_EXT" != "a" -a -r "$OBJECT$PROG_EXT" ] ; then
1208 Warning
"Appending $PROG_EXT to object file name"
1209 OBJECT
="$OBJECT$PROG_EXT"
1211 [ ! -d $COPYTO ] && DoNoErrCheck
$RM $COPYTO
1212 Do
$CP $OBJECT $COPYTO
1214 test -n "$COPY_EXIT" && Success
1218 for COPY
in `echo $MODCOPIES`
1220 if [ "a$COPY" != "a$OBJECT" ]
1222 [ -d $COPY ] && COPY
="$COPY/"
1223 if [ -n "$CMK_MOD_NAME_ALLCAPS" ] ; then
1224 OBJECT
=`echo $OBJECT | tr "a-z" "A-Z"`
1226 if [ -r "$OBJECT.$CMK_MOD_EXT" ] ; then
1227 Warning
"Appending .$CMK_MOD_EXT to object file name"
1228 OBJECT
="$OBJECT.$CMK_MOD_EXT"
1230 [ ! -d $COPY ] && DoNoErrCheck
$RM $COPY
1231 Do
$CP $OBJECT $COPY
1242 ##############################################################################
1244 # Preprocess the GEN-CPM files
1246 ##############################################################################
1248 Debug
"Preprocessing GEN-CPM files"
1250 if [ "$CMK_USING_BGCLANG" = "1" ]
1252 OPTS_CC_GENCPM
="-x c " # -x c is only applied for the preprocessing of the GEN-CPM files on BG/Q
1255 OPTS_CC_GENCPM
="$OPTS_CC $OPTS_CC_GENCPM"
1256 for FILE
in `echo $GENCPM`
1258 # This used to be "$FILE:r", which strips the extention
1259 BASE
=`stripExtention $FILE`
1260 TMP
=`basename $FILE`".TMP"
1261 DELETE
="$DELETE $TMP.c $TMP.i"
1262 DoNoErrCheck
$RM $BASE.cpm.h
$TMP.c
1263 Do
touch $BASE.cpm.h
1264 Do
$LN -f -s $FILE $TMP.c
1265 Do
$CMK_CPP_C -I$CHARMINC $CMK_SYSINC $OPTS_CC_GENCPM $OPTS_CPP $TMP.c
> $TMP.i
1266 Do
$CHARMBIN/conv-cpm
$TMP.i
$BASE.cpm.h
1269 ##############################################################################
1271 # Compile all specified files
1273 # All temporary files named *.TMP.* for easy cleanup.
1275 ##############################################################################
1277 Debug
"About to compile..."
1279 numFiles
=`echo $FILES | wc -w`
1280 for FILE
in `echo $FILES`
1282 BASE
=`stripExtention \`basename $FILE\
``
1283 TMP
=`basename $FILE`".TMP"
1284 FILE_EXT
=`getExtention $FILE`
1288 # in case of: charmc -o object.o -c foo.c,
1289 # avoid foo.c => remove foo.o => foo.o => object.o,
1290 # instead generate object.o directly.
1291 # remove and generate foo.o may be dangerous in parallel make
1292 # for example in the case of compiling several objs from one
1293 # same c file such as memory.c.
1294 if [ $numFiles = 1 -a -n "$OBJECT" ]
1296 OBJ_EXT
=`getExtention $OBJECT`
1297 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1304 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1307 .c|.s|.C|.cc|.cxx|.cpp|.c
++|.cu|.f|.F|.f90|.F90|.fpp|.FPP|.f77|.F77
)
1308 [ $VERBOSE ] && echo "Compiling $FILE"
1309 DoNoErrCheck
$RM $BASEO $BASE.f.o
1312 if [ ! -z "$SKIPLINK" ]
1318 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1322 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1325 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++)
1326 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE
1329 *.f|
*.F|
*.f77|
*.F77
)
1330 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1333 *.f90|
*.F90|
*.fpp|
*.FPP
)
1334 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1335 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE
1344 test "$LANGUAGE" = "f90charm" && XIOPTS
="$XIOPTS -f90"
1345 if [ "$PREPROCESS_CI" = "yes" ]
1347 Do
$CMK_CPP_CHARM $OPTS_CPP $FILE | Do
$CHARMBIN/charmxi
$XIOPTS -orig-file $FILE
1349 Do
$CHARMBIN/charmxi
$XIOPTS $FILE
1353 Do
$CMK_CC -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE $DESTO
1355 if [ "$Do_res" -ne 0 ]
1361 Do
$CMK_GCXX -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE $DESTO
1364 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu
)
1367 Do
$CMK_NATIVE_CXX -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP -c $FILE $DESTO
1369 Do
$CMK_CXX -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE $DESTO
1372 if [ "$Do_res" -ne 0 ]
1377 *.f|
*.F|
*.f77|
*.F77
)
1378 test -z "$CMK_CF90_FIXED" && Abort
"No F90 compiler (CMK_CF90_FIXED) defined"
1379 Do
$CMK_CF90_FIXED -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE $DESTO
1381 if [ "$Do_res" -ne 0 ]
1386 *.f90|
*.F90|
*.fpp|
*.FPP
)
1387 test -z "$CMK_CF90" && Abort
"No F90 compiler (CMK_CF90) defined"
1388 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1389 Do
$CMK_CF90 -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE $DESTO
1391 if [ "$Do_res" -ne 0 ]
1397 Abort
"I'm not yet smart enough to compile $FILE"
1399 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
1400 [ ! -s $FILE ] && Abort
"$FILE: file not recognized: File truncated"
1401 OBJECTFILES
="$OBJECTFILES $FILE"
1409 Abort
"file with unrecognized extension $FILE"
1411 # Handle new object files
1412 if [ -n "$NU_OBJ" -a -n "$OBJECT" ]
1414 if [ "$OBJECT" != "$BASEO" ]
1416 DELETE
="$DELETE $NU_OBJ"
1418 OBJECTFILES
="$OBJECTFILES $NU_OBJ"
1422 ##############################################################################
1424 # POSSIBLY, SKIP LINK-STEP
1426 # 1. No $OBJECT may be specified at all --- its just a compilation.
1427 # 2. If $OBJECT is a ".a" file, a library is created from $OBJECTFILES.
1428 # 3. If $OBJECT is a ".o" file, then an "LDRO" is created from $OBJECTFILES.
1429 # 4. Language may be sequential. Do a quick and easy linkage.
1431 # in any of these cases, the full link step is skipped.
1433 ##############################################################################
1436 Debugf
"Running ldro..."
1437 DoNoErrCheck
$RM $OBJECT
1438 # convert to absolute path if required
1439 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1441 dir
=`dirname $OBJECT`
1442 fname
=`basename $OBJECT`
1446 Warning
"Warning: creating $OBJECT "
1447 if test "$MAKE_LDXX" = "1"
1449 soCmd
="$CMK_LDXX -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1451 soCmd
="$CMK_LD -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1455 if [ $Do_res -ne 0 ]
1461 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1462 echo "!! Failed to compile Charm++ shared library. You can disable shared !!"
1463 echo "!! lib compilation by providing --no-build-shared build option like: !!"
1464 echo "!! ./build charm++ net-linux --no-build-shared -O !!"
1465 echo "!! or reexecute this charmc command with --no-build-shared compile option !!"
1466 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1467 Abort
"Command $soCmd returned error code $Do_res"
1473 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
1475 # We have no target object, or are playing preprocessor tricks-- just end
1476 Debugf
"No target object-- finished"
1480 Debug
"About to link..."
1482 # if interoperate dont create the library now, wait to collect all info
1483 if [ "$MPI_INTEROPERATE" = "" ]
1487 Debugf
"Converting $FILES to $OBJECTFILES"
1488 nFiles
=`echo $FILES | wc -w`
1489 nObj
=`echo $OBJECTFILES | wc -w`
1490 # One source file, one .o: just move the .o
1491 if [ $OBJECT != $OBJECTFILES ]
1493 Debugf
"Moving .o to destination"
1494 DoNoErrCheck
$RM $OBJECT
1495 Do
$MV $OBJECTFILES $OBJECT
1499 *.so|
*.so.
*|
*.sl|
*.dylib
)
1500 # Make shared library
1501 # if no build share is set, exit normally.
1502 if [ "$BUILD_SHARE" = 0 ]
1504 echo "Warning: building shared library is skipped, possibly due to not supported, check configuration files."
1506 elif [ "$CHARM_SHARED" = "0" ]
1512 # Make regular (.a, non-shared) library
1513 # in case building charm so, build .so under lib_so as well # Gengbin
1514 if [ "$BUILD_SHARE" = "1" ]
1521 DESTDIR
=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
1522 OBJECT
=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
1524 COPYTO
=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
1527 OBJECT
=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
1528 [ -f $DESTDIR/.charmso
] && MakeSO
1534 DoNoErrCheck
$RM $OBJECT
1535 Do
$CMK_AR $OBJECT $OBJECTFILES
1536 Do
$CMK_RANLIB $OBJECT
1541 # If the above case returns, we're not creating a .o or .a file,
1542 # so linking is needed.
1544 ############ Determine the language and libraries ##########
1546 # Parse out the real languages
1550 USE_F90_LIBRARIES
="1"
1553 PRE_LIBRARIES
="$PRE_LIBRARIES -lf90charm -lckf"
1554 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F90LIBS"
1556 "bluegene"|
"bigsim")
1557 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs"
1560 POST_LIBRARIES
="$POST_LIBRARIES -lbluegene"
1563 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1566 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1570 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1571 if [ $CMK_CELL -eq 1 ]
1574 if [ "$LANGUAGE" = "converse++" ]
1576 # Include a "do nothing" register_accel_spe_funcs() function
1577 POST_LIBRARIES
="$POST_LIBRARIES -lnoAccelStub"
1580 if [ "$LANGUAGE" = "charm++" ]
1583 if [ $SPU_USE_CPP -eq 1 ]
1585 SPU_COMPILER
=$CMK_SPU_CXX
1586 SPU_LINKER
=$CMK_SPU_LDXX
1588 SPU_COMPILER
=$CMK_SPU_CC
1589 SPU_LINKER
=$CMK_SPU_LD
1592 # Make the spe object file to be included
1593 Do
$SPU_COMPILER -c -I$CHARMINC $CMK_SYSINC -o main__funcLookup__.genSPECode.o main__funcLookup__.genSPECode.c
-DCMK_CELL_SPE=1
1594 Do
$SPU_LINKER -L$CHARMLIB -o main__funcLookup__.genSPECode main__funcLookup__.genSPECode.o
$CMK_SPERT_LIBS $SPU_EXTRA_LIBS
1595 Do
$CMK_PPU_EMBEDSPU spert_main main__funcLookup__.genSPECode main__funcLookup__.genSPECode.ppe.o
1597 # Include the spe object file for linking into main executable
1598 POST_LIBRARIES
="$POST_LIBRARIES main__funcLookup__.genSPECode.ppe.o"
1603 if [ "$AMPIMAIN" != "" ]
1605 OBJECTFILES
="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1608 if [ "$SWAPGLOBALS" = "1" ]
1610 swapo
="$CHARMLIB/libglobal-swap.a"
1611 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1613 echo "Global-swapping library $swapo missing--"
1614 echo " Is -swapglobals supported on this machine?"
1617 MIDDLE_LIBS
="-lglobal-swap $MIDDLE_LIBS"
1620 if [ "$SWAPGLOBALS" = "2" ]
1622 echo "-copyglobals option is no longer supported by Charm++/AMPI"
1626 if [ $USE_F77_LIBRARIES = "1" ]
1628 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F77LIBS"
1631 if [ $USE_F90_LIBRARIES = "1" ]
1633 if [ ! -r $CHARMLIB/libconv-utilf.a
]
1635 echo "Fortran support library $CHARMLIB/libconv-utilf.a missing"
1636 echo "Is your Fortran compiler working?"
1640 POST_LIBRARIES
="$POST_LIBRARIES -lconv-utilf $CMK_F90LIBS"
1644 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1646 POST_LIBRARIES
="-lmpi-mainmodule $POST_LIBRARIES"
1649 # check if we're linking a sequential object
1651 "c"|
"C"|
"f90"|
"f77")
1654 Do
$CMK_NATIVE_LD $OPTS_LD -o $OBJECT $OBJECTFILES \
1655 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
1657 Do
$CMK_SEQ_LD $OPTS_LD -o $OBJECT $OBJECTFILES \
1658 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
1665 Do
$CMK_NATIVE_LDXX $OPTS_LD -o $OBJECT $OBJECTFILES \
1666 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
1668 Do
$CMK_SEQ_LDXX $OPTS_LD -o $OBJECT $OBJECTFILES \
1669 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
1675 ##############################################################################
1677 # Some quick consistency checks prior to full link-step
1679 # Check for valid choice of TRACEMODE
1680 # Check for valid choice of BALANCE
1681 # Check for compatibility among BALANCE and TRACEMODE
1683 ##############################################################################
1685 Debug
"About to check TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1687 # Check for valid choice of TRACEMODE
1689 # [ -r $CHARMLIB/libtrace-projections.a ] || Abort "trace libraries not installed. Is Charm++ built properly?"
1691 if [ x
"$TRACEMODE" != x
]
1693 for trace
in $TRACEMODE; do
1694 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort
"charmc : No such tracemode $trace"
1695 TRACE_OBJ
="$TRACE_OBJ -ltrace-$trace"
1697 TRACE_OBJ
="$TRACE_OBJ $CMK_LIBZ"
1700 if test x
$LANGUAGE = x
"bgcharm++"
1705 BAL_EXT
=`getExtention $BALANCE`
1706 if [ -z "$BAL_EXT" ]; then
1707 # Balance has no extension-- is a library reference
1708 if [ -f "${CHARMLIB}/libldb-$BALANCE.a" ]; then
1709 BAL_OBJ
="${CHARMLIB}/libldb-$BALANCE.a"
1711 BAL_OBJ
="${CHARMLIBSO}/libldb-$BALANCE.so"
1714 # Balance has some extension-- must be a .o or .a file
1718 Debug
"Finished with BAL_OBJ=$BAL_OBJ, TRACEMODE=$TRACEMODE..."
1720 if [ ! -r "$BAL_OBJ" ]
1722 if [ "$BALANCE" = "$BAL_OBJ" ]
1724 Abort
"Could not find load balancer object $BAL_OBJ"
1726 (cd $CHARMLIB ; ls -al libldb-
*)
1727 Abort
"Unknown load balancer $BALANCE / $BAL_OBJ"
1731 BAL_OBJ
="-lldb-$BALANCE -lconv-ldb"
1733 # Check for valid choice of MEMORY
1735 if [ -f "${CHARMLIB}/libmemory-${MEMORY}.a" ]; then
1736 MEM_OBJ
="${CHARMLIB}/libmemory-${MEMORY}.a"
1738 MEM_OBJ
="${CHARMLIBSO}/libmemory-${MEMORY}.so"
1741 if [ ! -r $MEM_OBJ -o ! -s $MEM_OBJ ]
1743 (cd $CHARMLIB ; list
=`ls libmemory-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
1744 Abort
"charmc : No such memory mode $MEMORY"
1747 MEM_OBJ
="-lmemory-${MEMORY}"
1749 # For memory wrapping around the OS allocator, need to add also the wrapper object
1752 MEM_OBJ
=$MEM_OBJ" -lmemory-os-wrapper"
1756 # Check for valid choice of THREAD
1758 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1760 THREAD
=$CMK_LD_SHARED_THREAD
1762 if [ "$TLSGLOBALS" = "1" ]
1764 # make sure we don't add an extra -tls
1765 if ! echo $THREAD |
grep '\-tls$' > /dev
/null
2> /dev
/null
1767 THREAD
=${THREAD}-tls
1771 if [ -f "${CHARMLIB}/libthreads-${THREAD}.a" ]; then
1772 THREAD_OBJ
="${CHARMLIB}/libthreads-${THREAD}.a"
1774 THREAD_OBJ
="${CHARMLIBSO}/libthreads-${THREAD}.so"
1777 if [ ! -r $THREAD_OBJ -o ! -s $THREAD_OBJ ]
1779 (cd $CHARMLIB ; list
=`ls libthreads-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
1780 Abort
"charmc : No such thread mode $THREAD"
1783 THREAD_OBJ
="-lthreads-${THREAD}"
1785 ################# Build the module initialization function ##################
1786 modInitName
="moduleinit$$"
1787 modInitSrc
="$modInitName.C"
1788 modInitObj
="$modInitName.o"
1789 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
1791 for module
in $MODULES; do
1792 echo "extern void _register$module(void);" >> $modInitSrc
1794 for trace
in $TRACEMODE; do
1795 if test $trace = "summary"
1797 echo " extern void _registerTraceSummary();" >> $modInitSrc
1798 elif test $trace = "projections"
1800 echo " extern void _registerTraceProjections();" >> $modInitSrc
1801 elif test $trace = "simple"
1803 echo " extern void _registerTraceSimple();" >> $modInitSrc
1804 elif test $trace = "Tau"
1806 echo " extern void _registerTraceTau();" >> $modInitSrc
1807 elif test $trace = "utilization"
1809 echo " extern void _registerTraceUtilization();" >> $modInitSrc
1810 elif test $trace = "controlPoints"
1812 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
1813 elif test $trace = "perfReport"
1815 Do
$CP $CHARMBIN/fuzzytree.txt fuzzytree.txt
1816 Do
$CP $CHARMBIN/tree.txt tree.txt
1817 echo " extern void _registerTraceAutoPerf();" >> $modInitSrc
1819 elif test $trace = "all"
1821 echo " extern void _registerTraceProjections();" >> $modInitSrc
1822 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
1823 echo " extern void _registerTraceSummary();" >> $modInitSrc
1826 if test -n "$BALANCER"
1828 echo "extern void LBDefaultCreate(const char *);" >> $modInitSrc
1830 echo "void _registerExternalModules(char **argv) { (void)argv;" >> $modInitSrc
1831 for module
in $MODULES; do
1832 [ -n "$VERBOSE" ] && echo "Adding registration for module $module"
1833 echo " _register$module();" >> $modInitSrc
1835 for trace
in $TRACEMODE; do
1836 if test $trace = "summary"
1838 echo " _registerTraceSummary();" >> $modInitSrc
1839 elif test $trace = "projections"
1841 echo " _registerTraceProjections();" >> $modInitSrc
1842 elif test $trace = "Tau"
1845 echo " _registerTraceTau();" >> $modInitSrc
1846 elif test $trace = "simple"
1848 echo " _registerTraceSimple();" >> $modInitSrc
1849 elif test $trace = "utilization"
1851 echo " _registerTraceUtilization();" >> $modInitSrc
1852 elif test $trace = "controlPoints"
1854 echo " _registerTraceControlPoints();" >> $modInitSrc
1855 elif test $trace = "perfReport"
1857 echo " _registerTraceAutoPerf();" >> $modInitSrc
1858 elif test $trace = "all"
1860 echo " _registerTraceProjections();" >> $modInitSrc
1861 echo " _registerTraceControlPoints();" >> $modInitSrc
1862 echo " _registerTraceSummary();" >> $modInitSrc
1865 if test -n "$BALANCER"
1867 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
1868 for deflb
in $BALANCER
1870 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
1873 echo "}" >> $modInitSrc
1875 # creating projections
1876 echo "void _createTraces(char **argv) { (void)argv;" >> $modInitSrc
1877 for trace
in $TRACEMODE; do
1878 [ -n "$VERBOSE" ] && echo "Adding registration for trace $trace"
1879 echo "extern void _createTrace$trace(char **argv);" >> $modInitSrc
1880 echo "_createTrace$trace(argv);" >> $modInitSrc
1882 echo "}" >> $modInitSrc
1884 Do
$CMK_CXX $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $modInitSrc -o $modInitObj
1886 ###############################################################################
1890 ###############################################################################
1892 Debug
"About to perform final link..."
1897 CORE_LIBS
="-lconv-core -ltmgr -lconv-util -lconv-partition $TRACE_OBJ"
1899 # get TAU stub makefile variables
1900 if test "$CMK_WITH_TAU" = "true"
1902 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1903 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1904 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1905 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1906 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1907 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1908 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1912 # done getting TAU variables
1914 if [ "$BUILD_SHARE" = "0" ]
1916 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1922 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS "
1923 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1924 if [ "$NO_MAIN" = "" ]
1926 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1928 if [ "$TAU_TRACE_MPI" = "1" ]
1930 TAU_LIBS
="$TAU_MPI_FLIBS $TAU_LIBS"
1932 TAU_LIBS
="$TAU_LIBS"
1935 "charm"|
"charm++"|
"f90charm"|
"ckbluegene"|
"bgcharm++")
1937 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS "
1938 if [ "$NO_MAIN" = "" ]
1940 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1942 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1943 if [ "$TAU_TRACE_MPI" = "1" ]
1945 TAU_LIBS
="$TAU_MPI_LIBS $TAU_LIBS"
1947 TAU_LIBS
="$TAU_LIBS"
1952 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-cplus-n $CORE_LIBS -ltrace-converse "
1953 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1955 "converse++"|
"bluegene"|
"bigsim"|
"bgconverse++")
1957 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS -ltrace-converse "
1958 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1961 Abort
"Unrecognized choice of language $LANGUAGE"
1965 if [ "$BUILD_SHARE" = "0" ]
1967 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1970 if [ "$CHARM_SHARED" = "1" ]
1972 [ -z "$CHARMLIBSO" ] && Abort
"Charm++ lib_so directory not found!"
1973 # build user executable/shared lib linking with charm .so
1974 OPTS_LD
="$OPTS_LD $CMK_LD_LIBRARY_PATH"
1975 if [ "$BUILD_SHARE" = "1" ]
1977 LANG_LIBS
="-L$CHARMLIBSO $OBJECTFILES $PRE_LIBRARIES"
1979 LANG_LIBS
="-L$CHARMLIBSO $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1982 # if interoperate, need a lib with moduleinit
1983 if [ "$MPI_INTEROPERATE" != "" ]
1985 LANG_LIBS
="-L$CHARMLIB -I$CHARMINC $CMK_SYSINC $PRE_LIBRARIES"
1987 LANG_LIBS
="-L$CHARMLIB -I$CHARMINC $CMK_SYSINC $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1990 if [ "$TRACE_WITH_TAU" = 1 ]
1992 echo "Linking with the TAU libraries: $TAU_LIBS"
1993 ALL_LIBS
="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS $TAU_LIBS"
1995 ALL_LIBS
="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS"
1997 Debugf
"All libraries are: $ALL_LIBS"
1999 #currently only support creation of .a
2000 if [ "$MPI_INTEROPERATE" != "" ]
2004 # in case building charm so, build .so under lib_so as well # Gengbin
2005 DoNoErrCheck
$RM $OBJECT
2006 echo "$CMK_AR $OBJECT $OBJECTFILES $modInitObj"
2007 Do
$CMK_AR $OBJECT $OBJECTFILES $modInitObj
2008 Do
$CMK_RANLIB $OBJECT
2009 echo "export CHARM_ALL_LIBS=\"$ALL_LIBS\"" > .
/charm_all_libs.sh
2010 echo "CHARM_ALL_LIBS=\"$ALL_LIBS\""
2013 *.so|
*.so.
*|
*.sl|
*.dylib
)
2014 echo "Warning: building shared library failed; for interoperation build
2021 if [ "$MPI_INTEROPERATE" != "" ]
2023 ALL_LIBS
="$OBJECTFILES $modInitObj $ALL_LIBS"
2026 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2028 # build an application .so linking with charm .so
2029 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
2030 Debugf
"Running ldro..."
2031 DoNoErrCheck
$RM $OBJECT
2032 [ "$MAKE_LDXX" = "1" ] && Do
$CMK_LDXX $OPTS_LD $OPTS_LDXX -o $OBJECT $ALL_LIBS
2033 [ "$MAKE_LD" = "1" ] && Do
$CMK_LD $OPTS_LD -o $OBJECT $ALL_LIBS
2036 # Make a regular executable: call the appropriate linker
2037 [ "$MAKE_LDXX" = "1" ] && Do
$CMK_LDXX $OPTS_LD $OPTS_LDXX -o $OBJECT $ALL_LIBS
2038 [ "$MAKE_LD" = "1" ] && Do
$CMK_LD $OPTS_LD -o $OBJECT $ALL_LIBS
2041 ########################################################################
2043 # Copy conv-host to user directory if it is present in installation.
2045 ########################################################################
2047 if test "$COPY_CHARMRUN" = "true"
2049 targ
=charmrun
$CMK_POST_EXE
2050 [ ! -x $CHARMBIN/$targ -a -n "$CMK_POST_EXE" ] && targ
=charmrun
2051 convhost
=conv-host
$CMK_POST_EXE
2053 if [ -x $CHARMBIN/$targ ]
2055 DoNoErrCheck
$RM $targ
2056 Do
$CP $CHARMBIN/$targ $targ
2060 [ -z "$SAVE" ] && DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1