Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / bin / ace-install
blob123a3e3afeb8676e340fd20947e8c1dc5d960dbb
1 #!/bin/sh
3 #####################################################################
4 # install_ace: distill the minimal stuff out of the ACE+TAO distribution
5 # alias cpio 'xargs -i echo {}'; # just for testing the script
7 # according to David Levine <levine@cs.wustl.edu> on 1999/01/09:
9 # An even better way would be to only build what you need.
10 # These directories are probably a good start:
12 # ace
13 # apps/gperf/src
14 # TAO/tao
15 # TAO/TAO_IDL
16 # TAO/orbsvcs
18 # netsvcs ? - not built in here, probably useful
20 #####################################################################
22 # actions
23 unpack=0
24 config=0
25 compile=0
26 install=0
27 force=0
29 # can we do it?
30 die=0
32 # this script name without path
33 this_script=$(basename $0)
35 #####################################################################
36 # check for install_ace options
37 #####################################################################
39 while [ $# -gt 0 ]; do
41 case $1 in
43 ##########################################
44 # help output
46 -h | --help*)
47 echo " "
48 echo "$this_script [options]"
49 echo " "
50 echo "options:"
51 echo " -h, --help show brief help"
52 echo " "
53 echo "required options:"
54 echo " -r, --aceroot=ACE_ROOT use ACE_ROOT directory for build/install"
55 echo " "
56 echo "extracting and configuring options:"
57 echo " -z, --archive=FILE unpack specified source archive"
58 echo " -p, --platform=HEADER,MAKE use HEADER,MAKE as config.h, platform_macros"
59 echo " "
60 echo "compiling options:"
61 echo " -c, --compile=ACE_OPTS compile with make options (e.g. debug=0)"
62 echo " "
63 echo "installing options:"
64 echo " -i, --install=ACE_DEST install into ACE_DEST directory"
65 echo " -a, --arch=ACE_ARCH use ACE_ARCH subdirs for arch-dependent files"
66 echo " "
67 echo "miscellaneous options:"
68 echo " -f, --force don't ask for confirmation before proceeding"
69 echo " "
70 exit 0
73 ##########################################
74 # required options
76 -r)
77 shift
78 if [ $# -gt 0 ]; then
79 ACE_ROOT=$1; export ACE_ROOT
80 else
81 echo "no ACE_ROOT specified"
82 exit 1
84 shift
87 --aceroot*)
88 ACE_ROOT=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_ROOT
89 shift
92 ##########################################
93 # extracting and configuring options
95 -z)
96 shift
97 if [ $# -gt 0 ]; then
98 ACE_ARCHIVE=$1; export ACE_ARCHIVE
99 unpack=1
100 else
101 echo "no archive specified"
102 exit 1
104 shift
107 --archive*)
108 ACE_ARCHIVE=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_ARCHIVE
109 unpack=1
110 shift
114 shift
115 if [ $# -gt 0 ]; then
116 ACE_HEADER=$(echo $1 | cut -f 1 -d ,); export ACE_HEADER
117 ACE_MAKE=$(echo $1 | cut -f 2 -d ,); export ACE_MAKE
118 else
119 echo "no header,make files specified"
120 exit 1
122 config=1
123 shift
126 --platform*)
127 stuff=$(echo $1 | sed -e 's/^[^=]*=//g')
128 ACE_HEADER=$(echo $stuff | cut -f 1 -d ,); export ACE_HEADER
129 ACE_MAKE=$(echo $stuff | cut -f 2 -d ,); export ACE_MAKE
130 config=1
131 shift
134 ##########################################
135 # compiling options
138 shift
139 if [ $# -gt 0 ]; then
140 ACE_OPTS="$1"; export ACE_OPTS
141 compile=1
142 else
143 echo "no compilation options specified (e.g. debug=0)"
144 exit 1
146 shift
149 --compile*)
150 ACE_OPTS=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_OPTS
151 compile=1
152 shift
155 ##########################################
156 # installing options
159 shift
160 if [ $# -gt 0 ]; then
161 ACE_DEST=$1; export ACE_DEST
162 install=1
163 else
164 echo "no installation target directory specified (e.g. /tools/ace)"
165 exit 1
167 shift
170 --install*)
171 ACE_DEST=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_DEST
172 install=1
173 shift
177 shift
178 if [ $# -gt 0 ]; then
179 ACE_ARCH=$1; export ACE_ARCH
180 else
181 echo "no installation target architecture specified"
182 exit 1
184 shift
187 --arch*)
188 ACE_ARCH=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_ARCH
189 shift
192 ##########################################
193 # miscellaneous options
196 shift
197 force=1
201 # no more options, get on with life
202 if [ $# -gt 0 ]; then
203 echo "unrecognized option: $1"
204 exit 1
207 esac
208 done
211 #####################################################################
212 # sanity checks for required variables
213 #####################################################################
215 if [ $install -ne 0 ] && [ $compile -ne 0 ] && [ $unpack -eq 0 ]; then
216 echo "- No actions specified."
217 die=1
220 if [ $unpack -ne 0 ] && [ $compile -ne 0 ] && [ $config -eq 0 ] \
221 || [ $unpack -ne 0 ] && [ $install -ne 0 ] && [ $config -eq 0 ]; then
222 echo "- Must set platform config options with --platform option"
223 echo " ($this_script -h for help) to unpack and compile/install"
224 die=1
227 if [ -z "$ACE_ROOT" ]; then
228 echo "- Must set ACE_ROOT directory before proceeding..."
229 echo " The directory may be set with the ACE_ROOT environment"
230 echo " variable or the --aceroot option ($this_script -h for help)"
231 die=1
234 if [ $install -eq 1 ] && [ -z "$ACE_ARCH" ]; then
235 # just set it to blank if we want to flatten this level of subdirectory
236 ACE_ARCH=""
239 if [ $die -ne 0 ]; then
240 echo "- terminating $this_script script"
241 exit 2
245 #####################################################################
246 # announce intentions
247 #####################################################################
249 echo "This script will perform the following actions:"
251 echo "using ACE_ROOT directory: $ACE_ROOT"
253 if [ $unpack -ne 0 ]; then
254 echo " "
255 echo "Extracting:"
256 echo "- unpack source archive: $ACE_ARCHIVE"
259 if [ $config -ne 0 ]; then
260 echo " "
261 echo "Configuring:"
262 echo "- platform config.h header: $ACE_HEADER"
263 echo "- platform makefile macros: $ACE_MAKE"
266 if [ $compile -ne 0 ]; then
267 echo " "
268 echo "Compiling:"
269 echo "- ACE/TAO compile options: $ACE_OPTS"
272 if [ $install -ne 0 ]; then
273 echo " "
274 echo "Installing:"
275 echo "- install target directory: $ACE_DEST"
276 echo "- install target arch: $ACE_ARCH"
279 echo ""
282 #####################################################################
283 # confirm desire to proceed
284 #####################################################################
286 if [ $force -eq 0 ]; then
287 echo " "
288 echo "Type 'yes' to proceed, anything else to exit"
290 read -r ready
291 if [ "$ready" != "yes" ]; then
292 echo "Terminating install script. Thank you for playing."
293 echo "We have some lovely parting gifts for you. =)"
294 exit 1
299 #####################################################################
300 # extract ACE and TAO
301 #####################################################################
303 if [ $unpack -ne 0 ]; then
305 echo "Unpacking $ACE_ARCHIVE..."
307 cd $(dirname $ACE_ROOT)
308 gzip -dc $ACE_ARCHIVE | tar xvf -
313 #####################################################################
314 # configure ACE and TAO
315 #####################################################################
317 if [ $config -ne 0 ]; then
319 echo "Configuring: $ACE_HEADER,$ACE_MAKE..."
321 # copy the files if they exist
322 test -f $ACE_ROOT/ace/$ACE_HEADER \
323 && cp $ACE_ROOT/ace/$ACE_HEADER $ACE_ROOT/ace/config.h
324 test -f $ACE_ROOT/include/makeinclude/$ACE_MAKE \
325 && cp $ACE_ROOT/include/makeinclude/$ACE_MAKE \
326 $ACE_ROOT/include/makeinclude/platform_macros.GNU
328 # print error message and die if they don't
329 if [ ! -f $ACE_ROOT/ace/$ACE_HEADER ]; then
330 echo "error: $ACE_HEADER doesn't exist"
331 die=1
333 if [ ! -f $ACE_ROOT/include/makeinclude/$ACE_MAKE ]; then
334 echo "error: $ACE_MAKE doesn't exist"
335 die=1
338 if [ $die -ne 0 ]; then
339 exit $die
345 #####################################################################
346 # compile ACE and TAO
347 #####################################################################
349 if [ $compile -ne 0 ]; then
351 echo "Compiling: $ACE_OPTS..."
353 ##########################################
354 # add ACE_ROOT/ace to LD_LIBRARY_PATH so tao_idl can find libACE.so
355 if [ "$(uname -s)" = "HP-UX" ]; then
356 if [ ! -z "$SHLIB_PATH" ]; then
357 SHLIB_PATH=$ACE_ROOT/ace:$SHLIB_PATH
358 else
359 SHLIB_PATH=$ACE_ROOT/ace; export SHLIB_PATH
361 else
362 if [ ! -z "$LD_LIBRARY_PATH" ]; then
363 LD_LIBRARY_PATH=$ACE_ROOT/ace:$LD_LIBRARY_PATH
364 else
365 LD_LIBRARY_PATH=$ACE_ROOT/ace; export LD_LIBRARY_PATH
369 ##########################################
370 # compile a few select directories
371 for d in ace apps/gperf/src TAO/tao TAO/TAO_IDL TAO/orbsvcs TAO/utils; do
372 echo --- Building in $d.
373 cd "$ACE_ROOT/$d"
374 make $ACE_OPTS
375 if [ $? -ne 0 ]; then
376 echo --- Error during build: $?
377 exit $?
379 done
383 #####################################################################
384 # install ACE and TAO
385 #####################################################################
387 if [ $install -ne 0 ]; then
389 echo "Installing: $ACE_DEST..."
391 ##########################################
392 # determine final target directories
394 ACE_VER=$(head -n 1 $ACE_ROOT/VERSION.txt | sed -e 's/^[^0-9]*//' -e 's/[, ].*//')
395 ACE_DIR="$ACE_DEST/ACE-$ACE_VER"; export ACE_DIR
397 TAO_VER=$(head -n 1 $ACE_ROOT/TAO/VERSION.txt | sed -e 's/^[^0-9]*//' -e 's/[, ].*//')
398 TAO_DIR="$ACE_DEST/TAO-$TAO_VER"; export ACE_DIR
400 ##########################################
401 # create target directories as needed
402 echo "creating target directories..."
404 ace_dirs="$ACE_DIR $ACE_DIR/include $ACE_DIR/man"
405 ace_arch_dirs="$ACE_DIR/$ACE_ARCH/include/ace \
406 $ACE_DIR/$ACE_ARCH/bin $ACE_DIR/$ACE_ARCH/lib"
407 tao_dirs="$TAO_DIR $TAO_DIR/include $TAO_DIR/include/orbsvcs"
408 tao_arch_dirs="$TAO_DIR/$ACE_ARCH/include \
409 $TAO_DIR/$ACE_ARCH/bin $TAO_DIR/$ACE_ARCH/lib"
411 for dir in $ace_dirs $ace_arch_dirs $tao_dirs $tao_arch_dirs; do
412 if [ ! -d $dir ]; then
413 echo $dir
414 mkdir -p $dir
416 done
418 ##########################################
419 # copy TAO stuff
421 cd $ACE_ROOT/TAO
422 cp VERSION.txt $TAO_DIR/$ACE_ARCH/TAO-VERSION
424 # copy TAO includes
425 echo "Copying include files..."
426 find tao -type f -name "*.idl" -print | cpio -p -d -V $TAO_DIR/include
427 find tao -type f -name "*.pidl" -print | cpio -p -d -V $TAO_DIR/include
428 find tao -type f -name "*.h" -print | grep -v "^config\.h" | cpio -p -d -V $TAO_DIR/include
429 find tao -type f \( -name "*.i" -o -name "*.inl" \) -print | cpio -p -d -V $TAO_DIR/include
430 find tao -type f -name "*.cpp" -print | cpio -p -d -V $TAO_DIR/include
432 # NOTE: may need all .h, .i and .cpp under TAO/orbsvcs, instead of just TAO/orbsvcs/orbsvcs
433 cd orbsvcs
434 find orbsvcs -type f -name "*.idl" -print | cpio -p -d -V $TAO_DIR/include
435 find orbsvcs -type f -name "*.pidl" -print | cpio -p -d -V $TAO_DIR/include
436 find orbsvcs -type f -name "*.h" -print | grep -v "^config\.h" | cpio -p -d -V $TAO_DIR/include
437 find orbsvcs -type f \( -name "*.i" -o -name "*.inl" \) -print | cpio -p -d -V $TAO_DIR/include
438 find orbsvcs -type f -name "*.cpp" -print | cpio -p -d -V $TAO_DIR/include
439 cd ..
441 # copy TAO libs
442 echo "Copying libraries..."
443 for f in $(find . -type f \( -name "lib?*.so*" -o -name "lib?*.a" -o -name "lib?*.dll" -o -name "*.dylib" \) -print); do
444 echo $f
445 cp $f $TAO_DIR/$ACE_ARCH/lib
446 done
448 # copy TAO executables
449 echo "Copying executables..."
451 ALL_PROGS=$(find orbsvcs -type f -perm /a+x -print | grep -v ".*lib.*" | grep -v ".\.pl" | grep -v test | grep -v example)
452 ALL_PROGS="$(find utils -type f -perm /a+x -print) $ALL_PROGS"
453 PROGS=$(echo $ALL_PROGS | tr " " "\n" | grep -v test | grep -v default.bld | grep -v README | grep -v GNUmakefile)
455 for f in TAO_IDL/tao_idl $PROGS; do
456 echo $f
457 cp $f $TAO_DIR/$ACE_ARCH/bin
458 done
460 ##########################################
461 # copy ACE stuff
463 cd $ACE_ROOT
464 cp VERSION.txt $ACE_DIR/$ACE_ARCH/ACE-VERSION
466 # copy ACE includes
467 echo "Copying include files..."
468 find ace -type f -name "*.h" -print | grep -v "^config\.h" | cpio -p -d -V $ACE_DIR/include
469 find ace -type f \( -name "*.i" -o -name "*.inl" \) -print | cpio -p -d -V $ACE_DIR/include
470 find ace -type f -name "*.cpp" -print | cpio -p -d -V $ACE_DIR/include
471 cp ace/config.h $ACE_DIR/$ACE_ARCH/include/ace/config.h
472 chmod -R a+r $ACE_DIR/$ACE_ARCH/include
474 # copy ACE libs
475 echo "Copying libraries..."
476 for f in $(find . -type f \( -name "lib?*.so*" -o -name "lib?*.a" -o -name "lib?*.dll" -o -name "*.dylib" \) -print); do
477 # only copy libs if they're not already in $TAO_DIR/$ACE_ARCH/lib
478 maybe_tao_lib=$TAO_DIR/$ACE_ARCH/lib/$(basename $f)
479 if [ ! -f $maybe_tao_lib ]; then
480 echo $f
481 cp $f $ACE_DIR/$ACE_ARCH/lib
483 test -f $maybe_tao_lib && echo "library $f already installed with TAO"
484 done
486 # copy ACE executables
487 echo "Copying executables..."
488 ACE_PROGS=apps/gperf/src/ace_gperf
490 for f in $ACE_PROGS; do
491 echo $f
492 cp $f $ACE_DIR/$ACE_ARCH/bin
493 done
495 # copy ACE man pages
496 echo "Copying man pages..."
497 find man -type f -print | cpio -p -d -V $ACE_DIR
500 # PERMISSIONS
501 chmod -R a+r $ACE_DEST
502 find $ACE_DEST -type d -exec chmod a+x {} \;
503 find $ACE_DEST -type f -perm /a+x -exec chmod a+x {} \;
505 fi # if [ $install -ne 0 ]
508 #####################################################################
509 # that's all, folks
510 #####################################################################
512 echo "$this_script: done."