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.
42 #Generic options, passed to everything
45 #charm internal flag, only pass to c and cxx, not f90
46 OPTS_CPP_INTERNAL
="-D__CHARMC__=1"
61 EXPLICIT_COMPILATION
="no"
101 ROSE_OMP_TLS_GLOBALS
="no"
102 PRINT_BUILDING_BLOCKS
=""
105 TAU_MAKEFILE
=Make.tau
119 ####################################################################
121 # Utility routines used below
123 ###################################################################
125 # PrintUsage: prints a helpful command-line usage message and quits
126 # Args: any additional messages
130 echo "Usage: charmc [ flags ] <files>"
133 echo " -o <target> -g -O"
134 echo " -D<define> -I<include path> -L<lib path> -l<library> -s"
135 echo " -machine <mach> -seq -host -language <lang> -pg <opt>"
136 echo " -balance <mode> -tracemode <mode> -memory <mode>"
137 echo " -modules <comma-separated list of C++ modules> -thread"
138 echo " -debug-script -count-tokens -default-to-aout -E -S -M"
139 echo " -verbose -save -purify -cp <dest> -cpmod -gen-cpm <pkg>"
140 echo " -swapglobals -tlsglobals -roseomptlsglobals"
141 echo " -use-reliable-cc -use-fastest-cc -use-new-std"
142 echo " -cc <new cc> -c++ <new CC> -ld <new ld> -ld++ <new LD>"
143 echo " -cpp-option <opt> -ldro-option <opt> -cc-option <opt>"
144 echo " -c++-option <opt> -ld-option <opt> -ld++-option <opt>"
145 echo " -f90 <new f90> -f90-option <opt> -fmoddir <f90mod path>"
146 echo " -flibs -rpath <path> -custom-part -touch-on-failure"
147 echo " -mpi -openmp -no-trace-mpi -build-shared -charm-shared"
148 echo " -no-charmrun -no-preprocess-ci -nomain-module -nomain"
149 echo " -nof90main -f90main"
151 echo " Charmc compiles C, C++, f77, f90, AMPI, Converse, Converse++, Charm, "
152 echo "and Charm++ programs. The flags generally match those of cc or f77."
153 echo " Other options that are not listed here will be passed directly to the"
154 echo "underlying compiler and/or linker."
155 echo "Parallel Programming Lab, UIUC, 2019."
160 # End blows away the temporary files (unless SAVE is true) and exits
165 for FILE
in `echo $FILES`
167 #BASE=`stripExtention $FILE`
168 MYTMP
=`basename $FILE`".TMP"
169 $RM $MYTMP.P.C
$MYTMP.cpp
$MYTMP.space
$MYTMP.xlat
$MYTMP.o
170 $RM $MYTMP.c
$MYTMP.c
.0.h
$MYTMP.c
.1.h
$MYTMP.c
.2.h
171 $RM $MYTMP.i
$MYTMP.
$CMK_CPP_SUFFIX
174 if [ -z "$SKIP_MODULEINIT" -a -n "$modInitObj" ]
176 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
177 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
183 # Write this error message to stderr
184 # ("1>&2" redirects the echo output to stderr).
189 # This procedure prints an error message and exits.
190 # Args: written to stderr
192 Warning
"Fatal Error by charmc in directory "`pwd`
194 Warning
"charmc exiting..."
199 # Instead of an ECHO_CMD variable, I define a procedure Do,
200 # which (possibly) echos, runs, and tests the errors of the given command.
201 # Args: executed as given
203 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
210 # The UNIX result code better be zero, or we die
211 [ $Do_res -eq 0 -o -n "$NOABORT" ] || Abort
"Command $@ returned error code $Do_res"
214 # This procedure removes the extention (the ".c" in "./main.c") from
215 # its first argument, and prints the result. Unlike the builtin command
216 # basename, it keeps the directory path.
217 # Args: <name to strip>
219 se_base
=`basename $1`
220 # se_base=`echo $1 | awk -F/ '{print $NF}'`
221 se_strip
=`echo $se_base | awk -F. '{ORS="";print $1;for (i=2;i<NF;i++) print "."$i}'`
222 se_ret
=`echo $1 | awk -F/ '{ORS="";for (i=1;i<NF;i++) print $i"/"}'`"$se_strip"
226 # GetExtention returns the extention on the given file name
227 # or "" if none. (e.g. "./bob/snack.c" returns ".c")
228 # Args: <name to find extention of>
230 # se_base=`echo $1 | awk -F/ '{print $NF}'`
231 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
233 se_ret
=`echo $1 | sed -e 's/.*\././'`
234 if test "$se_ret" = $1
243 [ -n "$VERBOSE" ] && echo "charmc>" $@
247 if [ -n "$DEBUG_SCRIPT" ]
250 echo "------- Charmc Debugging info: $* -------"
251 echo "CHARMBIN=$CHARMBIN"
252 echo "CHARMINC=$CHARMINC"
253 echo "CHARMLIB=$CHARMLIB"
255 echo "DELETE=$DELETE"
256 echo "OBJECT=$OBJECT"
257 echo "LANGUAGE=$LANGUAGE"
258 echo "PARADIGM=$PARADIGM"
259 # echo "Working directory="`pwd`
263 # Return success if $1 is not in any of the other arguments
269 if [ "$search" = "$1" ]
271 # It's already in there-- fail
276 # It's missing--succeed
280 # Add arguments to our modules list, avoiding duplicates
284 notInList
$M $MODULES && MODULES
="$MODULES $M"
288 # Add this word to this list, avoiding duplicates
303 # Drop the first argument anywhere it appears in the subsequent list
311 if [ "$1" != "$drop" ]; then
320 # TEMP_BASE is appended with this script's process ID (PID),
321 # so multiple charmcs can run in parallel without overwriting
322 # each other's temporary files.
323 TEMP_BASE
="/tmp/charmc_tmp.$$"
325 # Try to find CHARMBIN by looking in directory where charmc is
327 if [ -z "$CHARMBIN" ]
330 CHARMBIN
=`dirname $SCRIPT`
331 # CHARMBIN=`cd $CHARMBIN; pwd`
332 # NOTE: this script no longer tries to follow soft links
333 # to find the "original" charmc-- if this is bad,
334 # translate these lines to Bourne shell from C shell:
335 # -------------------- Begin C Shell ------------------------->
336 # if ($SCRIPT:h != $SCRIPT:t) then
338 # set SCRIPT=$SCRIPT:t
340 # foreach dir ($path)
341 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
347 # while (x`find $SCRIPT -type l -print` == x$SCRIPT)
348 # set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
349 # if ($SCRIPT:h != $SCRIPT:t) then
351 # set SCRIPT=$SCRIPT:t
355 # <------------------ End C Shell -----------------------------
362 version
=`cat $CHARMBIN/../include/VERSION`
363 echo Charm
++ Version
$version
367 ##############################################################################
369 # The following section identifies CHARMBIN, the charm binary-directory.
371 ##############################################################################
375 # Try to find CHARMBIN by looking in directory where charmc is
380 FIRST_THREE
=`uname -s | awk '{print substr($1,1,3)}' `
381 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
383 # Running on a windows system-- append .exe to file names
387 CHARMLIB
="$CHARMBIN/../lib"
388 CHARMINC
="$CHARMBIN/../include"
390 if test -d "$CHARMBIN/../lib_so"
392 CHARMLIBSO
=`cd $CHARMBIN/../lib_so 2>/dev/null && pwd`
393 #getting absolute path is harder than thought because of symbolic links and ..
394 #ksh needs cd -P to resolve werid symbolic links, however -P is not portable
395 #csh is ok too if it exists
396 test -z "$CHARMLIBSO" && CHARMLIBSO
=`cd -P $CHARMBIN/../lib_so 2>/dev/null && pwd`
397 test -z "$CHARMLIBSO" && CHARMLIBSO
=`csh -c "cd $CHARMBIN/../lib_so >& /dev/null && pwd"`
398 test -z "$CHARMLIBSO" && echo "$CHARMBIN/../lib_so: not found" && exit 1
401 ##############################################################################
403 # Parse the arguments
405 # Don't do any analysis in here, just the parsing.
407 ##############################################################################
409 [ $# -eq 0 ] && printUsage
"Error: No arguments given."
438 SKIP_MODULEINIT
="yes"
442 # Parse out some fake languages (that are actually modules)
444 "ampi") AddModules tcharmmain ampi
; AMPI
="1" ;;
445 "ampif") AddModules tcharmmain ampif
; USE_F90_LIBRARIES
="1" ; AMPIF
="1" ;;
446 "armci") AddModules tcharmmain armci
;;
447 "armcif") AddModules tcharmmain armci
; USE_F90_LIBRARIES
="1" ;;
448 "fem") AddModules tcharmmain fem
; AMPIMAIN
="femmain";;
449 "femf") AddModules tcharmmain fem
; AMPIMAIN
="femmain"; USE_F90_LIBRARIES
="1" ;;
450 "ParFUM_TOPS") AddModules tcharmmain ParFUM ParFUM_TOPS
; AMPIMAIN
="ParFUMmain";;
451 "ParFUM") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain";;
452 "ParFUMf") AddModules tcharmmain ParFUM
; AMPIMAIN
="ParFUMmain"; USE_F90_LIBRARIES
="1" ;;
453 "mblock") AddModules tcharmmain mblock
;;
454 "mblockf") AddModules tcharmmain mblock
; USE_F90_LIBRARIES
="1" ;;
456 "charm"|
"charm++"|
"charm++f"|
"f90charm"|
"converse"|
"converse++"|
"bgcharm++"|
"bgconverse++"|
"bluegene"|
"ckbluegene"|
"bigsim")
470 # Requested support from charmdebug: add some modules and libraries
475 "-module"|
"-modules")
476 AddModules
`echo $1 | sed -e 's/,/ /g'`
482 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
483 BALANCER
="$BALANCER $1"
484 mod
=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
495 Warning
"Warning: -queue currently being ignored."
510 TRACEMODE_NEW
=`AddList $TRACEMODE $1`
511 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
513 Warning
"Warning: Duplicate tracemode $1 ignored"
515 TRACEMODE
=$TRACEMODE_NEW
523 "-swapglobal"|
"-swapglobals")
528 "-tlsglobal"|
"-tlsglobals")
532 "-roseomptlsglobals")
533 ROSE_OMP_TLS_GLOBALS
="yes"
537 echo "Verbose mode set"
546 SPU_EXTRA_LIBS
="$SPU_EXTRA_LIBS -l$1"
555 echo "Will give excessive charmc debugging output..."
601 OPTS_CPP
="$OPTS_CPP $1"
606 OPTS_LDRO
="$OPTS_LDRO $1"
611 OPTS_CC
="$OPTS_CC $1"
616 OPTS_CXX
="$OPTS_CXX $1"
621 OPTS_F90
="$OPTS_F90 $1"
625 "-ld-option"|
"-ld++-option")
626 OPTS_LD
="$OPTS_LD $1"
631 OPTS_LD
="$OPTS_LD -rpath $1"
639 "-fortran"|
"-flib"|
"-flibs")
640 USE_F90_LIBRARIES
="1"
645 "-fortran77"|
"-f77lib"|
"-f77libs")
646 USE_F77_LIBRARIES
="1"
649 # Run preprocessor only
655 # Run preprocessor as an extra step, continue after preprocessing
659 # Turn off the preprocessor for ci files
663 # Run preprocessor/assembler only
667 #------ Dependency generation ---------
668 "-M" |
"-MM" |
"-MMD" |
"-MG")
673 "-MF" |
"-MT" |
"-MQ" |
"-MD") #-MP will pass through automatically
677 #--------------------------------------
683 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
689 echo $arg | cut
-d'=' -f2
693 if [ "$EXPLICIT_OBJECT" = "no" ]
697 EXPLICIT_COMPILATION
="yes"
701 EXPLICIT_OBJECT
="yes"
712 MODCOPIES
="$1 $MODCOPIES"
722 OPTS_CPP
="$OPTS_CPP -I$1"
727 if echo "$arg" |
grep ' ' > /dev
/null
2>/dev
/null
729 OPTS_CPP
="$OPTS_CPP "\"$arg\"
731 OPTS_CPP
="$OPTS_CPP $arg"
752 Warning
"passing unrecognized option $arg to all compilers and linkers"
758 -L*|
-shared|
-G) # note that this is not executed if $arg == -shared|-G, due to the case above; might be a bug
759 OPTS_LD
="$OPTS_LD $arg"
765 # used internally when building Charm++ to create lib_so
769 # used internally not to build Charm++ lib_so
784 PRODUCTION_MODE
=false
788 POST_LIBRARIES
="$POST_LIBRARIES $arg"
796 F90_MODDIR
="$F90_MODDIR $1"
800 -l*|
*.a|
*.so|
*.so.
*|
*.dylib
)
801 if [ -n "$POST_LANGUAGE" ]
803 POST_LIBRARIES
="$POST_LIBRARIES $arg"
805 PRE_LIBRARIES
="$PRE_LIBRARIES $arg"
811 LINK_WHOLE_ARCHIVE
=true
819 OPTS_LD
="$OPTS_LD $arg"
837 MPI_INTEROPERATE
="yes"
847 CUSTOM_PARTITION
="yes"
855 SKIP_MODULEINIT
="yes"
858 -print-building-blocks)
859 PRINT_BUILDING_BLOCKS
="yes"
860 SKIP_MODULEINIT
="yes"
868 # Warning "passing unrecognized option $arg to all compilers and linkers"
872 [ -n "$VERBOSE" ] && echo "Adding file $arg..."
878 # printUsage "Error: Unrecognized argument $arg"
879 # Warning "passing unrecognized option $arg to all compilers and linkers"
888 # Process original command-line arguments
889 eval processArgs
"$@"
891 # Do not skip linking if user explicitly specified an output file
892 # This allows generating dependencies while compiling
893 if [ "$GENDEPENDS" = "yes" -a "$EXPLICIT_OBJECT" = "yes" ]; then
897 USER_POST_LIBRARIES
="$POST_LIBRARIES"
898 USER_PRE_LIBRARIES
="$PRE_LIBRARIES"
900 # Construct list of object files
901 numFiles
=`echo $FILES | wc -w`
906 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
907 OBJECTFILES
="$OBJECTFILES $FILE"
909 *.c|
*.s|
*.S|
*.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu|
*.f|
*.F|
*.f77|
*.F77|
*.f90|
*.F90|
*.fpp|
*.FPP
)
910 BASE
=`stripExtention \`basename $FILE\
``
913 if [ $numFiles = 1 -a -n "$OBJECT" ]
915 OBJ_EXT
=`getExtention $OBJECT`
916 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
922 # Handle new object files
923 if [ -n "$BASEO" -a -n "$OBJECT" ]
925 if [ "$OBJECT" != "$BASEO" ]
927 DELETE
="$DELETE $BASEO"
929 OBJECTFILES
="$OBJECTFILES $BASEO"
936 ##############################################################################
938 # Load module dependencies.
940 ##############################################################################
942 Debug
"About to read machine config script"
943 Debug
"Read config script, setting defaults..."
945 [ ! -r $CHARMINC/conv-config.sh
] && Abort
"Cannot find conv-config.sh in $CHARMINC"
946 .
$CHARMINC/conv-config.sh
$CHARMINC
948 Debug
"Setting vars..."
950 if [ "$USE_BUILD_OPTIONS" = "1" ]
952 [ -n "$VERBOSE" ] && echo "Charmc applying build time options: $BUILDOPTS"
953 OPTS
="$OPTS $BUILDOPTS"
956 # If we are debugging, add "-g -O0" to the C/C++ flags
957 if [ -n "$CHARMDEBUG" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]; then
958 if [ -n "$CMK_BUILD_PYTHON" ]; then
959 AddModules PythonCCS charmdebug_python
960 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lpython${CMK_BUILD_PYTHON}`
962 OPTS_CPP
="$OPTS_CPP -O0 -g"
965 # The purpose of the -rpath-origin option is for the resulting binary to have
966 # the literal text '$ORIGIN' in the RPATH field of its ELF header, essentially
967 # saying that it is okay for the binary to look in the same directory as itself
968 # for the shared objects it needs. Unfortunately, POSIX shells will interpret
969 # this text as a variable instead of passing in the string itself, requiring
970 # the string to be escaped.
971 # Additionally, some platforms do not need any special parameters.
972 if [ -n "$RPATH_ORIGIN" -a "$CMK_MACOSX" != "1" -a "$CMK_COMPILER" != "msvc" ]; then
973 OPTS_LD
="$OPTS_LD '-Wl,-rpath,\$ORIGIN'"
978 if [ "$WERROR" = "1" ]
980 OPTS
="$OPTS $CMK_WARNINGS_ARE_ERRORS"
983 # If the user has asked for the latest language standards (C11 or CPP11)
984 if [ "$USE_NEW_STD" = "1" ]
986 # and if configure confirmed that the underlying compiler knows abt C11, enable it
987 if [ "$CMK_COMPILER_KNOWS_C11" = "1" ]
989 OPTS_CC
="$OPTS $CMK_ENABLE_C11"
993 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
998 if [ ! -x "$CMK_ROSE_OMP_TOOL" ]
1000 Abort
"The environment variable CMK_ROSE_OMP_TOOL must contain the path to a built binary of the ROSE OpenMP variable privatization tool"
1004 if [ "$USE_OPENMP" = "yes" -o "$CMK_OMP" = "1" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]
1006 if [ "$CMK_HAS_OPENMP" != "1" ]
1008 echo "Error: OpenMP is unavailable!"
1011 [ -n "$VERBOSE" ] && echo OpenMP support enabled
1012 OPTS_CC
="$OPTS_CC $CMK_C_OPENMP"
1013 OPTS_CXX
="$OPTS_CXX $CMK_C_OPENMP"
1014 OPTS_F90
="$OPTS_F90 $CMK_F_OPENMP"
1015 OPTS_LD
="$OPTS_LD $CMK_LD_OPENMP"
1017 [ -n "$VERBOSE" ] && echo OpenMP support not enabled
1020 if [ "$TLSGLOBALS" = "1" ]
1022 TLSGLOBALS_OPTS
='-ftls-model=initial-exec'
1023 [ "$CMK_COMPILER_KNOWS_TLSDIRECTSEGREFS" = '1' ] && TLSGLOBALS_OPTS
="$TLSGLOBALS_OPTS -mno-tls-direct-seg-refs"
1024 OPTS_CC
="$OPTS_CC $TLSGLOBALS_OPTS"
1025 OPTS_CXX
="$OPTS_CXX $TLSGLOBALS_OPTS"
1026 OPTS_F90
="$OPTS_F90 $TLSGLOBALS_OPTS"
1029 # Look up and add the dependencies for module $1
1032 notInList
$M $PROCESSED_MODULES ||
return
1033 PROCESSED_MODULES
="$PROCESSED_MODULES $M"
1034 #PRE_LIBRARIES=`AddList $PRE_LIBRARIES -lmodule$M`
1035 PRE_LIBRARIES
=`AddList -lmodule$M $PRE_LIBRARIES`
1036 # HACK: add modules to both ends of library list, to avoid
1037 # undefined symbol CkRegisterMainModule when it's in a module file.
1038 POST_LIBRARIES
=`AddList $POST_LIBRARIES -lmodule$M`
1039 if [ "$M" = "PythonCCS" ]
1045 # fixme: should search everything in the -L library paths:
1046 for dir
in `echo . $CHARMLIB`
1048 d
="$dir/libmodule$M.dep"
1049 [ -r "$d" ] && dep
=$d
1053 # Add the module dependencies in this file
1054 # Debugf "Adding module" $M "dependencies from" $dep
1056 Debugf
"Module" $M "adds dependencies:" $deps
1061 # Repeat the module-dependency search until we find no
1064 while [ "$START_MODULES" != "$MODULES" ]
1066 Debugf
"----------- Module dependency search ------------"
1067 START_MODULES
="$MODULES"
1074 Debugf
"----------- Module dependency search complete ------------"
1078 ##############################################################################
1080 # Load machine-specific configuration data, then handle overrides to it.
1082 ##############################################################################
1085 if [ x
"$CMK_NO_BUILD_SHARED" = "xfalse" ]
1090 if [ "$BUILD_SHARE" = "1" ]
1096 if [ "$USE_PIC" = "1" ]
1098 OPTS_CC
="$OPTS_CC $OPTS_PIC"
1099 OPTS_CXX
="$OPTS_CXX $OPTS_PIC"
1100 OPTS_F90
="$OPTS_F90 $OPTS_PIC"
1101 OPTS_LD
="$OPTS_LD $OPTS_PIC"
1104 if [ "$BUILD_SHARE" = "1" ]
1106 # ignore BUILD_SHARE if the target is not .a or .so
1108 *.a|
*.so|
*.so.
*|
*.sl|
*.dylib
)
1109 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO"
1110 [ -n "$CHARMLIBSO" ] && OPTS_LD
="$OPTS_LD -L$CHARMLIBSO"
1118 if [ -n "$OVERRIDE_CC" ]
1120 CMK_CC
="$OVERRIDE_CC"
1123 if [ -n "$OVERRIDE_CXX" ]
1125 CMK_CXX
="$OVERRIDE_CXX"
1128 if [ -n "$OVERRIDE_F90" ]
1130 CMK_CF90
="$OVERRIDE_F90"
1133 if [ -n "$OVERRIDE_LD" ]
1135 CMK_LD
="$OVERRIDE_LD"
1138 if [ -n "$OVERRIDE_LDXX" ]
1140 CMK_LDXX
="$OVERRIDE_LDXX"
1143 if [ -n "$USE_RELIABLE_CC" ]
1145 CMK_CC
="$CMK_CC_RELIABLE"
1148 if [ -n "$USE_FASTEST_CC" ]
1150 CMK_CC
="$CMK_CC_FASTEST"
1153 if [ -n "$USE_F77" ]
1156 CMK_CF90_FIXED
=$CMK_CF77
1157 CMK_F90LIBS
=$CMK_F77LIBS
1160 if [ -n "$CMK_F90_MODINC" ]
1162 CMK_CF90_MODINC
="$CMK_F90_MODINC"
1164 CMK_CF90_MODINC
="-M"
1167 if [ -n "$F90_MODDIR" ]
1169 for dir
in $F90_MODDIR
1171 OPTS_F90
="$OPTS_F90 $CMK_CF90_MODINC $dir"
1175 if [ -n "$CMK_F90_USE_MODDIR" ]
1177 CMK_CF90
="$CMK_CF90 $CMK_CF90_MODINC $CHARMINC $CMK_SYSINC"
1180 if [ -n "$SEQUENTIAL" ]
1182 CMK_CC
="$CMK_SEQ_CC"
1183 CMK_LD
="$CMK_SEQ_LD"
1184 CMK_CXX
="$CMK_SEQ_CXX"
1185 CMK_CF90
="$CMK_SEQ_F90 "
1186 CMK_LDXX
="$CMK_SEQ_LDXX"
1187 CMK_AR
="$CMK_SEQ_AR"
1188 CMK_RANLIB
="$CMK_SEQ_RANLIB"
1190 CMK_CC_FLAGS
="$CMK_SEQ_CC_FLAGS -DCMK_SEQUENTIAL=1"
1191 CMK_LD_FLAGS
="$CMK_SEQ_LD_FLAGS"
1192 CMK_CXX_FLAGS
="$CMK_SEQ_CXX_FLAGS -DCMK_SEQUENTIAL=1"
1193 CMK_LDXX_FLAGS
="$CMK_SEQ_LDXX_FLAGS"
1198 CMK_CC
="$CMK_NATIVE_CC "
1199 CMK_LD
="$CMK_NATIVE_LD"
1200 CMK_CXX
="$CMK_NATIVE_CXX "
1201 CMK_LDXX
="$CMK_NATIVE_LDXX"
1203 CMK_CC_FLAGS
="$CMK_NATIVE_CC_FLAGS"
1204 CMK_LD_FLAGS
="$CMK_NATIVE_LD_FLAGS"
1205 CMK_CXX_FLAGS
="$CMK_NATIVE_CXX_FLAGS"
1206 CMK_LDXX_FLAGS
="$CMK_NATIVE_LDXX_FLAGS"
1209 if [ -n "$PREPROCESS" ]
1216 CMK_LD
="purify $CMK_LD"
1217 CMK_LDXX
="purify $CMK_LDXX"
1221 if [ "$OPTIMIZE_MODE" = "true" ]
1223 OPTS_CC
="$CMK_C_OPTIMIZE $OPTS_CC"
1224 OPTS_CXX
="$CMK_CXX_OPTIMIZE $OPTS_CXX"
1225 OPTS_F90
="$CMK_F90_OPTIMIZE $OPTS_F90"
1226 OPTS_LD
="$CMK_C_OPTIMIZE $OPTS_LD"
1229 # Pick up per-architecture production mode settings
1230 if [ "$PRODUCTION_MODE" = "true" ]
1232 OPTS_CC
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_CC"
1233 OPTS_CXX
="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_CXX"
1234 OPTS_F90
="$CMK_PRODUCTION $CMK_F90_PRODUCTION $OPTS_F90"
1235 OPTS_LD
="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_LD"
1238 if [ -n "$XI_INTERNAL" ]
1240 CMK_XIOPTS
="$CMK_XIOPTS -intrinsic"
1243 if [ "$GENDEPENDS" = "yes" ]
1245 CMK_XIOPTS
="$CMK_XIOPTS -M"
1248 if [ "$COUNTTOKENS" = "yes" ]
1250 CMK_XIOPTS
="$CMK_XIOPTS -count-tokens"
1253 if test "$CMK_WITH_TAU" = "true"
1255 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1256 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1257 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1258 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1259 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1260 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1261 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1266 #Add generic options to the compiler- and linker-options
1267 OPTS_CC
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CC"
1268 OPTS_CXX
="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CXX"
1269 OPTS_F90
="$OPTS $OPTS_F90"
1270 OPTS_LD
="$OPTS $OPTS_LD"
1272 # There's really no analog for this in the Bourne shell:
1273 # -------- C Shell ------> onintr failure
1274 # Luckily, it's irrelevant as long as nobody sends us a ^Z.
1276 ##############################################################################
1278 # Check for valid choice of LANGUAGE
1280 ##############################################################################
1281 Debug
"Checking language..."
1283 [ -z "$LANGUAGE" -a -n "$SEQUENTIAL" ] && LANGUAGE
=c
1284 [ -z "$PARADIGM" -a -n "$LANGUAGE" ] && PARADIGM
="$LANGUAGE"
1285 [ -z "$PARADIGM" ] && PARADIGM
="charm++"
1288 "c"|
"C"|
"c++"|
"C++")
1289 [ -z "$SEQUENTIAL" -a -z "$NATIVE" ] && Abort
"Language $LANGUAGE is for sequential programs"
1293 # update charm to bgcharm
1294 [ "$PARADIGM" = "charm++" -a -n "$CMK_BIGSIM" ] && PARADIGM
="bgcharm++"
1295 [ "$PARADIGM" = "converse++" -a -n "$CMK_BIGSIM" ] && PARADIGM
="bgconverse++"
1297 [ "$PARADIGM" = "bgcharm++" ] && TRACEMODE
=`AddList $TRACEMODE bluegene`
1299 if [ $USE_F77_LIBRARIES = "1" ]
1301 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F77LIBS"
1304 if [ $USE_F90_LIBRARIES = "1" ]
1307 if [ ! -r $CHARMLIB/libconv-utilf.a
]
1309 Abort
"Error: Fortran support library $CHARMLIB/libconv-utilf.a missing. Is your Fortran compiler working?"
1312 POST_LIBRARIES
="$POST_LIBRARIES -lconv-utilf $CMK_F90LIBS"
1316 if [ "$CMK_COMPILER" = "bgclang" ]
1318 OPTS_CC_GENCPM
="-x c " # -x c is only applied for the preprocessing of the GEN-CPM files on BG/Q
1321 OPTS_CC_GENCPM
="$OPTS_CC $OPTS_CC_GENCPM"
1323 ############ Determine the language and libraries ##########
1325 # Parse out the real languages
1329 USE_F90_LIBRARIES
="1"
1332 PRE_LIBRARIES
="$PRE_LIBRARIES -lf90charm -lckf"
1333 POST_LIBRARIES
="$POST_LIBRARIES $CMK_F90LIBS"
1335 "bluegene"|
"bigsim")
1336 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs"
1339 POST_LIBRARIES
="$POST_LIBRARIES -lbluegene"
1342 PRE_LIBRARIES
="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1345 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1349 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1350 if [ $CMK_CELL -eq 1 ]
1353 if [ "$PARADIGM" = "converse++" ]
1355 # Include a "do nothing" register_accel_spe_funcs() function
1356 POST_LIBRARIES
="$POST_LIBRARIES -lnoAccelStub"
1359 if [ "$PARADIGM" = "charm++" ]
1362 if [ $SPU_USE_CPP -eq 1 ]
1364 SPU_COMPILER
=$CMK_SPU_CXX
1365 SPU_LINKER
=$CMK_SPU_LDXX
1367 SPU_COMPILER
=$CMK_SPU_CC
1368 SPU_LINKER
=$CMK_SPU_LD
1371 # Include the spe object file for linking into main executable
1372 POST_LIBRARIES
="$POST_LIBRARIES main__funcLookup__.genSPECode.ppe.o"
1377 if [ "$AMPIMAIN" != "" ]
1379 OBJECTFILES
="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1384 CMK_SYSINC
="-I$CHARMINC/ampi $CMK_SYSINC"
1387 if [ "$TLSGLOBALS" = "1" ]
1389 if [ "$CMK_GDIR" = "uth" ]
1391 echo "Error: -tlsglobals is not supported with the uth machine layer."
1394 if [ "$CMK_COMPILER_KNOWS_TLSDIRECTSEGREFS" != '1' ] && [ "$CMK_COMPILER" != 'clang' -o "$CMK_MACOSX" != '1' ]
1396 echo "Warning: -tlsglobals may not work with compilers that do not recognize -mno-tls-direct-seg-refs."
1398 if [ "$CMK_HAS_ELF_H" != '1' -a "$CMK_MACOSX" != '1' ]
1400 echo "Warning: -tlsglobals requires elf.h"
1404 if [ "$SWAPGLOBALS" = "1" ]
1406 if [ "$CMK_HAS_ELF_H" != "1" ]
1408 echo "Error: -swapglobals requires elf.h"
1412 LD_VERSION_TEXT
=`$CMK_LD -Wl,--version,-v 2>/dev/null`
1413 if ! `printf "$LD_VERSION_TEXT" | grep -q 'GNU ld'`
1415 echo "Warning: -swapglobals may not work with linkers other than GNU ld."
1417 LD_VERSION
=`printf "$LD_VERSION_TEXT" | grep -Eo 'GNU ld (\([^)]*\) )?(version )?[-0-9._a-zA-Z]+' | awk '{print $NF}'`
1418 LD_VERSION_MAJOR
=`printf $LD_VERSION | cut -d. -f1`
1419 LD_VERSION_MINOR
=`printf $LD_VERSION | cut -d. -f2 | cut -d- -f1`
1420 if [ "$LD_VERSION_MAJOR" -gt 2 ] ||
[ "$LD_VERSION_MAJOR" -eq 2 -a "$LD_VERSION_MINOR" -gt 23 ]
1422 echo "Warning: -swapglobals may not work with GNU ld >= 2.24."
1423 echo "For some versions, an experimental patch is available:"
1424 echo 'https://charm.cs.illinois.edu/gerrit/gitweb?p=libbfd-patches.git;a=tree;f=swapglobals'
1428 if [ "$CMK_SMP" = "1" ]
1430 echo "Error: -swapglobals is not supported on SMP builds of Charm++/AMPI"
1433 swapo
="$CHARMLIB/libglobal-swap.a"
1434 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1436 echo "Error: global-swapping library $swapo missing--"
1437 echo " Is -swapglobals supported on this machine?"
1440 MIDDLE_LIBS
="-lglobal-swap $MIDDLE_LIBS"
1444 if [ "$SWAPGLOBALS" = "2" ]
1446 echo "-copyglobals option is no longer supported by Charm++/AMPI"
1452 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1454 POST_LIBRARIES
="-lmpi-mainmodule $POST_LIBRARIES"
1457 ##############################################################################
1459 # Some quick consistency checks in preparation for full link-step
1461 # Check for valid choice of TRACEMODE
1462 # Check for valid choice of BALANCE
1463 # Check for compatibility among BALANCE and TRACEMODE
1465 ##############################################################################
1467 Debug
"About to check TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1469 # Check for valid choice of TRACEMODE
1471 if [ x
"$TRACEMODE" != x
]
1473 for trace
in $TRACEMODE; do
1475 "converse"|
"converse++"|
"bgconverse++"|
"bigsim"|
"bluegene")
1476 if [ "$trace" != "counter" ]; then
1477 Warning
"Tracemode $trace isn't supported in Converse-level programs; Dropping it"
1478 TRACEMODE
=`DropList $trace $TRACEMODE`
1486 TRACE_OBJ
="$TRACE_OBJ -ltrace-$trace"
1491 if test x
$PARADIGM = x
"bgcharm++"
1496 Debug
"Finished with TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1498 BAL_OBJ
="-lldb-$BALANCE -lconv-ldb"
1500 # Check for valid choice of MEMORY
1502 # Set the default expansions of unprefixed variants
1504 'verbose'|
'paranoid'|
'leak'|
'isomalloc')
1508 MEMORY
="gnu-$MEMORY"
1512 # Isomalloc does not work on BGQ or Windows:
1513 if [ "$CMK_BLUEGENEQ" = "1" -o "$CMK_COMPILER" = "msvc" ] && [ "$MEMORY" = "${MEMORY%isomalloc}isomalloc" ]
1515 Abort
"Error: Isomalloc is not supported on BlueGene/Q or Windows."
1518 MEM_OBJ
="-lmemory-${MEMORY}"
1520 # For memory wrapping around the OS allocator, need to add also the wrapper object
1523 MEM_OBJ
=$MEM_OBJ" -lmemory-os-wrapper"
1527 # Check for valid choice of THREAD
1529 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1531 THREAD
=$CMK_LD_SHARED_THREAD
1533 if [ "$TLSGLOBALS" = "1" ]
1535 THREAD
=${THREAD%-tls}-tls
1538 THREAD_OBJ
="-lthreads-${THREAD}"
1543 modInitName
="moduleinit$$"
1544 modInitSrc
="$modInitName.C"
1545 modInitObj
="$modInitName.o"
1548 ##############################################################################
1550 # Final link step variables
1552 ##############################################################################
1557 CORE_LIBS
="-lconv-core -ltmgr -lconv-util -lconv-partition $TRACE_OBJ $CMK_HWLOC_LIBS"
1559 # get TAU stub makefile variables
1560 if test "$CMK_WITH_TAU" = "true"
1562 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1563 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1564 TAU_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1565 TAU_MPI_LIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1566 TAU_MPI_FLIBS
=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1567 TAU_DEFS
=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1568 TAU_INCLUDE
=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1572 # done getting TAU variables
1574 if [ "$BUILD_SHARE" = "0" ]
1576 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1579 CMK_SYSLIBS
="$CMK_SYSLIBS -lm"
1584 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1585 if [ -z "$NO_MAIN" ]
1587 MIDDLE_LIBS
="-lckmainf $MIDDLE_LIBS"
1590 if [ "$TAU_TRACE_MPI" = "1" ]
1592 TAU_LIBS
="$TAU_MPI_FLIBS $TAU_LIBS"
1594 TAU_LIBS
="$TAU_LIBS"
1597 "charm"|
"charm++"|
"f90charm"|
"ckbluegene"|
"bgcharm++")
1599 MIDDLE_LIBS
="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1600 if [ -z "$NO_MAIN" ]
1604 MIDDLE_LIBS
="-lckmainf $MIDDLE_LIBS"
1606 elif [ -z "$AMPIMAIN" ]
1608 MIDDLE_LIBS
="-lckmain $MIDDLE_LIBS"
1611 if [ "$TAU_TRACE_MPI" = "1" ]
1613 TAU_LIBS
="$TAU_MPI_LIBS $TAU_LIBS"
1615 TAU_LIBS
="$TAU_LIBS"
1620 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1622 "converse++"|
"bgconverse++"|
"bluegene"|
"bigsim")
1624 MIDDLE_LIBS
="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1626 "c"|
"C"|
"c++"|
"C++"|
"f90"|
"f77")
1629 Abort
"Unrecognized choice of language $LANGUAGE / paradigm $PARADIGM"
1633 if [ "$BUILD_SHARE" = "0" ]
1635 MIDDLE_LIBS
="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1638 if [ "$CHARM_SHARED" = "1" ]
1640 [ -z "$CHARMLIBSO" ] && Abort
"Charm++ lib_so directory not found!"
1641 # build user executable/shared lib linking with charm .so
1642 OPTS_LD
="$OPTS_LD $CMK_LD_LIBRARY_PATH"
1643 LANG_LIBS
="-L$CHARMLIBSO"
1645 LANG_LIBS
="-L$CHARMLIB"
1648 if [ -z "$STANDALONE" ]
1650 ALL_LIBS
="$LANG_LIBS $PRE_LIBRARIES $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES"
1652 "charm"|
"charm++"|
"f90charm"|
"ckbluegene"|
"bgcharm++")
1653 ALL_LIBS
="$ALL_LIBS -lmoduleNDMeshStreamer -lmodulecompletion"
1657 ALL_LIBS
="$USER_PRE_LIBRARIES $USER_POST_LIBRARIES"
1660 if [ -n "$LINK_WHOLE_ARCHIVE" ]
1662 ALL_LIBS
="$CXX_NO_AS_NEEDED $LDXX_WHOLE_ARCHIVE_PRE $ALL_LIBS $LDXX_WHOLE_ARCHIVE_POST $CMK_SYSLIBS"
1664 ALL_LIBS
="$ALL_LIBS $CMK_SYSLIBS"
1667 if [ "$BUILD_SHARE" = "0" ]
1669 ALL_LIBS
="$ALL_LIBS $CHARMLIB/conv-static.o"
1672 if [ -n "$LINK_CXX_STL" ]
1674 ALL_LIBS
="$ALL_LIBS -lstdc++"
1677 if [ "$TRACE_WITH_TAU" = 1 ]
1679 echo "Linking with the TAU libraries: $TAU_LIBS"
1680 ALL_LIBS
="$ALL_LIBS $TAU_LIBS"
1682 Debugf
"All libraries are: $ALL_LIBS"
1684 # preserve this variable in its state here for use later
1685 CHARM_ALL_LIBS
="$ALL_LIBS"
1686 if [ "$BUILD_SHARE" = "1" -o -n "$SKIP_MODULEINIT" ]
1688 ALL_LIBS
="$OBJECTFILES $ALL_LIBS"
1690 ALL_LIBS
="$OBJECTFILES $modInitObj $ALL_LIBS"
1693 if [ -n "$F90_MAIN" ]
1695 # for_main needs to be placed at beginning
1696 CMK_LD_FLAGS
="$CMK_F90MAINLIBS $CMK_LD_FLAGS"
1697 CMK_LDXX_FLAGS
="$CMK_F90MAINLIBS $CMK_LDXX_FLAGS"
1700 if [ -n "$F90_MAIN" -o "$USE_F90_LIBRARIES" = '1' ]
1702 if [ "$CMK_CAN_LINK_FORTRAN" != '1' ]
1704 echo "Error: Configure testing was unable to link a Fortran program."
1709 ########################################################################
1711 # Finalize command parameters
1713 ########################################################################
1715 CHARM_CPP_C
="$CMK_CPP_C"
1717 CHARM_CXX
="$CMK_CXX"
1719 CHARM_LDXX
="$CMK_LDXX"
1721 CHARM_CPP_C_FLAGS
="$CMK_CPP_C_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CC_GENCPM $OPTS_CPP"
1722 CHARM_CC_FLAGS
="$CMK_CC_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC"
1723 CHARM_CXX_FLAGS
="$CMK_CXX_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX"
1724 CHARM_LD_FLAGS
="$CMK_LD_FLAGS $CMK_LINK_BINARY $CMK_LIBDIR $OPTS_LD $ALL_LIBS"
1725 CHARM_LDXX_FLAGS
="$CMK_LDXX_FLAGS $CMK_LINK_BINARY $CMK_LIBDIR $OPTS_LD $ALL_LIBS"
1728 ########################################################################
1730 # Print command building blocks and quit, if specified
1732 ########################################################################
1734 if [ -n "$PRINT_BUILDING_BLOCKS" ]
1736 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
1738 eval "echo $i=\\'\${$i}\\'"
1744 ########################################################################
1746 # We've parsed and verified the command-line parameters.
1747 # Now we prepare routines to clean up and exit.
1748 # None of these routines ever returns-- they all just exit.
1750 ########################################################################
1754 if [ "a$COPYTO" != "a" -a "a$COPYTO" != "a$OBJECT" ]
1756 [ -d $COPYTO ] && COPYTO
="$COPYTO/"
1757 if [ "a$PROG_EXT" != "a" -a -r "$OBJECT$PROG_EXT" ] ; then
1758 Warning
"Appending $PROG_EXT to object file name"
1759 OBJECT
="$OBJECT$PROG_EXT"
1761 [ ! -d $COPYTO ] && DoNoErrCheck
$RM $COPYTO
1762 Do
$CP $OBJECT $COPYTO
1764 test -n "$COPY_EXIT" && Success
1768 for COPY
in `echo $MODCOPIES`
1770 if [ "a$COPY" != "a$OBJECT" ]
1772 [ -d $COPY ] && COPY
="$COPY/"
1773 if [ -n "$CMK_MOD_NAME_ALLCAPS" ] ; then
1774 OBJECT
=`echo $OBJECT | tr "a-z" "A-Z"`
1776 if [ -r "$OBJECT.$CMK_MOD_EXT" ] ; then
1777 Warning
"Appending .$CMK_MOD_EXT to object file name"
1778 OBJECT
="$OBJECT.$CMK_MOD_EXT"
1780 [ ! -d $COPY ] && DoNoErrCheck
$RM $COPY
1781 Do
$CP $OBJECT $COPY
1792 ##############################################################################
1794 # Preprocess the GEN-CPM files
1796 ##############################################################################
1798 Debug
"Preprocessing GEN-CPM files"
1800 for FILE
in `echo $GENCPM`
1802 # This used to be "$FILE:r", which strips the extention
1803 BASE
=`stripExtention $FILE`
1804 MYTMP
=`basename $FILE`".TMP"
1805 DELETE
="$DELETE $MYTMP.c $MYTMP.i"
1806 DoNoErrCheck
$RM $BASE.cpm.h
$MYTMP.c
1807 Do
touch $BASE.cpm.h
1808 Do
$LN -f -s $FILE $MYTMP.c
1809 Do
$CHARM_CPP_C $CHARM_CPP_C_FLAGS $MYTMP.c
> $MYTMP.i
1810 Do
$CHARMBIN/conv-cpm
$MYTMP.i
$BASE.cpm.h
1813 ##############################################################################
1815 # Compile all specified files
1817 # All temporary files named *.TMP.* for easy cleanup.
1819 ##############################################################################
1821 Debug
"About to compile..."
1825 BASE
=`stripExtention \`basename $FILE\
``
1826 MYTMP
=`basename $FILE`".TMP"
1827 FILE_EXT
=`getExtention $FILE`
1831 # in case of: charmc -o object.o -c foo.c,
1832 # avoid foo.c => remove foo.o => foo.o => object.o,
1833 # instead generate object.o directly.
1834 # remove and generate foo.o may be dangerous in parallel make
1835 # for example in the case of compiling several objs from one
1836 # same c file such as memory.C.
1837 if [ $numFiles = 1 -a -n "$OBJECT" ]
1839 OBJ_EXT
=`getExtention $OBJECT`
1840 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1847 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1850 .c|.s|.S|.C|.cc|.cxx|.cpp|.c
++|.cu|.f|.F|.f90|.F90|.fpp|.FPP|.f77|.F77
)
1851 [ $VERBOSE ] && echo "Compiling $FILE"
1852 DoNoErrCheck
$RM $BASEO `stripExtention $BASEO`.f.o
1855 if [ ! -z "$SKIPLINK" ]
1860 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1864 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1867 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++)
1868 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE
1871 *.f|
*.F|
*.f77|
*.F77
)
1872 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1875 *.f90|
*.F90|
*.fpp|
*.FPP
)
1876 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1877 Do
$CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE
1886 test "$PARADIGM" = "f90charm" && XIOPTS
="$XIOPTS -f90"
1887 if [ "$PREPROCESS_CI" = "yes" ]
1889 Do
$CMK_CPP_CHARM $OPTS_CPP $FILE | Do
$CHARMBIN/charmxi
$XIOPTS -orig-file $FILE
1891 Do
$CHARMBIN/charmxi
$XIOPTS $FILE
1895 Do
$CHARM_CC $CHARM_CC_FLAGS -c $FILE $DESTO
1896 if [ "$Do_res" -ne 0 ]
1901 *.C|
*.cc|
*.cxx|
*.cpp|
*.c
++|
*.cu
)
1904 Do
$CMK_NATIVE_CXX $CMK_NATIVE_CXX_FLAGS -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP -c $FILE $DESTO
1906 Do
$CHARM_CXX $CHARM_CXX_FLAGS -c $FILE $DESTO
1908 if [ "$Do_res" -ne 0 ]
1913 *.f|
*.F|
*.f77|
*.F77
)
1914 test -z "$CMK_CF90_FIXED" && Abort
"No F90 compiler (CMK_CF90_FIXED) defined"
1915 Do
$CMK_CF90_FIXED -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE $DESTO
1916 if [ "$Do_res" -ne 0 ]
1921 *.f90|
*.F90|
*.fpp|
*.FPP
)
1922 test -z "$CMK_CF90" && Abort
"No F90 compiler (CMK_CF90) defined"
1923 test -z "$PREPROCESS" && OPTS_F90
="$OPTS_F90 -c"
1924 Do
$CMK_CF90 -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE $DESTO
1925 if [ "$Do_res" -ne 0 ]
1931 Abort
"I'm not yet smart enough to compile $FILE"
1933 *.o|
*.so|
*.so.
*|
*.sl|
*.a|
*.dylib|
*.co
)
1934 [ ! -s $FILE ] && Abort
"$FILE: file not recognized: File truncated"
1942 Abort
"file with unrecognized extension $FILE"
1946 ##############################################################################
1948 # POSSIBLY, SKIP LINK-STEP
1950 # 1. No $OBJECT may be specified at all --- its just a compilation.
1951 # 2. If $OBJECT is a ".a" file, a library is created from $OBJECTFILES.
1952 # 3. If $OBJECT is a ".o" file, then an "LDRO" is created from $OBJECTFILES.
1953 # 4. Language may be sequential. Do a quick and easy linkage.
1955 # in any of these cases, the full link step is skipped.
1957 ##############################################################################
1960 Debugf
"Running ldro..."
1961 DoNoErrCheck
$RM $OBJECT
1962 # convert to absolute path if required
1963 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1965 dir
=`dirname $OBJECT`
1966 fname
=`basename $OBJECT`
1970 if test "$MAKE_LDXX" = "1"
1972 soTool
="$CMK_LDXX $CMK_LDXX_FLAGS"
1974 soTool
="$CMK_LD $CMK_LD_FLAGS"
1976 if [ -n "$STANDALONE" ]
1978 soLibs
="$USER_PRE_LIBRARIES $USER_POST_LIBRARIES"
1980 soLibs
="$PRE_LIBRARIES $POST_LIBRARIES"
1981 [ "$CMK_MACOSX" = "1" ] && OPTS_LD
="$OPTS_LD -Wl,-install_name,$CHARMLIBSO/$fname"
1983 if [ -n "$LINK_WHOLE_ARCHIVE" ]
1985 soLibs
="$CXX_NO_AS_NEEDED $LDXX_WHOLE_ARCHIVE_PRE $soLibs $LDXX_WHOLE_ARCHIVE_POST"
1987 soLibs
="$soLibs $CMK_SYSLIBS"
1988 if [ -n "$LINK_CXX_STL" ]
1990 soLibs
="$soLibs -lstdc++"
1992 soCmd
="$soTool $CMK_LIBDIR -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $soLibs $CMK_LD_SHARED_LIBS"
1995 if [ $Do_res -ne 0 ]
1997 if [ -n "$NOABORT" ]
2001 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
2002 echo "!! Failed to compile Charm++ shared library. You can disable shared !!"
2003 echo "!! lib compilation by providing --no-build-shared build option like: !!"
2004 echo "!! ./build charm++ netlrts-linux --no-build-shared -O !!"
2005 echo "!! or reexecute this charmc command with the --no-build-shared option !!"
2006 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
2007 Abort
"Command $soCmd returned error code $Do_res"
2013 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
2015 # We have no target object, or are playing preprocessor tricks-- just end
2016 Debugf
"No target object-- finished"
2020 Debug
"About to link..."
2022 if [ "$INPUT_GIVEN" != "1" ]
2024 Abort
"Trying to link, but no object files or library archives were specified"
2027 # if interoperate dont create the library now, wait to collect all info
2028 if [ "$MPI_INTEROPERATE" = "" ]
2032 Debugf
"Converting $FILES to $OBJECTFILES"
2033 nFiles
=`echo $FILES | wc -w`
2034 nObj
=`echo $OBJECTFILES | wc -w`
2035 # One source file, one .o: just move the .o
2036 if [ $OBJECT != $OBJECTFILES ]
2038 Debugf
"Moving .o to destination"
2039 DoNoErrCheck
$RM $OBJECT
2040 Do
$MV $OBJECTFILES $OBJECT
2044 *.so|
*.so.
*|
*.sl|
*.dylib
)
2045 # Make shared library
2046 # If building shared is not supported and this object is not standalone, exit.
2047 if [ "$BUILD_SHARE" = 0 -a -z "$STANDALONE" ]
2049 Warning
"Warning: building shared library is not supported, recompile charm++ with '--build-shared'."
2051 elif [ "$CHARM_SHARED" = "0" ]
2057 # Make regular (.a, non-shared) library
2058 # in case building charm so, build .so under lib_so as well # Gengbin
2059 if [ "$BUILD_SHARE" = "1" ]
2066 DESTDIR
=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
2067 OBJECT
=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
2069 COPYTO
=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
2072 OBJECT
=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
2073 [ -f $DESTDIR/.charmso
] && MakeSO
2079 DoNoErrCheck
$RM $OBJECT
2080 Do
$CMK_AR $OBJECT $OBJECTFILES
2081 Do
$CMK_RANLIB $OBJECT
2086 # If the above case returns, we're not creating a .o or .a file,
2087 # so linking is needed.
2089 if [ $CMK_CELL -eq 1 ]
2092 if [ "$PARADIGM" = "charm++" ]
2095 # Make the spe object file to be included
2096 Do
$SPU_COMPILER -c -I$CHARMINC $CMK_SYSINC -o main__funcLookup__.genSPECode.o main__funcLookup__.genSPECode.c
-DCMK_CELL_SPE=1
2097 Do
$SPU_LINKER -L$CHARMLIB -o main__funcLookup__.genSPECode main__funcLookup__.genSPECode.o
$CMK_SPERT_LIBS $SPU_EXTRA_LIBS
2098 Do
$CMK_PPU_EMBEDSPU spert_main main__funcLookup__.genSPECode main__funcLookup__.genSPECode.ppe.o
2103 # check if we're linking a sequential object
2105 "c"|
"C"|
"f90"|
"f77")
2108 Do
$CMK_NATIVE_LD $CMK_NATIVE_LD_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2109 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2111 Do
$CMK_SEQ_LD $CMK_SEQ_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2112 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2119 Do
$CMK_NATIVE_LDXX $CMK_NATIVE_LDXX_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2120 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2122 Do
$CMK_SEQ_LDXX $CMK_SEQ_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2123 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2130 ##############################################################################
2132 # Confirm that TRACEMODE, BALANCE, MEMORY, THREAD exist
2134 ##############################################################################
2136 # [ -r $CHARMLIB/libtrace-projections.a ] || Abort "trace libraries not installed. Is Charm++ built properly?"
2138 if [ x
"$TRACEMODE" != x
]
2140 for trace
in $TRACEMODE; do
2141 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort
"charmc : No such tracemode $trace"
2145 BAL_EXT
=`getExtention $BALANCE`
2146 if [ -z "$BAL_EXT" ]; then
2147 # Balance has no extension-- is a library reference
2148 if [ -f "${CHARMLIB}/libldb-$BALANCE.a" ]; then
2149 BAL_OBJ_FILE
="${CHARMLIB}/libldb-$BALANCE.a"
2151 BAL_OBJ_FILE
="${CHARMLIBSO}/libldb-$BALANCE.so"
2154 # Balance has some extension-- must be a .o or .a file
2155 BAL_OBJ_FILE
="$BALANCE"
2158 if [ ! -r "$BAL_OBJ_FILE" ]
2160 if [ "$BALANCE" = "$BAL_OBJ_FILE" ]
2162 Abort
"Could not find load balancer object $BAL_OBJ_FILE"
2164 (cd $CHARMLIB ; ls -al libldb-
*)
2165 Abort
"Unknown load balancer $BALANCE / $BAL_OBJ_FILE"
2169 if [ -f "${CHARMLIB}/libmemory-${MEMORY}.a" ]; then
2170 MEM_OBJ_FILE
="${CHARMLIB}/libmemory-${MEMORY}.a"
2172 MEM_OBJ_FILE
="${CHARMLIBSO}/libmemory-${MEMORY}.so"
2175 if [ ! -r $MEM_OBJ_FILE -o ! -s $MEM_OBJ_FILE ]
2177 (cd $CHARMLIB ; list
=`ls libmemory-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
2178 Abort
"charmc : No such memory mode $MEMORY"
2181 if [ -f "${CHARMLIB}/libthreads-${THREAD}.a" ]; then
2182 THREAD_OBJ_FILE
="${CHARMLIB}/libthreads-${THREAD}.a"
2184 THREAD_OBJ_FILE
="${CHARMLIBSO}/libthreads-${THREAD}.so"
2187 if [ ! -r $THREAD_OBJ_FILE -o ! -s $THREAD_OBJ_FILE ]
2189 (cd $CHARMLIB ; list
=`ls libthreads-* 2>/dev/null`; test -n "$list" && for i
in $list; do [ -s $i ] && ls -l $i; done )
2190 Abort
"charmc : No such thread mode $THREAD"
2194 ################# Build the module initialization function ##################
2196 if [ -z "$SKIP_MODULEINIT" ]
2198 DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1
2200 for module
in $MODULES; do
2201 echo "extern void _register$module(void);" >> $modInitSrc
2203 for trace
in $TRACEMODE; do
2204 if test $trace = "summary"
2206 echo " extern void _registerTraceSummary();" >> $modInitSrc
2207 elif test $trace = "projections"
2209 echo " extern void _registerTraceProjections();" >> $modInitSrc
2210 elif test $trace = "simple"
2212 echo " extern void _registerTraceSimple();" >> $modInitSrc
2213 elif test $trace = "Tau"
2215 echo " extern void _registerTraceTau();" >> $modInitSrc
2216 elif test $trace = "utilization"
2218 echo " extern void _registerTraceUtilization();" >> $modInitSrc
2219 elif test $trace = "controlPoints"
2221 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2222 elif test $trace = "perfReport"
2224 Do
$CP $CHARMBIN/fuzzytree.txt fuzzytree.txt
2225 Do
$CP $CHARMBIN/tree.txt tree.txt
2226 echo " extern void _registerTraceAutoPerf();" >> $modInitSrc
2228 elif test $trace = "all"
2230 echo " extern void _registerTraceProjections();" >> $modInitSrc
2231 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2232 echo " extern void _registerTraceSummary();" >> $modInitSrc
2235 if test -n "$BALANCER"
2237 echo "extern void LBDefaultCreate(const char *);" >> $modInitSrc
2239 echo "void _registerExternalModules(char **argv) { (void)argv;" >> $modInitSrc
2240 for module
in $MODULES; do
2241 [ -n "$VERBOSE" ] && echo "Adding registration for module $module"
2242 echo " _register$module();" >> $modInitSrc
2244 for trace
in $TRACEMODE; do
2245 if test $trace = "summary"
2247 echo " _registerTraceSummary();" >> $modInitSrc
2248 elif test $trace = "projections"
2250 echo " _registerTraceProjections();" >> $modInitSrc
2251 elif test $trace = "Tau"
2254 echo " _registerTraceTau();" >> $modInitSrc
2255 elif test $trace = "simple"
2257 echo " _registerTraceSimple();" >> $modInitSrc
2258 elif test $trace = "utilization"
2260 echo " _registerTraceUtilization();" >> $modInitSrc
2261 elif test $trace = "controlPoints"
2263 echo " _registerTraceControlPoints();" >> $modInitSrc
2264 elif test $trace = "perfReport"
2266 echo " _registerTraceAutoPerf();" >> $modInitSrc
2267 elif test $trace = "all"
2269 echo " _registerTraceProjections();" >> $modInitSrc
2270 echo " _registerTraceControlPoints();" >> $modInitSrc
2271 echo " _registerTraceSummary();" >> $modInitSrc
2274 if test -n "$BALANCER"
2276 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
2277 for deflb
in $BALANCER
2279 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
2282 echo "}" >> $modInitSrc
2284 # creating projections
2285 echo "void _createTraces(char **argv) { (void)argv;" >> $modInitSrc
2286 for trace
in $TRACEMODE; do
2287 [ -n "$VERBOSE" ] && echo "Adding registration for trace $trace"
2288 echo "extern void _createTrace$trace(char **argv);" >> $modInitSrc
2289 echo "_createTrace$trace(argv);" >> $modInitSrc
2291 echo "}" >> $modInitSrc
2293 Do
$CHARM_CXX $CHARM_CXX_FLAGS -c $modInitSrc -o $modInitObj
2296 ###############################################################################
2300 ###############################################################################
2302 Debug
"About to perform final link..."
2304 #currently only support creation of .a
2305 if [ "$MPI_INTEROPERATE" != "" ]
2309 # in case building charm so, build .so under lib_so as well # Gengbin
2310 DoNoErrCheck
$RM $OBJECT
2311 if [ -z "$SKIP_MODULEINIT" ]
2313 echo "$CMK_AR $OBJECT $OBJECTFILES $modInitObj"
2314 Do
$CMK_AR $OBJECT $OBJECTFILES $modInitObj
2316 Do
$CMK_RANLIB $OBJECT
2317 echo "export CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\"" > .
/charm_all_libs.sh
2318 echo "CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\""
2321 *.so|
*.so.
*|
*.sl|
*.dylib
)
2322 echo "Warning: building shared library failed; for interoperation build
2329 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2331 # build an application .so linking with charm .so
2332 OPTS_LD
="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
2333 Debugf
"Running ldro..."
2334 DoNoErrCheck
$RM $OBJECT
2335 [ "$MAKE_LDXX" = "1" ] && Do
$CMK_LDXX $CMK_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $ALL_LIBS
2336 [ "$MAKE_LD" = "1" ] && Do
$CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $ALL_LIBS
2339 # Make a regular executable: call the appropriate linker
2340 [ "$MAKE_LDXX" = "1" ] && Do
$CHARM_LDXX $CHARM_LDXX_FLAGS -o $OBJECT
2341 [ "$MAKE_LD" = "1" ] && Do
$CHARM_LD $CHARM_LD_FLAGS -o $OBJECT
2344 ########################################################################
2346 # Copy conv-host to user directory if it is present in installation.
2348 ########################################################################
2350 if test "$COPY_CHARMRUN" = "true"
2352 targ
=charmrun
$CMK_POST_EXE
2353 [ ! -x $CHARMBIN/$targ -a -n "$CMK_POST_EXE" ] && targ
=charmrun
2354 convhost
=conv-host
$CMK_POST_EXE
2356 if [ -x $CHARMBIN/$targ ]
2358 DoNoErrCheck
$RM $targ
2359 DoNoErrCheck
$CP $CHARMBIN/$targ $targ 2> /dev
/null
2363 [ -z "$SKIP_MODULEINIT" -a -z "$SAVE" ] && DoNoErrCheck
$RM $modInitSrc $modInitObj > /dev
/null
2>&1