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"
59 EXPLICIT_COMPILATION
="no"
93 ROSE_OMP_TLS_GLOBALS
="no"
109 ####################################################################
111 # Utility routines used below
113 ###################################################################
115 # PrintUsage: prints a helpful command-line usage message and quits
116 # Args: any additional messages
120 echo "Usage: charmc [ flags ] <files>"
123 echo " -o <target> -g -O"
124 echo " -D<define> -I<include path> -L<lib path> -l<library> -s"
125 echo " -machine <mach> -seq -host -language <lang> -pg <opt>"
126 echo " -balance <mode> -tracemode <mode> -memory <mode>"
127 echo " -modules <comma-separated list of C++ modules> -thread"
128 echo " -debug-script -count-tokens -default-to-aout -E -S -M"
129 echo " -verbose -save -purify -cp <dest> -cpmod -gen-cpm <pkg>"
130 echo " -swapglobals -copyglobals -tlsglobals -roseomptlsglobals"
131 echo " -use-reliable-cc -use-fastest-cc -use-new-std"
132 echo " -cc <new cc> -c++ <new CC> -ld <new ld> -ld++ <new LD>"
133 echo " -cpp-option <opt> -ldro-option <opt> -cc-option <opt>"
134 echo " -c++-option <opt> -ld-option <opt> -ld++-option <opt>"
135 echo " -f90 <new f90> -f90-option <opt> -fmoddir <f90mod path>"
136 echo " -flibs -rpath <path> -custom-part -touch-on-failure"
137 echo " -mpi -openmp -no-trace-mpi -build-shared -charm-shared"
138 echo " -no-charmrun -no-preprocess-ci -nomain-module -nomain"
139 echo " -nof90main -f90main"
141 echo " Charmc compiles C, C++, f77, f90, AMPI, Converse, Converse++, Charm, "
142 echo "and Charm++ programs. The flags generally match those of cc or f77."
143 echo "Parallel Programming Lab, UIUC, 2016."
148 # End blows away the temporary files (unless SAVE is true) and exits
153 for FILE
in `echo $FILES`
155 #BASE=`stripExtention $FILE`
156 TMP
=`basename $FILE`".TMP"
157 $RM $TMP.P.C
$TMP.cpp
$TMP.space
$TMP.xlat
$TMP.o
158 $RM $TMP.c
$TMP.c
.0.h
$TMP.c
.1.h
$TMP.c
.2.h
159 $RM $TMP.i
$TMP.
$CMK_CPP_SUFFIX
162 if test -n "$modInitObj"
164 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
165 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
171 # Write this error message to stderr
172 # ("1>&2" redirects the echo output to stderr).
177 # This procedure prints an error message and exits.
178 # Args: written to stderr
180 Warning
"Fatal Error by charmc in directory "`pwd`
182 Warning
"charmc exiting..."
187 # Instead of an ECHO_CMD variable, I define a procedure Do,
188 # which (possibly) echos, runs, and tests the errors of the given command.
189 # Args: executed as given
191 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
198 # The UNIX result code better be zero, or we die
199 [ $Do_res -eq 0 -o -n "$NOABORT" ] || Abort
"Command $@ returned error code $Do_res"
202 # This procedure removes the extention (the ".c" in "./main.c") from
203 # its first argument, and prints the result. Unlike the builtin command
204 # basename, it keeps the directory path.
205 # Args: <name to strip>
207 se_base
=`basename $1`
208 # se_base=`echo $1 | awk -F/ '{print $NF}'`
209 se_strip
=`echo $se_base | awk -F. '{ORS="";print $1;for (i=2;i<NF;i++) print "."$i}'`
210 se_ret
=`echo $1 | awk -F/ '{ORS="";for (i=1;i<NF;i++) print $i"/"}'`"$se_strip"
214 # GetExtention returns the extention on the given file name
215 # or "" if none. (e.g. "./bob/snack.c" returns ".c")
216 # Args: <name to find extention of>
218 # se_base=`echo $1 | awk -F/ '{print $NF}'`
219 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
221 se_ret
=`echo $1 | sed -e 's/.*\././'`
222 if test "$se_ret" = $1
231 [ -n "$VERBOSE" ] && echo "charmc>" $@
235 if [ -n "$DEBUG_SCRIPT" ]
238 echo "------- Charmc Debugging info: $* -------"
239 echo "CHARMBIN=$CHARMBIN"
240 echo "CHARMINC=$CHARMINC"
241 echo "CHARMLIB=$CHARMLIB"
243 echo "DELETE=$DELETE"
244 echo "OBJECT=$OBJECT"
245 echo "LANGUAGE=$LANGUAGE"
246 # echo "Working directory="`pwd`
250 # Return success if $1 is not in any of the other arguments
256 if [ "$search" = "$1" ]
258 # It's already in there-- fail
263 # It's missing--succeed
267 # Add arguments to our modules list, avoiding duplicates
271 notInList
$M $MODULES && MODULES
="$MODULES $M"
275 # Add this word to this list, avoiding duplicates
290 # TEMP_BASE is appended with this script's process ID (PID),
291 # so multiple charmcs can run in parallel without overwriting
292 # each other's temporary files.
293 TEMP_BASE
="/tmp/charmc_tmp.$$"
295 # Try to find CHARMBIN by looking in directory where charmc is
297 if [ -z "$CHARMBIN" ]
300 CHARMBIN
=`dirname $SCRIPT`
301 # CHARMBIN=`cd $CHARMBIN; pwd`
302 # NOTE: this script no longer tries to follow soft links
303 # to find the "original" charmc-- if this is bad,
304 # translate these lines to Bourne shell from C shell:
305 # -------------------- Begin C Shell ------------------------->
306 # if ($SCRIPT:h != $SCRIPT:t) then
308 # set SCRIPT=$SCRIPT:t
310 # foreach dir ($path)
311 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
317 # while (x`find $SCRIPT -type l -print` == x$SCRIPT)
318 # set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
319 # if ($SCRIPT:h != $SCRIPT:t) then
321 # set SCRIPT=$SCRIPT:t
325 # <------------------ End C Shell -----------------------------
332 version
=`cat $CHARMBIN/../include/VERSION`
333 echo Charm
++ Version
$version
337 ##############################################################################
339 # The following section identifies CHARMBIN, the charm binary-directory.
341 ##############################################################################
345 # Try to find CHARMBIN by looking in directory where charmc is
350 FIRST_THREE
=`uname -s | awk '{print substr($1,1,3)}' `
351 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
353 # Running on a windows system-- append .exe to file names
357 CHARMLIB
="$CHARMBIN/../lib"
358 CHARMINC
="$CHARMBIN/../include"
360 if test -d "$CHARMBIN/../lib_so"
362 CHARMLIBSO
=`cd $CHARMBIN/../lib_so 2>/dev/null && pwd`
363 #getting absolute path is harder than thought because of symbolic links and ..
364 #ksh needs cd -P to resolve werid symbolic links, however -P is not portable
365 #csh is ok too if it exists
366 test -z "$CHARMLIBSO" && CHARMLIBSO
=`cd -P $CHARMBIN/../lib_so 2>/dev/null && pwd`
367 test -z "$CHARMLIBSO" && CHARMLIBSO
=`csh -c "cd $CHARMBIN/../lib_so >& /dev/null && pwd"`
368 test -z "$CHARMLIBSO" && echo "$CHARMBIN/../lib_so: not found" && exit 1
371 ##############################################################################
373 # Parse the arguments
375 # Don't do any analysis in here, just the parsing.
377 ##############################################################################
379 [ $# -eq 0 ] && printUsage
"Error: No arguments given."
407 # Parse out some fake languages (that are actually modules)
409 "ampi") AddModules tcharmmain ampi
;;
410 "ampif") AddModules tcharmmain ampif
; USE_F90_LIBRARIES
="1" ;;
411 "armci") AddModules tcharmmain armci
;;
412 "armcif") AddModules tcharmmain armci
; USE_F90_LIBRARIES
="1" ;;
413 "fem") AddModules tcharmmain fem
; AMPIMAIN
="femmain";;
414 "femf") AddModules tcharmmain fem
; AMPIMAIN
="femmain"; USE_F90_LIBRARIES
="1" ;;
415 "ParFUM_TOPS") AddModules tcharmmain ParFUM ParFUM_TOPS
; AMPIMAIN
="ParFUMmain";;
416 "ParFUM") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain";;
417 "ParFUMf") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain"; USE_F90_LIBRARIES
="1" ;;
418 "mblock") AddModules tcharmmain mblock
;;
419 "mblockf") AddModules tcharmmain mblock
; USE_F90_LIBRARIES
="1" ;;
429 # Requested support from charmdebug: add some modules and libraries
434 "-module"|
"-modules")
435 AddModules
`echo $1 | sed -e 's/,/ /g'`
440 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
441 BALANCER
="$BALANCER $1"
442 mod
=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
453 Warning
"Warning: -queue currently being ignored."
468 TRACEMODE_NEW
=`AddList $TRACEMODE $1`
469 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
471 Warning
"Warning: Duplicate tracemode $1 ignored"
473 TRACEMODE
=$TRACEMODE_NEW
481 "-swapglobal"|
"-swapglobals")
486 "-copyglobal"|
"-copyglobals")
491 "-tlsglobal"|
"-tlsglobals")
495 "-roseomptlsglobals")
496 ROSE_OMP_TLS_GLOBALS
="yes"
500 echo "Verbose mode set"
509 SPU_EXTRA_LIBS
="$SPU_EXTRA_LIBS -l$1"
518 echo "Will give excessive charmc debugging output..."
564 OPTS_CPP
="$OPTS_CPP $1"
569 OPTS_LDRO
="$OPTS_LDRO $1"
574 OPTS_CC
="$OPTS_CC $1"
579 OPTS_CXX
="$OPTS_CXX $1"
584 OPTS_F90
="$OPTS_F90 $1"
589 OPTS_LD
="$OPTS_LD $1"
594 OPTS_LDXX
="$OPTS_LDXX $1"
599 OPTS_LDXX
="$OPTS_LDXX -rpath $1"
603 "-fortran"|
"-flib"|
"-flibs")
604 USE_F90_LIBRARIES
="1"
609 "-fortran77"|
"-f77lib"|
"-f77libs")
610 USE_F77_LIBRARIES
="1"
613 # Run preprocessor only
619 # Run preprocessor as an extra step, continue after preprocessing
623 # Turn off the preprocessor for ci files
627 # Run preprocessor/assembler only
641 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
647 echo $arg | cut
-d'=' -f2
651 if [ "$EXPLICIT_OBJECT" = "no" ]
655 EXPLICIT_COMPILATION
="yes"
659 EXPLICIT_OBJECT
="yes"
670 MODCOPIES
="$1 $MODCOPIES"
680 OPTS_CPP
="$OPTS_CPP -I$1"
685 if echo "$arg" |
grep ' ' > /dev
/null
2>/dev
/null
687 OPTS_CPP
="$OPTS_CPP "\"$arg\"
689 OPTS_CPP
="$OPTS_CPP $arg"
710 Warning
"passing unrecognized option $arg to all compilers and linkers"
717 OPTS_LD
="$OPTS_LD $arg"
723 # used internally when building Charm++ to create lib_so
727 # used internally not to build Charm++ lib_so
742 PRODUCTION_MODE
=false
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 for FILE
in `echo $GENCPM`
1252 # This used to be "$FILE:r", which strips the extention
1253 BASE
=`stripExtention $FILE`
1254 TMP
=`basename $FILE`".TMP"
1255 DELETE
="$DELETE $TMP.c $TMP.i"
1256 DoNoErrCheck
$RM $BASE.cpm.h
$TMP.c
1257 Do
touch $BASE.cpm.h
1258 Do
$LN -f -s $FILE $TMP.c
1259 Do
$CMK_CPP_C -I$CHARMINC $CMK_SYSINC $OPTS_CC $OPTS_CPP $TMP.c
> $TMP.i
1260 Do
$CHARMBIN/conv-cpm
$TMP.i
$BASE.cpm.h
1263 ##############################################################################
1265 # Compile all specified files
1267 # All temporary files named *.TMP.* for easy cleanup.
1269 ##############################################################################
1271 Debug
"About to compile..."
1273 numFiles
=`echo $FILES | wc -w`
1274 for FILE
in `echo $FILES`
1276 BASE
=`stripExtention \`basename $FILE\
``
1277 TMP
=`basename $FILE`".TMP"
1278 FILE_EXT
=`getExtention $FILE`
1282 # in case of: charmc -o object.o -c foo.c,
1283 # avoid foo.c => remove foo.o => foo.o => object.o,
1284 # instead generate object.o directly.
1285 # remove and generate foo.o may be dangerous in parallel make
1286 # for example in the case of compiling several objs from one
1287 # same c file such as memory.c.
1288 if [ $numFiles = 1 -a -n "$OBJECT" ]
1290 OBJ_EXT
=`getExtention $OBJECT`
1291 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1298 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1301 .c|.s|.C|.cc|.cxx|.cpp|.c
++|.cu|.f|.F|.f90|.F90
)
1302 [ $VERBOSE ] && echo "Compiling $FILE"
1303 DoNoErrCheck
$RM $BASEO $BASE.f.o
1306 if [ ! -z "$SKIPLINK" ]
1312 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1316 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1319 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++)
1320 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE
1324 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1328 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1329 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE
1338 test "$LANGUAGE" = "f90charm" && XIOPTS
="$XIOPTS -f90"
1339 if [ "$PREPROCESS_CI" = "yes" ]
1341 Do
$CMK_CPP_CHARM $OPTS_CPP $FILE | Do
$CHARMBIN/charmxi
$XIOPTS -orig-file $FILE
1343 Do
$CHARMBIN/charmxi
$XIOPTS $FILE
1347 Do
$CMK_CC -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE $DESTO
1349 if [ "$Do_res" -ne 0 ]
1355 Do
$CMK_GCXX -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE $DESTO
1358 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu
)
1359 Do
$CMK_CXX -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE $DESTO
1361 if [ "$Do_res" -ne 0 ]
1367 test -z "$CMK_CF90_FIXED" && Abort
"No F90 compiler (CMK_CF90_FIXED) defined"
1368 Do
$CMK_CF90_FIXED -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE $DESTO
1370 if [ "$Do_res" -ne 0 ]
1376 test -z "$CMK_CF90" && Abort
"No F90 compiler (CMK_CF90) defined"
1377 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1378 Do
$CMK_CF90 -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE $DESTO
1380 if [ "$Do_res" -ne 0 ]
1386 Abort
"I'm not yet smart enough to compile $FILE"
1388 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
1389 [ ! -s $FILE ] && Abort
"$FILE: file not recognized: File truncated"
1390 OBJECTFILES
="$OBJECTFILES $FILE"
1398 Abort
"file with unrecognized extension $FILE"
1400 # Handle new object files
1401 if [ -n "$NU_OBJ" -a -n "$OBJECT" ]
1403 if [ "$OBJECT" != "$BASEO" ]
1405 DELETE
="$DELETE $NU_OBJ"
1407 OBJECTFILES
="$OBJECTFILES $NU_OBJ"
1411 ##############################################################################
1413 # POSSIBLY, SKIP LINK-STEP
1415 # 1. No $OBJECT may be specified at all --- its just a compilation.
1416 # 2. If $OBJECT is a ".a" file, a library is created from $OBJECTFILES.
1417 # 3. If $OBJECT is a ".o" file, then an "LDRO" is created from $OBJECTFILES.
1418 # 4. Language may be sequential. Do a quick and easy linkage.
1420 # in any of these cases, the full link step is skipped.
1422 ##############################################################################
1425 Debugf
"Running ldro..."
1426 DoNoErrCheck
$RM $OBJECT
1427 # convert to absolute path if required
1428 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1430 dir
=`dirname $OBJECT`
1431 fname
=`basename $OBJECT`
1435 Warning
"Warning: creating $OBJECT "
1436 if test "$MAKE_LDXX" = "1"
1438 soCmd
="$CMK_LDXX -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1440 soCmd
="$CMK_LD -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1444 if [ $Do_res -ne 0 ]
1450 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1451 echo "!! Failed to compile Charm++ shared library. You can disable shared !!"
1452 echo "!! lib compilation by providing --no-build-shared build option like: !!"
1453 echo "!! ./build charm++ net-linux --no-build-shared -O !!"
1454 echo "!! or reexecute this charmc command with --no-build-shared compile option !!"
1455 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1456 Abort
"Command $soCmd returned error code $Do_res"
1462 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
1464 # We have no target object, or are playing preprocessor tricks-- just end
1465 Debugf
"No target object-- finished"
1469 Debug
"About to link..."
1471 # if interoperate dont create the library now, wait to collect all info
1472 if [ "$MPI_INTEROPERATE" = "" ]
1476 Debugf
"Converting $FILES to $OBJECTFILES"
1477 nFiles
=`echo $FILES | wc -w`
1478 nObj
=`echo $OBJECTFILES | wc -w`
1479 # One source file, one .o: just move the .o
1480 if [ $OBJECT != $OBJECTFILES ]
1482 Debugf
"Moving .o to destination"
1483 DoNoErrCheck
$RM $OBJECT
1484 Do
$MV $OBJECTFILES $OBJECT
1488 *.so|
*.so.
*|
*.sl|
*.dylib
)
1489 # Make shared library
1490 # if no build share is set, exit normally.
1491 if [ "$BUILD_SHARE" = 0 ]
1493 echo "Warning: building shared library is skipped, possibly due to not supported, check configuration files."
1495 elif [ "$CHARM_SHARED" = "0" ]
1501 # Make regular (.a, non-shared) library
1502 # in case building charm so, build .so under lib_so as well # Gengbin
1503 if [ "$BUILD_SHARE" = "1" ]
1510 DESTDIR
=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
1511 OBJECT
=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
1513 COPYTO
=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
1516 OBJECT
=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
1517 [ -f $DESTDIR/.charmso
] && MakeSO
1523 DoNoErrCheck
$RM $OBJECT
1524 Do
$CMK_AR $OBJECT $OBJECTFILES
1525 Do
$CMK_RANLIB $OBJECT
1530 # If the above case returns, we're not creating a .o or .a file,
1531 # so linking is needed.
1533 ############ Determine the language and libraries ##########
1535 # Parse out the real languages
1539 USE_F90_LIBRARIES
="1"
1542 PRE_LIBRARIES
="$PRE_LIBRARIES -lf90charm -lckf"
1543 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F90LIBS"
1545 "bluegene"|
"bigsim")
1546 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs"
1549 POST_LIBRARIES
="$POST_LIBRARIES -lbluegene"
1552 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1555 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1559 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1560 if [ $CMK_CELL -eq 1 ]
1563 if [ "$LANGUAGE" = "converse++" ]
1565 # Include a "do nothing" register_accel_spe_funcs() function
1566 POST_LIBRARIES
="$POST_LIBRARIES -lnoAccelStub"
1569 if [ "$LANGUAGE" = "charm++" ]
1572 if [ $SPU_USE_CPP -eq 1 ]
1574 SPU_COMPILER
=$CMK_SPU_CXX
1575 SPU_LINKER
=$CMK_SPU_LDXX
1577 SPU_COMPILER
=$CMK_SPU_CC
1578 SPU_LINKER
=$CMK_SPU_LD
1581 # Make the spe object file to be included
1582 Do
$SPU_COMPILER -c -I$CHARMINC $CMK_SYSINC -o main__funcLookup__.genSPECode.o main__funcLookup__.genSPECode.c
-DCMK_CELL_SPE=1
1583 Do
$SPU_LINKER -L$CHARMLIB -o main__funcLookup__.genSPECode main__funcLookup__.genSPECode.o
$CMK_SPERT_LIBS $SPU_EXTRA_LIBS
1584 Do
$CMK_PPU_EMBEDSPU spert_main main__funcLookup__.genSPECode main__funcLookup__.genSPECode.ppe.o
1586 # Include the spe object file for linking into main executable
1587 POST_LIBRARIES
="$POST_LIBRARIES main__funcLookup__.genSPECode.ppe.o"
1592 if [ "$AMPIMAIN" != "" ]
1594 OBJECTFILES
="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1597 if [ "$SWAPGLOBALS" = "1" ]
1599 swapo
="$CHARMLIB/libglobal-swap.a"
1600 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1602 echo "Global-swapping library $swapo missing--"
1603 echo " Is -swapglobals supported on this machine?"
1606 MIDDLE_LIBS
="-lglobal-swap $MIDDLE_LIBS"
1609 if [ "$SWAPGLOBALS" = "2" ]
1611 swapo
="$CHARMLIB/libglobal-copy.a"
1612 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1614 echo "Global-copying library $swapo missing--"
1615 echo " Is -copyglobals supported on this machine?"
1618 MIDDLE_LIBS
="-lglobal-copy $MIDDLE_LIBS"
1622 if [ $USE_F77_LIBRARIES = "1" ]
1624 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F77LIBS"
1627 if [ $USE_F90_LIBRARIES = "1" ]
1629 if [ ! -r $CHARMLIB/libconv-utilf.a
]
1631 echo "Fortran support library $CHARMLIB/libconv-utilf.a missing"
1632 echo "Is your Fortran compiler working?"
1636 POST_LIBRARIES
="$POST_LIBRARIES -lconv-utilf $CMK_F90LIBS"
1640 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1642 POST_LIBRARIES
="-lmpi-mainmodule $POST_LIBRARIES"
1645 # check if we're linking a sequential object
1647 "c"|
"C"|
"f90"|
"f77")
1650 Do
$CMK_NATIVE_LD $OPTS_LD -o $OBJECT $OBJECTFILES \
1651 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
1653 Do
$CMK_SEQ_LD $OPTS_LD -o $OBJECT $OBJECTFILES \
1654 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
1661 Do
$CMK_NATIVE_LDXX $OPTS_LD -o $OBJECT $OBJECTFILES \
1662 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
1664 Do
$CMK_SEQ_LDXX $OPTS_LD -o $OBJECT $OBJECTFILES \
1665 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
1671 ##############################################################################
1673 # Some quick consistency checks prior to full link-step
1675 # Check for valid choice of TRACEMODE
1676 # Check for valid choice of BALANCE
1677 # Check for compatibility among BALANCE and TRACEMODE
1679 ##############################################################################
1681 Debug
"About to check TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1683 # Check for valid choice of TRACEMODE
1685 # [ -r $CHARMLIB/libtrace-projections.a ] || Abort "trace libraries not installed. Is Charm++ built properly?"
1687 if [ x
"$TRACEMODE" != x
]
1689 for trace
in $TRACEMODE; do
1690 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort
"charmc : No such tracemode $trace"
1691 TRACE_OBJ
="$TRACE_OBJ -ltrace-$trace"
1693 TRACE_OBJ
="$TRACE_OBJ $CMK_LIBZ"
1696 if test x
$LANGUAGE = x
"bgcharm++"
1701 BAL_EXT
=`getExtention $BALANCE`
1702 if [ -z "$BAL_EXT" ]; then
1703 # Balance has no extension-- is a library reference
1704 if [ -f "${CHARMLIB}/libldb-$BALANCE.a" ]; then
1705 BAL_OBJ
="${CHARMLIB}/libldb-$BALANCE.a"
1707 BAL_OBJ
="${CHARMLIBSO}/libldb-$BALANCE.so"
1710 # Balance has some extension-- must be a .o or .a file
1714 Debug
"Finished with BAL_OBJ=$BAL_OBJ, TRACEMODE=$TRACEMODE..."
1716 if [ ! -r "$BAL_OBJ" ]
1718 if [ "$BALANCE" = "$BAL_OBJ" ]
1720 Abort
"Could not find load balancer object $BAL_OBJ"
1722 (cd $CHARMLIB ; ls -al libldb-
*)
1723 Abort
"Unknown load balancer $BALANCE / $BAL_OBJ"
1727 BAL_OBJ
="-lldb-$BALANCE -lconv-ldb"
1729 # Check for valid choice of MEMORY
1731 if [ -f "${CHARMLIB}/libmemory-${MEMORY}.a" ]; then
1732 MEM_OBJ
="${CHARMLIB}/libmemory-${MEMORY}.a"
1734 MEM_OBJ
="${CHARMLIBSO}/libmemory-${MEMORY}.so"
1737 if [ ! -r $MEM_OBJ -o ! -s $MEM_OBJ ]
1739 (cd $CHARMLIB ; list
=`ls libmemory-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
1740 Abort
"charmc : No such memory mode $MEMORY"
1743 MEM_OBJ
="-lmemory-${MEMORY}"
1745 # For memory wrapping around the OS allocator, need to add also the wrapper object
1748 MEM_OBJ
=$MEM_OBJ" -lmemory-os-wrapper"
1752 # Check for valid choice of THREAD
1754 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1756 THREAD
=$CMK_LD_SHARED_THREAD
1758 if [ "$TLSGLOBALS" = "1" ]
1760 # make sure we don't add an extra -tls
1761 if ! echo $THREAD |
grep '\-tls$' > /dev
/null
2> /dev
/null
1763 THREAD
=${THREAD}-tls
1767 if [ -f "${CHARMLIB}/libthreads-${THREAD}.a" ]; then
1768 THREAD_OBJ
="${CHARMLIB}/libthreads-${THREAD}.a"
1770 THREAD_OBJ
="${CHARMLIBSO}/libthreads-${THREAD}.so"
1773 if [ ! -r $THREAD_OBJ -o ! -s $THREAD_OBJ ]
1775 (cd $CHARMLIB ; list
=`ls libthreads-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
1776 Abort
"charmc : No such thread mode $THREAD"
1779 THREAD_OBJ
="-lthreads-${THREAD}"
1781 ################# Build the module initialization function ##################
1782 modInitName
="moduleinit$$"
1783 modInitSrc
="$modInitName.C"
1784 modInitObj
="$modInitName.o"
1785 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
1787 for module
in $MODULES; do
1788 echo "extern void _register$module(void);" >> $modInitSrc
1790 for trace
in $TRACEMODE; do
1791 if test $trace = "summary"
1793 echo " extern void _registerTraceSummary();" >> $modInitSrc
1794 elif test $trace = "projections"
1796 echo " extern void _registerTraceProjections();" >> $modInitSrc
1797 elif test $trace = "simple"
1799 echo " extern void _registerTraceSimple();" >> $modInitSrc
1800 elif test $trace = "Tau"
1802 echo " extern void _registerTraceTau();" >> $modInitSrc
1803 elif test $trace = "utilization"
1805 echo " extern void _registerTraceUtilization();" >> $modInitSrc
1806 elif test $trace = "controlPoints"
1808 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
1809 elif test $trace = "all"
1811 echo " extern void _registerTraceProjections();" >> $modInitSrc
1812 echo " extern void _registerTraceSummary();" >> $modInitSrc
1815 if test -n "$BALANCER"
1817 echo "extern void LBDefaultCreate(const char *);" >> $modInitSrc
1819 echo "void _registerExternalModules(char **argv) {" >> $modInitSrc
1820 for module
in $MODULES; do
1821 [ -n "$VERBOSE" ] && echo "Adding registration for module $module"
1822 echo " _register$module();" >> $modInitSrc
1824 for trace
in $TRACEMODE; do
1825 if test $trace = "summary"
1827 echo " _registerTraceSummary();" >> $modInitSrc
1828 elif test $trace = "projections"
1830 echo " _registerTraceProjections();" >> $modInitSrc
1831 elif test $trace = "Tau"
1834 echo " _registerTraceTau();" >> $modInitSrc
1835 elif test $trace = "simple"
1837 echo " _registerTraceSimple();" >> $modInitSrc
1838 elif test $trace = "utilization"
1840 echo " _registerTraceUtilization();" >> $modInitSrc
1841 elif test $trace = "controlPoints"
1843 echo " _registerTraceControlPoints();" >> $modInitSrc
1844 elif test $trace = "all"
1846 echo " _registerTraceProjections();" >> $modInitSrc
1847 echo " _registerTraceSummary();" >> $modInitSrc
1850 if test -n "$BALANCER"
1852 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
1853 for deflb
in $BALANCER
1855 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
1858 echo "}" >> $modInitSrc
1860 # creating projections
1861 echo "void _createTraces(char **argv) {" >> $modInitSrc
1862 for trace
in $TRACEMODE; do
1863 [ -n "$VERBOSE" ] && echo "Adding registration for trace $trace"
1864 echo "extern void _createTrace$trace(char **argv);" >> $modInitSrc
1865 echo "_createTrace$trace(argv);" >> $modInitSrc
1867 echo "}" >> $modInitSrc
1869 Do
$CMK_CXX $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $modInitSrc -o $modInitObj
1871 ###############################################################################
1875 ###############################################################################
1877 Debug
"About to perform final link..."
1882 CORE_LIBS
="-lconv-core -lconv-util -lconv-partition $TRACE_OBJ "
1884 # get TAU stub makefile variables
1885 if test "$CMK_WITH_TAU" = "true"
1887 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1888 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1889 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1890 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1891 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1892 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1893 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1897 # done getting TAU variables
1899 if [ "$BUILD_SHARE" = "0" ]
1901 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1907 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS "
1908 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1909 if [ "$NO_MAIN" = "" ]
1911 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1913 if [ "$TAU_TRACE_MPI" = "1" ]
1915 TAU_LIBS
="$TAU_MPI_FLIBS $TAU_LIBS"
1917 TAU_LIBS
="$TAU_LIBS"
1920 "charm"|
"charm++"|
"f90charm"|
"ckbluegene"|
"bgcharm++")
1922 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS "
1923 if [ "$NO_MAIN" = "" ]
1925 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1927 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1928 if [ "$TAU_TRACE_MPI" = "1" ]
1930 TAU_LIBS
="$TAU_MPI_LIBS $TAU_LIBS"
1932 TAU_LIBS
="$TAU_LIBS"
1937 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-cplus-n $CORE_LIBS -ltrace-converse "
1938 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1940 "converse++"|
"bluegene"|
"bigsim"|
"bgconverse++")
1942 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS -ltrace-converse "
1943 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1946 Abort
"Unrecognized choice of language $LANGUAGE"
1950 if [ "$BUILD_SHARE" = "0" ]
1952 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1955 if [ "$CHARM_SHARED" = "1" ]
1957 [ -z "$CHARMLIBSO" ] && Abort
"Charm++ lib_so directory not found!"
1958 # build user executable/shared lib linking with charm .so
1959 OPTS_LD
="$OPTS_LD $CMK_LD_LIBRARY_PATH"
1960 if [ "$BUILD_SHARE" = "1" ]
1962 LANG_LIBS
="-L$CHARMLIBSO $OBJECTFILES $PRE_LIBRARIES"
1964 LANG_LIBS
="-L$CHARMLIBSO $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1967 # if interoperate, need a lib with moduleinit
1968 if [ "$MPI_INTEROPERATE" != "" ]
1970 LANG_LIBS
="-L$CHARMLIB -I$CHARMINC $CMK_SYSINC $PRE_LIBRARIES"
1972 LANG_LIBS
="-L$CHARMLIB -I$CHARMINC $CMK_SYSINC $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1975 if [ "$TRACE_WITH_TAU" = 1 ]
1977 echo "Linking with the TAU libraries: $TAU_LIBS"
1978 ALL_LIBS
="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS $TAU_LIBS"
1980 ALL_LIBS
="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS"
1982 Debugf
"All libraries are: $ALL_LIBS"
1984 #currently only support creation of .a
1985 if [ "$MPI_INTEROPERATE" != "" ]
1989 # in case building charm so, build .so under lib_so as well # Gengbin
1990 DoNoErrCheck
$RM $OBJECT
1991 echo "$CMK_AR $OBJECT $OBJECTFILES $modInitObj"
1992 Do
$CMK_AR $OBJECT $OBJECTFILES $modInitObj
1993 Do
$CMK_RANLIB $OBJECT
1994 echo "export CHARM_ALL_LIBS=\"$ALL_LIBS\"" > .
/charm_all_libs.sh
1995 echo "CHARM_ALL_LIBS=\"$ALL_LIBS\""
1998 *.so|
*.so.
*|
*.sl|
*.dylib
)
1999 echo "Warning: building shared library failed; for interoperation build
2006 if [ "$MPI_INTEROPERATE" != "" ]
2008 ALL_LIBS
="$OBJECTFILES $modInitObj $ALL_LIBS"
2011 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2013 # build an application .so linking with charm .so
2014 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
2015 Debugf
"Running ldro..."
2016 DoNoErrCheck
$RM $OBJECT
2017 [ "$MAKE_LDXX" = "1" ] && Do
$CMK_LDXX $OPTS_LD $OPTS_LDXX -o $OBJECT $ALL_LIBS
2018 [ "$MAKE_LD" = "1" ] && Do
$CMK_LD $OPTS_LD -o $OBJECT $ALL_LIBS
2021 # Make a regular executable: call the appropriate linker
2022 [ "$MAKE_LDXX" = "1" ] && Do
$CMK_LDXX $OPTS_LD $OPTS_LDXX -o $OBJECT $ALL_LIBS
2023 [ "$MAKE_LD" = "1" ] && Do
$CMK_LD $OPTS_LD -o $OBJECT $ALL_LIBS
2026 ########################################################################
2028 # Copy conv-host to user directory if it is present in installation.
2030 ########################################################################
2032 if test "$COPY_CHARMRUN" = "true"
2034 targ
=charmrun
$CMK_POST_EXE
2035 [ ! -x $CHARMBIN/$targ -a -n "$CMK_POST_EXE" ] && targ
=charmrun
2036 convhost
=conv-host
$CMK_POST_EXE
2038 if [ -x $CHARMBIN/$targ ]
2040 DoNoErrCheck
$RM $targ
2041 Do
$CP $CHARMBIN/$targ $targ
2045 [ -z "$SAVE" ] && DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1