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.
41 #Generic options, passed to everything
44 #charm internal flag, only pass to c and cxx, not f90
45 OPTS_CPP_INTERNAL
="-D__CHARMC__=1"
61 EXPLICIT_COMPILATION
="no"
96 ROSE_OMP_TLS_GLOBALS
="no"
97 PRINT_BUILDING_BLOCKS
=""
100 TAU_MAKEFILE
=Make.tau
114 ####################################################################
116 # Utility routines used below
118 ###################################################################
120 # PrintUsage: prints a helpful command-line usage message and quits
121 # Args: any additional messages
125 echo "Usage: charmc [ flags ] <files>"
128 echo " -o <target> -g -O"
129 echo " -D<define> -I<include path> -L<lib path> -l<library> -s"
130 echo " -machine <mach> -seq -host -language <lang> -pg <opt>"
131 echo " -balance <mode> -tracemode <mode> -memory <mode>"
132 echo " -modules <comma-separated list of C++ modules> -thread"
133 echo " -debug-script -count-tokens -default-to-aout -E -S -M"
134 echo " -verbose -save -purify -cp <dest> -cpmod -gen-cpm <pkg>"
135 echo " -swapglobals -tlsglobals -roseomptlsglobals"
136 echo " -use-reliable-cc -use-fastest-cc -use-new-std"
137 echo " -cc <new cc> -c++ <new CC> -ld <new ld> -ld++ <new LD>"
138 echo " -cpp-option <opt> -ldro-option <opt> -cc-option <opt>"
139 echo " -c++-option <opt> -ld-option <opt> -ld++-option <opt>"
140 echo " -f90 <new f90> -f90-option <opt> -fmoddir <f90mod path>"
141 echo " -flibs -rpath <path> -custom-part -touch-on-failure"
142 echo " -mpi -openmp -no-trace-mpi -build-shared -charm-shared"
143 echo " -no-charmrun -no-preprocess-ci -nomain-module -nomain"
144 echo " -nof90main -f90main"
146 echo " Charmc compiles C, C++, f77, f90, AMPI, Converse, Converse++, Charm, "
147 echo "and Charm++ programs. The flags generally match those of cc or f77."
148 echo " Other options that are not listed here will be passed directly to the"
149 echo "underlying compiler and/or linker."
150 echo "Parallel Programming Lab, UIUC, 2018."
155 # End blows away the temporary files (unless SAVE is true) and exits
160 for FILE
in `echo $FILES`
162 #BASE=`stripExtention $FILE`
163 TMP
=`basename $FILE`".TMP"
164 $RM $TMP.P.C
$TMP.cpp
$TMP.space
$TMP.xlat
$TMP.o
165 $RM $TMP.c
$TMP.c
.0.h
$TMP.c
.1.h
$TMP.c
.2.h
166 $RM $TMP.i
$TMP.
$CMK_CPP_SUFFIX
169 if [ -z "$SKIP_MODULEINIT" -a -n "$modInitObj" ]
171 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
172 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
178 # Write this error message to stderr
179 # ("1>&2" redirects the echo output to stderr).
184 # This procedure prints an error message and exits.
185 # Args: written to stderr
187 Warning
"Fatal Error by charmc in directory "`pwd`
189 Warning
"charmc exiting..."
194 # Instead of an ECHO_CMD variable, I define a procedure Do,
195 # which (possibly) echos, runs, and tests the errors of the given command.
196 # Args: executed as given
198 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
205 # The UNIX result code better be zero, or we die
206 [ $Do_res -eq 0 -o -n "$NOABORT" ] || Abort
"Command $@ returned error code $Do_res"
209 # This procedure removes the extention (the ".c" in "./main.c") from
210 # its first argument, and prints the result. Unlike the builtin command
211 # basename, it keeps the directory path.
212 # Args: <name to strip>
214 se_base
=`basename $1`
215 # se_base=`echo $1 | awk -F/ '{print $NF}'`
216 se_strip
=`echo $se_base | awk -F. '{ORS="";print $1;for (i=2;i<NF;i++) print "."$i}'`
217 se_ret
=`echo $1 | awk -F/ '{ORS="";for (i=1;i<NF;i++) print $i"/"}'`"$se_strip"
221 # GetExtention returns the extention on the given file name
222 # or "" if none. (e.g. "./bob/snack.c" returns ".c")
223 # Args: <name to find extention of>
225 # se_base=`echo $1 | awk -F/ '{print $NF}'`
226 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
228 se_ret
=`echo $1 | sed -e 's/.*\././'`
229 if test "$se_ret" = $1
238 [ -n "$VERBOSE" ] && echo "charmc>" $@
242 if [ -n "$DEBUG_SCRIPT" ]
245 echo "------- Charmc Debugging info: $* -------"
246 echo "CHARMBIN=$CHARMBIN"
247 echo "CHARMINC=$CHARMINC"
248 echo "CHARMLIB=$CHARMLIB"
250 echo "DELETE=$DELETE"
251 echo "OBJECT=$OBJECT"
252 echo "LANGUAGE=$LANGUAGE"
253 echo "PARADIGM=$PARADIGM"
254 # echo "Working directory="`pwd`
258 # Return success if $1 is not in any of the other arguments
264 if [ "$search" = "$1" ]
266 # It's already in there-- fail
271 # It's missing--succeed
275 # Add arguments to our modules list, avoiding duplicates
279 notInList
$M $MODULES && MODULES
="$MODULES $M"
283 # Add this word to this list, avoiding duplicates
298 # Drop the first argument anywhere it appears in the subsequent list
306 if [ "$1" != "$drop" ]; then
315 # TEMP_BASE is appended with this script's process ID (PID),
316 # so multiple charmcs can run in parallel without overwriting
317 # each other's temporary files.
318 TEMP_BASE
="/tmp/charmc_tmp.$$"
320 # Try to find CHARMBIN by looking in directory where charmc is
322 if [ -z "$CHARMBIN" ]
325 CHARMBIN
=`dirname $SCRIPT`
326 # CHARMBIN=`cd $CHARMBIN; pwd`
327 # NOTE: this script no longer tries to follow soft links
328 # to find the "original" charmc-- if this is bad,
329 # translate these lines to Bourne shell from C shell:
330 # -------------------- Begin C Shell ------------------------->
331 # if ($SCRIPT:h != $SCRIPT:t) then
333 # set SCRIPT=$SCRIPT:t
335 # foreach dir ($path)
336 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
342 # while (x`find $SCRIPT -type l -print` == x$SCRIPT)
343 # set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
344 # if ($SCRIPT:h != $SCRIPT:t) then
346 # set SCRIPT=$SCRIPT:t
350 # <------------------ End C Shell -----------------------------
357 version
=`cat $CHARMBIN/../include/VERSION`
358 echo Charm
++ Version
$version
362 ##############################################################################
364 # The following section identifies CHARMBIN, the charm binary-directory.
366 ##############################################################################
370 # Try to find CHARMBIN by looking in directory where charmc is
375 FIRST_THREE
=`uname -s | awk '{print substr($1,1,3)}' `
376 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
378 # Running on a windows system-- append .exe to file names
382 CHARMLIB
="$CHARMBIN/../lib"
383 CHARMINC
="$CHARMBIN/../include"
385 if test -d "$CHARMBIN/../lib_so"
387 CHARMLIBSO
=`cd $CHARMBIN/../lib_so 2>/dev/null && pwd`
388 #getting absolute path is harder than thought because of symbolic links and ..
389 #ksh needs cd -P to resolve werid symbolic links, however -P is not portable
390 #csh is ok too if it exists
391 test -z "$CHARMLIBSO" && CHARMLIBSO
=`cd -P $CHARMBIN/../lib_so 2>/dev/null && pwd`
392 test -z "$CHARMLIBSO" && CHARMLIBSO
=`csh -c "cd $CHARMBIN/../lib_so >& /dev/null && pwd"`
393 test -z "$CHARMLIBSO" && echo "$CHARMBIN/../lib_so: not found" && exit 1
396 ##############################################################################
398 # Parse the arguments
400 # Don't do any analysis in here, just the parsing.
402 ##############################################################################
404 [ $# -eq 0 ] && printUsage
"Error: No arguments given."
432 # Parse out some fake languages (that are actually modules)
434 "ampi") AddModules tcharmmain ampi
;;
435 "ampif") AddModules tcharmmain ampif
; USE_F90_LIBRARIES
="1" ;;
436 "armci") AddModules tcharmmain armci
;;
437 "armcif") AddModules tcharmmain armci
; USE_F90_LIBRARIES
="1" ;;
438 "fem") AddModules tcharmmain fem
; AMPIMAIN
="femmain";;
439 "femf") AddModules tcharmmain fem
; AMPIMAIN
="femmain"; USE_F90_LIBRARIES
="1" ;;
440 "ParFUM_TOPS") AddModules tcharmmain ParFUM ParFUM_TOPS
; AMPIMAIN
="ParFUMmain";;
441 "ParFUM") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain";;
442 "ParFUMf") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain"; USE_F90_LIBRARIES
="1" ;;
443 "mblock") AddModules tcharmmain mblock
;;
444 "mblockf") AddModules tcharmmain mblock
; USE_F90_LIBRARIES
="1" ;;
446 "charm"|
"charm++"|
"charm++f"|
"f90charm"|
"converse"|
"converse++"|
"bgcharm++"|
"bgconverse++"|
"bluegene"|
"ckbluegene"|
"bigsim")
460 # Requested support from charmdebug: add some modules and libraries
465 "-module"|
"-modules")
466 AddModules
`echo $1 | sed -e 's/,/ /g'`
472 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
473 BALANCER
="$BALANCER $1"
474 mod
=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
485 Warning
"Warning: -queue currently being ignored."
500 TRACEMODE_NEW
=`AddList $TRACEMODE $1`
501 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
503 Warning
"Warning: Duplicate tracemode $1 ignored"
505 TRACEMODE
=$TRACEMODE_NEW
513 "-swapglobal"|
"-swapglobals")
518 "-tlsglobal"|
"-tlsglobals")
522 "-roseomptlsglobals")
523 ROSE_OMP_TLS_GLOBALS
="yes"
527 echo "Verbose mode set"
536 SPU_EXTRA_LIBS
="$SPU_EXTRA_LIBS -l$1"
545 echo "Will give excessive charmc debugging output..."
591 OPTS_CPP
="$OPTS_CPP $1"
596 OPTS_LDRO
="$OPTS_LDRO $1"
601 OPTS_CC
="$OPTS_CC $1"
606 OPTS_CXX
="$OPTS_CXX $1"
611 OPTS_F90
="$OPTS_F90 $1"
616 OPTS_LD
="$OPTS_LD $1"
621 OPTS_LDXX
="$OPTS_LDXX $1"
626 OPTS_LDXX
="$OPTS_LDXX -rpath $1"
630 "-fortran"|
"-flib"|
"-flibs")
631 USE_F90_LIBRARIES
="1"
636 "-fortran77"|
"-f77lib"|
"-f77libs")
637 USE_F77_LIBRARIES
="1"
640 # Run preprocessor only
646 # Run preprocessor as an extra step, continue after preprocessing
650 # Turn off the preprocessor for ci files
654 # Run preprocessor/assembler only
658 #------ Dependency generation ---------
659 "-M" |
"-MM" |
"-MMD" |
"-MG")
664 "-MF" |
"-MT" |
"-MQ" |
"-MD") #-MP will pass through automatically
668 #--------------------------------------
674 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
680 echo $arg | cut
-d'=' -f2
684 if [ "$EXPLICIT_OBJECT" = "no" ]
688 EXPLICIT_COMPILATION
="yes"
692 EXPLICIT_OBJECT
="yes"
703 MODCOPIES
="$1 $MODCOPIES"
713 OPTS_CPP
="$OPTS_CPP -I$1"
718 if echo "$arg" |
grep ' ' > /dev
/null
2>/dev
/null
720 OPTS_CPP
="$OPTS_CPP "\"$arg\"
722 OPTS_CPP
="$OPTS_CPP $arg"
743 Warning
"passing unrecognized option $arg to all compilers and linkers"
749 -L*|
-shared|
-G) # note that this is not executed if $arg == -shared|-G, due to the case above; might be a bug
750 OPTS_LD
="$OPTS_LD $arg"
756 # used internally when building Charm++ to create lib_so
760 # used internally not to build Charm++ lib_so
775 PRODUCTION_MODE
=false
779 POST_LIBRARIES
="$POST_LIBRARIES $arg"
787 F90_MODDIR
="$F90_MODDIR $1"
792 if [ -n "$POST_LANGUAGE" ]
794 POST_LIBRARIES
="$POST_LIBRARIES $arg"
796 PRE_LIBRARIES
="$PRE_LIBRARIES $arg"
802 OPTS_LD
="$OPTS_LD $arg"
820 MPI_INTEROPERATE
="yes"
830 CUSTOM_PARTITION
="yes"
838 SKIP_MODULEINIT
="yes"
841 -print-building-blocks)
842 PRINT_BUILDING_BLOCKS
="yes"
843 SKIP_MODULEINIT
="yes"
851 # Warning "passing unrecognized option $arg to all compilers and linkers"
855 [ -n "$VERBOSE" ] && echo "Adding file $arg..."
861 # printUsage "Error: Unrecognized argument $arg"
862 # Warning "passing unrecognized option $arg to all compilers and linkers"
871 # Process original command-line arguments
872 eval processArgs
"$@"
874 # Construct list of object files
875 numFiles
=`echo $FILES | wc -w`
880 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
881 # make sure to link against shared charm library if creating a shared object:
883 *.so|
*.so.
*|
*.dylib
) CHARM_SHARED
=1 ;;
885 OBJECTFILES
="$OBJECTFILES $FILE"
887 *.c|
*.s|
*.S|
*.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu|
*.f|
*.F|
*.f77|
*.F77|
*.f90|
*.F90|
*.fpp|
*.FPP
)
888 BASE
=`stripExtention \`basename $FILE\
``
891 if [ $numFiles = 1 -a -n "$OBJECT" ]
893 OBJ_EXT
=`getExtention $OBJECT`
894 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
900 # Handle new object files
901 if [ -n "$BASEO" -a -n "$OBJECT" ]
903 if [ "$OBJECT" != "$BASEO" ]
905 DELETE
="$DELETE $BASEO"
907 OBJECTFILES
="$OBJECTFILES $BASEO"
914 ##############################################################################
916 # Load module dependencies.
918 ##############################################################################
920 Debug
"About to read machine config script"
921 Debug
"Read config script, setting defaults..."
923 [ ! -r $CHARMINC/conv-config.sh
] && Abort
"Cannot find conv-config.sh in $CHARMINC"
924 .
$CHARMINC/conv-config.sh
$CHARMINC
926 Debug
"Setting vars..."
928 if [ "$USE_BUILD_OPTIONS" = "1" ]
930 [ -n "$VERBOSE" ] && echo "Charmc applying build time options: $BUILDOPTS"
931 OPTS
="$OPTS $BUILDOPTS"
934 # If we are debugging, add "-g -O0" to the C/C++ flags
935 if [ -n "$CHARMDEBUG" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]; then
936 if [ -n "$CMK_BUILD_PYTHON" ]; then
937 AddModules PythonCCS charmdebug_python
938 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lpython${CMK_BUILD_PYTHON}`
940 OPTS_CPP
="$OPTS_CPP -O0 -g"
945 if [ "$WERROR" = "1" ]
947 OPTS
="$OPTS $CMK_WARNINGS_ARE_ERRORS"
950 # If the user has asked for the latest language standards (C11 or CPP11)
951 if [ "$USE_NEW_STD" = "1" ]
953 # and if configure confirmed that the underlying compiler knows abt C11, enable it
954 if [ "$CMK_COMPILER_KNOWS_C11" = "1" ]
956 OPTS_CC
="$OPTS $CMK_ENABLE_C11"
958 # and if configure confirmed that the underlying compiler knows abt CPP11, enable it
959 if [ "$CMK_COMPILER_KNOWS_CPP11" = "1" ]
961 OPTS_CXX
="$OPTS $CMK_ENABLE_CPP11"
965 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
970 if [ ! -x "$CMK_ROSE_OMP_TOOL" ]
972 Abort
"The environment variable CMK_ROSE_OMP_TOOL must contain the path to a built binary of the ROSE OpenMP variable privatization tool"
976 if [ "$USE_OPENMP" = "yes" -o "$CMK_OMP" = "1" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]
978 [ -n "$VERBOSE" ] && echo OpenMP support enabled
979 OPTS_CC
="$OPTS_CC $CMK_C_OPENMP"
980 OPTS_CXX
="$OPTS_CXX $CMK_C_OPENMP"
981 OPTS_F90
="$OPTS_F90 $CMK_F_OPENMP"
982 OPTS_LD
="$OPTS_LD $CMK_LD_OPENMP"
983 OPTS_LDXX
="$OPTS_LDXX $CMK_LD_OPENMP"
985 [ -n "$VERBOSE" ] && echo OpenMP support not enabled
988 if [ "$TLSGLOBALS" = "1" ]
990 OPTS_CC
="$OPTS_CC -mno-tls-direct-seg-refs"
991 OPTS_CXX
="$OPTS_CXX -mno-tls-direct-seg-refs"
992 OPTS_F90
="$OPTS_F90 -mno-tls-direct-seg-refs"
993 OPTS_LD
="$OPTS_LD -static -Wl,--allow-multiple-definition"
994 OPTS_LDXX
="$OPTS_LDXX -static -Wl,--allow-multiple-definition"
997 # Look up and add the dependencies for module $1
1000 notInList
$M $PROCESSED_MODULES ||
return
1001 PROCESSED_MODULES
="$PROCESSED_MODULES $M"
1002 #PRE_LIBRARIES=`AddList $PRE_LIBRARIES -lmodule$M`
1003 PRE_LIBRARIES
=`AddList -lmodule$M $PRE_LIBRARIES`
1004 # HACK: add modules to both ends of library list, to avoid
1005 # undefined symbol CkRegisterMainModule when it's in a module file.
1006 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lmodule$M`
1007 if [ "$M" = "PythonCCS" ]
1013 # fixme: should search everything in the -L library paths:
1014 for dir
in `echo . $CHARMLIB`
1016 d
="$dir/libmodule$M.dep"
1017 [ -r "$d" ] && dep
=$d
1021 # Add the module dependencies in this file
1022 # Debugf "Adding module" $M "dependencies from" $dep
1024 Debugf
"Module" $M "adds dependencies:" $deps
1029 # Repeat the module-dependency search until we find no
1032 while [ "$START_MODULES" != "$MODULES" ]
1034 Debugf
"----------- Module dependency search ------------"
1035 START_MODULES
="$MODULES"
1042 Debugf
"----------- Module dependency search complete ------------"
1046 ##############################################################################
1048 # Load machine-specific configuration data, then handle overrides to it.
1050 ##############################################################################
1053 if [ x
"$CMK_NO_BUILD_SHARED" = "xfalse" ]
1058 if [ "$BUILD_SHARE" = "1" ]
1060 if [ x
"$CMK_NO_BUILD_SHARED" = "xtrue" -o -z "$CHARMLIBSO" ]
1069 if [ "$USE_PIC" = "1" ]
1071 OPTS_CC
="$OPTS_CC $OPTS_PIC"
1072 OPTS_CXX
="$OPTS_CXX $OPTS_PIC"
1073 OPTS_F90
="$OPTS_F90 $OPTS_PIC"
1074 OPTS_LD
="$OPTS_LD $OPTS_PIC"
1077 if [ "$BUILD_SHARE" = "1" ]
1079 # ignore BUILD_SHARE if the target is not .a or .so
1081 *.a|
*.so|
*.so.
*|
*.sl|
*.dylib
)
1082 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
1090 if [ -n "$OVERRIDE_CC" ]
1092 CMK_CC
="$OVERRIDE_CC"
1095 if [ -n "$OVERRIDE_CXX" ]
1097 CMK_CXX
="$OVERRIDE_CXX"
1100 if [ -n "$OVERRIDE_F90" ]
1102 CMK_CF90
="$OVERRIDE_F90"
1105 if [ -n "$OVERRIDE_LD" ]
1107 CMK_LD
="$OVERRIDE_LD"
1110 if [ -n "$OVERRIDE_LDXX" ]
1112 CMK_LDXX
="$OVERRIDE_LDXX"
1115 if [ -n "$USE_RELIABLE_CC" ]
1117 CMK_CC
="$CMK_CC_RELIABLE"
1120 if [ -n "$USE_FASTEST_CC" ]
1122 CMK_CC
="$CMK_CC_FASTEST"
1125 if [ -n "$USE_F77" ]
1128 CMK_CF90_FIXED
=$CMK_CF77
1129 CMK_F90LIBS
=$CMK_F77LIBS
1132 if [ -n "$CMK_F90_MODINC" ]
1134 CMK_CF90_MODINC
="$CMK_F90_MODINC"
1136 CMK_CF90_MODINC
="-M"
1139 if [ -n "$F90_MODDIR" ]
1141 for dir
in $F90_MODDIR
1143 OPTS_F90
="$OPTS_F90 $CMK_CF90_MODINC $dir"
1147 if [ -n "$CMK_F90_USE_MODDIR" ]
1149 CMK_CF90
="$CMK_CF90 $CMK_CF90_MODINC $CHARMINC $CMK_SYSINC"
1152 if [ -n "$SEQUENTIAL" ]
1154 CMK_CC
="$CMK_SEQ_CC"
1155 CMK_LD
="$CMK_SEQ_LD"
1156 CMK_CXX
="$CMK_SEQ_CXX"
1157 CMK_CF90
="$CMK_SEQ_F90 "
1158 CMK_LDXX
="$CMK_SEQ_LDXX"
1159 CMK_AR
="$CMK_SEQ_AR"
1160 CMK_RANLIB
="$CMK_SEQ_RANLIB"
1162 CMK_CC_FLAGS
="$CMK_SEQ_CC_FLAGS -DCMK_SEQUENTIAL=1"
1163 CMK_LD_FLAGS
="$CMK_SEQ_LD_FLAGS"
1164 CMK_CXX_FLAGS
="$CMK_SEQ_CXX_FLAGS -DCMK_SEQUENTIAL=1"
1165 CMK_LDXX_FLAGS
="$CMK_SEQ_LDXX_FLAGS"
1170 CMK_CC
="$CMK_NATIVE_CC "
1171 CMK_LD
="$CMK_NATIVE_LD"
1172 CMK_CXX
="$CMK_NATIVE_CXX "
1173 CMK_LDXX
="$CMK_NATIVE_LDXX"
1175 CMK_CC_FLAGS
="$CMK_NATIVE_CC_FLAGS"
1176 CMK_LD_FLAGS
="$CMK_NATIVE_LD_FLAGS"
1177 CMK_CXX_FLAGS
="$CMK_NATIVE_CXX_FLAGS"
1178 CMK_LDXX_FLAGS
="$CMK_NATIVE_LDXX_FLAGS"
1181 if [ -n "$PREPROCESS" ]
1188 CMK_LD
="purify $CMK_LD"
1189 CMK_LDXX
="purify $CMK_LDXX"
1193 if [ "$OPTIMIZE_MODE" = "true" ]
1195 OPTS_CC
="$CMK_C_OPTIMIZE $OPTS_CC"
1196 OPTS_CXX
="$CMK_CXX_OPTIMIZE $OPTS_CXX"
1197 OPTS_F90
="$CMK_F90_OPTIMIZE $OPTS_F90"
1198 OPTS_LD
="$CMK_C_OPTIMIZE $OPTS_LD"
1199 OPTS_LDXX
="$CMK_CXX_OPTIMIZE $OPTS_LDXX"
1202 # Pick up per-architecture production mode settings
1203 if [ "$PRODUCTION_MODE" = "true" ]
1205 OPTS_CC
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_CC"
1206 OPTS_CXX
="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_CXX"
1207 OPTS_F90
="$CMK_PRODUCTION $CMK_F90_PRODUCTION $OPTS_F90"
1208 OPTS_LD
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_LD"
1209 OPTS_LDXX
="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_LDXX"
1212 if [ -n "$XI_INTERNAL" ]
1214 CMK_XIOPTS
="$CMK_XIOPTS -intrinsic"
1217 if [ "$GENDEPENDS" = "yes" ]
1219 CMK_XIOPTS
="$CMK_XIOPTS -M"
1222 if [ "$COUNTTOKENS" = "yes" ]
1224 CMK_XIOPTS
="$CMK_XIOPTS -count-tokens"
1227 if test "$CMK_WITH_TAU" = "true"
1229 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1230 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1231 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1232 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1233 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1234 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1235 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1240 #Add generic options to the compiler- and linker-options
1241 OPTS_CC
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CC"
1242 OPTS_CXX
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CXX"
1243 OPTS_F90
="$OPTS $OPTS_F90"
1244 OPTS_LD
="$OPTS $OPTS_LD"
1245 # OPTS_LDXX gets OPTS from OPTS_LD
1247 if [ -n "$F90_MAIN" ]
1249 # for_main needs to be placed at beginning
1250 CMK_LD
="$CMK_LD $CMK_F90MAINLIBS"
1251 CMK_LDXX
="$CMK_LDXX $CMK_F90MAINLIBS"
1254 # There's really no analog for this in the Bourne shell:
1255 # -------- C Shell ------> onintr failure
1256 # Luckily, it's irrelevant as long as nobody sends us a ^Z.
1258 ##############################################################################
1260 # Check for valid choice of LANGUAGE
1262 ##############################################################################
1263 Debug
"Checking language..."
1265 [ -z "$LANGUAGE" -a -n "$SEQUENTIAL" ] && LANGUAGE
=c
1266 [ -z "$PARADIGM" -a -n "$LANGUAGE" ] && PARADIGM
="$LANGUAGE"
1267 [ -z "$PARADIGM" ] && PARADIGM
="charm++"
1270 "c"|
"C"|
"c++"|
"C++")
1271 [ -z "$SEQUENTIAL" -a -z "$NATIVE" ] && Abort
"Language $LANGUAGE is for sequential programs"
1275 # update charm to bgcharm
1276 [ "$PARADIGM" = "charm++" -a -n "$CMK_BIGSIM" ] && PARADIGM
="bgcharm++"
1277 [ "$PARADIGM" = "converse++" -a -n "$CMK_BIGSIM" ] && PARADIGM
="bgconverse++"
1279 [ "$PARADIGM" = "bgcharm++" ] && TRACEMODE
=`AddList $TRACEMODE bluegene`
1281 if [ $USE_F77_LIBRARIES = "1" ]
1283 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F77LIBS"
1286 if [ $USE_F90_LIBRARIES = "1" ]
1289 if [ ! -r $CHARMLIB/libconv-utilf.a
]
1291 Abort
"Error: Fortran support library $CHARMLIB/libconv-utilf.a missing. Is your Fortran compiler working?"
1294 POST_LIBRARIES
="$POST_LIBRARIES -lconv-utilf $CMK_F90LIBS"
1298 if [ "$CMK_COMPILER" = "bgclang" ]
1300 OPTS_CC_GENCPM
="-x c " # -x c is only applied for the preprocessing of the GEN-CPM files on BG/Q
1303 OPTS_CC_GENCPM
="$OPTS_CC $OPTS_CC_GENCPM"
1305 ############ Determine the language and libraries ##########
1307 # Parse out the real languages
1311 USE_F90_LIBRARIES
="1"
1314 PRE_LIBRARIES
="$PRE_LIBRARIES -lf90charm -lckf"
1315 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F90LIBS"
1317 "bluegene"|
"bigsim")
1318 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs"
1321 POST_LIBRARIES
="$POST_LIBRARIES -lbluegene"
1324 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1327 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1331 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1332 if [ $CMK_CELL -eq 1 ]
1335 if [ "$PARADIGM" = "converse++" ]
1337 # Include a "do nothing" register_accel_spe_funcs() function
1338 POST_LIBRARIES
="$POST_LIBRARIES -lnoAccelStub"
1341 if [ "$PARADIGM" = "charm++" ]
1344 if [ $SPU_USE_CPP -eq 1 ]
1346 SPU_COMPILER
=$CMK_SPU_CXX
1347 SPU_LINKER
=$CMK_SPU_LDXX
1349 SPU_COMPILER
=$CMK_SPU_CC
1350 SPU_LINKER
=$CMK_SPU_LD
1353 # Include the spe object file for linking into main executable
1354 POST_LIBRARIES
="$POST_LIBRARIES main__funcLookup__.genSPECode.ppe.o"
1359 if [ "$AMPIMAIN" != "" ]
1361 OBJECTFILES
="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1364 if [ "$SWAPGLOBALS" = "1" ]
1366 swapo
="$CHARMLIB/libglobal-swap.a"
1367 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1369 if [ "$CMK_SMP" == "1" ]
1371 echo "Error: -swapglobals is not supported on SMP builds of Charm++/AMPI"
1373 echo "Error: global-swapping library $swapo missing--"
1374 echo " Is -swapglobals supported on this machine?"
1378 MIDDLE_LIBS
="-lglobal-swap $MIDDLE_LIBS"
1381 if [ "$SWAPGLOBALS" = "2" ]
1383 echo "-copyglobals option is no longer supported by Charm++/AMPI"
1389 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1391 POST_LIBRARIES
="-lmpi-mainmodule $POST_LIBRARIES"
1394 ##############################################################################
1396 # Some quick consistency checks in preparation for full link-step
1398 # Check for valid choice of TRACEMODE
1399 # Check for valid choice of BALANCE
1400 # Check for compatibility among BALANCE and TRACEMODE
1402 ##############################################################################
1404 Debug
"About to check TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1406 # Check for valid choice of TRACEMODE
1408 if [ x
"$TRACEMODE" != x
]
1410 for trace
in $TRACEMODE; do
1412 "converse"|
"converse++"|
"bgconverse++"|
"bigsim"|
"bluegene")
1413 if [ "$trace" != "counter" ]; then
1414 Warning
"Tracemode $trace isn't supported in Converse-level programs; Dropping it"
1415 TRACEMODE
=`DropList $trace $TRACEMODE`
1423 TRACE_OBJ
="$TRACE_OBJ -ltrace-$trace"
1426 TRACE_OBJ
="$TRACE_OBJ $CMK_LIBZ"
1429 if test x
$PARADIGM = x
"bgcharm++"
1434 Debug
"Finished with TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1436 BAL_OBJ
="-lldb-$BALANCE -lconv-ldb"
1438 # Check for valid choice of MEMORY
1440 # Isomalloc does not work on BGQ or Windows:
1441 if [ "$CMK_BLUEGENEQ" = "1" -o "$CMK_COMPILER" = "msvc" ] && [ "$MEMORY" = "isomalloc" -o "$MEMORY" = "os-isomalloc" ]
1443 Abort
"Isomalloc is not supported on BlueGene/Q or Windows."
1446 # Isomalloc does not work on Clang in non-SMP mode or on Darwin at all, so use os-isomalloc instead:
1447 if [ "$MEMORY" = "isomalloc" -a "$CMK_COMPILER" = "clang" -a "$CMK_SMP" != "1" ] ||
[ "$MEMORY" = "isomalloc" -a "$CMK_MACOSX" = 1 ]
1449 MEMORY
="os-isomalloc"
1450 echo "Warning: changing '-memory isomalloc' to '-memory os-isomalloc' on Clang non-SMP or Darwin build targets."
1453 MEM_OBJ
="-lmemory-${MEMORY}"
1455 # For memory wrapping around the OS allocator, need to add also the wrapper object
1458 MEM_OBJ
=$MEM_OBJ" -lmemory-os-wrapper"
1462 # Check for valid choice of THREAD
1464 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1466 THREAD
=$CMK_LD_SHARED_THREAD
1468 if [ "$TLSGLOBALS" = "1" ]
1470 # make sure we don't add an extra -tls
1471 if ! echo $THREAD |
grep '\-tls$' > /dev
/null
2> /dev
/null
1473 THREAD
=${THREAD}-tls
1477 THREAD_OBJ
="-lthreads-${THREAD}"
1482 modInitName
="moduleinit$$"
1483 modInitSrc
="$modInitName.C"
1484 modInitObj
="$modInitName.o"
1487 ##############################################################################
1489 # Final link step variables
1491 ##############################################################################
1496 CORE_LIBS
="-lconv-core -ltmgr -lconv-partition $TRACE_OBJ $CMK_HWLOC_LIBS"
1498 # get TAU stub makefile variables
1499 if test "$CMK_WITH_TAU" = "true"
1501 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1502 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1503 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1504 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1505 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1506 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1507 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1511 # done getting TAU variables
1513 if [ "$BUILD_SHARE" = "0" ]
1515 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ -lconv-util"
1518 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1523 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1524 if [ "$NO_MAIN" = "" ]
1526 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1528 if [ "$TAU_TRACE_MPI" = "1" ]
1530 TAU_LIBS
="$TAU_MPI_FLIBS $TAU_LIBS"
1532 TAU_LIBS
="$TAU_LIBS"
1535 "charm"|
"charm++"|
"f90charm"|
"ckbluegene"|
"bgcharm++")
1537 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1538 if [ "$NO_MAIN" = "" ]
1540 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1542 if [ "$TAU_TRACE_MPI" = "1" ]
1544 TAU_LIBS
="$TAU_MPI_LIBS $TAU_LIBS"
1546 TAU_LIBS
="$TAU_LIBS"
1551 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1553 "converse++"|
"bluegene"|
"bigsim"|
"bgconverse++")
1555 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1557 "c"|
"C"|
"c++"|
"C++"|
"f90"|
"f77")
1560 Abort
"Unrecognized choice of language $LANGUAGE / paradigm $PARADIGM"
1564 if [ "$BUILD_SHARE" = "0" ]
1566 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ -lconv-util"
1569 CMK_SYSLIBS
="-lmoduleNDMeshStreamer -lmodulecompletion $CMK_SYSLIBS"
1571 if [ "$CHARM_SHARED" = "1" ]
1573 [ -z "$CHARMLIBSO" ] && Abort
"Charm++ lib_so directory not found!"
1574 # build user executable/shared lib linking with charm .so
1575 OPTS_LD
="$OPTS_LD $CMK_LD_LIBRARY_PATH"
1576 if [ "$BUILD_SHARE" = "1" -o -n "$SKIP_MODULEINIT" ]
1578 LANG_LIBS
="-L$CHARMLIBSO $OBJECTFILES $PRE_LIBRARIES"
1580 LANG_LIBS
="-L$CHARMLIBSO $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1583 # if interoperate, need a lib with moduleinit
1584 if [ "$MPI_INTEROPERATE" != "" ]
1586 LANG_LIBS
="-L$CHARMLIB $PRE_LIBRARIES"
1588 if [ -n "$SKIP_MODULEINIT" ]
1590 LANG_LIBS
="-L$CHARMLIB $OBJECTFILES $PRE_LIBRARIES"
1592 LANG_LIBS
="-L$CHARMLIB $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1596 if [ "$TRACE_WITH_TAU" = 1 ]
1598 echo "Linking with the TAU libraries: $TAU_LIBS"
1599 ALL_LIBS
="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS $TAU_LIBS"
1601 ALL_LIBS
="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS"
1603 Debugf
"All libraries are: $ALL_LIBS"
1605 if [ "$MPI_INTEROPERATE" != "" ]
1607 # preserve this variable in its state here for use later
1608 CHARM_ALL_LIBS
="$ALL_LIBS"
1609 if [ -n "$SKIP_MODULEINIT" ]
1611 ALL_LIBS
="$OBJECTFILES $ALL_LIBS"
1613 ALL_LIBS
="$OBJECTFILES $modInitObj $ALL_LIBS"
1618 ########################################################################
1620 # Finalize command parameters
1622 ########################################################################
1624 CHARM_CPP_C
="$CMK_CPP_C"
1626 CHARM_CXX
="$CMK_CXX"
1628 CHARM_LDXX
="$CMK_LDXX"
1630 CHARM_CPP_C_FLAGS
="$CMK_CPP_C_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CC_GENCPM $OPTS_CPP"
1631 CHARM_CC_FLAGS
="$CMK_CC_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC"
1632 CHARM_CXX_FLAGS
="$CMK_CXX_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX"
1633 CHARM_LD_FLAGS
="$CMK_LD_FLAGS $CMK_LIBDIR $OPTS_LD $ALL_LIBS"
1634 CHARM_LDXX_FLAGS
="$CMK_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD $OPTS_LDXX $ALL_LIBS"
1637 ########################################################################
1639 # Print command building blocks and quit, if specified
1641 ########################################################################
1643 if [ -n "$PRINT_BUILDING_BLOCKS" ]
1645 for i
in CHARM_CC CHARM_CXX CHARM_LD CHARM_LDXX CHARM_CC_FLAGS CHARM_CXX_FLAGS CHARM_LD_FLAGS CHARM_LDXX_FLAGS CHARMBIN CHARMINC CHARMLIB CHARMLIBSO
1647 eval "echo $i=\\'\${$i}\\'"
1653 ########################################################################
1655 # We've parsed and verified the command-line parameters.
1656 # Now we prepare routines to clean up and exit.
1657 # None of these routines ever returns-- they all just exit.
1659 ########################################################################
1663 if [ "a$COPYTO" != "a" -a "a$COPYTO" != "a$OBJECT" ]
1665 [ -d $COPYTO ] && COPYTO
="$COPYTO/"
1666 if [ "a$PROG_EXT" != "a" -a -r "$OBJECT$PROG_EXT" ] ; then
1667 Warning
"Appending $PROG_EXT to object file name"
1668 OBJECT
="$OBJECT$PROG_EXT"
1670 [ ! -d $COPYTO ] && DoNoErrCheck
$RM $COPYTO
1671 Do
$CP $OBJECT $COPYTO
1673 test -n "$COPY_EXIT" && Success
1677 for COPY
in `echo $MODCOPIES`
1679 if [ "a$COPY" != "a$OBJECT" ]
1681 [ -d $COPY ] && COPY
="$COPY/"
1682 if [ -n "$CMK_MOD_NAME_ALLCAPS" ] ; then
1683 OBJECT
=`echo $OBJECT | tr "a-z" "A-Z"`
1685 if [ -r "$OBJECT.$CMK_MOD_EXT" ] ; then
1686 Warning
"Appending .$CMK_MOD_EXT to object file name"
1687 OBJECT
="$OBJECT.$CMK_MOD_EXT"
1689 [ ! -d $COPY ] && DoNoErrCheck
$RM $COPY
1690 Do
$CP $OBJECT $COPY
1701 ##############################################################################
1703 # Preprocess the GEN-CPM files
1705 ##############################################################################
1707 Debug
"Preprocessing GEN-CPM files"
1709 for FILE
in `echo $GENCPM`
1711 # This used to be "$FILE:r", which strips the extention
1712 BASE
=`stripExtention $FILE`
1713 TMP
=`basename $FILE`".TMP"
1714 DELETE
="$DELETE $TMP.c $TMP.i"
1715 DoNoErrCheck
$RM $BASE.cpm.h
$TMP.c
1716 Do
touch $BASE.cpm.h
1717 Do
$LN -f -s $FILE $TMP.c
1718 Do
$CHARM_CPP_C $CHARM_CPP_C_FLAGS $TMP.c
> $TMP.i
1719 Do
$CHARMBIN/conv-cpm
$TMP.i
$BASE.cpm.h
1722 ##############################################################################
1724 # Compile all specified files
1726 # All temporary files named *.TMP.* for easy cleanup.
1728 ##############################################################################
1730 Debug
"About to compile..."
1734 BASE
=`stripExtention \`basename $FILE\
``
1735 TMP
=`basename $FILE`".TMP"
1736 FILE_EXT
=`getExtention $FILE`
1740 # in case of: charmc -o object.o -c foo.c,
1741 # avoid foo.c => remove foo.o => foo.o => object.o,
1742 # instead generate object.o directly.
1743 # remove and generate foo.o may be dangerous in parallel make
1744 # for example in the case of compiling several objs from one
1745 # same c file such as memory.c.
1746 if [ $numFiles = 1 -a -n "$OBJECT" ]
1748 OBJ_EXT
=`getExtention $OBJECT`
1749 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1756 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1759 .c|.s|.S|.C|.cc|.cxx|.cpp|.c
++|.cu|.f|.F|.f90|.F90|.fpp|.FPP|.f77|.F77
)
1760 [ $VERBOSE ] && echo "Compiling $FILE"
1761 DoNoErrCheck
$RM $BASEO $BASE.f.o
1764 if [ ! -z "$SKIPLINK" ]
1769 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1773 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1776 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++)
1777 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE
1780 *.f|
*.F|
*.f77|
*.F77
)
1781 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1784 *.f90|
*.F90|
*.fpp|
*.FPP
)
1785 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1786 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE
1795 test "$PARADIGM" = "f90charm" && XIOPTS
="$XIOPTS -f90"
1796 if [ "$PREPROCESS_CI" = "yes" ]
1798 Do
$CMK_CPP_CHARM $OPTS_CPP $FILE | Do
$CHARMBIN/charmxi
$XIOPTS -orig-file $FILE
1800 Do
$CHARMBIN/charmxi
$XIOPTS $FILE
1804 Do
$CHARM_CC $CHARM_CC_FLAGS -c $FILE $DESTO
1805 if [ "$Do_res" -ne 0 ]
1810 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu
)
1813 Do
$CMK_NATIVE_CXX $CMK_NATIVE_CXX_FLAGS -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP -c $FILE $DESTO
1815 Do
$CHARM_CXX $CHARM_CXX_FLAGS -c $FILE $DESTO
1817 if [ "$Do_res" -ne 0 ]
1822 *.f|
*.F|
*.f77|
*.F77
)
1823 test -z "$CMK_CF90_FIXED" && Abort
"No F90 compiler (CMK_CF90_FIXED) defined"
1824 Do
$CMK_CF90_FIXED -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE $DESTO
1825 if [ "$Do_res" -ne 0 ]
1830 *.f90|
*.F90|
*.fpp|
*.FPP
)
1831 test -z "$CMK_CF90" && Abort
"No F90 compiler (CMK_CF90) defined"
1832 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1833 Do
$CMK_CF90 -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE $DESTO
1834 if [ "$Do_res" -ne 0 ]
1840 Abort
"I'm not yet smart enough to compile $FILE"
1842 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
1843 [ ! -s $FILE ] && Abort
"$FILE: file not recognized: File truncated"
1851 Abort
"file with unrecognized extension $FILE"
1855 ##############################################################################
1857 # POSSIBLY, SKIP LINK-STEP
1859 # 1. No $OBJECT may be specified at all --- its just a compilation.
1860 # 2. If $OBJECT is a ".a" file, a library is created from $OBJECTFILES.
1861 # 3. If $OBJECT is a ".o" file, then an "LDRO" is created from $OBJECTFILES.
1862 # 4. Language may be sequential. Do a quick and easy linkage.
1864 # in any of these cases, the full link step is skipped.
1866 ##############################################################################
1869 Debugf
"Running ldro..."
1870 DoNoErrCheck
$RM $OBJECT
1871 # convert to absolute path if required
1872 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1874 dir
=`dirname $OBJECT`
1875 fname
=`basename $OBJECT`
1879 [ "$CMK_MACOSX" = "1" ] && OPTS_LD
="$OPTS_LD -Wl,-install_name,$CHARMLIBSO/$fname"
1880 if test "$MAKE_LDXX" = "1"
1882 soCmd
="$CMK_LDXX $CMK_LDXX_FLAGS $CMK_LIBDIR -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1884 soCmd
="$CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1888 if [ $Do_res -ne 0 ]
1894 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1895 echo "!! Failed to compile Charm++ shared library. You can disable shared !!"
1896 echo "!! lib compilation by providing --no-build-shared build option like: !!"
1897 echo "!! ./build charm++ netlrts-linux --no-build-shared -O !!"
1898 echo "!! or reexecute this charmc command with --no-build-shared compile option !!"
1899 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1900 Abort
"Command $soCmd returned error code $Do_res"
1906 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
1908 # We have no target object, or are playing preprocessor tricks-- just end
1909 Debugf
"No target object-- finished"
1913 Debug
"About to link..."
1915 if [ "$INPUT_GIVEN" != "1" ]
1917 Abort
"Trying to link, but no object files or library archives were specified"
1920 # if interoperate dont create the library now, wait to collect all info
1921 if [ "$MPI_INTEROPERATE" = "" ]
1925 Debugf
"Converting $FILES to $OBJECTFILES"
1926 nFiles
=`echo $FILES | wc -w`
1927 nObj
=`echo $OBJECTFILES | wc -w`
1928 # One source file, one .o: just move the .o
1929 if [ $OBJECT != $OBJECTFILES ]
1931 Debugf
"Moving .o to destination"
1932 DoNoErrCheck
$RM $OBJECT
1933 Do
$MV $OBJECTFILES $OBJECT
1937 *.so|
*.so.
*|
*.sl|
*.dylib
)
1938 # Make shared library
1939 # if no build share is set, exit normally.
1940 if [ "$BUILD_SHARE" = 0 ]
1942 Warning
"Warning: building shared library is not supported, recompile charm++ with '--build-shared'."
1944 elif [ "$CHARM_SHARED" = "0" ]
1950 # Make regular (.a, non-shared) library
1951 # in case building charm so, build .so under lib_so as well # Gengbin
1952 if [ "$BUILD_SHARE" = "1" ]
1959 DESTDIR
=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
1960 OBJECT
=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
1962 COPYTO
=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
1965 OBJECT
=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
1966 [ -f $DESTDIR/.charmso
] && MakeSO
1972 DoNoErrCheck
$RM $OBJECT
1973 Do
$CMK_AR $OBJECT $OBJECTFILES
1974 Do
$CMK_RANLIB $OBJECT
1979 # If the above case returns, we're not creating a .o or .a file,
1980 # so linking is needed.
1982 if [ $CMK_CELL -eq 1 ]
1985 if [ "$PARADIGM" = "charm++" ]
1988 # Make the spe object file to be included
1989 Do
$SPU_COMPILER -c -I$CHARMINC $CMK_SYSINC -o main__funcLookup__.genSPECode.o main__funcLookup__.genSPECode.c
-DCMK_CELL_SPE=1
1990 Do
$SPU_LINKER -L$CHARMLIB -o main__funcLookup__.genSPECode main__funcLookup__.genSPECode.o
$CMK_SPERT_LIBS $SPU_EXTRA_LIBS
1991 Do
$CMK_PPU_EMBEDSPU spert_main main__funcLookup__.genSPECode main__funcLookup__.genSPECode.ppe.o
1996 # check if we're linking a sequential object
1998 "c"|
"C"|
"f90"|
"f77")
2001 Do
$CMK_NATIVE_LD $CMK_NATIVE_LD_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2002 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2004 Do
$CMK_SEQ_LD $CMK_SEQ_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2005 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2012 Do
$CMK_NATIVE_LDXX $CMK_NATIVE_LDXX_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2013 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2015 Do
$CMK_SEQ_LDXX $CMK_SEQ_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2016 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2023 ##############################################################################
2025 # Confirm that TRACEMODE, BALANCE, MEMORY, THREAD exist
2027 ##############################################################################
2029 # [ -r $CHARMLIB/libtrace-projections.a ] || Abort "trace libraries not installed. Is Charm++ built properly?"
2031 if [ x
"$TRACEMODE" != x
]
2033 for trace
in $TRACEMODE; do
2034 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort
"charmc : No such tracemode $trace"
2038 BAL_EXT
=`getExtention $BALANCE`
2039 if [ -z "$BAL_EXT" ]; then
2040 # Balance has no extension-- is a library reference
2041 if [ -f "${CHARMLIB}/libldb-$BALANCE.a" ]; then
2042 BAL_OBJ_FILE
="${CHARMLIB}/libldb-$BALANCE.a"
2044 BAL_OBJ_FILE
="${CHARMLIBSO}/libldb-$BALANCE.so"
2047 # Balance has some extension-- must be a .o or .a file
2048 BAL_OBJ_FILE
="$BALANCE"
2051 if [ ! -r "$BAL_OBJ_FILE" ]
2053 if [ "$BALANCE" = "$BAL_OBJ_FILE" ]
2055 Abort
"Could not find load balancer object $BAL_OBJ_FILE"
2057 (cd $CHARMLIB ; ls -al libldb-
*)
2058 Abort
"Unknown load balancer $BALANCE / $BAL_OBJ_FILE"
2062 if [ -f "${CHARMLIB}/libmemory-${MEMORY}.a" ]; then
2063 MEM_OBJ_FILE
="${CHARMLIB}/libmemory-${MEMORY}.a"
2065 MEM_OBJ_FILE
="${CHARMLIBSO}/libmemory-${MEMORY}.so"
2068 if [ ! -r $MEM_OBJ_FILE -o ! -s $MEM_OBJ_FILE ]
2070 (cd $CHARMLIB ; list
=`ls libmemory-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
2071 Abort
"charmc : No such memory mode $MEMORY"
2074 if [ -f "${CHARMLIB}/libthreads-${THREAD}.a" ]; then
2075 THREAD_OBJ_FILE
="${CHARMLIB}/libthreads-${THREAD}.a"
2077 THREAD_OBJ_FILE
="${CHARMLIBSO}/libthreads-${THREAD}.so"
2080 if [ ! -r $THREAD_OBJ_FILE -o ! -s $THREAD_OBJ_FILE ]
2082 (cd $CHARMLIB ; list
=`ls libthreads-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
2083 Abort
"charmc : No such thread mode $THREAD"
2087 ################# Build the module initialization function ##################
2089 if [ -z "$SKIP_MODULEINIT" ]
2091 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
2093 for module
in $MODULES; do
2094 echo "extern void _register$module(void);" >> $modInitSrc
2096 for trace
in $TRACEMODE; do
2097 if test $trace = "summary"
2099 echo " extern void _registerTraceSummary();" >> $modInitSrc
2100 elif test $trace = "projections"
2102 echo " extern void _registerTraceProjections();" >> $modInitSrc
2103 elif test $trace = "simple"
2105 echo " extern void _registerTraceSimple();" >> $modInitSrc
2106 elif test $trace = "Tau"
2108 echo " extern void _registerTraceTau();" >> $modInitSrc
2109 elif test $trace = "utilization"
2111 echo " extern void _registerTraceUtilization();" >> $modInitSrc
2112 elif test $trace = "controlPoints"
2114 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2115 elif test $trace = "perfReport"
2117 Do
$CP $CHARMBIN/fuzzytree.txt fuzzytree.txt
2118 Do
$CP $CHARMBIN/tree.txt tree.txt
2119 echo " extern void _registerTraceAutoPerf();" >> $modInitSrc
2121 elif test $trace = "all"
2123 echo " extern void _registerTraceProjections();" >> $modInitSrc
2124 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2125 echo " extern void _registerTraceSummary();" >> $modInitSrc
2128 if test -n "$BALANCER"
2130 echo "extern void LBDefaultCreate(const char *);" >> $modInitSrc
2132 echo "void _registerExternalModules(char **argv) { (void)argv;" >> $modInitSrc
2133 for module
in $MODULES; do
2134 [ -n "$VERBOSE" ] && echo "Adding registration for module $module"
2135 echo " _register$module();" >> $modInitSrc
2137 for trace
in $TRACEMODE; do
2138 if test $trace = "summary"
2140 echo " _registerTraceSummary();" >> $modInitSrc
2141 elif test $trace = "projections"
2143 echo " _registerTraceProjections();" >> $modInitSrc
2144 elif test $trace = "Tau"
2147 echo " _registerTraceTau();" >> $modInitSrc
2148 elif test $trace = "simple"
2150 echo " _registerTraceSimple();" >> $modInitSrc
2151 elif test $trace = "utilization"
2153 echo " _registerTraceUtilization();" >> $modInitSrc
2154 elif test $trace = "controlPoints"
2156 echo " _registerTraceControlPoints();" >> $modInitSrc
2157 elif test $trace = "perfReport"
2159 echo " _registerTraceAutoPerf();" >> $modInitSrc
2160 elif test $trace = "all"
2162 echo " _registerTraceProjections();" >> $modInitSrc
2163 echo " _registerTraceControlPoints();" >> $modInitSrc
2164 echo " _registerTraceSummary();" >> $modInitSrc
2167 if test -n "$BALANCER"
2169 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
2170 for deflb
in $BALANCER
2172 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
2175 echo "}" >> $modInitSrc
2177 # creating projections
2178 echo "void _createTraces(char **argv) { (void)argv;" >> $modInitSrc
2179 for trace
in $TRACEMODE; do
2180 [ -n "$VERBOSE" ] && echo "Adding registration for trace $trace"
2181 echo "extern void _createTrace$trace(char **argv);" >> $modInitSrc
2182 echo "_createTrace$trace(argv);" >> $modInitSrc
2184 echo "}" >> $modInitSrc
2186 Do
$CHARM_CXX $CHARM_CXX_FLAGS -c $modInitSrc -o $modInitObj
2189 ###############################################################################
2193 ###############################################################################
2195 Debug
"About to perform final link..."
2197 #currently only support creation of .a
2198 if [ "$MPI_INTEROPERATE" != "" ]
2202 # in case building charm so, build .so under lib_so as well # Gengbin
2203 DoNoErrCheck
$RM $OBJECT
2204 if [ -z "$SKIP_MODULEINIT" ]
2206 echo "$CMK_AR $OBJECT $OBJECTFILES $modInitObj"
2207 Do
$CMK_AR $OBJECT $OBJECTFILES $modInitObj
2209 Do
$CMK_RANLIB $OBJECT
2210 echo "export CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\"" > .
/charm_all_libs.sh
2211 echo "CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\""
2214 *.so|
*.so.
*|
*.sl|
*.dylib
)
2215 echo "Warning: building shared library failed; for interoperation build
2222 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2224 # build an application .so linking with charm .so
2225 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
2226 Debugf
"Running ldro..."
2227 DoNoErrCheck
$RM $OBJECT
2228 [ "$MAKE_LDXX" = "1" ] && Do
$CMK_LDXX $CMK_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD $OPTS_LDXX -o $OBJECT $ALL_LIBS
2229 [ "$MAKE_LD" = "1" ] && Do
$CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $ALL_LIBS
2232 # Make a regular executable: call the appropriate linker
2233 [ "$MAKE_LDXX" = "1" ] && Do
$CHARM_LDXX $CHARM_LDXX_FLAGS -o $OBJECT
2234 [ "$MAKE_LD" = "1" ] && Do
$CHARM_LD $CHARM_LD_FLAGS -o $OBJECT
2237 ########################################################################
2239 # Copy conv-host to user directory if it is present in installation.
2241 ########################################################################
2243 if test "$COPY_CHARMRUN" = "true"
2245 targ
=charmrun
$CMK_POST_EXE
2246 [ ! -x $CHARMBIN/$targ -a -n "$CMK_POST_EXE" ] && targ
=charmrun
2247 convhost
=conv-host
$CMK_POST_EXE
2249 if [ -x $CHARMBIN/$targ ]
2251 DoNoErrCheck
$RM $targ
2252 DoNoErrCheck
$CP $CHARMBIN/$targ $targ
2256 [ -z "$SKIP_MODULEINIT" -a -z "$SAVE" ] && DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1