Implement malloc_info to replace mall_info
[charm.git] / src / scripts / charmc
blobfb522fc39c24feac713ff55a4ae11115bbf975c0
1 #!/bin/sh
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.
14 RM="rm -f"
15 CP="cp -p"
16 MV="mv"
17 LN="ln"
18 WC="wc"
19 SED="sed"
21 MACHTYPE=""
22 SEQUENTIAL=""
23 NATIVE=""
24 LANGUAGE=""
25 PARADIGM=""
26 BALANCE="rand"
27 TRACEMODE=""
28 TRACE_OBJ=
29 MEMORY="default"
30 THREAD="default"
31 VERBOSE=""
32 DEBUG_SCRIPT=""
33 SAVE=""
34 PURIFY=""
35 SKIPLINK=""
36 OVERRIDE_CC=""
37 OVERRIDE_CXX=""
38 OVERRIDE_F90=""
39 OVERRIDE_LD=""
40 OVERRIDE_LDXX=""
41 #Generic options, passed to everything
42 OPTS=""
43 #Specific options
44 #charm internal flag, only pass to c and cxx, not f90
45 OPTS_CPP_INTERNAL="-D__CHARMC__=1"
46 OPTS_CPP=
47 OPTS_LDRO=""
48 OPTS_CC=""
49 OPTS_CC_GENCPM=""
50 OPTS_CXX=""
51 OPTS_F90=""
52 OPTS_LD=""
53 OPTS_LDXX=""
54 OPTS_PIC=""
55 USE_PIC="0"
57 CHARMDEBUG=""
58 LINK_PYTHON=""
59 OBJECT=""
60 EXPLICIT_OBJECT="no"
61 EXPLICIT_COMPILATION="no"
62 POST_LANGUAGE=""
63 POST_LIBRARIES=""
64 PRE_LIBRARIES=""
65 USE_F90_LIBRARIES="0"
66 USE_F77_LIBRARIES="0"
67 F90_MODDIR=
68 AMPIMAIN=""
69 COPYTO=""
70 MODCOPIES=""
71 MODULES=""
72 BALANCER=""
73 FILES=""
74 OBJECTFILES=""
75 DELETE=""
76 MAINOBJ=""
77 GENCPM=""
78 OPTIMIZE_MODE=""
79 PRODUCTION_MODE=""
80 USE_RELIABLE_CC=""
81 USE_FASTEST_CC=""
82 PROG_EXT=""
83 GENDEPENDS="no"
84 COUNTTOKENS="no"
85 USE_OPENMP="no"
86 SKIP_MODULEINIT=""
88 COPY_CHARMRUN=true
89 USE_BUILD_OPTIONS=0
91 COPY_EXIT="true"
92 CHARM_SHARED="0"
93 BUILD_SHARE="0"
94 SWAPGLOBALS="0"
95 TLSGLOBALS="0"
96 ROSE_OMP_TLS_GLOBALS="no"
97 PRINT_BUILDING_BLOCKS=""
98 NOABORT=""
100 TAU_MAKEFILE=Make.tau
101 TAU_TRACE_MPI=1
103 CMK_CELL=0
104 SPU_USE_CPP=0
105 SPU_EXTRA_LIBS=""
107 MPI_INTEROPERATE=""
108 NO_MAIN_MODULE=""
109 NO_MAIN=""
110 CUSTOM_PARTITION=""
111 PREPROCESS_CI="yes"
112 INPUT_GIVEN=""
114 ####################################################################
116 # Utility routines used below
118 ###################################################################
120 # PrintUsage: prints a helpful command-line usage message and quits
121 # Args: any additional messages
122 printUsage() {
123 printVersion
124 echo
125 echo "Usage: charmc [ flags ] <files>"
126 echo
127 echo " flags:"
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"
145 echo
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."
151 echo $*
152 exit 1
155 # End blows away the temporary files (unless SAVE is true) and exits
156 # Args: <exit code>
157 End() {
158 if [ -z "$SAVE" ]
159 then
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
167 done
168 $RM core $DELETE
169 if [ -z "$SKIP_MODULEINIT" -a -n "$modInitObj" ]
170 then
171 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
172 DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
175 exit $1
178 # Write this error message to stderr
179 # ("1>&2" redirects the echo output to stderr).
180 Warning() {
181 echo "$@" 1>&2
184 # This procedure prints an error message and exits.
185 # Args: written to stderr
186 Abort() {
187 Warning "Fatal Error by charmc in directory "`pwd`
188 Warning " $@"
189 Warning "charmc exiting..."
190 End 1
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
197 DoNoErrCheck() {
198 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
199 eval "$@"
202 Do() {
203 DoNoErrCheck "$@"
204 Do_res=$?
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>
213 stripExtention() {
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"
218 echo $se_ret
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>
224 getExtention() {
225 # se_base=`echo $1 | awk -F/ '{print $NF}'`
226 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
227 # echo $se_ret
228 se_ret=`echo $1 | sed -e 's/.*\././'`
229 if test "$se_ret" = $1
230 then
231 echo ""
232 else
233 echo $se_ret
237 Debugf() {
238 [ -n "$VERBOSE" ] && echo "charmc>" $@
241 Debug() {
242 if [ -n "$DEBUG_SCRIPT" ]
243 then
244 echo
245 echo "------- Charmc Debugging info: $* -------"
246 echo "CHARMBIN=$CHARMBIN"
247 echo "CHARMINC=$CHARMINC"
248 echo "CHARMLIB=$CHARMLIB"
249 echo "FILES=$FILES"
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
259 notInList() {
260 search=$1
261 shift
262 while [ $# -gt 0 ]
264 if [ "$search" = "$1" ]
265 then
266 # It's already in there-- fail
267 return 1
269 shift
270 done
271 # It's missing--succeed
272 return 0
275 # Add arguments to our modules list, avoiding duplicates
276 AddModules() {
277 for M in "$@"
279 notInList $M $MODULES && MODULES="$MODULES $M"
280 done
283 # Add this word to this list, avoiding duplicates
284 AddList() {
285 ret=""
286 while [ $# -gt 1 ]
288 ret="$ret $1"
289 shift
290 done
291 if notInList $1 $ret
292 then
293 ret="$ret $1"
295 echo $ret
298 # Drop the first argument anywhere it appears in the subsequent list
299 DropList() {
300 drop="$1"
301 shift
303 ret=""
304 while [ $# -gt 1 ]
306 if [ "$1" != "$drop" ]; then
307 ret="$ret $1"
309 shift
310 done
312 echo $ret
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
321 findCharmBin() {
322 if [ -z "$CHARMBIN" ]
323 then
324 SCRIPT=$1
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
332 # cd $SCRIPT:h
333 # set SCRIPT=$SCRIPT:t
334 # else
335 # foreach dir ($path)
336 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
337 # cd $dir
338 # break
339 # endif
340 # end
341 # endif
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
345 # cd $SCRIPT:h
346 # set SCRIPT=$SCRIPT:t
347 # endif
348 # end
349 # set CHARMBIN=`pwd`
350 # <------------------ End C Shell -----------------------------
354 printVersion()
356 findCharmBin $0
357 version=`cat $CHARMBIN/../include/VERSION`
358 echo Charm++ Version $version
362 ##############################################################################
364 # The following section identifies CHARMBIN, the charm binary-directory.
366 ##############################################################################
368 ORIGDIR=`pwd`
370 # Try to find CHARMBIN by looking in directory where charmc is
372 findCharmBin $0
374 UNAME=`uname -s`
375 FIRST_THREE=`uname -s | awk '{print substr($1,1,3)}' `
376 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
377 then
378 # Running on a windows system-- append .exe to file names
379 PROG_EXT=".exe"
382 CHARMLIB="$CHARMBIN/../lib"
383 CHARMINC="$CHARMBIN/../include"
384 CHARMLIBSO=
385 if test -d "$CHARMBIN/../lib_so"
386 then
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."
406 processArgs() {
407 while [ ! $# -eq 0 ]
409 arg="$1"
410 shift
412 case "$arg" in
413 "-V")
414 printVersion
415 exit 0
418 "-machine")
419 MACHTYPE="$1"
420 shift
423 "-seq")
424 SEQUENTIAL=true
427 "-host")
428 NATIVE=true
431 "-language")
432 # Parse out some fake languages (that are actually modules)
433 case "$1" in
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")
447 PARADIGM="$1"
448 POST_LANGUAGE=1
452 LANGUAGE="$1"
453 POST_LANGUAGE=1
455 esac
456 shift
459 "-debug")
460 # Requested support from charmdebug: add some modules and libraries
461 CHARMDEBUG=1
462 MEMORY="charmdebug"
465 "-module"|"-modules")
466 AddModules `echo $1 | sed -e 's/,/ /g'`
467 INPUT_GIVEN="1"
468 shift
471 "-balancer")
472 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
473 BALANCER="$BALANCER $1"
474 mod=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
475 AddModules $mod
476 shift
479 "-balance")
480 BALANCE="$1"
481 shift
484 "-queue")
485 Warning "Warning: -queue currently being ignored."
486 shift
489 "-memory")
490 MEMORY="$1"
491 shift
494 "-thread")
495 THREAD="$1"
496 shift
499 "-tracemode")
500 TRACEMODE_NEW=`AddList $TRACEMODE $1`
501 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
502 then
503 Warning "Warning: Duplicate tracemode $1 ignored"
504 else
505 TRACEMODE=$TRACEMODE_NEW
507 shift
509 "-no-trace-mpi")
510 TAU_TRACE_MPI=0
513 "-swapglobal"|"-swapglobals")
514 SWAPGLOBALS="1"
515 USE_PIC="1"
518 "-tlsglobal"|"-tlsglobals")
519 TLSGLOBALS="1"
522 "-roseomptlsglobals")
523 ROSE_OMP_TLS_GLOBALS="yes"
526 "-verbose")
527 echo "Verbose mode set"
528 VERBOSE=true
531 "-spu-cpp")
532 SPU_USE_CPP=1
535 "-spu-lib")
536 SPU_EXTRA_LIBS="$SPU_EXTRA_LIBS -l$1"
537 shift
540 "-intrinsic")
541 XI_INTERNAL=true
544 "-debug-script")
545 echo "Will give excessive charmc debugging output..."
546 DEBUG_SCRIPT=true
549 "-save")
550 SAVE=true
553 "-purify")
554 PURIFY=true
557 "-use-reliable-cc")
558 USE_RELIABLE_CC=1
561 "-use-fastest-cc")
562 USE_FASTEST_CC=1
565 "-cc")
566 OVERRIDE_CC="$1"
567 shift
570 "-c++")
571 OVERRIDE_CXX="$1"
572 shift
575 "-f90")
576 OVERRIDE_F90="$1"
577 shift
580 "-ld")
581 OVERRIDE_LD="$1"
582 shift
585 "-ld++")
586 OVERRIDE_LDXX="$1"
587 shift
590 "-cpp-option")
591 OPTS_CPP="$OPTS_CPP $1"
592 shift
595 "-ldro-option")
596 OPTS_LDRO="$OPTS_LDRO $1"
597 shift
600 "-cc-option")
601 OPTS_CC="$OPTS_CC $1"
602 shift
605 "-c++-option")
606 OPTS_CXX="$OPTS_CXX $1"
607 shift
610 "-f90-option")
611 OPTS_F90="$OPTS_F90 $1"
612 shift
615 "-ld-option")
616 OPTS_LD="$OPTS_LD $1"
617 shift
620 "-ld++-option")
621 OPTS_LDXX="$OPTS_LDXX $1"
622 shift
625 "-rpath")
626 OPTS_LDXX="$OPTS_LDXX -rpath $1"
627 shift
630 "-fortran"|"-flib"|"-flibs")
631 USE_F90_LIBRARIES="1"
633 "-f77")
634 USE_F77="1"
636 "-fortran77"|"-f77lib"|"-f77libs")
637 USE_F77_LIBRARIES="1"
639 "-E")
640 # Run preprocessor only
641 PREPROCESS="yes"
642 SKIPLINK="yes"
643 OPTS="$OPTS $arg"
645 "-preprocess")
646 # Run preprocessor as an extra step, continue after preprocessing
647 PREPROCESS="yes"
649 "-no-preprocess-ci")
650 # Turn off the preprocessor for ci files
651 PREPROCESS_CI="no"
653 "-P"|"-S")
654 # Run preprocessor/assembler only
655 SKIPLINK="yes"
656 OPTS="$OPTS $arg"
658 #------ Dependency generation ---------
659 "-M" | "-MM" | "-MMD" | "-MG")
660 SKIPLINK="yes"
661 OPTS="$OPTS $arg"
662 GENDEPENDS="yes"
664 "-MF" | "-MT" | "-MQ" | "-MD") #-MP will pass through automatically
665 OPTS="$OPTS $arg $1"
666 shift
668 #--------------------------------------
669 "-count-tokens")
670 OPTS="$OPTS $arg"
671 COUNTTOKENS="yes"
673 "-default-to-aout")
674 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
675 then
676 OBJECT="a.out"
679 -print-prog-name=*)
680 echo $arg | cut -d'=' -f2
681 exit 0
683 "-c")
684 if [ "$EXPLICIT_OBJECT" = "no" ]
685 then
686 OBJECT=""
688 EXPLICIT_COMPILATION="yes"
691 "-o")
692 EXPLICIT_OBJECT="yes"
693 OBJECT=$1
694 shift
697 "-cp")
698 COPYTO="$1"
699 shift
702 "-cpmod")
703 MODCOPIES="$1 $MODCOPIES"
704 shift
707 "-gen-cpm")
708 GENCPM="$GENCPM $1"
709 shift
713 OPTS_CPP="$OPTS_CPP -I$1"
714 shift
717 -D*|-I*)
718 if echo "$arg" | grep ' ' > /dev/null 2>/dev/null
719 then
720 OPTS_CPP="$OPTS_CPP "\"$arg\"
721 else
722 OPTS_CPP="$OPTS_CPP $arg"
726 -Werror)
727 WERROR="1"
730 -Wno-error)
731 WERROR="0"
734 "-use-new-std")
735 USE_NEW_STD="1"
738 "-no-use-new-std")
739 USE_NEW_STD="0"
742 -LANG*)
743 Warning "passing unrecognized option $arg to all compilers and linkers"
744 OPTS="$OPTS $arg"
746 -shared|-G)
747 BUILD_SHARE="1"
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"
752 -charm-shared|-cs)
753 CHARM_SHARED="1"
755 -build-shared)
756 # used internally when building Charm++ to create lib_so
757 BUILD_SHARE="1"
759 -no-build-shared)
760 # used internally not to build Charm++ lib_so
761 BUILD_SHARE="0"
763 "-optimize")
764 OPTIMIZE_MODE=true
767 "-no-optimize")
768 OPTIMIZE_MODE=false
771 "-production")
772 PRODUCTION_MODE=true
774 "-no-production")
775 PRODUCTION_MODE=false
778 -Wl,*)
779 POST_LIBRARIES="$POST_LIBRARIES $arg"
782 "-pg"|"-g"|-W*|-O*)
783 OPTS="$OPTS $arg"
786 "-fmoddir")
787 F90_MODDIR="$F90_MODDIR $1"
788 shift
791 -l*|*.a)
792 if [ -n "$POST_LANGUAGE" ]
793 then
794 POST_LIBRARIES="$POST_LIBRARIES $arg"
795 else
796 PRE_LIBRARIES="$PRE_LIBRARIES $arg"
798 INPUT_GIVEN="1"
802 OPTS_LD="$OPTS_LD $arg"
804 -no-charmrun)
805 COPY_CHARMRUN=false
807 -use-build-options)
808 USE_BUILD_OPTIONS=1
810 -h|--help)
811 printUsage
813 -f90main)
814 F90_MAIN=1
816 -nof90main)
817 F90_MAIN=
819 -mpi)
820 MPI_INTEROPERATE="yes"
821 NO_MAIN="yes"
823 -nomain-module)
824 NO_MAIN_MODULE="yes"
826 -nomain)
827 NO_MAIN="yes"
829 -custom-part)
830 CUSTOM_PARTITION="yes"
833 -fopenmp|-openmp)
834 USE_OPENMP="yes"
837 -skip-module-init)
838 SKIP_MODULEINIT="yes"
841 -print-building-blocks)
842 PRINT_BUILDING_BLOCKS="yes"
843 SKIP_MODULEINIT="yes"
846 -touch-on-failure)
847 NOABORT="yes"
850 -*|+*)
851 # Warning "passing unrecognized option $arg to all compilers and linkers"
852 OPTS="$OPTS $arg"
854 *.*)
855 [ -n "$VERBOSE" ] && echo "Adding file $arg..."
856 FILES="$FILES $arg"
857 INPUT_GIVEN="1"
859 # Default
861 # printUsage "Error: Unrecognized argument $arg"
862 # Warning "passing unrecognized option $arg to all compilers and linkers"
863 OPTS="$OPTS $arg"
865 esac
866 done
869 trap 'End 1' 2
871 # Process original command-line arguments
872 eval processArgs "$@"
874 # Construct list of object files
875 numFiles=`echo $FILES | wc -w`
876 for FILE in $FILES
879 case "$FILE" in
880 *.o|*.so|*.so.*|*.sl|*.a|*.dylib|*.co)
881 # make sure to link against shared charm library if creating a shared object:
882 case "$FILE" in
883 *.so|*.so.*|*.dylib) CHARM_SHARED=1 ;;
884 esac
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\``
889 BASEO="$BASE.o"
891 if [ $numFiles = 1 -a -n "$OBJECT" ]
892 then
893 OBJ_EXT=`getExtention $OBJECT`
894 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
895 then
896 BASEO=$OBJECT
900 # Handle new object files
901 if [ -n "$BASEO" -a -n "$OBJECT" ]
902 then
903 if [ "$OBJECT" != "$BASEO" ]
904 then
905 DELETE="$DELETE $BASEO"
907 OBJECTFILES="$OBJECTFILES $BASEO"
910 esac
911 done
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" ]
929 then
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"
943 PROCESSED_MODULES=""
945 if [ "$WERROR" = "1" ]
946 then
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" ]
952 then
953 # and if configure confirmed that the underlying compiler knows abt C11, enable it
954 if [ "$CMK_COMPILER_KNOWS_C11" = "1" ]
955 then
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" ]
960 then
961 OPTS_CXX="$OPTS $CMK_ENABLE_CPP11"
965 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
966 then
967 USE_OPENMP="yes"
968 TLSGLOBALS="1"
970 if [ ! -x "$CMK_ROSE_OMP_TOOL" ]
971 then
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" ]
977 then
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"
984 else
985 [ -n "$VERBOSE" ] && echo OpenMP support not enabled
988 if [ "$TLSGLOBALS" = "1" ]
989 then
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
998 findModuleDep() {
999 M=$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" ]
1008 then
1009 LINK_PYTHON=1
1012 dep=""
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
1018 done
1019 if [ -r "$dep" ]
1020 then
1021 # Add the module dependencies in this file
1022 # Debugf "Adding module" $M "dependencies from" $dep
1023 deps=`cat $dep`
1024 Debugf "Module" $M "adds dependencies:" $deps
1025 processArgs $deps
1029 # Repeat the module-dependency search until we find no
1030 # new modules:
1031 START_MODULES=""
1032 while [ "$START_MODULES" != "$MODULES" ]
1034 Debugf "----------- Module dependency search ------------"
1035 START_MODULES="$MODULES"
1036 for m in $MODULES
1038 findModuleDep $m
1039 done
1040 done
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" ]
1054 then
1055 BUILD_SHARE="1"
1058 if [ "$BUILD_SHARE" = "1" ]
1059 then
1060 if [ x"$CMK_NO_BUILD_SHARED" = "xtrue" -o -z "$CHARMLIBSO" ]
1061 then
1062 BUILD_SHARE="0"
1063 else
1064 USE_PIC="1"
1068 OPTS_PIC="$CMK_PIC"
1069 if [ "$USE_PIC" = "1" ]
1070 then
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" ]
1078 then
1079 # ignore BUILD_SHARE if the target is not .a or .so
1080 case "$OBJECT" in
1081 *.a|*.so|*.so.*|*.sl|*.dylib)
1082 OPTS_LD="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
1085 BUILD_SHARE="0"
1087 esac
1090 if [ -n "$OVERRIDE_CC" ]
1091 then
1092 CMK_CC="$OVERRIDE_CC"
1094 Debug "set 2"
1095 if [ -n "$OVERRIDE_CXX" ]
1096 then
1097 CMK_CXX="$OVERRIDE_CXX"
1100 if [ -n "$OVERRIDE_F90" ]
1101 then
1102 CMK_CF90="$OVERRIDE_F90"
1105 if [ -n "$OVERRIDE_LD" ]
1106 then
1107 CMK_LD="$OVERRIDE_LD"
1110 if [ -n "$OVERRIDE_LDXX" ]
1111 then
1112 CMK_LDXX="$OVERRIDE_LDXX"
1115 if [ -n "$USE_RELIABLE_CC" ]
1116 then
1117 CMK_CC="$CMK_CC_RELIABLE"
1120 if [ -n "$USE_FASTEST_CC" ]
1121 then
1122 CMK_CC="$CMK_CC_FASTEST"
1125 if [ -n "$USE_F77" ]
1126 then
1127 CMK_CF90=$CMK_CF77
1128 CMK_CF90_FIXED=$CMK_CF77
1129 CMK_F90LIBS=$CMK_F77LIBS
1132 if [ -n "$CMK_F90_MODINC" ]
1133 then
1134 CMK_CF90_MODINC="$CMK_F90_MODINC"
1135 else
1136 CMK_CF90_MODINC="-M"
1139 if [ -n "$F90_MODDIR" ]
1140 then
1141 for dir in $F90_MODDIR
1143 OPTS_F90="$OPTS_F90 $CMK_CF90_MODINC $dir"
1144 done
1147 if [ -n "$CMK_F90_USE_MODDIR" ]
1148 then
1149 CMK_CF90="$CMK_CF90 $CMK_CF90_MODINC $CHARMINC $CMK_SYSINC"
1152 if [ -n "$SEQUENTIAL" ]
1153 then
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"
1168 if [ -n "$NATIVE" ]
1169 then
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" ]
1182 then
1183 CMK_CF90=$CMK_FPP
1186 if [ -n "$PURIFY" ]
1187 then
1188 CMK_LD="purify $CMK_LD"
1189 CMK_LDXX="purify $CMK_LDXX"
1192 Debug "set 4"
1193 if [ "$OPTIMIZE_MODE" = "true" ]
1194 then
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" ]
1204 then
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" ]
1213 then
1214 CMK_XIOPTS="$CMK_XIOPTS -intrinsic"
1217 if [ "$GENDEPENDS" = "yes" ]
1218 then
1219 CMK_XIOPTS="$CMK_XIOPTS -M"
1222 if [ "$COUNTTOKENS" = "yes" ]
1223 then
1224 CMK_XIOPTS="$CMK_XIOPTS -count-tokens"
1227 if test "$CMK_WITH_TAU" = "true"
1228 then
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`
1237 rm -f _make.tau.tmp
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" ]
1248 then
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++"
1269 case "$LANGUAGE" in
1270 "c"|"C"|"c++"|"C++")
1271 [ -z "$SEQUENTIAL" -a -z "$NATIVE" ] && Abort "Language $LANGUAGE is for sequential programs"
1273 esac
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" ]
1282 then
1283 POST_LIBRARIES="$POST_LIBRARIES $CMK_F77LIBS"
1286 if [ $USE_F90_LIBRARIES = "1" ]
1287 then
1289 if [ ! -r $CHARMLIB/libconv-utilf.a ]
1290 then
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"
1297 # GEN-CPM options
1298 if [ "$CMK_COMPILER" = "bgclang" ]
1299 then
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
1308 case "$PARADIGM" in
1309 "charm++f")
1310 PARADIGM="charm++"
1311 USE_F90_LIBRARIES="1"
1313 "f90charm")
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"
1320 "ckbluegene")
1321 POST_LIBRARIES="$POST_LIBRARIES -lbluegene"
1323 "bgcharm++")
1324 PRE_LIBRARIES="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1326 "bgconverse++")
1327 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1329 esac
1331 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1332 if [ $CMK_CELL -eq 1 ]
1333 then
1335 if [ "$PARADIGM" = "converse++" ]
1336 then
1337 # Include a "do nothing" register_accel_spe_funcs() function
1338 POST_LIBRARIES="$POST_LIBRARIES -lnoAccelStub"
1341 if [ "$PARADIGM" = "charm++" ]
1342 then
1344 if [ $SPU_USE_CPP -eq 1 ]
1345 then
1346 SPU_COMPILER=$CMK_SPU_CXX
1347 SPU_LINKER=$CMK_SPU_LDXX
1348 else
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" != "" ]
1360 then
1361 OBJECTFILES="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1364 if [ "$SWAPGLOBALS" = "1" ]
1365 then
1366 swapo="$CHARMLIB/libglobal-swap.a"
1367 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1368 then
1369 if [ "$CMK_SMP" == "1" ]
1370 then
1371 echo "Error: -swapglobals is not supported on SMP builds of Charm++/AMPI"
1372 else
1373 echo "Error: global-swapping library $swapo missing--"
1374 echo " Is -swapglobals supported on this machine?"
1376 exit 1
1377 else
1378 MIDDLE_LIBS="-lglobal-swap $MIDDLE_LIBS"
1381 if [ "$SWAPGLOBALS" = "2" ]
1382 then
1383 echo "-copyglobals option is no longer supported by Charm++/AMPI"
1384 exit 1
1388 # dummy main module
1389 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1390 then
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 ]
1409 then
1410 for trace in $TRACEMODE; do
1411 case "$PARADIGM" in
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`
1416 continue
1421 esac
1423 TRACE_OBJ="$TRACE_OBJ -ltrace-$trace"
1424 done
1426 TRACE_OBJ="$TRACE_OBJ $CMK_LIBZ"
1429 if test x$PARADIGM = x"bgcharm++"
1430 then
1431 BALANCE=bluegene
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" ]
1442 then
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 ]
1448 then
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
1456 case $MEMORY in
1457 os-*)
1458 MEM_OBJ=$MEM_OBJ" -lmemory-os-wrapper"
1460 esac
1462 # Check for valid choice of THREAD
1464 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1465 then
1466 THREAD=$CMK_LD_SHARED_THREAD
1468 if [ "$TLSGLOBALS" = "1" ]
1469 then
1470 # make sure we don't add an extra -tls
1471 if ! echo $THREAD | grep '\-tls$' > /dev/null 2> /dev/null
1472 then
1473 THREAD=${THREAD}-tls
1477 THREAD_OBJ="-lthreads-${THREAD}"
1480 # Module name
1482 modInitName="moduleinit$$"
1483 modInitSrc="$modInitName.C"
1484 modInitObj="$modInitName.o"
1487 ##############################################################################
1489 # Final link step variables
1491 ##############################################################################
1493 MAKE_LDXX="0"
1494 MAKE_LD="0"
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"
1500 then
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`
1509 rm -f _make.tau.tmp
1511 # done getting TAU variables
1513 if [ "$BUILD_SHARE" = "0" ]
1514 then
1515 MIDDLE_LIBS="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ -lconv-util"
1518 CMK_SYSLIBS="$CMK_SYSLIBS -lm"
1520 case "$PARADIGM" in
1521 "f90charm")
1522 MAKE_LDXX="1"
1523 MIDDLE_LIBS="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1524 if [ "$NO_MAIN" = "" ]
1525 then
1526 MIDDLE_LIBS="-lckmain $MIDDLE_LIBS"
1528 if [ "$TAU_TRACE_MPI" = "1" ]
1529 then
1530 TAU_LIBS="$TAU_MPI_FLIBS $TAU_LIBS"
1531 else
1532 TAU_LIBS="$TAU_LIBS"
1535 "charm"|"charm++"|"f90charm"|"ckbluegene"|"bgcharm++")
1536 MAKE_LDXX="1"
1537 MIDDLE_LIBS="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1538 if [ "$NO_MAIN" = "" ]
1539 then
1540 MIDDLE_LIBS="-lckmain $MIDDLE_LIBS"
1542 if [ "$TAU_TRACE_MPI" = "1" ]
1543 then
1544 TAU_LIBS="$TAU_MPI_LIBS $TAU_LIBS"
1545 else
1546 TAU_LIBS="$TAU_LIBS"
1549 "converse")
1550 MAKE_LD="1"
1551 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1553 "converse++"|"bluegene"|"bigsim"|"bgconverse++")
1554 MAKE_LDXX="1"
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"
1562 esac
1564 if [ "$BUILD_SHARE" = "0" ]
1565 then
1566 MIDDLE_LIBS="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ -lconv-util"
1569 CMK_SYSLIBS="-lmoduleNDMeshStreamer -lmodulecompletion $CMK_SYSLIBS"
1571 if [ "$CHARM_SHARED" = "1" ]
1572 then
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" ]
1577 then
1578 LANG_LIBS="-L$CHARMLIBSO $OBJECTFILES $PRE_LIBRARIES"
1579 else
1580 LANG_LIBS="-L$CHARMLIBSO $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1582 else
1583 # if interoperate, need a lib with moduleinit
1584 if [ "$MPI_INTEROPERATE" != "" ]
1585 then
1586 LANG_LIBS="-L$CHARMLIB $PRE_LIBRARIES"
1587 else
1588 if [ -n "$SKIP_MODULEINIT" ]
1589 then
1590 LANG_LIBS="-L$CHARMLIB $OBJECTFILES $PRE_LIBRARIES"
1591 else
1592 LANG_LIBS="-L$CHARMLIB $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1596 if [ "$TRACE_WITH_TAU" = 1 ]
1597 then
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"
1600 else
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" != "" ]
1606 then
1607 # preserve this variable in its state here for use later
1608 CHARM_ALL_LIBS="$ALL_LIBS"
1609 if [ -n "$SKIP_MODULEINIT" ]
1610 then
1611 ALL_LIBS="$OBJECTFILES $ALL_LIBS"
1612 else
1613 ALL_LIBS="$OBJECTFILES $modInitObj $ALL_LIBS"
1618 ########################################################################
1620 # Finalize command parameters
1622 ########################################################################
1624 CHARM_CPP_C="$CMK_CPP_C"
1625 CHARM_CC="$CMK_CC"
1626 CHARM_CXX="$CMK_CXX"
1627 CHARM_LD="$CMK_LD"
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" ]
1644 then
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}\\'"
1648 done
1649 exit 0
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 ########################################################################
1662 Copyobj() {
1663 if [ "a$COPYTO" != "a" -a "a$COPYTO" != "a$OBJECT" ]
1664 then
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
1676 Copymod() {
1677 for COPY in `echo $MODCOPIES`
1679 if [ "a$COPY" != "a$OBJECT" ]
1680 then
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
1692 done
1693 Success
1696 Success() {
1697 End 0
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
1720 done
1722 ##############################################################################
1724 # Compile all specified files
1726 # All temporary files named *.TMP.* for easy cleanup.
1728 ##############################################################################
1730 Debug "About to compile..."
1732 for FILE in $FILES
1734 BASE=`stripExtention \`basename $FILE\``
1735 TMP=`basename $FILE`".TMP"
1736 FILE_EXT=`getExtention $FILE`
1737 BASEO="$BASE.o"
1738 DESTO="-o $BASEO"
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" ]
1747 then
1748 OBJ_EXT=`getExtention $OBJECT`
1749 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1750 then
1751 BASEO=$OBJECT
1752 DESTO="-o $OBJECT"
1756 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1757 # then
1758 case "$FILE_EXT" in
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
1762 esac
1763 # fi
1764 if [ ! -z "$SKIPLINK" ]
1765 then
1766 DESTO=""
1769 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1770 then
1771 case "$FILE" in
1772 *.c)
1773 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1774 FILE="rose_$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
1778 FILE="rose_$FILE"
1780 *.f|*.F|*.f77|*.F77)
1781 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1782 FILE="rose_$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
1787 FILE="rose_$FILE"
1789 esac
1792 case "$FILE" in
1793 *.ci)
1794 XIOPTS=$CMK_XIOPTS
1795 test "$PARADIGM" = "f90charm" && XIOPTS="$XIOPTS -f90"
1796 if [ "$PREPROCESS_CI" = "yes" ]
1797 then
1798 Do $CMK_CPP_CHARM $OPTS_CPP $FILE | Do $CHARMBIN/charmxi $XIOPTS -orig-file $FILE
1799 else
1800 Do $CHARMBIN/charmxi $XIOPTS $FILE
1803 *.c|*.s|*.S)
1804 Do $CHARM_CC $CHARM_CC_FLAGS -c $FILE $DESTO
1805 if [ "$Do_res" -ne 0 ]
1806 then
1807 touch $BASEO
1810 *.C|*.cc|*.cxx|*.cpp|*.c++|*.cu)
1811 if [ -n "$NATIVE" ]
1812 then
1813 Do $CMK_NATIVE_CXX $CMK_NATIVE_CXX_FLAGS -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP -c $FILE $DESTO
1814 else
1815 Do $CHARM_CXX $CHARM_CXX_FLAGS -c $FILE $DESTO
1817 if [ "$Do_res" -ne 0 ]
1818 then
1819 touch $BASEO
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 ]
1826 then
1827 touch $BASEO
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 ]
1835 then
1836 touch $BASEO
1839 *.fc|*.FC)
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"
1845 *.M|*.mod)
1846 OBJECT="$BASE"
1847 Copymod
1848 Success
1851 Abort "file with unrecognized extension $FILE"
1852 esac
1853 done
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 ##############################################################################
1868 MakeSO() {
1869 Debugf "Running ldro..."
1870 DoNoErrCheck $RM $OBJECT
1871 # convert to absolute path if required
1872 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1873 then
1874 dir=`dirname $OBJECT`
1875 fname=`basename $OBJECT`
1876 dir=`cd $dir; pwd`
1877 OBJECT=$dir/$fname
1879 [ "$CMK_MACOSX" = "1" ] && OPTS_LD="$OPTS_LD -Wl,-install_name,$CHARMLIBSO/$fname"
1880 if test "$MAKE_LDXX" = "1"
1881 then
1882 soCmd="$CMK_LDXX $CMK_LDXX_FLAGS $CMK_LIBDIR -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1883 else
1884 soCmd="$CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1886 DoNoErrCheck $soCmd
1887 Do_res=$?
1888 if [ $Do_res -ne 0 ]
1889 then
1890 if [ -n $NOABORT ]
1891 then
1892 touch $OBJECT
1893 else
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"
1903 Copyobj
1906 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
1907 then
1908 # We have no target object, or are playing preprocessor tricks-- just end
1909 Debugf "No target object-- finished"
1910 Success
1913 Debug "About to link..."
1915 if [ "$INPUT_GIVEN" != "1" ]
1916 then
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" = "" ]
1922 then
1923 case "$OBJECT" in
1924 *.o)
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 ]
1930 then
1931 Debugf "Moving .o to destination"
1932 DoNoErrCheck $RM $OBJECT
1933 Do $MV $OBJECTFILES $OBJECT
1935 Copyobj
1937 *.so|*.so.*|*.sl|*.dylib)
1938 # Make shared library
1939 # if no build share is set, exit normally.
1940 if [ "$BUILD_SHARE" = 0 ]
1941 then
1942 Warning "Warning: building shared library is not supported, recompile charm++ with '--build-shared'."
1943 End 0
1944 elif [ "$CHARM_SHARED" = "0" ]
1945 then
1946 MakeSO
1949 *.a)
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" ]
1953 then
1954 COPY_EXIT=""
1955 OBJECT_SAVE=$OBJECT
1956 COPYTO_SAVE=$COPYTO
1957 if [ -z "$COPYTO" ]
1958 then
1959 DESTDIR=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
1960 OBJECT=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
1961 else
1962 COPYTO=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
1963 DESTDIR=$COPYTO
1965 OBJECT=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
1966 [ -f $DESTDIR/.charmso ] && MakeSO
1967 COPYTO=$COPYTO_SAVE
1968 OBJECT=$OBJECT_SAVE
1969 COPY_EXIT="true"
1971 # build normal .a
1972 DoNoErrCheck $RM $OBJECT
1973 Do $CMK_AR $OBJECT $OBJECTFILES
1974 Do $CMK_RANLIB $OBJECT
1975 Copyobj
1977 esac
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 ]
1983 then
1985 if [ "$PARADIGM" = "charm++" ]
1986 then
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
1997 case "$LANGUAGE" in
1998 "c"|"C"|"f90"|"f77")
1999 if [ -n "$NATIVE" ]
2000 then
2001 Do $CMK_NATIVE_LD $CMK_NATIVE_LD_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2002 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2003 else
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
2007 Copyobj
2009 "c++"|"C++")
2010 if [ -n "$NATIVE" ]
2011 then
2012 Do $CMK_NATIVE_LDXX $CMK_NATIVE_LDXX_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2013 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2014 else
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
2018 Copyobj
2020 esac
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 ]
2032 then
2033 for trace in $TRACEMODE; do
2034 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort "charmc : No such tracemode $trace"
2035 done
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"
2043 else
2044 BAL_OBJ_FILE="${CHARMLIBSO}/libldb-$BALANCE.so"
2046 else
2047 # Balance has some extension-- must be a .o or .a file
2048 BAL_OBJ_FILE="$BALANCE"
2051 if [ ! -r "$BAL_OBJ_FILE" ]
2052 then
2053 if [ "$BALANCE" = "$BAL_OBJ_FILE" ]
2054 then
2055 Abort "Could not find load balancer object $BAL_OBJ_FILE"
2056 else
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"
2064 else
2065 MEM_OBJ_FILE="${CHARMLIBSO}/libmemory-${MEMORY}.so"
2068 if [ ! -r $MEM_OBJ_FILE -o ! -s $MEM_OBJ_FILE ]
2069 then
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"
2076 else
2077 THREAD_OBJ_FILE="${CHARMLIBSO}/libthreads-${THREAD}.so"
2080 if [ ! -r $THREAD_OBJ_FILE -o ! -s $THREAD_OBJ_FILE ]
2081 then
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" ]
2090 then
2091 DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
2093 for module in $MODULES; do
2094 echo "extern void _register$module(void);" >> $modInitSrc
2095 done
2096 for trace in $TRACEMODE; do
2097 if test $trace = "summary"
2098 then
2099 echo " extern void _registerTraceSummary();" >> $modInitSrc
2100 elif test $trace = "projections"
2101 then
2102 echo " extern void _registerTraceProjections();" >> $modInitSrc
2103 elif test $trace = "simple"
2104 then
2105 echo " extern void _registerTraceSimple();" >> $modInitSrc
2106 elif test $trace = "Tau"
2107 then
2108 echo " extern void _registerTraceTau();" >> $modInitSrc
2109 elif test $trace = "utilization"
2110 then
2111 echo " extern void _registerTraceUtilization();" >> $modInitSrc
2112 elif test $trace = "controlPoints"
2113 then
2114 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2115 elif test $trace = "perfReport"
2116 then
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"
2122 then
2123 echo " extern void _registerTraceProjections();" >> $modInitSrc
2124 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2125 echo " extern void _registerTraceSummary();" >> $modInitSrc
2127 done
2128 if test -n "$BALANCER"
2129 then
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
2136 done
2137 for trace in $TRACEMODE; do
2138 if test $trace = "summary"
2139 then
2140 echo " _registerTraceSummary();" >> $modInitSrc
2141 elif test $trace = "projections"
2142 then
2143 echo " _registerTraceProjections();" >> $modInitSrc
2144 elif test $trace = "Tau"
2145 then
2146 TRACE_WITH_TAU=1
2147 echo " _registerTraceTau();" >> $modInitSrc
2148 elif test $trace = "simple"
2149 then
2150 echo " _registerTraceSimple();" >> $modInitSrc
2151 elif test $trace = "utilization"
2152 then
2153 echo " _registerTraceUtilization();" >> $modInitSrc
2154 elif test $trace = "controlPoints"
2155 then
2156 echo " _registerTraceControlPoints();" >> $modInitSrc
2157 elif test $trace = "perfReport"
2158 then
2159 echo " _registerTraceAutoPerf();" >> $modInitSrc
2160 elif test $trace = "all"
2161 then
2162 echo " _registerTraceProjections();" >> $modInitSrc
2163 echo " _registerTraceControlPoints();" >> $modInitSrc
2164 echo " _registerTraceSummary();" >> $modInitSrc
2166 done
2167 if test -n "$BALANCER"
2168 then
2169 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
2170 for deflb in $BALANCER
2172 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
2173 done
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
2183 done
2184 echo "}" >> $modInitSrc
2186 Do $CHARM_CXX $CHARM_CXX_FLAGS -c $modInitSrc -o $modInitObj
2189 ###############################################################################
2191 # Finally, LINK
2193 ###############################################################################
2195 Debug "About to perform final link..."
2197 #currently only support creation of .a
2198 if [ "$MPI_INTEROPERATE" != "" ]
2199 then
2200 case "$OBJECT" in
2201 *.a)
2202 # in case building charm so, build .so under lib_so as well # Gengbin
2203 DoNoErrCheck $RM $OBJECT
2204 if [ -z "$SKIP_MODULEINIT" ]
2205 then
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\""
2212 Copyobj
2214 *.so|*.so.*|*.sl|*.dylib)
2215 echo "Warning: building shared library failed; for interoperation build
2216 static library."
2217 End 0
2219 esac
2222 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2223 then
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
2230 Copyobj
2231 else
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"
2244 then
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 ]
2250 then
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
2258 Copyobj