Bug #1062: Fix linking errors by moving definition of userDrivenMode to machine-commo...
[charm.git] / src / scripts / charmc
blob27720c2a3a9c22f0cc3ad602f86310ef0e11bee4
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 BALANCE="rand"
26 TRACEMODE=""
27 TRACE_OBJ=
28 MEMORY="default"
29 THREAD="default"
30 VERBOSE=""
31 DEBUG_SCRIPT=""
32 SAVE=""
33 PURIFY=""
34 SKIPLINK=""
35 OVERRIDE_CC=""
36 OVERRIDE_CXX=""
37 OVERRIDE_F90=""
38 OVERRIDE_LD=""
39 OVERRIDE_LDXX=""
40 #Generic options, passed to everything
41 OPTS=""
42 #Specific options
43 #charm internal flag, only pass to c and cxx, not f90
44 OPTS_CPP_INTERNAL="-D__CHARMC__=1"
45 OPTS_CPP=
46 OPTS_LDRO=""
47 OPTS_CC=""
48 OPTS_CXX=""
49 OPTS_F90=""
50 OPTS_LD=""
51 OPTS_LDXX=""
52 OPTS_PIC=""
53 USE_PIC="0"
55 CHARMDEBUG=""
56 LINK_PYTHON=""
57 OBJECT=""
58 EXPLICIT_OBJECT="no"
59 EXPLICIT_COMPILATION="no"
60 POST_LANGUAGE=""
61 POST_LIBRARIES=""
62 PRE_LIBRARIES=""
63 USE_F90_LIBRARIES="0"
64 USE_F77_LIBRARIES="0"
65 F90_MODDIR=
66 AMPIMAIN=""
67 COPYTO=""
68 MODCOPIES=""
69 MODULES=""
70 BALANCER=""
71 FILES=""
72 OBJECTFILES=""
73 DELETE=""
74 MAINOBJ=""
75 GENCPM=""
76 OPTIMIZE_MODE=""
77 PRODUCTION_MODE=""
78 USE_RELIABLE_CC=""
79 USE_FASTEST_CC=""
80 PROG_EXT=""
81 GENDEPENDS="no"
82 COUNTTOKENS="no"
83 USE_OPENMP="no"
85 COPY_CHARMRUN=true
86 USE_BUILD_OPTIONS=0
88 COPY_EXIT="true"
89 CHARM_SHARED="0"
90 BUILD_SHARE="0"
91 SWAPGLOBALS="0"
92 TLSGLOBALS="0"
93 ROSE_OMP_TLS_GLOBALS="no"
94 NOABORT=""
96 TAU_MAKEFILE=Make.tau
97 TAU_TRACE_MPI=1
99 CMK_CELL=0
100 SPU_USE_CPP=0
101 SPU_EXTRA_LIBS=""
103 MPI_INTEROPERATE=""
104 NO_MAIN_MODULE=""
105 NO_MAIN=""
106 CUSTOM_PARTITION=""
107 PREPROCESS_CI="yes"
109 ####################################################################
111 # Utility routines used below
113 ###################################################################
115 # PrintUsage: prints a helpful command-line usage message and quits
116 # Args: any additional messages
117 printUsage() {
118 printVersion
119 echo
120 echo "Usage: charmc [ flags ] <files>"
121 echo
122 echo " flags:"
123 echo " -o <target> -g -O"
124 echo " -D<define> -I<include path> -L<lib path> -l<library> -s"
125 echo " -machine <mach> -seq -host -language <lang> -pg <opt>"
126 echo " -balance <mode> -tracemode <mode> -memory <mode>"
127 echo " -modules <comma-separated list of C++ modules> -thread"
128 echo " -debug-script -count-tokens -default-to-aout -E -S -M"
129 echo " -verbose -save -purify -cp <dest> -cpmod -gen-cpm <pkg>"
130 echo " -swapglobals -copyglobals -tlsglobals -roseomptlsglobals"
131 echo " -use-reliable-cc -use-fastest-cc -use-new-std"
132 echo " -cc <new cc> -c++ <new CC> -ld <new ld> -ld++ <new LD>"
133 echo " -cpp-option <opt> -ldro-option <opt> -cc-option <opt>"
134 echo " -c++-option <opt> -ld-option <opt> -ld++-option <opt>"
135 echo " -f90 <new f90> -f90-option <opt> -fmoddir <f90mod path>"
136 echo " -flibs -rpath <path> -custom-part -touch-on-failure"
137 echo " -mpi -openmp -no-trace-mpi -build-shared -charm-shared"
138 echo " -no-charmrun -no-preprocess-ci -nomain-module -nomain"
139 echo " -nof90main -f90main"
140 echo
141 echo " Charmc compiles C, C++, f77, f90, AMPI, Converse, Converse++, Charm, "
142 echo "and Charm++ programs. The flags generally match those of cc or f77."
143 echo "Parallel Programming Lab, UIUC, 2016."
144 echo $*
145 exit 1
148 # End blows away the temporary files (unless SAVE is true) and exits
149 # Args: <exit code>
150 End() {
151 if [ -z "$SAVE" ]
152 then
153 for FILE in `echo $FILES`
155 #BASE=`stripExtention $FILE`
156 TMP=`basename $FILE`".TMP"
157 $RM $TMP.P.C $TMP.cpp $TMP.space $TMP.xlat $TMP.o
158 $RM $TMP.c $TMP.c.0.h $TMP.c.1.h $TMP.c.2.h
159 $RM $TMP.i $TMP.$CMK_CPP_SUFFIX
160 done
161 $RM core $DELETE
162 if test -n "$modInitObj"
163 then
164 [ -n "$VERBOSE" ] && echo $RM $modInitSrc $modInitObj
165 DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
168 exit $1
171 # Write this error message to stderr
172 # ("1>&2" redirects the echo output to stderr).
173 Warning() {
174 echo "$@" 1>&2
177 # This procedure prints an error message and exits.
178 # Args: written to stderr
179 Abort() {
180 Warning "Fatal Error by charmc in directory "`pwd`
181 Warning " $@"
182 Warning "charmc exiting..."
183 End 1
187 # Instead of an ECHO_CMD variable, I define a procedure Do,
188 # which (possibly) echos, runs, and tests the errors of the given command.
189 # Args: executed as given
190 DoNoErrCheck() {
191 [ -n "$VERBOSE" ] && echo "charmc: Executing $@" 1>&2
192 eval "$@"
195 Do() {
196 DoNoErrCheck "$@"
197 Do_res=$?
198 # The UNIX result code better be zero, or we die
199 [ $Do_res -eq 0 -o -n "$NOABORT" ] || Abort "Command $@ returned error code $Do_res"
202 # This procedure removes the extention (the ".c" in "./main.c") from
203 # its first argument, and prints the result. Unlike the builtin command
204 # basename, it keeps the directory path.
205 # Args: <name to strip>
206 stripExtention() {
207 se_base=`basename $1`
208 # se_base=`echo $1 | awk -F/ '{print $NF}'`
209 se_strip=`echo $se_base | awk -F. '{ORS="";print $1;for (i=2;i<NF;i++) print "."$i}'`
210 se_ret=`echo $1 | awk -F/ '{ORS="";for (i=1;i<NF;i++) print $i"/"}'`"$se_strip"
211 echo $se_ret
214 # GetExtention returns the extention on the given file name
215 # or "" if none. (e.g. "./bob/snack.c" returns ".c")
216 # Args: <name to find extention of>
217 getExtention() {
218 # se_base=`echo $1 | awk -F/ '{print $NF}'`
219 # se_ret=`echo $se_base | awk -F. '{if (NF<=1) print ""; else print "."$NF}'`
220 # echo $se_ret
221 se_ret=`echo $1 | sed -e 's/.*\././'`
222 if test "$se_ret" = $1
223 then
224 echo ""
225 else
226 echo $se_ret
230 Debugf() {
231 [ -n "$VERBOSE" ] && echo "charmc>" $@
234 Debug() {
235 if [ -n "$DEBUG_SCRIPT" ]
236 then
237 echo
238 echo "------- Charmc Debugging info: $* -------"
239 echo "CHARMBIN=$CHARMBIN"
240 echo "CHARMINC=$CHARMINC"
241 echo "CHARMLIB=$CHARMLIB"
242 echo "FILES=$FILES"
243 echo "DELETE=$DELETE"
244 echo "OBJECT=$OBJECT"
245 echo "LANGUAGE=$LANGUAGE"
246 # echo "Working directory="`pwd`
250 # Return success if $1 is not in any of the other arguments
251 notInList() {
252 search=$1
253 shift
254 while [ $# -gt 0 ]
256 if [ "$search" = "$1" ]
257 then
258 # It's already in there-- fail
259 return 1
261 shift
262 done
263 # It's missing--succeed
264 return 0
267 # Add arguments to our modules list, avoiding duplicates
268 AddModules() {
269 for M in "$@"
271 notInList $M $MODULES && MODULES="$MODULES $M"
272 done
275 # Add this word to this list, avoiding duplicates
276 AddList() {
277 ret=""
278 while [ $# -gt 1 ]
280 ret="$ret $1"
281 shift
282 done
283 if notInList $1 $ret
284 then
285 ret="$ret $1"
287 echo $ret
290 # TEMP_BASE is appended with this script's process ID (PID),
291 # so multiple charmcs can run in parallel without overwriting
292 # each other's temporary files.
293 TEMP_BASE="/tmp/charmc_tmp.$$"
295 # Try to find CHARMBIN by looking in directory where charmc is
296 findCharmBin() {
297 if [ -z "$CHARMBIN" ]
298 then
299 SCRIPT=$1
300 CHARMBIN=`dirname $SCRIPT`
301 # CHARMBIN=`cd $CHARMBIN; pwd`
302 # NOTE: this script no longer tries to follow soft links
303 # to find the "original" charmc-- if this is bad,
304 # translate these lines to Bourne shell from C shell:
305 # -------------------- Begin C Shell ------------------------->
306 # if ($SCRIPT:h != $SCRIPT:t) then
307 # cd $SCRIPT:h
308 # set SCRIPT=$SCRIPT:t
309 # else
310 # foreach dir ($path)
311 # if (-x $dir/$SCRIPT && ! -d $dir/$SCRIPT) then
312 # cd $dir
313 # break
314 # endif
315 # end
316 # endif
317 # while (x`find $SCRIPT -type l -print` == x$SCRIPT)
318 # set SCRIPT=`ls -al ./$SCRIPT:t | sed -e "s@.*-> @@"`
319 # if ($SCRIPT:h != $SCRIPT:t) then
320 # cd $SCRIPT:h
321 # set SCRIPT=$SCRIPT:t
322 # endif
323 # end
324 # set CHARMBIN=`pwd`
325 # <------------------ End C Shell -----------------------------
329 printVersion()
331 findCharmBin $0
332 version=`cat $CHARMBIN/../include/VERSION`
333 echo Charm++ Version $version
337 ##############################################################################
339 # The following section identifies CHARMBIN, the charm binary-directory.
341 ##############################################################################
343 ORIGDIR=`pwd`
345 # Try to find CHARMBIN by looking in directory where charmc is
347 findCharmBin $0
349 UNAME=`uname -s`
350 FIRST_THREE=`uname -s | awk '{print substr($1,1,3)}' `
351 if [ "$FIRST_THREE" = "CYG" -o "$UNAME" = "Interix" ]
352 then
353 # Running on a windows system-- append .exe to file names
354 PROG_EXT=".exe"
357 CHARMLIB="$CHARMBIN/../lib"
358 CHARMINC="$CHARMBIN/../include"
359 CHARMLIBSO=
360 if test -d "$CHARMBIN/../lib_so"
361 then
362 CHARMLIBSO=`cd $CHARMBIN/../lib_so 2>/dev/null && pwd`
363 #getting absolute path is harder than thought because of symbolic links and ..
364 #ksh needs cd -P to resolve werid symbolic links, however -P is not portable
365 #csh is ok too if it exists
366 test -z "$CHARMLIBSO" && CHARMLIBSO=`cd -P $CHARMBIN/../lib_so 2>/dev/null && pwd`
367 test -z "$CHARMLIBSO" && CHARMLIBSO=`csh -c "cd $CHARMBIN/../lib_so >& /dev/null && pwd"`
368 test -z "$CHARMLIBSO" && echo "$CHARMBIN/../lib_so: not found" && exit 1
371 ##############################################################################
373 # Parse the arguments
375 # Don't do any analysis in here, just the parsing.
377 ##############################################################################
379 [ $# -eq 0 ] && printUsage "Error: No arguments given."
381 processArgs() {
382 while [ ! $# -eq 0 ]
384 arg="$1"
385 shift
387 case "$arg" in
388 "-V")
389 printVersion
390 exit 0
393 "-machine")
394 MACHTYPE="$1"
395 shift
398 "-seq")
399 SEQUENTIAL=true
402 "-host")
403 NATIVE=true
406 "-language")
407 # Parse out some fake languages (that are actually modules)
408 case "$1" in
409 "ampi") AddModules tcharmmain ampi ;;
410 "ampif") AddModules tcharmmain ampif ; USE_F90_LIBRARIES="1" ;;
411 "armci") AddModules tcharmmain armci ;;
412 "armcif") AddModules tcharmmain armci ; USE_F90_LIBRARIES="1" ;;
413 "fem") AddModules tcharmmain fem ; AMPIMAIN="femmain";;
414 "femf") AddModules tcharmmain fem ; AMPIMAIN="femmain"; USE_F90_LIBRARIES="1" ;;
415 "ParFUM_TOPS") AddModules tcharmmain ParFUM ParFUM_TOPS ; AMPIMAIN="ParFUMmain";;
416 "ParFUM") AddModules tcharmmain ParFUM ; AMPIMAIN="ParFUMmain";;
417 "ParFUMf") AddModules tcharmmain ParFUM ; AMPIMAIN="ParFUMmain"; USE_F90_LIBRARIES="1" ;;
418 "mblock") AddModules tcharmmain mblock ;;
419 "mblockf") AddModules tcharmmain mblock ; USE_F90_LIBRARIES="1" ;;
421 LANGUAGE="$1"
422 POST_LANGUAGE=1
424 esac
425 shift
428 "-debug")
429 # Requested support from charmdebug: add some modules and libraries
430 CHARMDEBUG=1
431 MEMORY="charmdebug"
434 "-module"|"-modules")
435 AddModules `echo $1 | sed -e 's/,/ /g'`
436 shift
439 "-balancer")
440 # test -n "$BALANCER" && Abort "More than one -balancer specified!"
441 BALANCER="$BALANCER $1"
442 mod=`echo $1| sed -e 's/:/ /' -e 's/,/ /g'`
443 AddModules $mod
444 shift
447 "-balance")
448 BALANCE="$1"
449 shift
452 "-queue")
453 Warning "Warning: -queue currently being ignored."
454 shift
457 "-memory")
458 MEMORY="$1"
459 shift
462 "-thread")
463 THREAD="$1"
464 shift
467 "-tracemode")
468 TRACEMODE_NEW=`AddList $TRACEMODE $1`
469 if [ "$TRACEMODE_NEW" = "$TRACEMODE" ]
470 then
471 Warning "Warning: Duplicate tracemode $1 ignored"
472 else
473 TRACEMODE=$TRACEMODE_NEW
475 shift
477 "-no-trace-mpi")
478 TAU_TRACE_MPI=0
481 "-swapglobal"|"-swapglobals")
482 SWAPGLOBALS="1"
483 USE_PIC="1"
486 "-copyglobal"|"-copyglobals")
487 SWAPGLOBALS="2"
488 USE_PIC="1"
491 "-tlsglobal"|"-tlsglobals")
492 TLSGLOBALS="1"
495 "-roseomptlsglobals")
496 ROSE_OMP_TLS_GLOBALS="yes"
499 "-verbose")
500 echo "Verbose mode set"
501 VERBOSE=true
504 "-spu-cpp")
505 SPU_USE_CPP=1
508 "-spu-lib")
509 SPU_EXTRA_LIBS="$SPU_EXTRA_LIBS -l$1"
510 shift
513 "-intrinsic")
514 XI_INTERNAL=true
517 "-debug-script")
518 echo "Will give excessive charmc debugging output..."
519 DEBUG_SCRIPT=true
522 "-save")
523 SAVE=true
526 "-purify")
527 PURIFY=true
530 "-use-reliable-cc")
531 USE_RELIABLE_CC=1
534 "-use-fastest-cc")
535 USE_FASTEST_CC=1
538 "-cc")
539 OVERRIDE_CC="$1"
540 shift
543 "-c++")
544 OVERRIDE_CXX="$1"
545 shift
548 "-f90")
549 OVERRIDE_F90="$1"
550 shift
553 "-ld")
554 OVERRIDE_LD="$1"
555 shift
558 "-ld++")
559 OVERRIDE_LDXX="$1"
560 shift
563 "-cpp-option")
564 OPTS_CPP="$OPTS_CPP $1"
565 shift
568 "-ldro-option")
569 OPTS_LDRO="$OPTS_LDRO $1"
570 shift
573 "-cc-option")
574 OPTS_CC="$OPTS_CC $1"
575 shift
578 "-c++-option")
579 OPTS_CXX="$OPTS_CXX $1"
580 shift
583 "-f90-option")
584 OPTS_F90="$OPTS_F90 $1"
585 shift
588 "-ld-option")
589 OPTS_LD="$OPTS_LD $1"
590 shift
593 "-ld++-option")
594 OPTS_LDXX="$OPTS_LDXX $1"
595 shift
598 "-rpath")
599 OPTS_LDXX="$OPTS_LDXX -rpath $1"
600 shift
603 "-fortran"|"-flib"|"-flibs")
604 USE_F90_LIBRARIES="1"
606 "-f77")
607 USE_F77="1"
609 "-fortran77"|"-f77lib"|"-f77libs")
610 USE_F77_LIBRARIES="1"
612 "-E")
613 # Run preprocessor only
614 PREPROCESS="yes"
615 SKIPLINK="yes"
616 OPTS="$OPTS $arg"
618 "-preprocess")
619 # Run preprocessor as an extra step, continue after preprocessing
620 PREPROCESS="yes"
622 "-no-preprocess-ci")
623 # Turn off the preprocessor for ci files
624 PREPROCESS_CI="no"
626 "-P"|"-S")
627 # Run preprocessor/assembler only
628 SKIPLINK="yes"
629 OPTS="$OPTS $arg"
631 "-M")
632 SKIPLINK="yes"
633 OPTS="$OPTS $arg"
634 GENDEPENDS="yes"
636 "-count-tokens")
637 OPTS="$OPTS $arg"
638 COUNTTOKENS="yes"
640 "-default-to-aout")
641 if [ "$EXPLICIT_OBJECT $EXPLICIT_COMPILATION" = "no no" ]
642 then
643 OBJECT="a.out"
646 -print-prog-name=*)
647 echo $arg | cut -d'=' -f2
648 exit 0
650 "-c")
651 if [ "$EXPLICIT_OBJECT" = "no" ]
652 then
653 OBJECT=""
655 EXPLICIT_COMPILATION="yes"
658 "-o")
659 EXPLICIT_OBJECT="yes"
660 OBJECT=$1
661 shift
664 "-cp")
665 COPYTO="$1"
666 shift
669 "-cpmod")
670 MODCOPIES="$1 $MODCOPIES"
671 shift
674 "-gen-cpm")
675 GENCPM="$GENCPM $1"
676 shift
680 OPTS_CPP="$OPTS_CPP -I$1"
681 shift
684 -D*|-I*)
685 if echo "$arg" | grep ' ' > /dev/null 2>/dev/null
686 then
687 OPTS_CPP="$OPTS_CPP "\"$arg\"
688 else
689 OPTS_CPP="$OPTS_CPP $arg"
693 -Werror)
694 WERROR="1"
697 -Wno-error)
698 WERROR="0"
701 "-use-new-std")
702 USE_NEW_STD="1"
705 "-no-use-new-std")
706 USE_NEW_STD="0"
709 -LANG*)
710 Warning "passing unrecognized option $arg to all compilers and linkers"
711 OPTS="$OPTS $arg"
713 -shared|-G)
714 BUILD_SHARE="1"
716 -L*|-shared|-G)
717 OPTS_LD="$OPTS_LD $arg"
719 -charm-shared|-cs)
720 CHARM_SHARED="1"
722 -build-shared)
723 # used internally when building Charm++ to create lib_so
724 BUILD_SHARE="1"
726 -no-build-shared)
727 # used internally not to build Charm++ lib_so
728 BUILD_SHARE="0"
730 "-optimize")
731 OPTIMIZE_MODE=true
734 "-no-optimize")
735 OPTIMIZE_MODE=false
738 "-production")
739 PRODUCTION_MODE=true
741 "-no-production")
742 PRODUCTION_MODE=false
745 "-pg"|"-g"|-W*|-O*)
746 OPTS="$OPTS $arg"
749 "-fmoddir")
750 F90_MODDIR="$F90_MODDIR $1"
751 shift
754 -l*|*.a)
755 if [ -n "$POST_LANGUAGE" ]
756 then
757 POST_LIBRARIES="$POST_LIBRARIES $arg"
758 else
759 PRE_LIBRARIES="$PRE_LIBRARIES $arg"
764 OPTS_LD="$OPTS_LD $arg"
766 -no-charmrun)
767 COPY_CHARMRUN=false
769 -use-build-options)
770 USE_BUILD_OPTIONS=1
772 -h|--help)
773 printUsage
775 -f90main)
776 F90_MAIN=1
778 -nof90main)
779 F90_MAIN=
781 -mpi)
782 MPI_INTEROPERATE="yes"
783 NO_MAIN="yes"
785 -nomain-module)
786 NO_MAIN_MODULE="yes"
788 -nomain)
789 NO_MAIN="yes"
791 -custom-part)
792 CUSTOM_PARTITION="yes"
795 -fopenmp|-openmp)
796 USE_OPENMP="yes"
799 -touch-on-failure)
800 NOABORT="yes"
803 -*|+*)
804 # Warning "passing unrecognized option $arg to all compilers and linkers"
805 OPTS="$OPTS $arg"
807 *.*)
808 [ -n "$VERBOSE" ] && echo "Adding file $arg..."
809 FILES="$FILES $arg"
811 # Default
813 # printUsage "Error: Unrecognized argument $arg"
814 # Warning "passing unrecognized option $arg to all compilers and linkers"
815 OPTS="$OPTS $arg"
817 esac
818 done
821 trap 'End 1' 2
823 # Process original command-line arguments
824 eval processArgs "$@"
827 ##############################################################################
829 # Load module dependencies.
831 ##############################################################################
833 Debug "About to read machine config script"
834 Debug "Read config script, setting defaults..."
836 [ ! -r $CHARMINC/conv-config.sh ] && Abort "Cannot find conv-config.sh in $CHARMINC"
837 . $CHARMINC/conv-config.sh $CHARMINC
839 Debug "Setting vars..."
841 if [ "$USE_BUILD_OPTIONS" = "1" ]
842 then
843 [ -n "$VERBOSE" ] && echo "Charmc applying build time options: $BUILDOPTS"
844 OPTS="$OPTS $BUILDOPTS"
847 # If we are debugging, add "-g -O0" to the C/C++ flags
848 if [ -n "$CHARMDEBUG" -a -z "$SEQUENTIAL" -a -z "$NATIVE" ]; then
849 if [ -n "$CMK_BUILD_PYTHON" ]; then
850 AddModules PythonCCS charmdebug_python
851 POST_LIBRARIES=`AddList $POST_LIBRARIES -lpython${CMK_BUILD_PYTHON}`
853 OPTS_CPP="$OPTS_CPP -O0 -g"
856 PROCESSED_MODULES=""
858 if [ "$WERROR" = "1" ]
859 then
860 OPTS="$OPTS $CMK_WARNINGS_ARE_ERRORS"
863 # If the user has asked for the latest language standards (C11 or CPP11)
864 if [ "$USE_NEW_STD" = "1" ]
865 then
866 # and if configure confirmed that the underlying compiler knows abt C11, enable it
867 if [ "$CMK_COMPILER_KNOWS_C11" = "1" ]
868 then
869 OPTS_CC="$OPTS $CMK_ENABLE_C11"
871 # and if configure confirmed that the underlying compiler knows abt CPP11, enable it
872 if [ "$CMK_COMPILER_KNOWS_CPP11" = "1" ]
873 then
874 OPTS_CXX="$OPTS $CMK_ENABLE_CPP11"
878 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
879 then
880 USE_OPENMP="yes"
881 TLSGLOBALS="1"
883 if [ ! -x "$CMK_ROSE_OMP_TOOL" ]
884 then
885 Abort "The environment variable CMK_ROSE_OMP_TOOL must contain the path to a built binary of the ROSE OpenMP variable privatization tool"
889 if [ "$USE_OPENMP" = "yes" ]
890 then
891 [ -n "$VERBOSE" ] && echo OpenMP support enabled
892 OPTS_CC="$OPTS_CC $CMK_C_OPENMP"
893 OPTS_CXX="$OPTS_CXX $CMK_C_OPENMP"
894 OPTS_F90="$OPTS_F90 $CMK_F_OPENMP"
895 OPTS_LD="$OPTS_LD $CMK_LD_OPENMP"
896 OPTS_LDXX="$OPTS_LDXX $CMK_LD_OPENMP"
897 else
898 [ -n "$VERBOSE" ] && echo OpenMP support not enabled
901 if [ "$TLSGLOBALS" = "1" ]
902 then
903 OPTS_CC="$OPTS_CC -mno-tls-direct-seg-refs"
904 OPTS_CXX="$OPTS_CXX -mno-tls-direct-seg-refs"
905 OPTS_F90="$OPTS_F90 -mno-tls-direct-seg-refs"
906 OPTS_LD="$OPTS_LD -static -Wl,--allow-multiple-definition"
907 OPTS_LDXX="$OPTS_LDXX -static -Wl,--allow-multiple-definition"
910 # Look up and add the dependencies for module $1
911 findModuleDep() {
912 M=$1
913 notInList $M $PROCESSED_MODULES || return
914 PROCESSED_MODULES="$PROCESSED_MODULES $M"
915 #PRE_LIBRARIES=`AddList $PRE_LIBRARIES -lmodule$M`
916 PRE_LIBRARIES=`AddList -lmodule$M $PRE_LIBRARIES`
917 # HACK: add modules to both ends of library list, to avoid
918 # undefined symbol CkRegisterMainModule when it's in a module file.
919 POST_LIBRARIES=`AddList $POST_LIBRARIES -lmodule$M`
920 if [ "$M" = "PythonCCS" ]
921 then
922 LINK_PYTHON=1
925 dep=""
926 # fixme: should search everything in the -L library paths:
927 for dir in `echo . $CHARMLIB`
929 d="$dir/libmodule$M.dep"
930 [ -r "$d" ] && dep=$d
931 done
932 if [ -r "$dep" ]
933 then
934 # Add the module dependencies in this file
935 # Debugf "Adding module" $M "dependencies from" $dep
936 deps=`cat $dep`
937 Debugf "Module" $M "adds dependencies:" $deps
938 processArgs $deps
942 # Repeat the module-dependency search until we find no
943 # new modules:
944 START_MODULES=""
945 while [ "$START_MODULES" != "$MODULES" ]
947 Debugf "----------- Module dependency search ------------"
948 START_MODULES="$MODULES"
949 for m in $MODULES
951 findModuleDep $m
952 done
953 done
955 Debugf "----------- Module dependency search complete ------------"
959 ##############################################################################
961 # Load machine-specific configuration data, then handle overrides to it.
963 ##############################################################################
966 if [ x"$CMK_NO_BUILD_SHARED" = "xfalse" ]
967 then
968 BUILD_SHARE="1"
971 if [ "$BUILD_SHARE" = "1" ]
972 then
973 if [ x"$CMK_NO_BUILD_SHARED" = "xtrue" -o -z "$CHARMLIBSO" ]
974 then
975 BUILD_SHARE="0"
976 else
977 USE_PIC="1"
981 OPTS_PIC="$CMK_PIC"
982 if [ "$USE_PIC" = "1" ]
983 then
984 OPTS_CC="$OPTS_CC $OPTS_PIC"
985 OPTS_CXX="$OPTS_CXX $OPTS_PIC"
986 OPTS_F90="$OPTS_F90 $OPTS_PIC"
987 OPTS_LD="$OPTS_LD $OPTS_PIC"
990 if [ "$BUILD_SHARE" = "1" ]
991 then
992 # ignore BUILD_SHARE if the target is not .a or .so
993 case "$OBJECT" in
994 *.a|*.so|*.so.*|*.sl|*.dylib)
995 OPTS_LD="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
998 BUILD_SHARE="0"
1000 esac
1003 if [ -n "$OVERRIDE_CC" ]
1004 then
1005 CMK_CC="$OVERRIDE_CC"
1007 Debug "set 2"
1008 if [ -n "$OVERRIDE_CXX" ]
1009 then
1010 CMK_CXX="$OVERRIDE_CXX"
1013 if [ -n "$OVERRIDE_F90" ]
1014 then
1015 CMK_CF90="$OVERRIDE_F90"
1018 if [ -n "$OVERRIDE_LD" ]
1019 then
1020 CMK_LD="$OVERRIDE_LD"
1023 if [ -n "$OVERRIDE_LDXX" ]
1024 then
1025 CMK_LDXX="$OVERRIDE_LDXX"
1028 if [ -n "$USE_RELIABLE_CC" ]
1029 then
1030 CMK_CC="$CMK_CC_RELIABLE"
1033 if [ -n "$USE_FASTEST_CC" ]
1034 then
1035 CMK_CC="$CMK_CC_FASTEST"
1038 if [ -n "$USE_F77" ]
1039 then
1040 CMK_CF90=$CMK_CF77
1041 CMK_CF90_FIXED=$CMK_CF77
1042 CMK_F90LIBS=$CMK_F77LIBS
1045 if [ -n "$CMK_F90_MODINC" ]
1046 then
1047 CMK_CF90_MODINC="$CMK_F90_MODINC"
1048 else
1049 CMK_CF90_MODINC="-M"
1052 if [ -n "$F90_MODDIR" ]
1053 then
1054 for dir in $F90_MODDIR
1056 OPTS_F90="$OPTS_F90 $CMK_CF90_MODINC $dir"
1057 done
1060 if [ -n "$CMK_F90_USE_MODDIR" ]
1061 then
1062 CMK_CF90="$CMK_CF90 $CMK_CF90_MODINC $CHARMINC $CMK_SYSINC"
1065 if [ -n "$SEQUENTIAL" ]
1066 then
1067 CMK_CC="$CMK_SEQ_CC -DCMK_SEQUENTIAL=1 "
1068 CMK_LD="$CMK_SEQ_LD"
1069 CMK_CXX="$CMK_SEQ_CXX -DCMK_SEQUENTIAL=1 "
1070 CMK_CF90="$CMK_SEQ_F90 "
1071 CMK_LDXX="$CMK_SEQ_LDXX"
1072 CMK_AR="$CMK_SEQ_AR"
1073 CMK_RANLIB="$CMK_SEQ_RANLIB"
1076 if [ -n "$NATIVE" ]
1077 then
1078 CMK_CC="$CMK_NATIVE_CC "
1079 CMK_LD="$CMK_NATIVE_LD"
1080 CMK_CXX="$CMK_NATIVE_CXX "
1081 CMK_LDXX="$CMK_NATIVE_LDXX"
1084 if [ -n "$PREPROCESS" ]
1085 then
1086 CMK_CF90=$CMK_FPP
1089 if [ -n "$PURIFY" ]
1090 then
1091 CMK_LD="purify $CMK_LD"
1092 CMK_LDXX="purify $CMK_LDXX"
1095 Debug "set 4"
1096 if [ "$OPTIMIZE_MODE" = "true" ]
1097 then
1098 OPTS_CC="$CMK_C_OPTIMIZE $OPTS_CC"
1099 OPTS_CXX="$CMK_CXX_OPTIMIZE $OPTS_CXX"
1100 OPTS_F90="$CMK_F90_OPTIMIZE $OPTS_F90"
1101 OPTS_LD="$CMK_C_OPTIMIZE $OPTS_LD"
1102 OPTS_LDXX="$CMK_CXX_OPTIMIZE $OPTS_LDXX"
1105 # Pick up per-architecture production mode settings
1106 if [ "$PRODUCTION_MODE" = "true" ]
1107 then
1108 OPTS_CC="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_CC"
1109 OPTS_CXX="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_CXX"
1110 OPTS_F90="$CMK_PRODUCTION $CMK_F90_PRODUCTION $OPTS_F90"
1111 OPTS_LD="$CMK_PRODUCTION $CMK_C_PRODUCTION $OPTS_LD"
1112 OPTS_LDXX="$CMK_PRODUCTION $CMK_CXX_PRODUCTION $OPTS_LDXX"
1115 if [ -n "$XI_INTERNAL" ]
1116 then
1117 CMK_XIOPTS="$CMK_XIOPTS -intrinsic"
1120 if [ "$GENDEPENDS" = "yes" ]
1121 then
1122 CMK_XIOPTS="$CMK_XIOPTS -M"
1125 if [ "$COUNTTOKENS" = "yes" ]
1126 then
1127 CMK_XIOPTS="$CMK_XIOPTS -count-tokens"
1130 if test "$CMK_WITH_TAU" = "true"
1131 then
1132 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1133 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1134 TAU_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1135 TAU_MPI_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1136 TAU_MPI_FLIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1137 TAU_DEFS=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1138 TAU_INCLUDE=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1140 rm -f _make.tau.tmp
1143 #Add generic options to the compiler- and linker-options
1144 OPTS_CC="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CC"
1145 OPTS_CXX="$OPTS $TAU_DEFS $TAU_INCLUDE $OPTS_CXX"
1146 OPTS_F90="$OPTS $OPTS_F90"
1147 OPTS_LD="$OPTS $OPTS_LD"
1148 # OPTS_LDXX gets OPTS from OPTS_LD
1150 if [ -n "$F90_MAIN" ]
1151 then
1152 # for_main needs to be placed at beginning
1153 CMK_LD="$CMK_LD $CMK_F90MAINLIBS"
1154 CMK_LDXX="$CMK_LDXX $CMK_F90MAINLIBS"
1157 # There's really no analog for this in the Bourne shell:
1158 # -------- C Shell ------> onintr failure
1159 # Luckily, it's irrelevant as long as nobody sends us a ^Z.
1161 ##############################################################################
1163 # Check for valid choice of LANGUAGE
1165 ##############################################################################
1166 Debug "Checking language..."
1168 if [ -z "$LANGUAGE" ]
1169 then
1170 LANGUAGE="charm++"
1171 [ -n "$SEQUENTIAL" ] && LANGUAGE=c
1174 case "$LANGUAGE" in
1175 "c"|"C"|"c++"|"C++")
1176 [ -z "$SEQUENTIAL" -a -z "$NATIVE" ] && Abort "Language $LANGUAGE is for sequential programs"
1178 esac
1180 # update charm to bgcharm
1181 if [ "$LANGUAGE" = "charm++" -a -n "$CMK_BIGSIM" ]
1182 then
1183 LANGUAGE="bgcharm++"
1185 if [ "$LANGUAGE" = "converse++" -a -n "$CMK_BIGSIM" ]
1186 then
1187 LANGUAGE="bgconverse++"
1189 if [ "$LANGUAGE" = "bgcharm++" ]
1190 then
1191 TRACEMODE=`AddList $TRACEMODE bluegene`
1194 ########################################################################
1196 # We've parsed and verified the command-line parameters.
1197 # Now we prepare routines to clean up and exit.
1198 # None of these routines ever returns-- they all just exit.
1200 ########################################################################
1203 Copyobj() {
1204 if [ "a$COPYTO" != "a" -a "a$COPYTO" != "a$OBJECT" ]
1205 then
1206 [ -d $COPYTO ] && COPYTO="$COPYTO/"
1207 if [ "a$PROG_EXT" != "a" -a -r "$OBJECT$PROG_EXT" ] ; then
1208 Warning "Appending $PROG_EXT to object file name"
1209 OBJECT="$OBJECT$PROG_EXT"
1211 [ ! -d $COPYTO ] && DoNoErrCheck $RM $COPYTO
1212 Do $CP $OBJECT $COPYTO
1214 test -n "$COPY_EXIT" && Success
1217 Copymod() {
1218 for COPY in `echo $MODCOPIES`
1220 if [ "a$COPY" != "a$OBJECT" ]
1221 then
1222 [ -d $COPY ] && COPY="$COPY/"
1223 if [ -n "$CMK_MOD_NAME_ALLCAPS" ] ; then
1224 OBJECT=`echo $OBJECT | tr "a-z" "A-Z"`
1226 if [ -r "$OBJECT.$CMK_MOD_EXT" ] ; then
1227 Warning "Appending .$CMK_MOD_EXT to object file name"
1228 OBJECT="$OBJECT.$CMK_MOD_EXT"
1230 [ ! -d $COPY ] && DoNoErrCheck $RM $COPY
1231 Do $CP $OBJECT $COPY
1233 done
1234 Success
1237 Success() {
1238 End 0
1242 ##############################################################################
1244 # Preprocess the GEN-CPM files
1246 ##############################################################################
1248 Debug "Preprocessing GEN-CPM files"
1250 for FILE in `echo $GENCPM`
1252 # This used to be "$FILE:r", which strips the extention
1253 BASE=`stripExtention $FILE`
1254 TMP=`basename $FILE`".TMP"
1255 DELETE="$DELETE $TMP.c $TMP.i"
1256 DoNoErrCheck $RM $BASE.cpm.h $TMP.c
1257 Do touch $BASE.cpm.h
1258 Do $LN -f -s $FILE $TMP.c
1259 Do $CMK_CPP_C -I$CHARMINC $CMK_SYSINC $OPTS_CC $OPTS_CPP $TMP.c > $TMP.i
1260 Do $CHARMBIN/conv-cpm $TMP.i $BASE.cpm.h
1261 done
1263 ##############################################################################
1265 # Compile all specified files
1267 # All temporary files named *.TMP.* for easy cleanup.
1269 ##############################################################################
1271 Debug "About to compile..."
1273 numFiles=`echo $FILES | wc -w`
1274 for FILE in `echo $FILES`
1276 BASE=`stripExtention \`basename $FILE\``
1277 TMP=`basename $FILE`".TMP"
1278 FILE_EXT=`getExtention $FILE`
1279 BASEO="$BASE.o"
1280 DESTO="-o $BASEO"
1282 # in case of: charmc -o object.o -c foo.c,
1283 # avoid foo.c => remove foo.o => foo.o => object.o,
1284 # instead generate object.o directly.
1285 # remove and generate foo.o may be dangerous in parallel make
1286 # for example in the case of compiling several objs from one
1287 # same c file such as memory.c.
1288 if [ $numFiles = 1 -a -n "$OBJECT" ]
1289 then
1290 OBJ_EXT=`getExtention $OBJECT`
1291 if [ "$OBJ_EXT" = '.o' -o "$OBJ_EXT" = '.co' ]
1292 then
1293 BASEO=$OBJECT
1294 DESTO="-o $OBJECT"
1298 # if [ "$FILE_EXT" != ".o" -a "$FILE_EXT" != ".co" -a "$FILE_EXT" != ".M" -a "$FILE_EXT" != ".ci" ]
1299 # then
1300 case "$FILE_EXT" in
1301 .c|.s|.C|.cc|.cxx|.cpp|.c++|.cu|.f|.F|.f90|.F90)
1302 [ $VERBOSE ] && echo "Compiling $FILE"
1303 DoNoErrCheck $RM $BASEO $BASE.f.o
1304 esac
1305 # fi
1306 if [ ! -z "$SKIPLINK" ]
1307 then
1308 DESTO=""
1310 NU_OBJ=""
1312 if [ "$ROSE_OMP_TLS_GLOBALS" = "yes" ]
1313 then
1314 case "$FILE" in
1315 *.c)
1316 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE
1317 FILE="rose_$FILE"
1319 *.C|*.cc|*.cxx|*.cpp|*.c++)
1320 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE
1321 FILE="rose_$FILE"
1323 *.f|*.F)
1324 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE
1325 FILE="rose_$FILE"
1327 *.f90|*.F90)
1328 test -z "$PREPROCESS" && OPTS_F90="$OPTS_F90 -c"
1329 Do $CMK_ROSE_OMP_TOOL -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE
1330 FILE="rose_$FILE"
1332 esac
1335 case "$FILE" in
1336 *.ci)
1337 XIOPTS=$CMK_XIOPTS
1338 test "$LANGUAGE" = "f90charm" && XIOPTS="$XIOPTS -f90"
1339 if [ "$PREPROCESS_CI" = "yes" ]
1340 then
1341 Do $CMK_CPP_CHARM $OPTS_CPP $FILE | Do $CHARMBIN/charmxi $XIOPTS -orig-file $FILE
1342 else
1343 Do $CHARMBIN/charmxi $XIOPTS $FILE
1346 *.c|*.s)
1347 Do $CMK_CC -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CC -c $FILE $DESTO
1348 NU_OBJ=$BASEO
1349 if [ "$Do_res" -ne 0 ]
1350 then
1351 touch $BASEO
1354 bglmachine.C)
1355 Do $CMK_GCXX -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE $DESTO
1356 NU_OBJ=$BASEO
1358 *.C|*.cc|*.cxx|*.cpp|*.c++|*.cu)
1359 Do $CMK_CXX -I$CHARMINC $CMK_SYSINC $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $FILE $DESTO
1360 NU_OBJ=$BASEO
1361 if [ "$Do_res" -ne 0 ]
1362 then
1363 touch $BASEO
1366 *.f|*.F)
1367 test -z "$CMK_CF90_FIXED" && Abort "No F90 compiler (CMK_CF90_FIXED) defined"
1368 Do $CMK_CF90_FIXED -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 -c $FILE $DESTO
1369 NU_OBJ=$BASEO
1370 if [ "$Do_res" -ne 0 ]
1371 then
1372 touch $BASEO
1375 *.f90|*.F90)
1376 test -z "$CMK_CF90" && Abort "No F90 compiler (CMK_CF90) defined"
1377 test -z "$PREPROCESS" && OPTS_F90="$OPTS_F90 -c"
1378 Do $CMK_CF90 -I$CHARMINC $CMK_SYSINC $OPTS_CPP $OPTS_F90 $FILE $DESTO
1379 NU_OBJ=$BASEO
1380 if [ "$Do_res" -ne 0 ]
1381 then
1382 touch $BASEO
1385 *.fc|*.FC)
1386 Abort "I'm not yet smart enough to compile $FILE"
1388 *.o|*.so|*.so.*|*.sl|*.a|*.dylib|*.co)
1389 [ ! -s $FILE ] && Abort "$FILE: file not recognized: File truncated"
1390 OBJECTFILES="$OBJECTFILES $FILE"
1392 *.M|*.mod)
1393 OBJECT="$BASE"
1394 Copymod
1395 Success
1398 Abort "file with unrecognized extension $FILE"
1399 esac
1400 # Handle new object files
1401 if [ -n "$NU_OBJ" -a -n "$OBJECT" ]
1402 then
1403 if [ "$OBJECT" != "$BASEO" ]
1404 then
1405 DELETE="$DELETE $NU_OBJ"
1407 OBJECTFILES="$OBJECTFILES $NU_OBJ"
1409 done
1411 ##############################################################################
1413 # POSSIBLY, SKIP LINK-STEP
1415 # 1. No $OBJECT may be specified at all --- its just a compilation.
1416 # 2. If $OBJECT is a ".a" file, a library is created from $OBJECTFILES.
1417 # 3. If $OBJECT is a ".o" file, then an "LDRO" is created from $OBJECTFILES.
1418 # 4. Language may be sequential. Do a quick and easy linkage.
1420 # in any of these cases, the full link step is skipped.
1422 ##############################################################################
1424 MakeSO() {
1425 Debugf "Running ldro..."
1426 DoNoErrCheck $RM $OBJECT
1427 # convert to absolute path if required
1428 if test -n "$CMK_LD_SHARED_ABSOLUTE_PATH"
1429 then
1430 dir=`dirname $OBJECT`
1431 fname=`basename $OBJECT`
1432 dir=`cd $dir; pwd`
1433 OBJECT=$dir/$fname
1435 Warning "Warning: creating $OBJECT "
1436 if test "$MAKE_LDXX" = "1"
1437 then
1438 soCmd="$CMK_LDXX -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1439 else
1440 soCmd="$CMK_LD -o $OBJECT $OPTS_LD $OPTS_LDRO $OBJECTFILES $PRE_LIBRARIES $POST_LIBRARIES $CMK_LD_SHARED_LIBS"
1442 DoNoErrCheck $soCmd
1443 Do_res=$?
1444 if [ $Do_res -ne 0 ]
1445 then
1446 if [ -n $NOABORT ]
1447 then
1448 touch $OBJECT
1449 else
1450 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1451 echo "!! Failed to compile Charm++ shared library. You can disable shared !!"
1452 echo "!! lib compilation by providing --no-build-shared build option like: !!"
1453 echo "!! ./build charm++ net-linux --no-build-shared -O !!"
1454 echo "!! or reexecute this charmc command with --no-build-shared compile option !!"
1455 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
1456 Abort "Command $soCmd returned error code $Do_res"
1459 Copyobj
1462 if [ -z "$OBJECT" -o ! -z "$SKIPLINK" ]
1463 then
1464 # We have no target object, or are playing preprocessor tricks-- just end
1465 Debugf "No target object-- finished"
1466 Success
1469 Debug "About to link..."
1471 # if interoperate dont create the library now, wait to collect all info
1472 if [ "$MPI_INTEROPERATE" = "" ]
1473 then
1474 case "$OBJECT" in
1475 *.o)
1476 Debugf "Converting $FILES to $OBJECTFILES"
1477 nFiles=`echo $FILES | wc -w`
1478 nObj=`echo $OBJECTFILES | wc -w`
1479 # One source file, one .o: just move the .o
1480 if [ $OBJECT != $OBJECTFILES ]
1481 then
1482 Debugf "Moving .o to destination"
1483 DoNoErrCheck $RM $OBJECT
1484 Do $MV $OBJECTFILES $OBJECT
1486 Copyobj
1488 *.so|*.so.*|*.sl|*.dylib)
1489 # Make shared library
1490 # if no build share is set, exit normally.
1491 if [ "$BUILD_SHARE" = 0 ]
1492 then
1493 echo "Warning: building shared library is skipped, possibly due to not supported, check configuration files."
1494 End 0
1495 elif [ "$CHARM_SHARED" = "0" ]
1496 then
1497 MakeSO
1500 *.a)
1501 # Make regular (.a, non-shared) library
1502 # in case building charm so, build .so under lib_so as well # Gengbin
1503 if [ "$BUILD_SHARE" = "1" ]
1504 then
1505 COPY_EXIT=""
1506 OBJECT_SAVE=$OBJECT
1507 COPYTO_SAVE=$COPYTO
1508 if [ -z "$COPYTO" ]
1509 then
1510 DESTDIR=`echo $OBJECT | sed -e 's@lib/[^/]*\.a$@lib_so@'`
1511 OBJECT=`echo $OBJECT | sed -e 's@lib/\([^/]*\)\.a$@lib_so/\1.a@'`
1512 else
1513 COPYTO=`echo $COPYTO | sed -e 's@lib[/]*$@lib_so@'`
1514 DESTDIR=$COPYTO
1516 OBJECT=`echo $OBJECT | sed -e 's/\.a$/.'"$CMK_SHARED_SUF"'/'`
1517 [ -f $DESTDIR/.charmso ] && MakeSO
1518 COPYTO=$COPYTO_SAVE
1519 OBJECT=$OBJECT_SAVE
1520 COPY_EXIT="true"
1522 # build normal .a
1523 DoNoErrCheck $RM $OBJECT
1524 Do $CMK_AR $OBJECT $OBJECTFILES
1525 Do $CMK_RANLIB $OBJECT
1526 Copyobj
1528 esac
1530 # If the above case returns, we're not creating a .o or .a file,
1531 # so linking is needed.
1533 ############ Determine the language and libraries ##########
1535 # Parse out the real languages
1536 case "$LANGUAGE" in
1537 "charm++f")
1538 LANGUAGE="charm++"
1539 USE_F90_LIBRARIES="1"
1541 "f90charm")
1542 PRE_LIBRARIES="$PRE_LIBRARIES -lf90charm -lckf"
1543 POST_LIBRARIES="$POST_LIBRARIES $CMK_F90LIBS"
1545 "bluegene"|"bigsim")
1546 PRE_LIBRARIES="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs"
1548 "ckbluegene")
1549 POST_LIBRARIES="$POST_LIBRARIES -lbluegene"
1551 "bgcharm++")
1552 PRE_LIBRARIES="$PRE_LIBRARIES -lconv-bigsim -lconv-bigsim-logs -lconv-bluegene-stub"
1554 "bgconverse++")
1555 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-bigsim -lconv-bigsim-logs"
1557 esac
1559 # DMK - ACCEL SUPPORT - If this is a cell build, add the spe code object to POST_LIBRARIES
1560 if [ $CMK_CELL -eq 1 ]
1561 then
1563 if [ "$LANGUAGE" = "converse++" ]
1564 then
1565 # Include a "do nothing" register_accel_spe_funcs() function
1566 POST_LIBRARIES="$POST_LIBRARIES -lnoAccelStub"
1569 if [ "$LANGUAGE" = "charm++" ]
1570 then
1572 if [ $SPU_USE_CPP -eq 1 ]
1573 then
1574 SPU_COMPILER=$CMK_SPU_CXX
1575 SPU_LINKER=$CMK_SPU_LDXX
1576 else
1577 SPU_COMPILER=$CMK_SPU_CC
1578 SPU_LINKER=$CMK_SPU_LD
1581 # Make the spe object file to be included
1582 Do $SPU_COMPILER -c -I$CHARMINC $CMK_SYSINC -o main__funcLookup__.genSPECode.o main__funcLookup__.genSPECode.c -DCMK_CELL_SPE=1
1583 Do $SPU_LINKER -L$CHARMLIB -o main__funcLookup__.genSPECode main__funcLookup__.genSPECode.o $CMK_SPERT_LIBS $SPU_EXTRA_LIBS
1584 Do $CMK_PPU_EMBEDSPU spert_main main__funcLookup__.genSPECode main__funcLookup__.genSPECode.ppe.o
1586 # Include the spe object file for linking into main executable
1587 POST_LIBRARIES="$POST_LIBRARIES main__funcLookup__.genSPECode.ppe.o"
1592 if [ "$AMPIMAIN" != "" ]
1593 then
1594 OBJECTFILES="$CHARMLIB/lib$AMPIMAIN.o $OBJECTFILES"
1597 if [ "$SWAPGLOBALS" = "1" ]
1598 then
1599 swapo="$CHARMLIB/libglobal-swap.a"
1600 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1601 then
1602 echo "Global-swapping library $swapo missing--"
1603 echo " Is -swapglobals supported on this machine?"
1604 exit 1
1605 else
1606 MIDDLE_LIBS="-lglobal-swap $MIDDLE_LIBS"
1609 if [ "$SWAPGLOBALS" = "2" ]
1610 then
1611 swapo="$CHARMLIB/libglobal-copy.a"
1612 if [ ! -r "$swapo" -o ! -s "$swapo" ]
1613 then
1614 echo "Global-copying library $swapo missing--"
1615 echo " Is -copyglobals supported on this machine?"
1616 exit 1
1617 else
1618 MIDDLE_LIBS="-lglobal-copy $MIDDLE_LIBS"
1622 if [ $USE_F77_LIBRARIES = "1" ]
1623 then
1624 POST_LIBRARIES="$POST_LIBRARIES $CMK_F77LIBS"
1627 if [ $USE_F90_LIBRARIES = "1" ]
1628 then
1629 if [ ! -r $CHARMLIB/libconv-utilf.a ]
1630 then
1631 echo "Fortran support library $CHARMLIB/libconv-utilf.a missing"
1632 echo "Is your Fortran compiler working?"
1633 exit 1
1636 POST_LIBRARIES="$POST_LIBRARIES -lconv-utilf $CMK_F90LIBS"
1639 # dummy main module
1640 if [ "$MPI_INTEROPERATE" != "" -a "$NO_MAIN_MODULE" = "" ]
1641 then
1642 POST_LIBRARIES="-lmpi-mainmodule $POST_LIBRARIES"
1645 # check if we're linking a sequential object
1646 case "$LANGUAGE" in
1647 "c"|"C"|"f90"|"f77")
1648 if [ -n "$NATIVE" ]
1649 then
1650 Do $CMK_NATIVE_LD $OPTS_LD -o $OBJECT $OBJECTFILES \
1651 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
1652 else
1653 Do $CMK_SEQ_LD $OPTS_LD -o $OBJECT $OBJECTFILES \
1654 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
1656 Copyobj
1658 "c++"|"C++")
1659 if [ -n "$NATIVE" ]
1660 then
1661 Do $CMK_NATIVE_LDXX $OPTS_LD -o $OBJECT $OBJECTFILES \
1662 -L$CHARMLIB $PRE_LIBRARIES $CMK_NATIVE_LIBS $POST_LIBRARIES
1663 else
1664 Do $CMK_SEQ_LDXX $OPTS_LD -o $OBJECT $OBJECTFILES \
1665 -L$CHARMLIB $PRE_LIBRARIES $CMK_SEQ_LIBS $POST_LIBRARIES
1667 Copyobj
1669 esac
1671 ##############################################################################
1673 # Some quick consistency checks prior to full link-step
1675 # Check for valid choice of TRACEMODE
1676 # Check for valid choice of BALANCE
1677 # Check for compatibility among BALANCE and TRACEMODE
1679 ##############################################################################
1681 Debug "About to check TRACEMODE=$TRACEMODE and BALANCE=$BALANCE..."
1683 # Check for valid choice of TRACEMODE
1685 # [ -r $CHARMLIB/libtrace-projections.a ] || Abort "trace libraries not installed. Is Charm++ built properly?"
1687 if [ x"$TRACEMODE" != x ]
1688 then
1689 for trace in $TRACEMODE; do
1690 [ ! -r "$CHARMLIB/libtrace-$trace.a" ] && Abort "charmc : No such tracemode $trace"
1691 TRACE_OBJ="$TRACE_OBJ -ltrace-$trace"
1692 done
1693 TRACE_OBJ="$TRACE_OBJ $CMK_LIBZ"
1696 if test x$LANGUAGE = x"bgcharm++"
1697 then
1698 BALANCE=bluegene
1701 BAL_EXT=`getExtention $BALANCE`
1702 if [ -z "$BAL_EXT" ]; then
1703 # Balance has no extension-- is a library reference
1704 if [ -f "${CHARMLIB}/libldb-$BALANCE.a" ]; then
1705 BAL_OBJ="${CHARMLIB}/libldb-$BALANCE.a"
1706 else
1707 BAL_OBJ="${CHARMLIBSO}/libldb-$BALANCE.so"
1709 else
1710 # Balance has some extension-- must be a .o or .a file
1711 BAL_OBJ="$BALANCE"
1714 Debug "Finished with BAL_OBJ=$BAL_OBJ, TRACEMODE=$TRACEMODE..."
1716 if [ ! -r "$BAL_OBJ" ]
1717 then
1718 if [ "$BALANCE" = "$BAL_OBJ" ]
1719 then
1720 Abort "Could not find load balancer object $BAL_OBJ"
1721 else
1722 (cd $CHARMLIB ; ls -al libldb-*)
1723 Abort "Unknown load balancer $BALANCE / $BAL_OBJ"
1727 BAL_OBJ="-lldb-$BALANCE -lconv-ldb"
1729 # Check for valid choice of MEMORY
1731 if [ -f "${CHARMLIB}/libmemory-${MEMORY}.a" ]; then
1732 MEM_OBJ="${CHARMLIB}/libmemory-${MEMORY}.a"
1733 else
1734 MEM_OBJ="${CHARMLIBSO}/libmemory-${MEMORY}.so"
1737 if [ ! -r $MEM_OBJ -o ! -s $MEM_OBJ ]
1738 then
1739 (cd $CHARMLIB ; list=`ls libmemory-* 2>/dev/null`; test -n "$list" && for i in $list; do [ -s $i ] && ls -l $i; done )
1740 Abort "charmc : No such memory mode $MEMORY"
1743 MEM_OBJ="-lmemory-${MEMORY}"
1745 # For memory wrapping around the OS allocator, need to add also the wrapper object
1746 case $MEMORY in
1747 os-*)
1748 MEM_OBJ=$MEM_OBJ" -lmemory-os-wrapper"
1750 esac
1752 # Check for valid choice of THREAD
1754 if [ "$CHARM_SHARED" = "1" -a -n "$CMK_LD_SHARED_THREAD" -a "$THREAD" = "default" ]
1755 then
1756 THREAD=$CMK_LD_SHARED_THREAD
1758 if [ "$TLSGLOBALS" = "1" ]
1759 then
1760 # make sure we don't add an extra -tls
1761 if ! echo $THREAD | grep '\-tls$' > /dev/null 2> /dev/null
1762 then
1763 THREAD=${THREAD}-tls
1767 if [ -f "${CHARMLIB}/libthreads-${THREAD}.a" ]; then
1768 THREAD_OBJ="${CHARMLIB}/libthreads-${THREAD}.a"
1769 else
1770 THREAD_OBJ="${CHARMLIBSO}/libthreads-${THREAD}.so"
1773 if [ ! -r $THREAD_OBJ -o ! -s $THREAD_OBJ ]
1774 then
1775 (cd $CHARMLIB ; list=`ls libthreads-* 2>/dev/null`; test -n "$list" && for i in $list; do [ -s $i ] && ls -l $i; done )
1776 Abort "charmc : No such thread mode $THREAD"
1779 THREAD_OBJ="-lthreads-${THREAD}"
1781 ################# Build the module initialization function ##################
1782 modInitName="moduleinit$$"
1783 modInitSrc="$modInitName.C"
1784 modInitObj="$modInitName.o"
1785 DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
1787 for module in $MODULES; do
1788 echo "extern void _register$module(void);" >> $modInitSrc
1789 done
1790 for trace in $TRACEMODE; do
1791 if test $trace = "summary"
1792 then
1793 echo " extern void _registerTraceSummary();" >> $modInitSrc
1794 elif test $trace = "projections"
1795 then
1796 echo " extern void _registerTraceProjections();" >> $modInitSrc
1797 elif test $trace = "simple"
1798 then
1799 echo " extern void _registerTraceSimple();" >> $modInitSrc
1800 elif test $trace = "Tau"
1801 then
1802 echo " extern void _registerTraceTau();" >> $modInitSrc
1803 elif test $trace = "utilization"
1804 then
1805 echo " extern void _registerTraceUtilization();" >> $modInitSrc
1806 elif test $trace = "controlPoints"
1807 then
1808 echo " extern void _registerTraceControlPoints();" >> $modInitSrc
1809 elif test $trace = "all"
1810 then
1811 echo " extern void _registerTraceProjections();" >> $modInitSrc
1812 echo " extern void _registerTraceSummary();" >> $modInitSrc
1814 done
1815 if test -n "$BALANCER"
1816 then
1817 echo "extern void LBDefaultCreate(const char *);" >> $modInitSrc
1819 echo "void _registerExternalModules(char **argv) {" >> $modInitSrc
1820 for module in $MODULES; do
1821 [ -n "$VERBOSE" ] && echo "Adding registration for module $module"
1822 echo " _register$module();" >> $modInitSrc
1823 done
1824 for trace in $TRACEMODE; do
1825 if test $trace = "summary"
1826 then
1827 echo " _registerTraceSummary();" >> $modInitSrc
1828 elif test $trace = "projections"
1829 then
1830 echo " _registerTraceProjections();" >> $modInitSrc
1831 elif test $trace = "Tau"
1832 then
1833 TRACE_WITH_TAU=1
1834 echo " _registerTraceTau();" >> $modInitSrc
1835 elif test $trace = "simple"
1836 then
1837 echo " _registerTraceSimple();" >> $modInitSrc
1838 elif test $trace = "utilization"
1839 then
1840 echo " _registerTraceUtilization();" >> $modInitSrc
1841 elif test $trace = "controlPoints"
1842 then
1843 echo " _registerTraceControlPoints();" >> $modInitSrc
1844 elif test $trace = "all"
1845 then
1846 echo " _registerTraceProjections();" >> $modInitSrc
1847 echo " _registerTraceSummary();" >> $modInitSrc
1849 done
1850 if test -n "$BALANCER"
1851 then
1852 [ -n "$VERBOSE" ] && echo "Adding load balancer for $BALANCER"
1853 for deflb in $BALANCER
1855 echo " LBDefaultCreate(\"$deflb\");" >> $modInitSrc
1856 done
1858 echo "}" >> $modInitSrc
1860 # creating projections
1861 echo "void _createTraces(char **argv) {" >> $modInitSrc
1862 for trace in $TRACEMODE; do
1863 [ -n "$VERBOSE" ] && echo "Adding registration for trace $trace"
1864 echo "extern void _createTrace$trace(char **argv);" >> $modInitSrc
1865 echo "_createTrace$trace(argv);" >> $modInitSrc
1866 done
1867 echo "}" >> $modInitSrc
1869 Do $CMK_CXX $OPTS_CPP_INTERNAL $OPTS_CPP $OPTS_CXX -c $modInitSrc -o $modInitObj
1871 ###############################################################################
1873 # Finally, LINK
1875 ###############################################################################
1877 Debug "About to perform final link..."
1879 MAKE_LDXX="0"
1880 MAKE_LD="0"
1882 CORE_LIBS="-lconv-core -lconv-util -lconv-partition $TRACE_OBJ "
1884 # get TAU stub makefile variables
1885 if test "$CMK_WITH_TAU" = "true"
1886 then
1887 echo "include $TAU_MAKEFILE" > _make.tau.tmp
1888 echo "print-%:; @echo \$(\$*)" >> _make.tau.tmp
1889 TAU_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_LIBS`
1890 TAU_MPI_LIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_LIBS`
1891 TAU_MPI_FLIBS=`make --no-print-directory -f _make.tau.tmp print-TAU_MPI_FLIBS`
1892 TAU_DEFS=`make --no-print-directory -f _make.tau.tmp print-TAU_DEFS`
1893 TAU_INCLUDE=`make --no-print-directory -f _make.tau.tmp print-TAU_INCLUDE`
1895 rm -f _make.tau.tmp
1897 # done getting TAU variables
1899 if [ "$BUILD_SHARE" = "0" ]
1900 then
1901 MIDDLE_LIBS="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1904 case "$LANGUAGE" in
1905 "f90charm")
1906 MAKE_LDXX="1"
1907 MIDDLE_LIBS="-lck $MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS "
1908 CMK_SYSLIBS="$CMK_SYSLIBS -lm"
1909 if [ "$NO_MAIN" = "" ]
1910 then
1911 MIDDLE_LIBS="-lckmain $MIDDLE_LIBS"
1913 if [ "$TAU_TRACE_MPI" = "1" ]
1914 then
1915 TAU_LIBS="$TAU_MPI_FLIBS $TAU_LIBS"
1916 else
1917 TAU_LIBS="$TAU_LIBS"
1920 "charm"|"charm++"|"f90charm"|"ckbluegene"|"bgcharm++")
1921 MAKE_LDXX="1"
1922 MIDDLE_LIBS="-lck $MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS "
1923 if [ "$NO_MAIN" = "" ]
1924 then
1925 MIDDLE_LIBS="-lckmain $MIDDLE_LIBS"
1927 CMK_SYSLIBS="$CMK_SYSLIBS -lm"
1928 if [ "$TAU_TRACE_MPI" = "1" ]
1929 then
1930 TAU_LIBS="$TAU_MPI_LIBS $TAU_LIBS"
1931 else
1932 TAU_LIBS="$TAU_LIBS"
1935 "converse")
1936 MAKE_LD="1"
1937 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-cplus-n $CORE_LIBS -ltrace-converse "
1938 CMK_SYSLIBS="$CMK_SYSLIBS -lm"
1940 "converse++"|"bluegene"|"bigsim"|"bgconverse++")
1941 MAKE_LDXX="1"
1942 MIDDLE_LIBS="$MIDDLE_LIBS -lconv-cplus-y $CORE_LIBS -ltrace-converse "
1943 CMK_SYSLIBS="$CMK_SYSLIBS -lm"
1946 Abort "Unrecognized choice of language $LANGUAGE"
1948 esac
1950 if [ "$BUILD_SHARE" = "0" ]
1951 then
1952 MIDDLE_LIBS="$MIDDLE_LIBS $MEM_OBJ $THREAD_OBJ"
1955 if [ "$CHARM_SHARED" = "1" ]
1956 then
1957 [ -z "$CHARMLIBSO" ] && Abort "Charm++ lib_so directory not found!"
1958 # build user executable/shared lib linking with charm .so
1959 OPTS_LD="$OPTS_LD $CMK_LD_LIBRARY_PATH"
1960 if [ "$BUILD_SHARE" = "1" ]
1961 then
1962 LANG_LIBS="-L$CHARMLIBSO $OBJECTFILES $PRE_LIBRARIES"
1963 else
1964 LANG_LIBS="-L$CHARMLIBSO $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1966 else
1967 # if interoperate, need a lib with moduleinit
1968 if [ "$MPI_INTEROPERATE" != "" ]
1969 then
1970 LANG_LIBS="-L$CHARMLIB -I$CHARMINC $CMK_SYSINC $PRE_LIBRARIES"
1971 else
1972 LANG_LIBS="-L$CHARMLIB -I$CHARMINC $CMK_SYSINC $OBJECTFILES $modInitObj $PRE_LIBRARIES"
1975 if [ "$TRACE_WITH_TAU" = 1 ]
1976 then
1977 echo "Linking with the TAU libraries: $TAU_LIBS"
1978 ALL_LIBS="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS $TAU_LIBS"
1979 else
1980 ALL_LIBS="$LANG_LIBS $MIDDLE_LIBS $BAL_OBJ $CMK_LIBS $POST_LIBRARIES $CMK_SYSLIBS"
1982 Debugf "All libraries are: $ALL_LIBS"
1984 #currently only support creation of .a
1985 if [ "$MPI_INTEROPERATE" != "" ]
1986 then
1987 case "$OBJECT" in
1988 *.a)
1989 # in case building charm so, build .so under lib_so as well # Gengbin
1990 DoNoErrCheck $RM $OBJECT
1991 echo "$CMK_AR $OBJECT $OBJECTFILES $modInitObj"
1992 Do $CMK_AR $OBJECT $OBJECTFILES $modInitObj
1993 Do $CMK_RANLIB $OBJECT
1994 echo "export CHARM_ALL_LIBS=\"$ALL_LIBS\"" > ./charm_all_libs.sh
1995 echo "CHARM_ALL_LIBS=\"$ALL_LIBS\""
1996 Copyobj
1998 *.so|*.so.*|*.sl|*.dylib)
1999 echo "Warning: building shared library failed; for interoperation build
2000 static library."
2001 End 0
2003 esac
2006 if [ "$MPI_INTEROPERATE" != "" ]
2007 then
2008 ALL_LIBS="$OBJECTFILES $modInitObj $ALL_LIBS"
2011 if [ "$BUILD_SHARE" = "1" -a "$CHARM_SHARED" = "1" ]
2012 then
2013 # build an application .so linking with charm .so
2014 OPTS_LD="$OPTS_LD $CMK_LD_SHARED $OPTS_LDRO -L$CHARMLIBSO"
2015 Debugf "Running ldro..."
2016 DoNoErrCheck $RM $OBJECT
2017 [ "$MAKE_LDXX" = "1" ] && Do $CMK_LDXX $OPTS_LD $OPTS_LDXX -o $OBJECT $ALL_LIBS
2018 [ "$MAKE_LD" = "1" ] && Do $CMK_LD $OPTS_LD -o $OBJECT $ALL_LIBS
2019 Copyobj
2020 else
2021 # Make a regular executable: call the appropriate linker
2022 [ "$MAKE_LDXX" = "1" ] && Do $CMK_LDXX $OPTS_LD $OPTS_LDXX -o $OBJECT $ALL_LIBS
2023 [ "$MAKE_LD" = "1" ] && Do $CMK_LD $OPTS_LD -o $OBJECT $ALL_LIBS
2026 ########################################################################
2028 # Copy conv-host to user directory if it is present in installation.
2030 ########################################################################
2032 if test "$COPY_CHARMRUN" = "true"
2033 then
2034 targ=charmrun$CMK_POST_EXE
2035 [ ! -x $CHARMBIN/$targ -a -n "$CMK_POST_EXE" ] && targ=charmrun
2036 convhost=conv-host$CMK_POST_EXE
2038 if [ -x $CHARMBIN/$targ ]
2039 then
2040 DoNoErrCheck $RM $targ
2041 Do $CP $CHARMBIN/$targ $targ
2045 [ -z "$SAVE" ] && DoNoErrCheck $RM $modInitSrc $modInitObj > /dev/null 2>&1
2047 Copyobj