*** empty log message ***
[charm.git] / build
blob40b703534944c4883773034f1cbe68cc14e4bd5d
1 #!/bin/sh
3 # Silly shorthand, used for source reorganization
4 src="src/arch"
6 more=0
8 syntax() {
9 echo ''
10 echo 'Usage: build <target> <version> <options> [charmc-options ...]'
11 echo ''
12 echo '<targets>: converse charm++ LIBS AMPI FEM bigemulator pose jade msa'
13 echo '<targets>: doc ps-doc pdf-doc html-doc'
14 if test $more = 1
15 then
16 echo ''
17 echo ' charm++ compile Charm++ core only'
18 echo ' AMPI compile Adaptive MPI on top of Charm++'
19 echo ' FEM compile FEM framework'
20 echo ' LIBS compile additional parallel libraries with Charm++ core'
21 echo ' bigemulator build additional BigSim libraries'
22 echo ' pose build POSE parallel discrete event simulator'
23 echo ' jade build Jade compiler (auto-builds charm++, msa)'
24 echo ' msa build Multiphase Shared Arrays(MSA) library'
25 echo ''
27 echo '<versions>: '
28 ( cd $src ; ls -1 | egrep -v '(^CVS)|(^shmem$)|(^mpi$)|(^sim$)|(^net$)|(^elan$)|(^util$)|(^common$)|(^uth$)|(^conv-mach-fix.sh$)|(^win32$)|(^win64$)|(^paragon$)|(^vmi$)|(^lapi$)|(^cell$)|(^template$)' | pr -3 -t )
29 echo ''
30 echo '<options>: compiler and platform specific options'
31 echo 'cc cc64 cxx kcc pgcc acc icc ecc gcc3 gcc4 mpcc pathscale'
32 echo 'help smp gm tcp vmi scyld clustermatic bigemulator ooc syncft papi'
33 echo 'pthreads lam'
34 echo '--incdir --libdir --basedir --no-build-shared -j'
35 if test $more = 1
36 then
37 echo ''
38 echo 'For platform specific options, use help option:'
39 echo ' help platform specific help, e.g. ./build charm++ net-linux help'
40 echo ''
41 echo 'Choose a compiler (only one option is allowed from this section):'
42 echo ' cc, cc64 For Sun WorkShop C++ 32/64 bit compilers'
43 echo ' cxx DIGITAL C++ compiler (DEC Alpha)'
44 echo ' kcc KAI C++ compiler'
45 echo " pgcc Portland Group's C++ compiler"
46 echo ' acc HP aCC compiler'
47 echo ' icc Intel C/C++ compiler for Linux IA32'
48 echo ' ecc Intel C/C++ compiler for Linux IA64'
49 echo ' gcc3 use gcc3 - GNU GCC/G++ version 3'
50 echo ' gcc4 use gcc4 - GNU GCC/G++ version 4 (only mpi-crayxt3)'
51 echo ' mpcc SUN Solaris C++ compiler for MPI'
52 echo ' pathscale use pathscale compiler suite'
53 echo ''
54 echo 'Choose a fortran compile (only one option is allowed from this section):'
55 echo ' g95 G95 at http://ww.g95.org'
56 echo ' absoft Absoft fortran compiler'
57 echo " pgf90 Portland Group\'s Fortran compiler"
58 echo ' ifc Intel Fortran compiler (older versions)'
59 echo ' ifort Intel Fortran compiler (newer versions)'
60 echo ''
61 echo 'Platform specific options (choose multiple if apply):'
62 echo ' lam Use LAM MPI'
63 echo ' smp support for SMP, multithreaded charm on each node'
64 echo ' mpt use SGI Message Passing Toolkit (only for mpi version)'
65 echo ' gm use Myrinet for communication'
66 echo ' tcp use TCP sockets for communication (ony for net version)'
67 echo " vmi use NCSA's VMI for communication (only for mpi version)"
68 echo ' scyld compile for Scyld Beowulf cluster based on bproc'
69 echo ' clustermatic compile for Clustermatic (support version 3 and 4) '
70 echo ' pthreads compile with pthreads Converse threads'
71 echo ''
72 echo 'Advanced options:'
73 echo ' bigemulator compile for BigSim simulator'
74 echo ' ooc compile with out of core support'
75 echo ' syncft compile with Charm++ fault tolerance support'
76 echo ' papi compile with PAPI performance counter support (if any)'
77 echo ''
78 echo "Charm++ dynamic libraries:"
79 echo " --build-shared build Charm++ dynamic libraries (.so) (default)"
80 echo " --no-build-shared don't build Charm++'s shared libraries"
81 echo ''
82 echo 'Miscellaneous options:'
83 echo ' --incdir=DIR specify additional include path for compiler'
84 echo ' --libdir=DIR specify additional lib path for compiler'
85 echo ' --basedir=DIR shortcut for the above two - DIR/include and DIR/lib'
86 echo ' -j[N] parallel make, N is the number of paralle make jobs'
87 echo " --with-romio build AMPI with ROMIO library"
89 echo ''
90 echo '<charmc-options>: normal compiler options e.g. -g -O -save -verbose'
91 if test $more = 1
92 then
93 echo ''
94 echo 'Examples:'
95 echo "1. display all supported options for net-linux using 'help':"
96 echo ' ./build charm++ net-linux help'
97 echo '2. compile Charm++ on Linux with optimizations:'
98 echo ' ./build charm++ net-linux -O -DCMK_OPTIMIZE'
99 echo '3. compile Charm++ for Linux clustermatic Beowulf cluster with Intel compiler:'
100 echo ' ./build charm++ net-linux clustermatic icc -O'
101 echo '4. compile Charm++ for IA64 Linux cluster with MPICH-GM:'
102 echo ' ./build charm++ mpi-linux-ia64 gm -O'
103 echo '5. compile Charm++ for Windows with VC++ (Cygwin required):'
104 echo ' ./build charm++ net-win32 -O'
105 echo '6. compile on IBM SP with MPI using parallel gmake, 4 jobs simultaneously:'
106 echo ' MAKE=gmake ./build charm++ mpi-sp -j4 -O # sh'
107 echo ' setenv MAKE gmake; ./build charm++ mpi-sp -j4 -O # csh'
108 echo '7. compile Charm++ with MPI that is installed at /usr/local/mpich:'
109 echo ' ./build charm++ mpi-linux --incdir /usr/local/mpich/include --libdir /usr/local/mpich/lib -O'
110 echo ' or in short,'
111 echo ' ./build charm++ mpi-linux --basedir /usr/local/mpich -O'
112 echo ''
113 echo 'Note: This script:'
114 echo ' 1. Creates directories <version> and <version>/tmp';
115 echo ' 2. Copies src/scripts/Makefile into <version>/tmp';
116 echo ' 3. Does a "make <target> <version> OPTS=<charmc-options>" in <version>/tmp.'
117 echo "That's all build does. The rest is handled by the Makefile."
118 echo ''
119 echo 'You should register your copy of Charm++ with us by sending email'
120 echo 'to tms@charm.cs.uiuc.edu containing the message "subscribe charm-users"'
121 echo 'This will allow us to notify you of new releases of Charm++.'
122 echo ''
123 echo 'Thank you for using Charm++, please send questions or comments to '
124 echo 'Parallel Programming Lab at University of Illinois at Urbana-Champaign'
125 echo '(email: ppl@cs.uiuc.edu).'
127 else
128 echo ''
129 echo "To get more detailed help, run ./build --help"
133 printOption() {
134 for prefix in cc conv-mach
136 str="Supported compilers:"
137 [ "$prefix" = "conv-mach" ] && str="Supported options:"
138 opts=""
139 for dir in $OPT_DIRS
141 # echo "Checking for $prefix in $dir"
142 files=`cd $dir; ls $prefix-*.h 2>/dev/null`
143 opts="$opts "`echo $files | sed 's/'$prefix'-\([^.]*\).h/\1/g'`
144 done
145 tmp=.tmp.$$
146 rm -f $tmp; touch $tmp
147 for o in $opts
149 echo $o >> $tmp
150 done
151 opts=`sort $tmp | uniq`
152 rm -f $tmp
153 echo $str $opts
154 done
155 exit 1
158 CheckDir() {
159 for d in $*
161 if test ! -d $d
162 then
163 echo Error: cannot find $d!
164 exit 1
166 done
169 TestIfCompiler() {
170 for dir in $OPT_DIRS
172 [ -f $dir/cc-$1.sh ] && return 1
173 done
174 return 0
177 TestIfOption() {
178 for dir in $OPT_DIRS
180 [ -f $dir/conv-mach-$1.h ] && return 1
181 done
183 echo "Error> option: $1 is not supported in this version!";
184 printOption
188 # start
190 MAKEOPTS=""
191 OPTS=""
192 BOPTS=""
193 MORE=""
194 COMPILER=""
195 BASEDIR=
196 LIBDIR=
197 INCDIR=
198 ARCH=
199 BUILD_SHARED=
200 WITH_ROMIO=
201 BUILD_EMULATOR=0
203 [ "$1" = '--help' -o "$1" = '-h' ] && more=1 && syntax | more && exit 1
204 [ $# -lt 2 ] && syntax && exit 1
205 PROGRAM=$1
206 shift
207 VERSION=$1; BASEVERSION=$1; ARCH=`echo $1 | sed -e 's@-.*@@'`
208 shift
210 echo $src
211 echo $BASEVERSION
212 echo $ARCH
214 OPT_DIRS="$src/$BASEVERSION $src/$ARCH $src/common"
216 while [ ! $# -eq 0 ]
218 case "$1" in
219 "--basedir")
220 shift;
221 for dir in $1
223 CheckDir $dir/include $dir/lib
224 LIBDIR="$LIBDIR -L$dir/lib";
225 INCDIR="$INCDIR -I$dir/include"
226 done
227 shift
229 --basedir=*)
230 basedir=`echo $1 | awk -F= '{print $2}'`
231 for dir in $basedir
233 CheckDir $dir/include $dir/lib
234 LIBDIR="$LIBDIR -L$dir/lib";
235 INCDIR="$INCDIR -I$dir/include"
236 done
237 shift
239 "--libdir")
240 shift; CheckDir $1
241 for dir in $1
243 LIBDIR="$LIBDIR -L$dir";
244 done
245 shift
247 --libdir=*)
248 libdir=`echo $1 | awk -F= '{print $2}'`
249 CheckDir $libdir
250 for dir in $libdir
252 LIBDIR="$LIBDIR -L$dir";
253 done
254 shift
256 "--incdir")
257 shift; CheckDir $1
258 for dir in $1
260 INCDIR="$INCDIR -I$dir";
261 done
262 shift
264 --incdir=*)
265 incdir=`echo $1 | awk -F= '{print $2}'`
266 CheckDir $incdir
267 for dir in $incdir
269 INCDIR="$INCDIR -I$dir";
270 done
271 shift
273 --no-build-shared|-nobs|--no-shared)
274 BUILD_SHARED="-nobs"; shift
276 --with-romio)
277 WITH_ROMIO="true"; shift
279 --build-shared|-bs)
280 # obsolete, do nothing
281 shift
283 -j*)
284 PMAKENUM=`echo $1 | awk -Fj '{print $2}'`
285 MAKEOPTS="$MAKEOPTS -j $PMAKENUM"
286 shift;
288 -*)
289 # We hit a real compiler option (like -g, or -Dfoo),
290 # so just copy over all remaining options
291 while [ ! $# -eq 0 ]
293 OPTS="$OPTS $1"; shift
294 done
296 "help")
297 printOption
300 # This has to be a build-time option (like "smp", "gcc3", or "kcc")
301 TestIfCompiler $1
302 if [ $? -eq 1 ]
303 then
304 # It specifies a compiler:
305 if [ ! -z "$COMPILER" ]
306 then
307 echo "Error> Tried to specify two compilers: $COMPILER and $1"
308 printOption
310 COMPILER=$1
311 else
312 # It specifies some other option:
313 TestIfOption $1
314 BOPTS="$BOPTS $1"
315 [ $1 = "bigemulator" ] && BUILD_EMULATOR=1
317 shift
319 esac
320 done
322 [ "x$VERSION" = "x" ] && syntax && exit 1
324 if [ -z "$MAKE" ]
325 then
326 # prefer gmake
327 MAKE=`which gmake 2>/dev/null`
328 [ -z "$MAKE" -o ! -x "$MAKE" ] && MAKE='make'
331 if [ ! -f $src/$BASEVERSION/conv-mach.h ]
332 then
333 echo "Error> build can not find arch: $BASEVERSION!"
334 exit 1
337 #generate VERSION name combining all the build-time options.
338 if [ -n "$BOPTS" -o -n "$COMPILER" ]
339 then
340 echo "Selected Compiler: $COMPILER"
341 echo "Selected Options: $BOPTS"
342 SORTED=`echo $BOPTS | awk '{ for (i = 1; i <= NF; ++i) print $i }' | sort`
343 BOPTS_WITHCOMPILER=`echo $SORTED $COMPILER`
344 for i in $BOPTS_WITHCOMPILER
346 VERSION=$VERSION-$i
347 done
350 [ -d $VERSION ] || echo "Creating dir: $VERSION"
351 [ -d $VERSION ] || mkdir $VERSION
352 [ -d $VERSION/tmp ] || echo "Creating dir: $VERSION/tmp"
353 [ -d $VERSION/tmp ] || mkdir $VERSION/tmp
355 echo "Copying src/scripts/Makefile to $VERSION/tmp"
356 rm -f $VERSION/tmp/Makefile
357 rm -f $VERSION/tmp/Make.depends
358 rm -f $VERSION/tmp/Make.lb
359 rm -f $VERSION/tmp/Make.machine
362 # Create the bin, lib, include, etc. links:
363 if [ "x_`echo $VERSION | awk -F- '{print $2}'`" = "x_win32" ]
364 then
365 #Win32 version needs special compilers and *copied* (not linked)
366 # source files.
367 echo "Copying compilers for win32 into cygwin /bin directory"
368 cp $src/win32/unix2nt* /bin
369 cp $src/win32/system_ln $VERSION/tmp
370 cp $src/win32/unistd.h $VERSION/tmp
371 cp $src/win32/createlink.exe /bin
372 chmod +x $VERSION/tmp/system_ln
373 elif [ "x_`echo $VERSION | awk -F- '{print $2}'`" = "x_win64" ]
374 then
375 #Win64 version needs special compilers and *copied* (not linked)
376 # source files.
377 echo "Copying compilers for win64 into cygwin /bin directory"
378 cp $src/win64/unix2nt* /bin
379 cp $src/win64/system_ln $VERSION/tmp
380 cp $src/win64/unistd.h $VERSION/tmp
381 cp $src/win64/unistd.h $VERSION/include
382 cp $src/win64/createlink.exe /bin
383 chmod +x $VERSION/tmp/system_ln
384 else
385 cat > $VERSION/tmp/system_ln <<EOF
386 #!/bin/sh
387 ln -f -s \$@
389 chmod +x $VERSION/tmp/system_ln
390 for newdir in `echo bin lib lib_so include tmp`
392 echo "Soft-linking over $newdir"
393 if [ -r $newdir ]
394 then
395 rm -fr $newdir || exit 1
397 $VERSION/tmp/system_ln $VERSION/$newdir $newdir
398 done
399 rm -f VERSION
400 $VERSION/tmp/system_ln $VERSION/include/VERSION VERSION
403 $VERSION/tmp/system_ln "../../src/scripts/Make.depends" $VERSION/tmp/Make.depends
404 $VERSION/tmp/system_ln "../../src/ck-ldb/Make.lb" $VERSION/tmp/Make.lb
405 $VERSION/tmp/system_ln "../../src/scripts/Makefile" $VERSION/tmp/Makefile
406 touch $VERSION/tmp/Makefile.machine
408 ConvUsr="$VERSION/tmp/conv-mach-pre.sh"
409 echo "Generating $ConvUsr"
410 echo > $ConvUsr
411 if test -n "$LIBDIR"
412 then
413 echo 'USER_OPTS_LD="$USER_OPTS_LD '$LIBDIR'"' >> $ConvUsr
414 echo 'USER_OPTS_LDXX="$USER_OPTS_LDXX '$LIBDIR'"' >> $ConvUsr
416 if test -n "$INCDIR"
417 then
418 echo 'USER_OPTS_CC="$USER_OPTS_CC '$INCDIR'"' >> $ConvUsr
419 echo 'USER_OPTS_CXX="$USER_OPTS_CXX '$INCDIR'"' >> $ConvUsr
421 chmod +x $ConvUsr
423 # Create conv-mach-opt headers with special build-time options
424 ConvHeader="$VERSION/tmp/conv-mach-opt.h"
425 ConvSh="$VERSION/tmp/conv-mach-opt.sh"
426 if [ ! -f $ConvSh -o ! -f $ConvHeader ]
427 then
428 echo "Generating $ConvHeader, conv-mach-opt.sh"
429 echo '/* Build-time options header, automatically generated by charm/build*/'> $ConvHeader
430 echo '# Built-time options header, automatically generated by charm/build'> $ConvSh
431 echo '[ -z "$CHARMINC" ] && CHARMINC="."' >> $ConvSh
433 if test -n "$COMPILER"
434 then
435 i="$COMPILER"
436 echo '#include "'cc-$i.h'"' >> $ConvHeader
437 echo '. $CHARMINC/'"cc-$i.sh" >> $ConvSh
439 if test -n "$BOPTS"
440 then
441 for i in $BOPTS
443 echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
444 echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
445 done
448 if test -n "$BUILD_SHARED"
449 then
450 echo "CMK_NO_BUILD_SHARED=true" >> $ConvSh
453 if test -n "$WITH_ROMIO"
454 then
455 echo "CMK_AMPI_WITH_ROMIO=\"true\"" >> $ConvSh
458 echo $BASEVERSION > $VERSION/tmp/.vdir
460 if test $BUILD_EMULATOR = 1
461 then
462 PROGRAM="$PROGRAM bigsim"
465 echo "Performing '$MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS"' in $VERSION/tmp"
466 cd $VERSION/tmp
467 $MAKE $MAKEOPTS $PROGRAM OPTS="$OPTS $BUILD_SHARED"
469 MAKEEXIT=$?
470 if [ $MAKEEXIT -eq 0 ]
471 then
472 echo "-------------------------------------------------"
473 echo "$PROGRAM built successfully."
474 echo "Next, try out a sample program like" \
475 "tests/charm++/simplearrayhello"
476 else
477 echo "-------------------------------------------------"
478 echo "Charm++ NOT BUILT. Either cd into $VERSION/tmp and try"
479 echo "to resolve the problems yourself, visit"
480 echo " http://charm.cs.uiuc.edu/"
481 echo "for more information. Otherwise, email the developers at ppl@cs.uiuc.edu"
482 exit $MAKEEXIT