summaryrefslogtreecommitdiff
path: root/ACE/bin/ace-install
blob: 123a3e3afeb8676e340fd20947e8c1dc5d960dbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#!/bin/sh

#####################################################################
# install_ace: distill the minimal stuff out of the ACE+TAO distribution
# alias cpio 'xargs -i echo {}'; # just for testing the script
#
# according to David Levine <levine@cs.wustl.edu> on 1999/01/09:
#
#     An even better way would be to only build what you need.
#     These directories are probably a good start:
#
#     ace
#     apps/gperf/src
#     TAO/tao
#     TAO/TAO_IDL
#     TAO/orbsvcs
#
#     netsvcs ? - not built in here, probably useful
#
#####################################################################

# actions
unpack=0
config=0
compile=0
install=0
force=0

# can we do it?
die=0

# this script name without path
this_script=$(basename $0)

#####################################################################
# check for install_ace options
#####################################################################

while [ $# -gt 0 ]; do

    case $1 in

        ##########################################
        # help output

        -h | --help*)
            echo " "
            echo "$this_script [options]"
            echo " "
            echo "options:"
            echo "  -h, --help                show brief help"
            echo " "
            echo "required options:"
            echo "  -r, --aceroot=ACE_ROOT    use ACE_ROOT directory for build/install"
            echo " "
            echo "extracting and configuring options:"
            echo "  -z, --archive=FILE        unpack specified source archive"
            echo "  -p, --platform=HEADER,MAKE  use HEADER,MAKE as config.h, platform_macros"
            echo " "
            echo "compiling options:"
            echo "  -c, --compile=ACE_OPTS    compile with make options (e.g. debug=0)"
            echo " "
            echo "installing options:"
            echo "  -i, --install=ACE_DEST    install into ACE_DEST directory"
            echo "  -a, --arch=ACE_ARCH       use ACE_ARCH subdirs for arch-dependent files"
            echo " "
            echo "miscellaneous options:"
            echo "  -f, --force               don't ask for confirmation before proceeding"
            echo " "
            exit 0
            ;;

        ##########################################
        # required options

        -r)
            shift
            if [ $# -gt 0 ]; then
                ACE_ROOT=$1; export ACE_ROOT
            else
                echo "no ACE_ROOT specified"
                exit 1
            fi
            shift
            ;;

        --aceroot*)
            ACE_ROOT=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_ROOT
            shift
            ;;

        ##########################################
        # extracting and configuring options

        -z)
            shift
            if [ $# -gt 0 ]; then
                ACE_ARCHIVE=$1; export ACE_ARCHIVE
                unpack=1
            else
                echo "no archive specified"
                exit 1
            fi
            shift
            ;;

        --archive*)
            ACE_ARCHIVE=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_ARCHIVE
            unpack=1
            shift
            ;;

        -p)
            shift
            if [ $# -gt 0 ]; then
                ACE_HEADER=$(echo $1 | cut -f 1 -d ,); export ACE_HEADER
                ACE_MAKE=$(echo $1 | cut -f 2 -d ,); export ACE_MAKE
            else
                echo "no header,make files specified"
                exit 1
            fi
            config=1
            shift
            ;;

        --platform*)
            stuff=$(echo $1 | sed -e 's/^[^=]*=//g')
            ACE_HEADER=$(echo $stuff | cut -f 1 -d ,); export ACE_HEADER
            ACE_MAKE=$(echo $stuff | cut -f 2 -d ,); export ACE_MAKE
            config=1
            shift
            ;;

        ##########################################
        # compiling options

        -c)
            shift
            if [ $# -gt 0 ]; then
                ACE_OPTS="$1"; export ACE_OPTS
                compile=1
            else
                echo "no compilation options specified (e.g. debug=0)"
                exit 1
            fi
            shift
            ;;

        --compile*)
            ACE_OPTS=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_OPTS
            compile=1
            shift
            ;;

        ##########################################
        # installing options

        -i)
            shift
            if [ $# -gt 0 ]; then
                ACE_DEST=$1; export ACE_DEST
                install=1
            else
                echo "no installation target directory specified (e.g. /tools/ace)"
                exit 1
            fi
            shift
            ;;

        --install*)
            ACE_DEST=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_DEST
            install=1
            shift
            ;;

        -a)
            shift
            if [ $# -gt 0 ]; then
                ACE_ARCH=$1; export ACE_ARCH
            else
                echo "no installation target architecture specified"
                exit 1
            fi
            shift
            ;;

        --arch*)
            ACE_ARCH=$(echo $1 | sed -e 's/^[^=]*=//g'); export ACE_ARCH
            shift
            ;;

        ##########################################
        # miscellaneous options

        -f)
            shift
            force=1
            ;;

        *)
            # no more options, get on with life
            if [ $# -gt 0 ]; then
                echo "unrecognized option: $1"
                exit 1
            fi
            ;;
    esac
done


#####################################################################
# sanity checks for required variables
#####################################################################

if [ $install -ne 0 ] && [ $compile -ne 0 ] && [ $unpack -eq 0 ]; then
    echo "- No actions specified."
    die=1
fi

if [ $unpack -ne 0 ] && [ $compile -ne 0 ] && [ $config -eq 0 ] \
        || [ $unpack -ne 0 ] && [ $install -ne 0 ] && [ $config -eq 0 ]; then
    echo "- Must set platform config options with --platform option"
    echo "  ($this_script -h for help) to unpack and compile/install"
    die=1
fi

if [ -z "$ACE_ROOT" ]; then
    echo "- Must set ACE_ROOT directory before proceeding..."
    echo "  The directory may be set with the ACE_ROOT environment"
    echo "  variable or the --aceroot option ($this_script -h for help)"
    die=1
fi

if [ $install -eq 1 ] && [ -z "$ACE_ARCH" ]; then
	# just set it to blank if we want to flatten this level of subdirectory
	ACE_ARCH=""
fi

if [ $die -ne 0 ]; then
    echo "- terminating $this_script script"
    exit 2
fi


#####################################################################
# announce intentions
#####################################################################

echo "This script will perform the following actions:"

echo "using ACE_ROOT directory: $ACE_ROOT"

if [ $unpack -ne 0 ]; then
    echo " "
    echo "Extracting:"
    echo "- unpack source archive:    $ACE_ARCHIVE"
fi

if [ $config -ne 0 ]; then
    echo " "
    echo "Configuring:"
    echo "- platform config.h header: $ACE_HEADER"
    echo "- platform makefile macros: $ACE_MAKE"
fi

if [ $compile -ne 0 ]; then
    echo " "
    echo "Compiling:"
    echo "- ACE/TAO compile options:  $ACE_OPTS"
fi

if [ $install -ne 0 ]; then
    echo " "
    echo "Installing:"
    echo "- install target directory: $ACE_DEST"
    echo "- install target arch:      $ACE_ARCH"
fi

echo ""


#####################################################################
# confirm desire to proceed
#####################################################################

if [ $force -eq 0 ]; then
    echo " "
    echo "Type 'yes' to proceed, anything else to exit"

    read -r ready
    if [ "$ready" != "yes" ]; then
        echo "Terminating install script.  Thank you for playing."
        echo "We have some lovely parting gifts for you. =)"
        exit 1
    fi
fi


#####################################################################
# extract ACE and TAO
#####################################################################

if [ $unpack -ne 0 ]; then

    echo "Unpacking $ACE_ARCHIVE..."

    cd $(dirname $ACE_ROOT)
    gzip -dc $ACE_ARCHIVE | tar xvf -

fi


#####################################################################
# configure ACE and TAO
#####################################################################

if [ $config -ne 0 ]; then

    echo "Configuring: $ACE_HEADER,$ACE_MAKE..."

    # copy the files if they exist
    test -f $ACE_ROOT/ace/$ACE_HEADER \
        && cp $ACE_ROOT/ace/$ACE_HEADER $ACE_ROOT/ace/config.h
    test -f $ACE_ROOT/include/makeinclude/$ACE_MAKE \
        && cp $ACE_ROOT/include/makeinclude/$ACE_MAKE \
            $ACE_ROOT/include/makeinclude/platform_macros.GNU

    # print error message and die if they don't
    if [ ! -f $ACE_ROOT/ace/$ACE_HEADER ]; then
      echo "error: $ACE_HEADER doesn't exist"
      die=1
    fi
    if [ ! -f $ACE_ROOT/include/makeinclude/$ACE_MAKE ]; then
      echo "error: $ACE_MAKE doesn't exist"
      die=1
    fi

    if [ $die -ne 0 ]; then
        exit $die
    fi

fi


#####################################################################
# compile ACE and TAO
#####################################################################

if [ $compile -ne 0 ]; then

    echo "Compiling: $ACE_OPTS..."

    ##########################################
    # add ACE_ROOT/ace to LD_LIBRARY_PATH so tao_idl can find libACE.so
    if [ "$(uname -s)" = "HP-UX" ]; then
      if [ ! -z "$SHLIB_PATH" ]; then
          SHLIB_PATH=$ACE_ROOT/ace:$SHLIB_PATH
      else
          SHLIB_PATH=$ACE_ROOT/ace; export SHLIB_PATH
      fi
    else
      if [ ! -z "$LD_LIBRARY_PATH" ]; then
          LD_LIBRARY_PATH=$ACE_ROOT/ace:$LD_LIBRARY_PATH
      else
          LD_LIBRARY_PATH=$ACE_ROOT/ace; export LD_LIBRARY_PATH
      fi
    fi

    ##########################################
    # compile a few select directories
    for d in ace apps/gperf/src TAO/tao TAO/TAO_IDL TAO/orbsvcs TAO/utils; do
        echo --- Building in $d.
        cd "$ACE_ROOT/$d"
        make $ACE_OPTS
        if [ $? -ne 0 ]; then
            echo --- Error during build: $?
            exit $?
        fi
    done
fi


#####################################################################
# install ACE and  TAO
#####################################################################

if [ $install -ne 0 ]; then

    echo "Installing: $ACE_DEST..."

    ##########################################
    # determine final target directories

    ACE_VER=$(head -n 1 $ACE_ROOT/VERSION.txt | sed -e 's/^[^0-9]*//' -e 's/[, ].*//')
    ACE_DIR="$ACE_DEST/ACE-$ACE_VER"; export ACE_DIR

    TAO_VER=$(head -n 1 $ACE_ROOT/TAO/VERSION.txt | sed -e 's/^[^0-9]*//' -e 's/[, ].*//')
    TAO_DIR="$ACE_DEST/TAO-$TAO_VER"; export ACE_DIR

    ##########################################
    # create target directories as needed
    echo "creating target directories..."

    ace_dirs="$ACE_DIR $ACE_DIR/include $ACE_DIR/man"
    ace_arch_dirs="$ACE_DIR/$ACE_ARCH/include/ace \
                            $ACE_DIR/$ACE_ARCH/bin $ACE_DIR/$ACE_ARCH/lib"
    tao_dirs="$TAO_DIR $TAO_DIR/include $TAO_DIR/include/orbsvcs"
    tao_arch_dirs="$TAO_DIR/$ACE_ARCH/include \
                            $TAO_DIR/$ACE_ARCH/bin $TAO_DIR/$ACE_ARCH/lib"

    for dir in $ace_dirs $ace_arch_dirs $tao_dirs $tao_arch_dirs; do
        if [ ! -d $dir ]; then
          echo $dir
          mkdir -p $dir
        fi
    done

    ##########################################
    # copy TAO stuff

    cd $ACE_ROOT/TAO
    cp VERSION.txt $TAO_DIR/$ACE_ARCH/TAO-VERSION

    # copy TAO includes
    echo "Copying include files..."
    find tao -type f -name "*.idl" -print | cpio -p -d -V $TAO_DIR/include
    find tao -type f -name "*.pidl" -print | cpio -p -d -V $TAO_DIR/include
    find tao -type f -name "*.h" -print | grep -v "^config\.h" | cpio -p -d -V $TAO_DIR/include
    find tao -type f \( -name  "*.i" -o -name "*.inl" \) -print | cpio -p -d -V $TAO_DIR/include
    find tao -type f -name "*.cpp" -print | cpio -p -d -V $TAO_DIR/include

    # NOTE: may need all .h, .i and .cpp under TAO/orbsvcs, instead of just TAO/orbsvcs/orbsvcs
    cd orbsvcs
    find orbsvcs -type f -name "*.idl" -print | cpio -p -d -V $TAO_DIR/include
    find orbsvcs -type f -name "*.pidl" -print | cpio -p -d -V $TAO_DIR/include
    find orbsvcs -type f -name "*.h" -print | grep -v "^config\.h" | cpio -p -d -V $TAO_DIR/include
    find orbsvcs -type f \( -name "*.i" -o -name "*.inl" \) -print | cpio -p -d -V $TAO_DIR/include
    find orbsvcs -type f -name "*.cpp" -print | cpio -p -d -V $TAO_DIR/include
    cd ..

    # copy TAO libs
    echo "Copying libraries..."
    for f in $(find . -type f \( -name "lib?*.so*" -o -name "lib?*.a" -o -name "lib?*.dll" -o -name "*.dylib" \) -print); do
        echo $f
        cp $f $TAO_DIR/$ACE_ARCH/lib
    done

    # copy TAO executables
    echo "Copying executables..."

    ALL_PROGS=$(find orbsvcs -type f -perm /a+x -print | grep -v ".*lib.*" | grep -v ".\.pl" | grep -v test | grep -v example)
    ALL_PROGS="$(find utils  -type f -perm /a+x -print) $ALL_PROGS"
    PROGS=$(echo $ALL_PROGS | tr " " "\n" | grep -v test | grep -v default.bld | grep -v README | grep -v GNUmakefile)

    for f in TAO_IDL/tao_idl $PROGS; do
        echo $f
        cp $f $TAO_DIR/$ACE_ARCH/bin
    done

    ##########################################
    # copy ACE stuff

    cd $ACE_ROOT
    cp VERSION.txt $ACE_DIR/$ACE_ARCH/ACE-VERSION

    # copy ACE includes
    echo "Copying include files..."
    find ace -type f -name "*.h" -print | grep -v "^config\.h" | cpio -p -d -V $ACE_DIR/include
    find ace -type f \( -name "*.i" -o -name "*.inl" \) -print | cpio -p -d -V $ACE_DIR/include
    find ace -type f -name "*.cpp" -print | cpio -p -d -V $ACE_DIR/include
    cp ace/config.h $ACE_DIR/$ACE_ARCH/include/ace/config.h
    chmod -R a+r $ACE_DIR/$ACE_ARCH/include

    # copy ACE libs
    echo "Copying libraries..."
    for f in $(find . -type f \( -name "lib?*.so*" -o -name "lib?*.a" -o -name "lib?*.dll" -o -name "*.dylib" \) -print); do
        # only copy libs if they're not already in $TAO_DIR/$ACE_ARCH/lib
        maybe_tao_lib=$TAO_DIR/$ACE_ARCH/lib/$(basename $f)
        if [ ! -f $maybe_tao_lib ]; then
          echo $f
          cp $f $ACE_DIR/$ACE_ARCH/lib
        fi
        test -f $maybe_tao_lib && echo "library $f already installed with TAO"
    done

    # copy ACE executables
    echo "Copying executables..."
    ACE_PROGS=apps/gperf/src/ace_gperf

    for f in $ACE_PROGS; do
        echo $f
        cp $f $ACE_DIR/$ACE_ARCH/bin
    done

    # copy ACE man pages
    echo "Copying man pages..."
    find man -type f -print | cpio -p -d -V $ACE_DIR


   # PERMISSIONS
   chmod -R a+r $ACE_DEST
   find $ACE_DEST -type d -exec chmod a+x {} \;
   find $ACE_DEST -type f -perm /a+x -exec chmod a+x {} \;

fi   # if [ $install -ne 0 ]


#####################################################################
# that's all, folks
#####################################################################

echo "$this_script: done."