build: Don't create the lib_so folder if --build-shared is not specified
[charm.git] / src / scripts / charmc
blob3bc509707da112d1f2962167502c326ab294b84a
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 STANDALONE=""
25 LANGUAGE=""
26 PARADIGM=""
27 BALANCE="rand"
28 TRACEMODE=""
29 TRACE_OBJ=
30 MEMORY="default"
31 THREAD="default"
32 VERBOSE=""
33 DEBUG_SCRIPT=""
34 SAVE=""
35 PURIFY=""
36 SKIPLINK=""
37 OVERRIDE_CC=""
38 OVERRIDE_CXX=""
39 OVERRIDE_F90=""
40 OVERRIDE_LD=""
41 OVERRIDE_LDXX=""
42 #Generic options, passed to everything
43 OPTS=""
44 #Specific options
45 #charm internal flag, only pass to c and cxx, not f90
46 OPTS_CPP_INTERNAL="-D__CHARMC__=1"
47 OPTS_CPP=
48 OPTS_LDRO=""
49 OPTS_CC=""
50 OPTS_CC_GENCPM=""
51 OPTS_CXX=""
52 OPTS_F90=""
53 OPTS_LD=""
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 AMPIF=""
70 COPYTO=""
71 MODCOPIES=""
72 MODULES=""
73 BALANCER=""
74 FILES=""
75 OBJECTFILES=""
76 DELETE=""
77 MAINOBJ=""
78 GENCPM=""
79 OPTIMIZE_MODE=""
80 PRODUCTION_MODE=""
81 USE_RELIABLE_CC=""
82 USE_FASTEST_CC=""
83 PROG_EXT=""
84 GENDEPENDS="no"
85 COUNTTOKENS="no"
86 USE_OPENMP="no"
87 SKIP_MODULEINIT=""
88 RPATH_ORIGIN=""
89 LINK_WHOLE_ARCHIVE=""
90 LINK_CXX_STL=""
92 COPY_CHARMRUN=true
93 USE_BUILD_OPTIONS=0
95 COPY_EXIT="true"
96 CHARM_SHARED="0"
97 BUILD_SHARE="0"
98 SWAPGLOBALS="0"
99 TLSGLOBALS="0"
100 ROSE_OMP_TLS_GLOBALS="no"
101 PRINT_BUILDING_BLOCKS=""
102 NOABORT=""
104 TAU_MAKEFILE=Make.tau
105 TAU_TRACE_MPI=1
107 CMK_CELL=0
108 SPU_USE_CPP=0
109 SPU_EXTRA_LIBS=""
111 MPI_INTEROPERATE=""
112 NO_MAIN_MODULE=""
113 NO_MAIN=""
114 CUSTOM_PARTITION=""
115 PREPROCESS_CI="yes"
116 INPUT_GIVEN=""
118 ####################################################################
120 # Utility routines used below
122 ###################################################################
124 # PrintUsage: prints a helpful command-line usage message and quits
125 # Args: any additional messages
126 printUsage() {
127 printVersion
128 echo
129 echo "Usage: charmc [ flags ] <files>"
130 echo
131 echo " flags:"
132 echo " -o <target> -g -O"
133 echo " -D<define> -I<include path> -L<lib path> -l<library> -s"
134 echo " -machine <mach> -seq -host -language <lang> -pg <opt>"
135 echo " -balance <mode> -tracemode <mode> -memory <mode>"
136 echo " -modules <comma-separated list of C++ modules> -thread"
137 echo " -debug-script -count-tokens -default-to-aout -E -S -M"
138 echo " -verbose -save -purify -cp <dest> -cpmod -gen-cpm <pkg>"
139 echo " -swapglobals -tlsglobals -roseomptlsglobals"
140 echo " -use-reliable-cc -use-fastest-cc -use-new-std"
141 echo " -cc <new cc> -c++ <new CC> -ld <new ld> -ld++ <new LD>"
142 echo " -cpp-option <opt> -ldro-option <opt> -cc-option <opt>"
143 echo " -c++-option <opt> -ld-option <opt> -ld++-option <opt>"
144 echo " -f90 <new f90> -f90-option <opt> -fmoddir <f90mod path>"
145 echo " -flibs -rpath <path> -custom-part -touch-on-failure"
146 echo " -mpi -openmp -no-trace-mpi -build-shared -charm-shared"
147 echo " -no-charmrun -no-preprocess-ci -nomain-module -nomain"
148 echo " -nof90main -f90main"
149 echo
150 echo " Charmc compiles C, C++, f77, f90, AMPI, Converse, Converse++, Charm, "
151 echo "and Charm++ programs. The flags generally match those of cc or f77."
152 echo " Other options that are not listed here will be passed directly to the"
153 echo "underlying compiler and/or linker."
154 echo "Parallel Programming Lab, UIUC, 2018."
155 echo $*
156 exit 1
159 # End blows away the temporary files (unless SAVE is true) and exits
160 # Args: <exit code>
161 End() {
162 if [ -z "$SAVE" ]
163 then
164 for FILE in `echo $FILES`
166 #BASE=`stripExtention $FILE`
167 MYTMP=`basename $FILE`".TMP"
168 $RM $MYTMP.P.C $MYTMP.cpp $MYTMP.space $MYTMP.xlat $MYTMP.o
169 $RM $MYTMP.c $MYTMP.c.0.h $MYTMP.c.1.h $MYTMP.c.2.h
170 $RM $MYTMP.i $MYTMP.$CMK_CPP_SUFFIX
171 done
172 $RM core $DELETE
173 if [ -z "$SKIP_MODULEINIT" -a -n "$modInitObj" ]
174 then
175 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
176 DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
179 exit $1
182 # Write this error message to stderr
183 # ("1>&2" redirects the echo output to stderr).
184 Warning() {
185 echo "$@" 1>&2
188 # This procedure prints an error message and exits.
189 # Args: written to stderr
190 Abort() {
191 Warning "Fatal Error by charmc in directory "`pwd`
192 Warning " $@"
193 Warning "charmc exiting..."
194 End 1
198 # Instead of an ECHO_CMD variable, I define a procedure Do,
199 # which (possibly) echos, runs, and tests the errors of the given command.
200 # Args: executed as given
201 DoNoErrCheck() {
202 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
203 eval "$@"
206 Do() {
207 DoNoErrCheck "$@"
208 Do_res=$?
209 # The UNIX result code better be zero, or we die
210 [ $Do_res -eq 0 -o -n "$NOABORT" ] || Abort "Command $@ returned error code $Do_res"
213 # This procedure removes the extention (the ".c" in "./main.c") from
214 # its first argument, and prints the result. Unlike the builtin command
215 # basename, it keeps the directory path.
216 # Args: <name to strip>
217 stripExtention() {
218 se_base=`basename $1`
219 # se_base=`echo $1 | awk -F/ '{print $NF}'`
220 se_strip=`echo $se_base | awk -F. '{ORS="";print $1;for (i=2;i<NF;i++) print "."$i}'`
221 se_ret=`echo $1 | awk -F/ '{ORS="";for (i=1;i<NF;i++) print $i"/"}'`"$se_strip"
222 echo $se_ret
225 # GetExtention returns the extention on the given file name
226 # or "" if none. (e.g. "./bob/snack.c" returns ".c")
227 # Args: <name to find extention of>
228 getExtention() {
229 # se_base=`echo $1 | awk -F/ '{print $NF}'`
230 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
231 # echo $se_ret
232 se_ret=`echo $1 | sed -e 's/.*\././'`
233 if test "$se_ret" = $1
234 then
235 echo ""
236 else
237 echo $se_ret
241 Debugf() {
242 [ -n "$VERBOSE" ] && echo "charmc>" $@
245 Debug() {
246 if [ -n "$DEBUG_SCRIPT" ]
247 then
248 echo
249 echo "------- Charmc Debugging info: $* -------"
250 echo "CHARMBIN=$CHARMBIN"
251 echo "CHARMINC=$CHARMINC"
252 echo "CHARMLIB=$CHARMLIB"
253 echo "FILES=$FILES"
254 echo "DELETE=$DELETE"
255 echo "OBJECT=$OBJECT"
256 echo "LANGUAGE=$LANGUAGE"
257 echo "PARADIGM=$PARADIGM"
258 # echo "Working directory="`pwd`
262 # Return success if $1 is not in any of the other arguments
263 notInList() {
264 search=$1
265 shift
266 while [ $# -gt 0 ]
268 if [ "$search" = "$1" ]
269 then
270 # It's already in there-- fail
271 return 1
273 shift
274 done
275 # It's missing--succeed
276 return 0
279 # Add arguments to our modules list, avoiding duplicates
280 AddModules() {
281 for M in "$@"
283 notInList $M $MODULES && MODULES="$MODULES $M"
284 done
287 # Add this word to this list, avoiding duplicates
288 AddList() {
289 ret=""
290 while [ $# -gt 1 ]
292 ret="$ret $1"
293 shift
294 done
295 if notInList $1 $ret
296 then
297 ret="$ret $1"
299 echo $ret
302 # Drop the first argument anywhere it appears in the subsequent list
303 DropList() {
304 drop="$1"
305 shift
307 ret=""
308 while [ $# -gt 1 ]
310 if [ "$1" != "$drop" ]; then
311 ret="$ret $1"
313 shift
314 done
316 echo $ret
319 # TEMP_BASE is appended with this script's process ID (PID),
320 # so multiple charmcs can run in parallel without overwriting
321 # each other's temporary files.
322 TEMP_BASE="/tmp/charmc_tmp.$$"
324 # Try to find CHARMBIN by looking in directory where charmc is
325 findCharmBin() {
326 if [ -z "$CHARMBIN" ]
327 then
328 SCRIPT=$1
329 CHARMBIN=`dirname $SCRIPT`
330 # CHARMBIN=`cd $CHARMBIN; pwd`
331 # NOTE: this script no longer tries to follow soft links
332 # to find the "original" charmc-- if this is bad,
333 # translate these lines to Bourne shell from C shell:
334 # -------------------- Begin C Shell ------------------------->
335 # if ($SCRIPT:h != $SCRIPT:t) then
336 # cd $SCRIPT:h
337 # set SCRIPT=$SCRIPT:t
338 # else
339 # foreach dir ($path)
340 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
341 # cd $dir
342 # break
343 # endif
344 # end
345 # endif
346 # while (x`find $SCRIPT -type l -print` == x$SCRIPT)
347 # set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
348 # if ($SCRIPT:h != $SCRIPT:t) then
349 # cd $SCRIPT:h
350 # set SCRIPT=$SCRIPT:t
351 # endif
352 # end
353 # set CHARMBIN=`pwd`
354 # <------------------ End C Shell -----------------------------
358 printVersion()
360 findCharmBin $0
361 version=`cat $CHARMBIN/../include/VERSION`
362 echo Charm++ Version $version
366 ##############################################################################
368 # The following section identifies CHARMBIN, the charm binary-directory.
370 ##############################################################################
372 ORIGDIR=`pwd`
374 # Try to find CHARMBIN by looking in directory where charmc is
376 findCharmBin $0
378 UNAME=`uname -s`
379 FIRST_THREE=`uname -s | awk '{print substr($1,1,3)}' `
380 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
381 then
382 # Running on a windows system-- append .exe to file names
383 PROG_EXT=".exe"
386 CHARMLIB="$CHARMBIN/../lib"
387 CHARMINC="$CHARMBIN/../include"
388 CHARMLIBSO=
389 if test -d "$CHARMBIN/../lib_so"
390 then
391 CHARMLIBSO=`cd $CHARMBIN/../lib_so 2>/dev/null && pwd`
392 #getting absolute path is harder than thought because of symbolic links and ..
393 #ksh needs cd -P to resolve werid symbolic links, however -P is not portable
394 #csh is ok too if it exists
395 test -z "$CHARMLIBSO" && CHARMLIBSO=`cd -P $CHARMBIN/../lib_so 2>/dev/null && pwd`
396 test -z "$CHARMLIBSO" && CHARMLIBSO=`csh -c "cd $CHARMBIN/../lib_so >& /dev/null && pwd"`
397 test -z "$CHARMLIBSO" && echo "$CHARMBIN/../lib_so: not found" && exit 1
400 ##############################################################################
402 # Parse the arguments
404 # Don't do any analysis in here, just the parsing.
406 ##############################################################################
408 [ $# -eq 0 ] && printUsage "Error: No arguments given."
410 processArgs() {
411 while [ ! $# -eq 0 ]
413 arg="$1"
414 shift
416 case "$arg" in
417 "-V")
418 printVersion
419 exit 0
422 "-machine")
423 MACHTYPE="$1"
424 shift
427 "-seq")
428 SEQUENTIAL=true
431 "-host")
432 NATIVE=true
435 "-standalone")
436 STANDALONE="true"
437 SKIP_MODULEINIT="yes"
440 "-language")
441 # Parse out some fake languages (that are actually modules)
442 case "$1" in
443 "ampi") AddModules tcharmmain ampi ;;
444 "ampif") AddModules tcharmmain ampif ; USE_F90_LIBRARIES="1" ; AMPIF="1" ;;
445 "armci") AddModules tcharmmain armci ;;
446 "armcif") AddModules tcharmmain armci ; USE_F90_LIBRARIES="1" ;;
447 "fem") AddModules tcharmmain fem ; AMPIMAIN="femmain";;
448 "femf") AddModules tcharmmain fem ; AMPIMAIN="femmain"; USE_F90_LIBRARIES="1" ;;
449 "ParFUM_TOPS") AddModules tcharmmain ParFUM ParFUM_TOPS ; AMPIMAIN="ParFUMmain";;
450 "ParFUM") AddModules tcharmmain ParFUM ; AMPIMAIN="ParFUMmain";;
451 "ParFUMf") AddModules tcharmmain ParFUM ; AMPIMAIN="ParFUMmain"; USE_F90_LIBRARIES="1" ;;
452 "mblock") AddModules tcharmmain mblock ;;
453 "mblockf") AddModules tcharmmain mblock ; USE_F90_LIBRARIES="1" ;;
455 "charm"|"charm++"|"charm++f"|"f90charm"|"converse"|"converse++"|"bgcharm++"|"bgconverse++"|"bluegene"|"ckbluegene"|"bigsim")
456 PARADIGM="$1"
457 POST_LANGUAGE=1
461 LANGUAGE="$1"
462 POST_LANGUAGE=1
464 esac
465 shift
468 "-debug")
469 # Requested support from charmdebug: add some modules and libraries
470 CHARMDEBUG=1
471 MEMORY="charmdebug"
474 "-module"|"-modules")
475 AddModules `echo $1 | sed -e 's/,/ /g'`
476 INPUT_GIVEN="1"
477 shift
480 "-balancer")
481 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
482 BALANCER="$BALANCER $1"
483 mod=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
484 AddModules $mod
485 shift
488 "-balance")
489 BALANCE="$1"
490 shift
493 "-queue")
494 Warning "Warning: -queue currently being ignored."
495 shift
498 "-memory")
499 MEMORY="$1"
500 shift
503 "-thread")
504 THREAD="$1"
505 shift
508 "-tracemode")
509 TRACEMODE_NEW=`AddList $TRACEMODE $1`
510 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
511 then
512 Warning "Warning: Duplicate tracemode $1 ignored"
513 else
514 TRACEMODE=$TRACEMODE_NEW
516 shift
518 "-no-trace-mpi")
519 TAU_TRACE_MPI=0
522 "-swapglobal"|"-swapglobals")
523 SWAPGLOBALS="1"
524 USE_PIC="1"
527 "-tlsglobal"|"-tlsglobals")
528 TLSGLOBALS="1"
531 "-roseomptlsglobals")
532 ROSE_OMP_TLS_GLOBALS="yes"
535 "-verbose")
536 echo "Verbose mode set"
537 VERBOSE=true
540 "-spu-cpp")
541 SPU_USE_CPP=1
544 "-spu-lib")
545 SPU_EXTRA_LIBS="$SPU_EXTRA_LIBS -l$1"
546 shift
549 "-intrinsic")
550 XI_INTERNAL=true
553 "-debug-script")
554 echo "Will give excessive charmc debugging output..."
555 DEBUG_SCRIPT=true
558 "-save")
559 SAVE=true
562 "-purify")
563 PURIFY=true
566 "-use-reliable-cc")
567 USE_RELIABLE_CC=1
570 "-use-fastest-cc")
571 USE_FASTEST_CC=1
574 "-cc")
575 OVERRIDE_CC="$1"
576 shift
579 "-c++")
580 OVERRIDE_CXX="$1"
581 shift
584 "-f90")
585 OVERRIDE_F90="$1"
586 shift
589 "-ld")
590 OVERRIDE_LD="$1"
591 shift
594 "-ld++")
595 OVERRIDE_LDXX="$1"
596 shift
599 "-cpp-option")
600 OPTS_CPP="$OPTS_CPP $1"
601 shift
604 "-ldro-option")
605 OPTS_LDRO="$OPTS_LDRO $1"
606 shift
609 "-cc-option")
610 OPTS_CC="$OPTS_CC $1"
611 shift
614 "-c++-option")
615 OPTS_CXX="$OPTS_CXX $1"
616 shift
619 "-f90-option")
620 OPTS_F90="$OPTS_F90 $1"
621 shift
624 "-ld-option"|"-ld++-option")
625 OPTS_LD="$OPTS_LD $1"
626 shift
629 "-rpath")
630 OPTS_LD="$OPTS_LD -rpath $1"
631 shift
634 "-rpath-origin")
635 RPATH_ORIGIN="yes"
638 "-fortran"|"-flib"|"-flibs")
639 USE_F90_LIBRARIES="1"
641 "-f77")
642 USE_F77="1"
644 "-fortran77"|"-f77lib"|"-f77libs")
645 USE_F77_LIBRARIES="1"
647 "-E")
648 # Run preprocessor only
649 PREPROCESS="yes"
650 SKIPLINK="yes"
651 OPTS="$OPTS $arg"
653 "-preprocess")
654 # Run preprocessor as an extra step, continue after preprocessing
655 PREPROCESS="yes"
657 "-no-preprocess-ci")
658 # Turn off the preprocessor for ci files
659 PREPROCESS_CI="no"
661 "-P"|"-S")
662 # Run preprocessor/assembler only
663 SKIPLINK="yes"
664 OPTS="$OPTS $arg"
666 #------ Dependency generation ---------
667 "-M" | "-MM" | "-MMD" | "-MG")
668 SKIPLINK="yes"
669 OPTS="$OPTS $arg"
670 GENDEPENDS="yes"
672 "-MF" | "-MT" | "-MQ" | "-MD") #-MP will pass through automatically
673 OPTS="$OPTS $arg $1"
674 shift
676 #--------------------------------------
677 "-count-tokens")
678 OPTS="$OPTS $arg"
679 COUNTTOKENS="yes"
681 "-default-to-aout")
682 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
683 then
684 OBJECT="a.out"
687 -print-prog-name=*)
688 echo $arg | cut -d'=' -f2
689 exit 0
691 "-c")
692 if [ "$EXPLICIT_OBJECT" = "no" ]
693 then
694 OBJECT=""
696 EXPLICIT_COMPILATION="yes"
699 "-o")
700 EXPLICIT_OBJECT="yes"
701 OBJECT=$1
702 shift
705 "-cp")
706 COPYTO="$1"
707 shift
710 "-cpmod")
711 MODCOPIES="$1 $MODCOPIES"
712 shift
715 "-gen-cpm")
716 GENCPM="$GENCPM $1"
717 shift
721 OPTS_CPP="$OPTS_CPP -I$1"
722 shift
725 -D*|-I*)
726 if echo "$arg" | grep ' ' > /dev/null 2>/dev/null
727 then
728 OPTS_CPP="$OPTS_CPP "\"$arg\"
729 else
730 OPTS_CPP="$OPTS_CPP $arg"
734 -Werror)
735 WERROR="1"
738 -Wno-error)
739 WERROR="0"
742 "-use-new-std")
743 USE_NEW_STD="1"
746 "-no-use-new-std")
747 USE_NEW_STD="0"
750 -LANG*)
751 Warning "passing unrecognized option $arg to all compilers and linkers"
752 OPTS="$OPTS $arg"
754 -shared|-G)
755 BUILD_SHARE="1"
757 -L*|-shared|-G) # note that this is not executed if $arg == -shared|-G, due to the case above; might be a bug
758 OPTS_LD="$OPTS_LD $arg"
760 -charm-shared|-cs)
761 CHARM_SHARED="1"
763 -build-shared)
764 # used internally when building Charm++ to create lib_so
765 BUILD_SHARE="1"
767 -no-build-shared)
768 # used internally not to build Charm++ lib_so
769 BUILD_SHARE="0"
771 "-optimize")
772 OPTIMIZE_MODE=true
775 "-no-optimize")
776 OPTIMIZE_MODE=false
779 "-production")
780 PRODUCTION_MODE=true
782 "-no-production")
783 PRODUCTION_MODE=false
786 -Wl,*)
787 POST_LIBRARIES="$POST_LIBRARIES $arg"
790 "-pg"|"-g"|-W*|-O*)
791 OPTS="$OPTS $arg"
794 "-fmoddir")
795 F90_MODDIR="$F90_MODDIR $1"
796 shift
799 -l*|*.a|*.so|*.so.*|*.dylib)
800 if [ -n "$POST_LANGUAGE" ]
801 then
802 POST_LIBRARIES="$POST_LIBRARIES $arg"
803 else
804 PRE_LIBRARIES="$PRE_LIBRARIES $arg"
806 INPUT_GIVEN="1"
809 "-whole-archive")
810 LINK_WHOLE_ARCHIVE=true
813 "-c++stl")
814 LINK_CXX_STL=true
818 OPTS_LD="$OPTS_LD $arg"
820 -no-charmrun)
821 COPY_CHARMRUN=false
823 -use-build-options)
824 USE_BUILD_OPTIONS=1
826 -h|--help)
827 printUsage
829 -f90main)
830 F90_MAIN=1
832 -nof90main)
833 F90_MAIN=
835 -mpi)
836 MPI_INTEROPERATE="yes"
837 NO_MAIN="yes"
839 -nomain-module)
840 NO_MAIN_MODULE="yes"
842 -nomain)
843 NO_MAIN="yes"
845 -custom-part)
846 CUSTOM_PARTITION="yes"
849 -fopenmp|-openmp)
850 USE_OPENMP="yes"
853 -skip-module-init)
854 SKIP_MODULEINIT="yes"
857 -print-building-blocks)
858 PRINT_BUILDING_BLOCKS="yes"
859 SKIP_MODULEINIT="yes"
862 -touch-on-failure)
863 NOABORT="yes"
866 -*|+*)
867 # Warning "passing unrecognized option $arg to all compilers and linkers"
868 OPTS="$OPTS $arg"
870 *.*)
871 [ -n "$VERBOSE" ] && echo "Adding file $arg..."
872 FILES="$FILES $arg"
873 INPUT_GIVEN="1"
875 # Default
877 # printUsage "Error: Unrecognized argument $arg"
878 # Warning "passing unrecognized option $arg to all compilers and linkers"
879 OPTS="$OPTS $arg"
881 esac
882 done
885 trap 'End 1' 2
887 # Process original command-line arguments
888 eval processArgs "$@"
890 # Do not skip linking if user explicitly specified an output file
891 # This allows generating dependencies while compiling
892 if [ "$GENDEPENDS" = "yes" -a "$EXPLICIT_OBJECT" = "yes" ]; then
893 SKIPLINK=""
896 USER_POST_LIBRARIES="$POST_LIBRARIES"
897 USER_PRE_LIBRARIES="$PRE_LIBRARIES"
899 # Construct list of object files
900 numFiles=`echo $FILES | wc -w`
901 for FILE in $FILES
904 case "$FILE" in
905 *.o|*.so|*.so.*|*.sl|*.a|*.dylib|*.co)
906 OBJECTFILES="$OBJECTFILES $FILE"
908 *.c|*.s|*.S|*.C|*.cc|*.cxx|*.cpp|*.c++|*.cu|*.f|*.F|*.f77|*.F77|*.f90|*.F90|*.fpp|*.FPP)
909 BASE=`stripExtention \`basename $FILE\``
910 BASEO="$BASE.o"
912 if [ $numFiles = 1 -a -n "$OBJECT" ]
913 then
914 OBJ_EXT=`getExtention $OBJECT`
915 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
916 then
917 BASEO=$OBJECT
921 # Handle new object files
922 if [ -n "$BASEO" -a -n "$OBJECT" ]
923 then
924 if [ "$OBJECT" != "$BASEO" ]
925 then
926 DELETE="$DELETE $BASEO"
928 OBJECTFILES="$OBJECTFILES $BASEO"
931 esac
932 done
935 ##############################################################################
937 # Load module dependencies.
939 ##############################################################################
941 Debug "About to read machine config script"
942 Debug "Read config script, setting defaults..."
944 [ ! -r $CHARMINC/conv-config.sh ] && Abort "Cannot find conv-config.sh in $CHARMINC"
945 . $CHARMINC/conv-config.sh $CHARMINC
947 Debug "Setting vars..."
949 if [ "$USE_BUILD_OPTIONS" = "1" ]
950 then
951 [ -n "$VERBOSE" ] && echo "Charmc applying build time options: $BUILDOPTS"
952 OPTS="$OPTS $BUILDOPTS"
955 # If we are debugging, add "-g -O0" to the C/C++ flags
956 if [ -n "$CHARMDEBUG" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]; then
957 if [ -n "$CMK_BUILD_PYTHON" ]; then
958 AddModules PythonCCS charmdebug_python
959 POST_LIBRARIES=`AddList $POST_LIBRARIES -lpython${CMK_BUILD_PYTHON}`
961 OPTS_CPP="$OPTS_CPP -O0 -g"
964 # The purpose of the -rpath-origin option is for the resulting binary to have
965 # the literal text '$ORIGIN' in the RPATH field of its ELF header, essentially
966 # saying that it is okay for the binary to look in the same directory as itself
967 # for the shared objects it needs. Unfortunately, POSIX shells will interpret
968 # this text as a variable instead of passing in the string itself, requiring
969 # the string to be escaped.
970 # Additionally, some platforms do not need any special parameters.
971 if [ -n "$RPATH_ORIGIN" -a "$CMK_MACOSX" != "1" -a "$CMK_COMPILER" != "msvc" ]; then
972 OPTS_LD="$OPTS_LD '-Wl,-rpath,\$ORIGIN'"
975 PROCESSED_MODULES=""
977 if [ "$WERROR" = "1" ]
978 then
979 OPTS="$OPTS $CMK_WARNINGS_ARE_ERRORS"
982 # If the user has asked for the latest language standards (C11 or CPP11)
983 if [ "$USE_NEW_STD" = "1" ]
984 then
985 # and if configure confirmed that the underlying compiler knows abt C11, enable it
986 if [ "$CMK_COMPILER_KNOWS_C11" = "1" ]
987 then
988 OPTS_CC="$OPTS $CMK_ENABLE_C11"
992 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
993 then
994 USE_OPENMP="yes"
995 TLSGLOBALS="1"
997 if [ ! -x "$CMK_ROSE_OMP_TOOL" ]
998 then
999 Abort "The environment variable CMK_ROSE_OMP_TOOL must contain the path to a built binary of the ROSE OpenMP variable privatization tool"
1003 if [ "$USE_OPENMP" = "yes" -o "$CMK_OMP" = "1" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]
1004 then
1005 if [ "$CMK_HAS_OPENMP" != "1" ]
1006 then
1007 echo "Error: OpenMP is unavailable!"
1008 exit 1
1010 [ -n "$VERBOSE" ] && echo OpenMP support enabled
1011 OPTS_CC="$OPTS_CC $CMK_C_OPENMP"
1012 OPTS_CXX="$OPTS_CXX $CMK_C_OPENMP"
1013 OPTS_F90="$OPTS_F90 $CMK_F_OPENMP"
1014 OPTS_LD="$OPTS_LD $CMK_LD_OPENMP"
1015 else
1016 [ -n "$VERBOSE" ] && echo OpenMP support not enabled
1019 if [ "$TLSGLOBALS" = "1" ]
1020 then
1021 OPTS_CC="$OPTS_CC -mno-tls-direct-seg-refs -ftls-model=initial-exec"
1022 OPTS_CXX="$OPTS_CXX -mno-tls-direct-seg-refs -ftls-model=initial-exec"
1023 OPTS_F90="$OPTS_F90 -mno-tls-direct-seg-refs -ftls-model=initial-exec"
1026 # Look up and add the dependencies for module $1
1027 findModuleDep() {
1028 M=$1
1029 notInList $M $PROCESSED_MODULES || return
1030 PROCESSED_MODULES="$PROCESSED_MODULES $M"
1031 #PRE_LIBRARIES=`AddList $PRE_LIBRARIES -lmodule$M`
1032 PRE_LIBRARIES=`AddList -lmodule$M $PRE_LIBRARIES`
1033 # HACK: add modules to both ends of library list, to avoid
1034 # undefined symbol CkRegisterMainModule when it's in a module file.
1035 POST_LIBRARIES=`AddList $POST_LIBRARIES -lmodule$M`
1036 if [ "$M" = "PythonCCS" ]
1037 then
1038 LINK_PYTHON=1
1041 dep=""
1042 # fixme: should search everything in the -L library paths:
1043 for dir in `echo . $CHARMLIB`
1045 d="$dir/libmodule$M.dep"
1046 [ -r "$d" ] && dep=$d
1047 done
1048 if [ -r "$dep" ]
1049 then
1050 # Add the module dependencies in this file
1051 # Debugf "Adding module" $M "dependencies from" $dep
1052 deps=`cat $dep`
1053 Debugf "Module" $M "adds dependencies:" $deps
1054 processArgs $deps
1058 # Repeat the module-dependency search until we find no
1059 # new modules:
1060 START_MODULES=""
1061 while [ "$START_MODULES" != "$MODULES" ]
1063 Debugf "----------- Module dependency search ------------"
1064 START_MODULES="$MODULES"
1065 for m in $MODULES
1067 findModuleDep $m
1068 done
1069 done
1071 Debugf "----------- Module dependency search complete ------------"
1075 ##############################################################################
1077 # Load machine-specific configuration data, then handle overrides to it.
1079 ##############################################################################
1082 if [ x"$CMK_NO_BUILD_SHARED" = "xfalse" ]
1083 then
1084 BUILD_SHARE="1"
1087 if [ "$BUILD_SHARE" = "1" ]
1088 then
1089 USE_PIC="1"
1092 OPTS_PIC="$CMK_PIC"
1093 if [ "$USE_PIC" = "1" ]
1094 then
1095 OPTS_CC="$OPTS_CC $OPTS_PIC"
1096 OPTS_CXX="$OPTS_CXX $OPTS_PIC"
1097 OPTS_F90="$OPTS_F90 $OPTS_PIC"
1098 OPTS_LD="$OPTS_LD $OPTS_PIC"
1101 if [ "$BUILD_SHARE" = "1" ]
1102 then
1103 # ignore BUILD_SHARE if the target is not .a or .so
1104 case "$OBJECT" in
1105 *.a|*.so|*.so.*|*.sl|*.dylib)
1106 OPTS_LD="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO"
1107 [ -n "$CHARMLIBSO" ] && OPTS_LD="$OPTS_LD -L$CHARMLIBSO"
1110 BUILD_SHARE="0"
1112 esac
1115 if [ -n "$OVERRIDE_CC" ]
1116 then
1117 CMK_CC="$OVERRIDE_CC"
1119 Debug "set 2"
1120 if [ -n "$OVERRIDE_CXX" ]
1121 then
1122 CMK_CXX="$OVERRIDE_CXX"
1125 if [ -n "$OVERRIDE_F90" ]
1126 then
1127 CMK_CF90="$OVERRIDE_F90"
1130 if [ -n "$OVERRIDE_LD" ]
1131 then
1132 CMK_LD="$OVERRIDE_LD"
1135 if [ -n "$OVERRIDE_LDXX" ]
1136 then
1137 CMK_LDXX="$OVERRIDE_LDXX"
1140 if [ -n "$USE_RELIABLE_CC" ]
1141 then
1142 CMK_CC="$CMK_CC_RELIABLE"
1145 if [ -n "$USE_FASTEST_CC" ]
1146 then
1147 CMK_CC="$CMK_CC_FASTEST"
1150 if [ -n "$USE_F77" ]
1151 then
1152 CMK_CF90=$CMK_CF77
1153 CMK_CF90_FIXED=$CMK_CF77
1154 CMK_F90LIBS=$CMK_F77LIBS
1157 if [ -n "$CMK_F90_MODINC" ]
1158 then
1159 CMK_CF90_MODINC="$CMK_F90_MODINC"
1160 else
1161 CMK_CF90_MODINC="-M"
1164 if [ -n "$F90_MODDIR" ]
1165 then
1166 for dir in $F90_MODDIR
1168 OPTS_F90="$OPTS_F90 $CMK_CF90_MODINC $dir"
1169 done
1172 if [ -n "$CMK_F90_USE_MODDIR" ]
1173 then
1174 CMK_CF90="$CMK_CF90 $CMK_CF90_MODINC $CHARMINC $CMK_SYSINC"
1177 if [ -n "$SEQUENTIAL" ]
1178 then
1179 CMK_CC="$CMK_SEQ_CC"
1180 CMK_LD="$CMK_SEQ_LD"
1181 CMK_CXX="$CMK_SEQ_CXX"
1182 CMK_CF90="$CMK_SEQ_F90 "
1183 CMK_LDXX="$CMK_SEQ_LDXX"
1184 CMK_AR="$CMK_SEQ_AR"
1185 CMK_RANLIB="$CMK_SEQ_RANLIB"
1187 CMK_CC_FLAGS="$CMK_SEQ_CC_FLAGS -DCMK_SEQUENTIAL=1"
1188 CMK_LD_FLAGS="$CMK_SEQ_LD_FLAGS"
1189 CMK_CXX_FLAGS="$CMK_SEQ_CXX_FLAGS -DCMK_SEQUENTIAL=1"
1190 CMK_LDXX_FLAGS="$CMK_SEQ_LDXX_FLAGS"
1193 if [ -n "$NATIVE" ]
1194 then
1195 CMK_CC="$CMK_NATIVE_CC "
1196 CMK_LD="$CMK_NATIVE_LD"
1197 CMK_CXX="$CMK_NATIVE_CXX "
1198 CMK_LDXX="$CMK_NATIVE_LDXX"
1200 CMK_CC_FLAGS="$CMK_NATIVE_CC_FLAGS"
1201 CMK_LD_FLAGS="$CMK_NATIVE_LD_FLAGS"
1202 CMK_CXX_FLAGS="$CMK_NATIVE_CXX_FLAGS"
1203 CMK_LDXX_FLAGS="$CMK_NATIVE_LDXX_FLAGS"
1206 if [ -n "$PREPROCESS" ]
1207 then
1208 CMK_CF90=$CMK_FPP
1211 if [ -n "$PURIFY" ]
1212 then
1213 CMK_LD="purify $CMK_LD"
1214 CMK_LDXX="purify $CMK_LDXX"
1217 Debug "set 4"
1218 if [ "$OPTIMIZE_MODE" = "true" ]
1219 then
1220 OPTS_CC="$CMK_C_OPTIMIZE $OPTS_CC"
1221 OPTS_CXX="$CMK_CXX_OPTIMIZE $OPTS_CXX"
1222 OPTS_F90="$CMK_F90_OPTIMIZE $OPTS_F90"
1223 OPTS_LD="$CMK_C_OPTIMIZE $OPTS_LD"
1226 # Pick up per-architecture production mode settings
1227 if [ "$PRODUCTION_MODE" = "true" ]
1228 then
1229 OPTS_CC="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_CC"
1230 OPTS_CXX="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_CXX"
1231 OPTS_F90="$CMK_PRODUCTION $CMK_F90_PRODUCTION $OPTS_F90"
1232 OPTS_LD="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_LD"
1235 if [ -n "$XI_INTERNAL" ]
1236 then
1237 CMK_XIOPTS="$CMK_XIOPTS -intrinsic"
1240 if [ "$GENDEPENDS" = "yes" ]
1241 then
1242 CMK_XIOPTS="$CMK_XIOPTS -M"
1245 if [ "$COUNTTOKENS" = "yes" ]
1246 then
1247 CMK_XIOPTS="$CMK_XIOPTS -count-tokens"
1250 if test "$CMK_WITH_TAU" = "true"
1251 then
1252 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1253 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1254 TAU_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1255 TAU_MPI_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1256 TAU_MPI_FLIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1257 TAU_DEFS=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1258 TAU_INCLUDE=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1260 rm -f _make.tau.tmp
1263 #Add generic options to the compiler- and linker-options
1264 OPTS_CC="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CC"
1265 OPTS_CXX="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CXX"
1266 OPTS_F90="$OPTS $OPTS_F90"
1267 OPTS_LD="$OPTS $OPTS_LD"
1269 # There's really no analog for this in the Bourne shell:
1270 # -------- C Shell ------> onintr failure
1271 # Luckily, it's irrelevant as long as nobody sends us a ^Z.
1273 ##############################################################################
1275 # Check for valid choice of LANGUAGE
1277 ##############################################################################
1278 Debug "Checking language..."
1280 [ -z "$LANGUAGE" -a -n "$SEQUENTIAL" ] && LANGUAGE=c
1281 [ -z "$PARADIGM" -a -n "$LANGUAGE" ] && PARADIGM="$LANGUAGE"
1282 [ -z "$PARADIGM" ] && PARADIGM="charm++"
1284 case "$LANGUAGE" in
1285 "c"|"C"|"c++"|"C++")
1286 [ -z "$SEQUENTIAL" -a -z "$NATIVE" ] && Abort "Language $LANGUAGE is for sequential programs"
1288 esac
1290 # update charm to bgcharm
1291 [ "$PARADIGM" = "charm++" -a -n "$CMK_BIGSIM" ] && PARADIGM="bgcharm++"
1292 [ "$PARADIGM" = "converse++" -a -n "$CMK_BIGSIM" ] && PARADIGM="bgconverse++"
1294 [ "$PARADIGM" = "bgcharm++" ] && TRACEMODE=`AddList $TRACEMODE bluegene`
1296 if [ $USE_F77_LIBRARIES = "1" ]
1297 then
1298 POST_LIBRARIES="$POST_LIBRARIES $CMK_F77LIBS"
1301 if [ $USE_F90_LIBRARIES = "1" ]
1302 then
1304 if [ ! -r $CHARMLIB/libconv-utilf.a ]
1305 then
1306 Abort "Error: Fortran support library $CHARMLIB/libconv-utilf.a missing. Is your Fortran compiler working?"
1309 POST_LIBRARIES="$POST_LIBRARIES -lconv-utilf $CMK_F90LIBS"
1312 # GEN-CPM options
1313 if [ "$CMK_COMPILER" = "bgclang" ]
1314 then
1315 OPTS_CC_GENCPM="-x c " # -x c is only applied for the preprocessing of the GEN-CPM files on BG/Q
1318 OPTS_CC_GENCPM="$OPTS_CC $OPTS_CC_GENCPM"
1320 ############ Determine the language and libraries ##########
1322 # Parse out the real languages
1323 case "$PARADIGM" in
1324 "charm++f")
1325 PARADIGM="charm++"
1326 USE_F90_LIBRARIES="1"
1328 "f90charm")
1329 PRE_LIBRARIES="$PRE_LIBRARIES -lf90charm -lckf"
1330 POST_LIBRARIES="$POST_LIBRARIES $CMK_F90LIBS"
1332 "bluegene"|"bigsim")
1333 PRE_LIBRARIES="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs"
1335 "ckbluegene")
1336 POST_LIBRARIES="$POST_LIBRARIES -lbluegene"
1338 "bgcharm++")
1339 PRE_LIBRARIES="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1341 "bgconverse++")
1342 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1344 esac
1346 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1347 if [ $CMK_CELL -eq 1 ]
1348 then
1350 if [ "$PARADIGM" = "converse++" ]
1351 then
1352 # Include a "do nothing" register_accel_spe_funcs() function
1353 POST_LIBRARIES="$POST_LIBRARIES -lnoAccelStub"
1356 if [ "$PARADIGM" = "charm++" ]
1357 then
1359 if [ $SPU_USE_CPP -eq 1 ]
1360 then
1361 SPU_COMPILER=$CMK_SPU_CXX
1362 SPU_LINKER=$CMK_SPU_LDXX
1363 else
1364 SPU_COMPILER=$CMK_SPU_CC
1365 SPU_LINKER=$CMK_SPU_LD
1368 # Include the spe object file for linking into main executable
1369 POST_LIBRARIES="$POST_LIBRARIES main__funcLookup__.genSPECode.ppe.o"
1374 if [ "$AMPIMAIN" != "" ]
1375 then
1376 OBJECTFILES="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1379 if [ "$TLSGLOBALS" = "1" ]
1380 then
1381 if [ "$CMK_GDIR" = "uth" ]
1382 then
1383 echo "Error: -tlsglobals is not supported with the uth machine layer."
1384 exit 1
1386 if ! `$CMK_CC --version | grep -q gcc`
1387 then
1388 echo "Warning: -tlsglobals may not work with compilers other than GCC."
1390 if ! `$CMK_LD -Wl,--version,-v 2>&1 | grep -q elf`
1391 then
1392 echo "Warning: -tlsglobals may not work with a linker that does not report ELF support."
1396 if [ "$SWAPGLOBALS" = "1" ]
1397 then
1398 if [ "$CMK_HAS_ELF_H" != "1" ]
1399 then
1400 echo "Error: -swapglobals requires elf.h"
1401 exit 1
1404 LD_VERSION_TEXT=`$CMK_LD -Wl,--version,-v 2>/dev/null`
1405 if ! `printf "$LD_VERSION_TEXT" | grep -q 'GNU ld'`
1406 then
1407 echo "Warning: -swapglobals may not work with linkers other than GNU ld."
1408 else
1409 LD_VERSION=`printf "$LD_VERSION_TEXT" | grep -Eo 'GNU ld (\([^)]*\) )?(version )?[-0-9._a-zA-Z]+' | awk '{print $NF}'`
1410 LD_VERSION_MAJOR=`printf $LD_VERSION | cut -d. -f1`
1411 LD_VERSION_MINOR=`printf $LD_VERSION | cut -d. -f2 | cut -d- -f1`
1412 if [ "$LD_VERSION_MAJOR" -gt 2 ] || [ "$LD_VERSION_MAJOR" -eq 2 -a "$LD_VERSION_MINOR" -gt 23 ]
1413 then
1414 echo "Warning: -swapglobals may not work with GNU ld >= 2.24."
1415 echo "For some versions, an experimental patch is available:"
1416 echo 'https://charm.cs.illinois.edu/gerrit/gitweb?p=libbfd-patches.git;a=tree;f=swapglobals'
1420 if [ "$CMK_SMP" = "1" ]
1421 then
1422 echo "Error: -swapglobals is not supported on SMP builds of Charm++/AMPI"
1423 exit 1
1424 else
1425 swapo="$CHARMLIB/libglobal-swap.a"
1426 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1427 then
1428 echo "Error: global-swapping library $swapo missing--"
1429 echo " Is -swapglobals supported on this machine?"
1430 exit 1
1431 else
1432 MIDDLE_LIBS="-lglobal-swap $MIDDLE_LIBS"
1436 if [ "$SWAPGLOBALS" = "2" ]
1437 then
1438 echo "-copyglobals option is no longer supported by Charm++/AMPI"
1439 exit 1
1443 # dummy main module
1444 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1445 then
1446 POST_LIBRARIES="-lmpi-mainmodule $POST_LIBRARIES"
1449 ##############################################################################
1451 # Some quick consistency checks in preparation for full link-step
1453 # Check for valid choice of TRACEMODE
1454 # Check for valid choice of BALANCE
1455 # Check for compatibility among BALANCE and TRACEMODE
1457 ##############################################################################
1459 Debug "About to check TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1461 # Check for valid choice of TRACEMODE
1463 if [ x"$TRACEMODE" != x ]
1464 then
1465 for trace in $TRACEMODE; do
1466 case "$PARADIGM" in
1467 "converse"|"converse++"|"bgconverse++"|"bigsim"|"bluegene")
1468 if [ "$trace" != "counter" ]; then
1469 Warning "Tracemode $trace isn't supported in Converse-level programs; Dropping it"
1470 TRACEMODE=`DropList $trace $TRACEMODE`
1471 continue
1476 esac
1478 TRACE_OBJ="$TRACE_OBJ -ltrace-$trace"
1479 done
1483 if test x$PARADIGM = x"bgcharm++"
1484 then
1485 BALANCE=bluegene
1488 Debug "Finished with TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1490 BAL_OBJ="-lldb-$BALANCE -lconv-ldb"
1492 # Check for valid choice of MEMORY
1494 # Set the default expansions of unprefixed variants
1495 case "$MEMORY" in
1496 'verbose'|'paranoid'|'leak'|'isomalloc')
1497 MEMORY="os-$MEMORY"
1499 charmdebug*)
1500 MEMORY="gnu-$MEMORY"
1502 esac
1504 # Isomalloc does not work on BGQ or Windows:
1505 if [ "$CMK_BLUEGENEQ" = "1" -o "$CMK_COMPILER" = "msvc" ] && [ "$MEMORY" = "${MEMORY%isomalloc}isomalloc" ]
1506 then
1507 Abort "Error: Isomalloc is not supported on BlueGene/Q or Windows."
1510 MEM_OBJ="-lmemory-${MEMORY}"
1512 # For memory wrapping around the OS allocator, need to add also the wrapper object
1513 case $MEMORY in
1514 os-*)
1515 MEM_OBJ=$MEM_OBJ" -lmemory-os-wrapper"
1517 esac
1519 # Check for valid choice of THREAD
1521 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1522 then
1523 THREAD=$CMK_LD_SHARED_THREAD
1525 if [ "$TLSGLOBALS" = "1" ]
1526 then
1527 # make sure we don't add an extra -tls
1528 if ! echo $THREAD | grep '\-tls$' > /dev/null 2> /dev/null
1529 then
1530 THREAD=${THREAD}-tls
1534 THREAD_OBJ="-lthreads-${THREAD}"
1537 # Module name
1539 modInitName="moduleinit$$"
1540 modInitSrc="$modInitName.C"
1541 modInitObj="$modInitName.o"
1544 ##############################################################################
1546 # Final link step variables
1548 ##############################################################################
1550 MAKE_LDXX="0"
1551 MAKE_LD="0"
1553 CORE_LIBS="-lconv-core -ltmgr -lconv-util -lconv-partition $TRACE_OBJ $CMK_HWLOC_LIBS"
1555 # get TAU stub makefile variables
1556 if test "$CMK_WITH_TAU" = "true"
1557 then
1558 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1559 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1560 TAU_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1561 TAU_MPI_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1562 TAU_MPI_FLIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1563 TAU_DEFS=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1564 TAU_INCLUDE=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1566 rm -f _make.tau.tmp
1568 # done getting TAU variables
1570 if [ "$BUILD_SHARE" = "0" ]
1571 then
1572 MIDDLE_LIBS="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1575 CMK_SYSLIBS="$CMK_SYSLIBS -lm"
1577 case "$PARADIGM" in
1578 "f90charm")
1579 MAKE_LDXX="1"
1580 MIDDLE_LIBS="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1581 if [ -z "$NO_MAIN" ]
1582 then
1583 MIDDLE_LIBS="-lckmainf $MIDDLE_LIBS"
1584 F90_MAIN="1"
1586 if [ "$TAU_TRACE_MPI" = "1" ]
1587 then
1588 TAU_LIBS="$TAU_MPI_FLIBS $TAU_LIBS"
1589 else
1590 TAU_LIBS="$TAU_LIBS"
1593 "charm"|"charm++"|"f90charm"|"ckbluegene"|"bgcharm++")
1594 MAKE_LDXX="1"
1595 MIDDLE_LIBS="-lck $MIDDLE_LIBS -lconv-machine $CORE_LIBS "
1596 if [ -z "$NO_MAIN" ]
1597 then
1598 if [ -n "$AMPIF" ]
1599 then
1600 MIDDLE_LIBS="-lckmainf $MIDDLE_LIBS"
1601 F90_MAIN="1"
1602 elif [ -z "$AMPIMAIN" ]
1603 then
1604 MIDDLE_LIBS="-lckmain $MIDDLE_LIBS"
1607 if [ "$TAU_TRACE_MPI" = "1" ]
1608 then
1609 TAU_LIBS="$TAU_MPI_LIBS $TAU_LIBS"
1610 else
1611 TAU_LIBS="$TAU_LIBS"
1614 "converse")
1615 MAKE_LD="1"
1616 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1618 "converse++"|"bgconverse++"|"bluegene"|"bigsim")
1619 MAKE_LDXX="1"
1620 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-machine $CORE_LIBS -ltrace-converse "
1622 "c"|"C"|"c++"|"C++"|"f90"|"f77")
1625 Abort "Unrecognized choice of language $LANGUAGE / paradigm $PARADIGM"
1627 esac
1629 if [ "$BUILD_SHARE" = "0" ]
1630 then
1631 MIDDLE_LIBS="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1634 if [ "$CHARM_SHARED" = "1" ]
1635 then
1636 [ -z "$CHARMLIBSO" ] && Abort "Charm++ lib_so directory not found!"
1637 # build user executable/shared lib linking with charm .so
1638 OPTS_LD="$OPTS_LD $CMK_LD_LIBRARY_PATH"
1639 LANG_LIBS="-L$CHARMLIBSO"
1640 else
1641 LANG_LIBS="-L$CHARMLIB"
1644 if [ -z "$STANDALONE" ]
1645 then
1646 ALL_LIBS="$LANG_LIBS $PRE_LIBRARIES $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES"
1647 case "$PARADIGM" in
1648 "charm"|"charm++"|"f90charm"|"ckbluegene"|"bgcharm++")
1649 ALL_LIBS="$ALL_LIBS -lmoduleNDMeshStreamer -lmodulecompletion"
1651 esac
1652 else
1653 ALL_LIBS="$USER_PRE_LIBRARIES $USER_POST_LIBRARIES"
1656 if [ -n "$LINK_WHOLE_ARCHIVE" ]
1657 then
1658 ALL_LIBS="$CXX_NO_AS_NEEDED $LDXX_WHOLE_ARCHIVE_PRE $ALL_LIBS $LDXX_WHOLE_ARCHIVE_POST $CMK_SYSLIBS"
1659 else
1660 ALL_LIBS="$ALL_LIBS $CMK_SYSLIBS"
1663 if [ "$BUILD_SHARE" = "0" ]
1664 then
1665 ALL_LIBS="$ALL_LIBS $CHARMLIB/conv-static.o"
1668 if [ -n "$LINK_CXX_STL" ]
1669 then
1670 ALL_LIBS="$ALL_LIBS -lstdc++"
1673 if [ "$TRACE_WITH_TAU" = 1 ]
1674 then
1675 echo "Linking with the TAU libraries: $TAU_LIBS"
1676 ALL_LIBS="$ALL_LIBS $TAU_LIBS"
1678 Debugf "All libraries are: $ALL_LIBS"
1680 # preserve this variable in its state here for use later
1681 CHARM_ALL_LIBS="$ALL_LIBS"
1682 if [ "$BUILD_SHARE" = "1" -o -n "$SKIP_MODULEINIT" ]
1683 then
1684 ALL_LIBS="$OBJECTFILES $ALL_LIBS"
1685 else
1686 ALL_LIBS="$OBJECTFILES $modInitObj $ALL_LIBS"
1689 if [ -n "$F90_MAIN" ]
1690 then
1691 # for_main needs to be placed at beginning
1692 CMK_LD_FLAGS="$CMK_F90MAINLIBS $CMK_LD_FLAGS"
1693 CMK_LDXX_FLAGS="$CMK_F90MAINLIBS $CMK_LDXX_FLAGS"
1696 if [ -n "$F90_MAIN" -o "$USE_F90_LIBRARIES" = '1' ]
1697 then
1698 if [ "$CMK_CAN_LINK_FORTRAN" != '1' ]
1699 then
1700 echo "Error: Configure testing was unable to link a Fortran program."
1701 exit 1
1705 ########################################################################
1707 # Finalize command parameters
1709 ########################################################################
1711 CHARM_CPP_C="$CMK_CPP_C"
1712 CHARM_CC="$CMK_CC"
1713 CHARM_CXX="$CMK_CXX"
1714 CHARM_LD="$CMK_LD"
1715 CHARM_LDXX="$CMK_LDXX"
1717 CHARM_CPP_C_FLAGS="$CMK_CPP_C_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CC_GENCPM $OPTS_CPP"
1718 CHARM_CC_FLAGS="$CMK_CC_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC"
1719 CHARM_CXX_FLAGS="$CMK_CXX_FLAGS -I$CHARMINC $CMK_INCDIR $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX"
1720 CHARM_LD_FLAGS="$CMK_LD_FLAGS $CMK_LINK_BINARY $CMK_LIBDIR $OPTS_LD $ALL_LIBS"
1721 CHARM_LDXX_FLAGS="$CMK_LDXX_FLAGS $CMK_LINK_BINARY $CMK_LIBDIR $OPTS_LD $ALL_LIBS"
1724 ########################################################################
1726 # Print command building blocks and quit, if specified
1728 ########################################################################
1730 if [ -n "$PRINT_BUILDING_BLOCKS" ]
1731 then
1732 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
1734 eval "echo $i=\\'\${$i}\\'"
1735 done
1736 exit 0
1740 ########################################################################
1742 # We've parsed and verified the command-line parameters.
1743 # Now we prepare routines to clean up and exit.
1744 # None of these routines ever returns-- they all just exit.
1746 ########################################################################
1749 Copyobj() {
1750 if [ "a$COPYTO" != "a" -a "a$COPYTO" != "a$OBJECT" ]
1751 then
1752 [ -d $COPYTO ] && COPYTO="$COPYTO/"
1753 if [ "a$PROG_EXT" != "a" -a -r "$OBJECT$PROG_EXT" ] ; then
1754 Warning "Appending $PROG_EXT to object file name"
1755 OBJECT="$OBJECT$PROG_EXT"
1757 [ ! -d $COPYTO ] && DoNoErrCheck $RM $COPYTO
1758 Do $CP $OBJECT $COPYTO
1760 test -n "$COPY_EXIT" && Success
1763 Copymod() {
1764 for COPY in `echo $MODCOPIES`
1766 if [ "a$COPY" != "a$OBJECT" ]
1767 then
1768 [ -d $COPY ] && COPY="$COPY/"
1769 if [ -n "$CMK_MOD_NAME_ALLCAPS" ] ; then
1770 OBJECT=`echo $OBJECT | tr "a-z" "A-Z"`
1772 if [ -r "$OBJECT.$CMK_MOD_EXT" ] ; then
1773 Warning "Appending .$CMK_MOD_EXT to object file name"
1774 OBJECT="$OBJECT.$CMK_MOD_EXT"
1776 [ ! -d $COPY ] && DoNoErrCheck $RM $COPY
1777 Do $CP $OBJECT $COPY
1779 done
1780 Success
1783 Success() {
1784 End 0
1788 ##############################################################################
1790 # Preprocess the GEN-CPM files
1792 ##############################################################################
1794 Debug "Preprocessing GEN-CPM files"
1796 for FILE in `echo $GENCPM`
1798 # This used to be "$FILE:r", which strips the extention
1799 BASE=`stripExtention $FILE`
1800 MYTMP=`basename $FILE`".TMP"
1801 DELETE="$DELETE $MYTMP.c $MYTMP.i"
1802 DoNoErrCheck $RM $BASE.cpm.h $MYTMP.c
1803 Do touch $BASE.cpm.h
1804 Do $LN -f -s $FILE $MYTMP.c
1805 Do $CHARM_CPP_C $CHARM_CPP_C_FLAGS $MYTMP.c > $MYTMP.i
1806 Do $CHARMBIN/conv-cpm $MYTMP.i $BASE.cpm.h
1807 done
1809 ##############################################################################
1811 # Compile all specified files
1813 # All temporary files named *.TMP.* for easy cleanup.
1815 ##############################################################################
1817 Debug "About to compile..."
1819 for FILE in $FILES
1821 BASE=`stripExtention \`basename $FILE\``
1822 MYTMP=`basename $FILE`".TMP"
1823 FILE_EXT=`getExtention $FILE`
1824 BASEO="$BASE.o"
1825 DESTO="-o $BASEO"
1827 # in case of: charmc -o object.o -c foo.c,
1828 # avoid foo.c => remove foo.o => foo.o => object.o,
1829 # instead generate object.o directly.
1830 # remove and generate foo.o may be dangerous in parallel make
1831 # for example in the case of compiling several objs from one
1832 # same c file such as memory.C.
1833 if [ $numFiles = 1 -a -n "$OBJECT" ]
1834 then
1835 OBJ_EXT=`getExtention $OBJECT`
1836 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1837 then
1838 BASEO=$OBJECT
1839 DESTO="-o $OBJECT"
1843 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1844 # then
1845 case "$FILE_EXT" in
1846 .c|.s|.S|.C|.cc|.cxx|.cpp|.c++|.cu|.f|.F|.f90|.F90|.fpp|.FPP|.f77|.F77)
1847 [ $VERBOSE ] && echo "Compiling $FILE"
1848 DoNoErrCheck $RM $BASEO `stripExtention $BASEO`.f.o
1849 esac
1850 # fi
1851 if [ ! -z "$SKIPLINK" ]
1852 then
1853 DESTO=""
1856 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1857 then
1858 case "$FILE" in
1859 *.c)
1860 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1861 FILE="rose_$FILE"
1863 *.C|*.cc|*.cxx|*.cpp|*.c++)
1864 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE
1865 FILE="rose_$FILE"
1867 *.f|*.F|*.f77|*.F77)
1868 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1869 FILE="rose_$FILE"
1871 *.f90|*.F90|*.fpp|*.FPP)
1872 test -z "$PREPROCESS" && OPTS_F90="$OPTS_F90 -c"
1873 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE
1874 FILE="rose_$FILE"
1876 esac
1879 case "$FILE" in
1880 *.ci)
1881 XIOPTS=$CMK_XIOPTS
1882 test "$PARADIGM" = "f90charm" && XIOPTS="$XIOPTS -f90"
1883 if [ "$PREPROCESS_CI" = "yes" ]
1884 then
1885 Do $CMK_CPP_CHARM $OPTS_CPP $FILE | Do $CHARMBIN/charmxi $XIOPTS -orig-file $FILE
1886 else
1887 Do $CHARMBIN/charmxi $XIOPTS $FILE
1890 *.c|*.s|*.S)
1891 Do $CHARM_CC $CHARM_CC_FLAGS -c $FILE $DESTO
1892 if [ "$Do_res" -ne 0 ]
1893 then
1894 touch $BASEO
1897 *.C|*.cc|*.cxx|*.cpp|*.c++|*.cu)
1898 if [ -n "$NATIVE" ]
1899 then
1900 Do $CMK_NATIVE_CXX $CMK_NATIVE_CXX_FLAGS -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP -c $FILE $DESTO
1901 else
1902 Do $CHARM_CXX $CHARM_CXX_FLAGS -c $FILE $DESTO
1904 if [ "$Do_res" -ne 0 ]
1905 then
1906 touch $BASEO
1909 *.f|*.F|*.f77|*.F77)
1910 test -z "$CMK_CF90_FIXED" && Abort "No F90 compiler (CMK_CF90_FIXED) defined"
1911 Do $CMK_CF90_FIXED -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE $DESTO
1912 if [ "$Do_res" -ne 0 ]
1913 then
1914 touch $BASEO
1917 *.f90|*.F90|*.fpp|*.FPP)
1918 test -z "$CMK_CF90" && Abort "No F90 compiler (CMK_CF90) defined"
1919 test -z "$PREPROCESS" && OPTS_F90="$OPTS_F90 -c"
1920 Do $CMK_CF90 -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE $DESTO
1921 if [ "$Do_res" -ne 0 ]
1922 then
1923 touch $BASEO
1926 *.fc|*.FC)
1927 Abort "I'm not yet smart enough to compile $FILE"
1929 *.o|*.so|*.so.*|*.sl|*.a|*.dylib|*.co)
1930 [ ! -s $FILE ] && Abort "$FILE: file not recognized: File truncated"
1932 *.M|*.mod)
1933 OBJECT="$BASE"
1934 Copymod
1935 Success
1938 Abort "file with unrecognized extension $FILE"
1939 esac
1940 done
1942 ##############################################################################
1944 # POSSIBLY, SKIP LINK-STEP
1946 # 1. No $OBJECT may be specified at all --- its just a compilation.
1947 # 2. If $OBJECT is a ".a" file, a library is created from $OBJECTFILES.
1948 # 3. If $OBJECT is a ".o" file, then an "LDRO" is created from $OBJECTFILES.
1949 # 4. Language may be sequential. Do a quick and easy linkage.
1951 # in any of these cases, the full link step is skipped.
1953 ##############################################################################
1955 MakeSO() {
1956 Debugf "Running ldro..."
1957 DoNoErrCheck $RM $OBJECT
1958 # convert to absolute path if required
1959 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1960 then
1961 dir=`dirname $OBJECT`
1962 fname=`basename $OBJECT`
1963 dir=`cd $dir; pwd`
1964 OBJECT=$dir/$fname
1966 if test "$MAKE_LDXX" = "1"
1967 then
1968 soTool="$CMK_LDXX $CMK_LDXX_FLAGS"
1969 else
1970 soTool="$CMK_LD $CMK_LD_FLAGS"
1972 if [ -n "$STANDALONE" ]
1973 then
1974 soLibs="$USER_PRE_LIBRARIES $USER_POST_LIBRARIES"
1975 else
1976 soLibs="$PRE_LIBRARIES $POST_LIBRARIES"
1977 [ "$CMK_MACOSX" = "1" ] && OPTS_LD="$OPTS_LD -Wl,-install_name,$CHARMLIBSO/$fname"
1979 if [ -n "$LINK_WHOLE_ARCHIVE" ]
1980 then
1981 soLibs="$CXX_NO_AS_NEEDED $LDXX_WHOLE_ARCHIVE_PRE $soLibs $LDXX_WHOLE_ARCHIVE_POST"
1983 soLibs="$soLibs $CMK_SYSLIBS"
1984 if [ -n "$LINK_CXX_STL" ]
1985 then
1986 soLibs="$soLibs -lstdc++"
1988 soCmd="$soTool $CMK_LIBDIR -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $soLibs $CMK_LD_SHARED_LIBS"
1989 DoNoErrCheck $soCmd
1990 Do_res=$?
1991 if [ $Do_res -ne 0 ]
1992 then
1993 if [ -n "$NOABORT" ]
1994 then
1995 touch $OBJECT
1996 else
1997 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1998 echo "!! Failed to compile Charm++ shared library. You can disable shared !!"
1999 echo "!! lib compilation by providing --no-build-shared build option like: !!"
2000 echo "!! ./build charm++ netlrts-linux --no-build-shared -O !!"
2001 echo "!! or reexecute this charmc command with the --no-build-shared option !!"
2002 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
2003 Abort "Command $soCmd returned error code $Do_res"
2006 Copyobj
2009 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
2010 then
2011 # We have no target object, or are playing preprocessor tricks-- just end
2012 Debugf "No target object-- finished"
2013 Success
2016 Debug "About to link..."
2018 if [ "$INPUT_GIVEN" != "1" ]
2019 then
2020 Abort "Trying to link, but no object files or library archives were specified"
2023 # if interoperate dont create the library now, wait to collect all info
2024 if [ "$MPI_INTEROPERATE" = "" ]
2025 then
2026 case "$OBJECT" in
2027 *.o)
2028 Debugf "Converting $FILES to $OBJECTFILES"
2029 nFiles=`echo $FILES | wc -w`
2030 nObj=`echo $OBJECTFILES | wc -w`
2031 # One source file, one .o: just move the .o
2032 if [ $OBJECT != $OBJECTFILES ]
2033 then
2034 Debugf "Moving .o to destination"
2035 DoNoErrCheck $RM $OBJECT
2036 Do $MV $OBJECTFILES $OBJECT
2038 Copyobj
2040 *.so|*.so.*|*.sl|*.dylib)
2041 # Make shared library
2042 # If building shared is not supported and this object is not standalone, exit.
2043 if [ "$BUILD_SHARE" = 0 -a -z "$STANDALONE" ]
2044 then
2045 Warning "Warning: building shared library is not supported, recompile charm++ with '--build-shared'."
2046 End 1
2047 elif [ "$CHARM_SHARED" = "0" ]
2048 then
2049 MakeSO
2052 *.a)
2053 # Make regular (.a, non-shared) library
2054 # in case building charm so, build .so under lib_so as well # Gengbin
2055 if [ "$BUILD_SHARE" = "1" ]
2056 then
2057 COPY_EXIT=""
2058 OBJECT_SAVE=$OBJECT
2059 COPYTO_SAVE=$COPYTO
2060 if [ -z "$COPYTO" ]
2061 then
2062 DESTDIR=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
2063 OBJECT=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
2064 else
2065 COPYTO=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
2066 DESTDIR=$COPYTO
2068 OBJECT=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
2069 [ -f $DESTDIR/.charmso ] && MakeSO
2070 COPYTO=$COPYTO_SAVE
2071 OBJECT=$OBJECT_SAVE
2072 COPY_EXIT="true"
2074 # build normal .a
2075 DoNoErrCheck $RM $OBJECT
2076 Do $CMK_AR $OBJECT $OBJECTFILES
2077 Do $CMK_RANLIB $OBJECT
2078 Copyobj
2080 esac
2082 # If the above case returns, we're not creating a .o or .a file,
2083 # so linking is needed.
2085 if [ $CMK_CELL -eq 1 ]
2086 then
2088 if [ "$PARADIGM" = "charm++" ]
2089 then
2091 # Make the spe object file to be included
2092 Do $SPU_COMPILER -c -I$CHARMINC $CMK_SYSINC -o main__funcLookup__.genSPECode.o main__funcLookup__.genSPECode.c -DCMK_CELL_SPE=1
2093 Do $SPU_LINKER -L$CHARMLIB -o main__funcLookup__.genSPECode main__funcLookup__.genSPECode.o $CMK_SPERT_LIBS $SPU_EXTRA_LIBS
2094 Do $CMK_PPU_EMBEDSPU spert_main main__funcLookup__.genSPECode main__funcLookup__.genSPECode.ppe.o
2099 # check if we're linking a sequential object
2100 case "$LANGUAGE" in
2101 "c"|"C"|"f90"|"f77")
2102 if [ -n "$NATIVE" ]
2103 then
2104 Do $CMK_NATIVE_LD $CMK_NATIVE_LD_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2105 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2106 else
2107 Do $CMK_SEQ_LD $CMK_SEQ_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2108 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2110 Copyobj
2112 "c++"|"C++")
2113 if [ -n "$NATIVE" ]
2114 then
2115 Do $CMK_NATIVE_LDXX $CMK_NATIVE_LDXX_FLAGS $OPTS_LD -o $OBJECT $OBJECTFILES \
2116 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
2117 else
2118 Do $CMK_SEQ_LDXX $CMK_SEQ_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $OBJECTFILES \
2119 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
2121 Copyobj
2123 esac
2126 ##############################################################################
2128 # Confirm that TRACEMODE, BALANCE, MEMORY, THREAD exist
2130 ##############################################################################
2132 # [ -r $CHARMLIB/libtrace-projections.a ] || Abort "trace libraries not installed. Is Charm++ built properly?"
2134 if [ x"$TRACEMODE" != x ]
2135 then
2136 for trace in $TRACEMODE; do
2137 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort "charmc : No such tracemode $trace"
2138 done
2141 BAL_EXT=`getExtention $BALANCE`
2142 if [ -z "$BAL_EXT" ]; then
2143 # Balance has no extension-- is a library reference
2144 if [ -f "${CHARMLIB}/libldb-$BALANCE.a" ]; then
2145 BAL_OBJ_FILE="${CHARMLIB}/libldb-$BALANCE.a"
2146 else
2147 BAL_OBJ_FILE="${CHARMLIBSO}/libldb-$BALANCE.so"
2149 else
2150 # Balance has some extension-- must be a .o or .a file
2151 BAL_OBJ_FILE="$BALANCE"
2154 if [ ! -r "$BAL_OBJ_FILE" ]
2155 then
2156 if [ "$BALANCE" = "$BAL_OBJ_FILE" ]
2157 then
2158 Abort "Could not find load balancer object $BAL_OBJ_FILE"
2159 else
2160 (cd $CHARMLIB ; ls -al libldb-*)
2161 Abort "Unknown load balancer $BALANCE / $BAL_OBJ_FILE"
2165 if [ -f "${CHARMLIB}/libmemory-${MEMORY}.a" ]; then
2166 MEM_OBJ_FILE="${CHARMLIB}/libmemory-${MEMORY}.a"
2167 else
2168 MEM_OBJ_FILE="${CHARMLIBSO}/libmemory-${MEMORY}.so"
2171 if [ ! -r $MEM_OBJ_FILE -o ! -s $MEM_OBJ_FILE ]
2172 then
2173 (cd $CHARMLIB ; list=`ls libmemory-* 2>/dev/null`; test -n "$list" && for i in $list; do [ -s $i ] && ls -l $i; done )
2174 Abort "charmc : No such memory mode $MEMORY"
2177 if [ -f "${CHARMLIB}/libthreads-${THREAD}.a" ]; then
2178 THREAD_OBJ_FILE="${CHARMLIB}/libthreads-${THREAD}.a"
2179 else
2180 THREAD_OBJ_FILE="${CHARMLIBSO}/libthreads-${THREAD}.so"
2183 if [ ! -r $THREAD_OBJ_FILE -o ! -s $THREAD_OBJ_FILE ]
2184 then
2185 (cd $CHARMLIB ; list=`ls libthreads-* 2>/dev/null`; test -n "$list" && for i in $list; do [ -s $i ] && ls -l $i; done )
2186 Abort "charmc : No such thread mode $THREAD"
2190 ################# Build the module initialization function ##################
2192 if [ -z "$SKIP_MODULEINIT" ]
2193 then
2194 DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
2196 for module in $MODULES; do
2197 echo "extern void _register$module(void);" >> $modInitSrc
2198 done
2199 for trace in $TRACEMODE; do
2200 if test $trace = "summary"
2201 then
2202 echo " extern void _registerTraceSummary();" >> $modInitSrc
2203 elif test $trace = "projections"
2204 then
2205 echo " extern void _registerTraceProjections();" >> $modInitSrc
2206 elif test $trace = "simple"
2207 then
2208 echo " extern void _registerTraceSimple();" >> $modInitSrc
2209 elif test $trace = "Tau"
2210 then
2211 echo " extern void _registerTraceTau();" >> $modInitSrc
2212 elif test $trace = "utilization"
2213 then
2214 echo " extern void _registerTraceUtilization();" >> $modInitSrc
2215 elif test $trace = "controlPoints"
2216 then
2217 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2218 elif test $trace = "perfReport"
2219 then
2220 Do $CP $CHARMBIN/fuzzytree.txt fuzzytree.txt
2221 Do $CP $CHARMBIN/tree.txt tree.txt
2222 echo " extern void _registerTraceAutoPerf();" >> $modInitSrc
2224 elif test $trace = "all"
2225 then
2226 echo " extern void _registerTraceProjections();" >> $modInitSrc
2227 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
2228 echo " extern void _registerTraceSummary();" >> $modInitSrc
2230 done
2231 if test -n "$BALANCER"
2232 then
2233 echo "extern void LBDefaultCreate(const char *);" >> $modInitSrc
2235 echo "void _registerExternalModules(char **argv) { (void)argv;" >> $modInitSrc
2236 for module in $MODULES; do
2237 [ -n "$VERBOSE" ] && echo "Adding registration for module $module"
2238 echo " _register$module();" >> $modInitSrc
2239 done
2240 for trace in $TRACEMODE; do
2241 if test $trace = "summary"
2242 then
2243 echo " _registerTraceSummary();" >> $modInitSrc
2244 elif test $trace = "projections"
2245 then
2246 echo " _registerTraceProjections();" >> $modInitSrc
2247 elif test $trace = "Tau"
2248 then
2249 TRACE_WITH_TAU=1
2250 echo " _registerTraceTau();" >> $modInitSrc
2251 elif test $trace = "simple"
2252 then
2253 echo " _registerTraceSimple();" >> $modInitSrc
2254 elif test $trace = "utilization"
2255 then
2256 echo " _registerTraceUtilization();" >> $modInitSrc
2257 elif test $trace = "controlPoints"
2258 then
2259 echo " _registerTraceControlPoints();" >> $modInitSrc
2260 elif test $trace = "perfReport"
2261 then
2262 echo " _registerTraceAutoPerf();" >> $modInitSrc
2263 elif test $trace = "all"
2264 then
2265 echo " _registerTraceProjections();" >> $modInitSrc
2266 echo " _registerTraceControlPoints();" >> $modInitSrc
2267 echo " _registerTraceSummary();" >> $modInitSrc
2269 done
2270 if test -n "$BALANCER"
2271 then
2272 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
2273 for deflb in $BALANCER
2275 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
2276 done
2278 echo "}" >> $modInitSrc
2280 # creating projections
2281 echo "void _createTraces(char **argv) { (void)argv;" >> $modInitSrc
2282 for trace in $TRACEMODE; do
2283 [ -n "$VERBOSE" ] && echo "Adding registration for trace $trace"
2284 echo "extern void _createTrace$trace(char **argv);" >> $modInitSrc
2285 echo "_createTrace$trace(argv);" >> $modInitSrc
2286 done
2287 echo "}" >> $modInitSrc
2289 Do $CHARM_CXX $CHARM_CXX_FLAGS -c $modInitSrc -o $modInitObj
2292 ###############################################################################
2294 # Finally, LINK
2296 ###############################################################################
2298 Debug "About to perform final link..."
2300 #currently only support creation of .a
2301 if [ "$MPI_INTEROPERATE" != "" ]
2302 then
2303 case "$OBJECT" in
2304 *.a)
2305 # in case building charm so, build .so under lib_so as well # Gengbin
2306 DoNoErrCheck $RM $OBJECT
2307 if [ -z "$SKIP_MODULEINIT" ]
2308 then
2309 echo "$CMK_AR $OBJECT $OBJECTFILES $modInitObj"
2310 Do $CMK_AR $OBJECT $OBJECTFILES $modInitObj
2312 Do $CMK_RANLIB $OBJECT
2313 echo "export CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\"" > ./charm_all_libs.sh
2314 echo "CHARM_ALL_LIBS=\"$CHARM_ALL_LIBS\""
2315 Copyobj
2317 *.so|*.so.*|*.sl|*.dylib)
2318 echo "Warning: building shared library failed; for interoperation build
2319 static library."
2320 End 0
2322 esac
2325 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2326 then
2327 # build an application .so linking with charm .so
2328 OPTS_LD="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
2329 Debugf "Running ldro..."
2330 DoNoErrCheck $RM $OBJECT
2331 [ "$MAKE_LDXX" = "1" ] && Do $CMK_LDXX $CMK_LDXX_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $ALL_LIBS
2332 [ "$MAKE_LD" = "1" ] && Do $CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR $OPTS_LD -o $OBJECT $ALL_LIBS
2333 Copyobj
2334 else
2335 # Make a regular executable: call the appropriate linker
2336 [ "$MAKE_LDXX" = "1" ] && Do $CHARM_LDXX $CHARM_LDXX_FLAGS -o $OBJECT
2337 [ "$MAKE_LD" = "1" ] && Do $CHARM_LD $CHARM_LD_FLAGS -o $OBJECT
2340 ########################################################################
2342 # Copy conv-host to user directory if it is present in installation.
2344 ########################################################################
2346 if test "$COPY_CHARMRUN" = "true"
2347 then
2348 targ=charmrun$CMK_POST_EXE
2349 [ ! -x $CHARMBIN/$targ -a -n "$CMK_POST_EXE" ] && targ=charmrun
2350 convhost=conv-host$CMK_POST_EXE
2352 if [ -x $CHARMBIN/$targ ]
2353 then
2354 DoNoErrCheck $RM $targ
2355 DoNoErrCheck $CP $CHARMBIN/$targ $targ 2> /dev/null
2359 [ -z "$SKIP_MODULEINIT" -a -z "$SAVE" ] && DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
2361 Copyobj