dtksh/sfio: resolved a naming collision on FreeBSD 11
[oweals/cde.git] / cde / programs / dtksh / ksh93 / ship / shipin
1 csh=obsolete || exec sh $0 $argv:q
2 OLDEST_nmake=950509 OLDEST_pax=950509
3 csh=obsolete || exec sh $0 $argv:q
4 #
5 # software shipment installation control
6 #
7 : "this id string works around a bug introduced sometime in 1991
8 @(#)shipin (AT&T Bell Laboratories) 05/09/95
9 "
10 #
11 # ship/shipin [options] [component ...] [name=value ...]
12 #
13 # options:
14 #
15 #       -c      don't compute closure if components specified
16 #       -d      for debugging
17 #       -i      read in from spool but do not uncrate or build
18 #               (files set up for shipout)
19 #       -n      show actions but do not execute
20 #       -p      don't run proto on uncrate
21 #       -r usr  usr is the shipment recipient
22 #       -s dir  shipment spool hierarchy copied to dir
23 #       -t      show component closure but do not build
24 #       -u      uncrate shipment source but do not build
25 #       -x      set -x
26 #       -E      ignore previous tool build errors
27 #       -F      force (re)build (no uncrating unless -u)
28 #       -L      don't generate proto line syncs on uncrate
29 #       -O      preserve old shipments
30 #       -P      delete #pragma prototyped on input
31 #       -X tool exclude tools from uncrating or building
32 #
33 # The component arguments cause shipin to build only on those components.
34 # All component source will be uncrated.
35 #
36 # The remaining arguments are passed as arguments to the generating
37 # makes or shell scripts -- handy for `name=value' overrides.
38 #
39 # The minimum configuration must have an $INSTALLROOT/ship subdirectory.
40 # See $INSTALLROOT/ship/README for more details.
41 #
42 # If $CC is not set then CC=$INSTALLROOT/bin/cc if it exists.  This
43 # provides a workaround hook for botches in the compilation system
44 # that go beyond setting CC and CCFLAGS.  Botches are so bad/ugly/temporary
45 # that we refuse to incorporate workarounds in our mainline code.
46 # Systems that currently require workarounds are:
47 #                       NeXT
48 #                       Win/NT
49 #
50
51 case $1 in
52 -x)     set -x
53         ;;
54 *)      case $- in
55         *x*)    set '' -x ${1+"$@"}; shift ;;
56         esac
57         ;;
58 esac
59 case $- in
60 *x*)    case $PS4 in
61         *'$LINENO'*)    ;;
62         *)              PS4='+$LINENO+ ' ;;
63         esac
64         ;;
65 esac
66
67 # disable the builtin wc because ksh may hang during the execution later of "wc pic.o"
68 builtin -d wc
69
70 #
71 # this script may be overwritten while it is being executed
72 # so copy it and exec from the copy
73 #
74
75 _command_=ship/shipin
76 _command_save_=ship/SHIPin
77 _check_=": $* :"
78 case $_ship_check_ in
79 $_check_)
80         ;;
81 *)      _ship_check_=$_check_
82         export _ship_check_
83         cp $_command_ $_command_save_ 2>/dev/null && chmod +x $_command_save_ && exec $_command_save_ ${1+"$@"}
84         ;;
85 esac
86
87 #
88 # the components in ORDER are built first
89 # OLDEST_<cmd> is the oldest version of <cmd> that can be used
90 #
91
92 INSTALLROOT=`pwd`
93 export INSTALLROOT
94
95 ORDER="pax ksh nmake"
96
97 USER=${USER-${LOGNAME-`echo $HOME | sed 's/.*\///'`}}
98 INSTALLER=$USER
99 export INSTALLER
100 RECIPIENT=${RECIPIENT-$USER}
101 FROMSYS=`(uname -n || hostname || cat /etc/whoami) 2>/dev/null`
102 d=/lib:/usr/lib:/usr/local/lib
103 for i in LD_LIBRARY_PATH
104 do      eval v='$'$i
105         case $v in
106         "")     eval $i='$'INSTALLROOT/lib ;;
107         *)      eval $i='$'INSTALLROOT/lib:$v ;;
108         esac
109         export $i
110 done
111 OPATH=/bin:/usr/bin:$PATH
112 PATH=:$PATH:$INSTALLROOT/bin
113 export PATH
114 case $PS4 in
115 +\ *|+*\ )
116         ;;
117 *)      PS4="+ $PS4"
118         export PS4
119         ;;
120 esac
121
122 SHIP=$INSTALLROOT/ship
123 BIN=$INSTALLROOT/bin
124 _bypass_=Install
125 LOG=in.log
126 _mail_=/bin/mail
127 OWNER=owner
128 _read_=
129 REPORT=report
130 SHIPDATE=[0-9][0-9][0-9][0-9][0-9][0-9]
131 SHIPMENT=*$SHIPDATE
132 SHIPSLOG=$SHIP/shipslog
133 TMP=tmp
134
135 for f in $ORDER
136 do      eval RELEASE_$f=
137         eval STATE_$f=
138 done
139
140 if      (unalias make) 2> /dev/null
141 then    unalias cp make rm
142 fi
143
144 #
145 # check for old exit status botch
146 #
147
148 _set_=
149 (set -e; false || true) && _set_=e || echo "$_command_: command errors ignored because of shell botch" >&2
150 _set_="set -x$_set_;"
151
152 #
153 # gobble the options
154 #
155
156 _closure_=1
157 _debug_=
158 _exclude_=" bin cmd lib src shipslog "
159 _export_="CC CCFLAGS"
160 _force_=
161 _ignore_=
162 _intermediate_=
163 _options_=
164 _preserve_=
165 _proto_=1
166 _proto_default_=npr
167 _proto_opt_=
168 _total_=
169 _trace_=
170 _uncrate_=
171 _uuspool_=
172 while   :
173 do      case $# in
174         0)      break ;;
175         esac
176         case $1 in
177         -[rsX]) case $# in
178                 1)      set '?'; continue ;;
179                 esac
180                 case $1 in
181                 -r)     RECIPIENT=$2 ;;
182                 -s)     _uuspool_="$_uuspool_ $2" ;;
183                 -X)     _exclude_="$_exclude$2 " ;;
184                 esac
185                 _options_="$_options_ $1"
186                 shift
187                 ;;
188         -c)     _closure_= ORDER= ;;
189         -d)     _debug_=1 ;;
190         -i)     _intermediate_=1 ;;
191         -n)     _trace_=echo ;;
192         -p)     _proto_= ;;
193         -t)     _total_=1 _trace_=: _components_= ;;
194         -u)     _uncrate_=1 ;;
195         -x)     set -x ;;
196         -E)     _ignore_=1 ;;
197         -F)     _force_=1 ;;
198         -L)     _proto_default_=pr ;;
199         -O)     _preserve_=1 ;;
200         -P)     _proto_opt_=z$_proto_opt_ ;;
201         --)     _options_="$_options_ $1"; shift; break ;;
202         '?'|[-+]*) echo "Usage: $_command_ [-cinptuxEF] [-r recipient] [-s spool-dir] [-X tool] [tool ...] [name=value ...]" >&2; exit 2 ;;
203         *=*)    eval `echo $1 | sed -e '/^[a-zA-Z0-9_]*=/!d' -e "s/\([^=]*\)=\(.*\)/i=\1 \1=\'\2\'/"`
204                 _export_="$_export_ $i"
205                 ;;
206         *)      break ;;
207         esac
208         _options_="$_options_ $1"
209         shift
210 done
211
212 #
213 # option controlled vars
214 #
215
216 export RECIPIENT
217 case $_uuspool_ in
218 "")     case $SHIPSPOOL in
219         "")     SHIPSPOOL="/usr/spool/uucppublic/$RECIPIENT/* /usr/spool/uucppublic/receive/$RECIPIENT/*" ;;
220         esac
221         ;;
222 *)      SHIPSPOOL=$_uuspool_ ;;
223 esac
224 export SHIPSPOOL
225
226 #
227 # must be in $INSTALLROOT
228 #
229
230 if      test ! -d ship
231 then    echo "$_command_: must have \$INSTALLROOT/ship directory" >&2; exit 1
232 fi
233
234 cd $SHIP
235 case $_trace_ in
236 ?*)     $_trace_ cd $SHIP ;;
237 esac
238 _tmp_=SHIPtmp
239
240 #
241 # best guess for cc command and flags
242 # probe info cached in $_ship_probe_
243 #
244
245 case $CC in
246 ""|cc)  test -f $INSTALLROOT/bin/cc && CC=$INSTALLROOT/bin/cc ;;
247 esac
248 case $CC in
249 $INSTALLROOT/bin/cc)
250         ;;
251 *)      _ship_probe_=SHIPprobe
252         _ship_probe_PATH=
253         _ship_probe_CC=
254         _ship_probe_CCFLAGS=
255         test -f $_ship_probe_ && . ./$_ship_probe_
256         case "+ $_ship_probe_PATH + $_ship_probe_CC +" in
257         "+ $PATH + $CC +")
258                 CC="$_ship_probe_CC $_ship_probe_CCFLAGS"
259                 case $_ship_probe_CCFLAGS in
260                 ?*)     CC="$CC $_ship_probe_CCFLAGS" ;;
261                 esac
262                 ;;
263         *)      _ship_probe_PATH=$PATH
264                 case $CC in
265                 "")     echo 'main() { return 0; }' > ${_tmp_}0.c
266                         cat > $_tmp_.c <<'!'
267 #include <stdio.h>
268 #include <limits.h>
269 #define STD_POSIX1      (1<<5)
270 #define STD_LIMITS      (1<<4)
271 #define STD_C           (0<<3)
272 #define STD_POSIX2      (1<<2)
273 #define STD_XOPEN       (1<<1)
274 #define STD_ALL         (1<<0)
275 main(argc, argv)
276 int     argc;
277 char**  argv;
278 {
279         int std = 0;
280 #ifdef __STDC__
281         std |= STD_C;
282 #endif
283 #ifdef CHAR_BIT
284         std |= STD_LIMITS;
285 #endif
286 #ifdef PIPE_BUF
287         std |= STD_POSIX1;
288 #endif
289 #ifdef LINE_MAX
290         std |= STD_POSIX2;
291 #endif
292 #ifdef DBL_MAX
293         std |= STD_XOPEN;
294 #endif
295 #ifdef PID_MAX
296         std |= STD_ALL;
297 #endif
298         printf("#ccflags#%04o#%s\n", std, argv[1]);
299         return 0;
300 }
301 !
302                         CC="`ifs=\$IFS
303                         IFS=:
304                         set /opt/SUNWspro/bin:+:$PATH:+:/opt/gnu/bin:/usr/add-on/gnu/bin:/usr/local/bin
305                         IFS=\$ifs
306                         path=\$*
307                         set cc 9 gcc 8 xlc 7 acc 6 apcc 5
308                         std=
309                         while   :
310                         do      case \$# in
311                                 0|1)    break ;;
312                                 esac
313                                 for bin in \$path -
314                                 do      case \$bin in
315                                         +)      std=1\$std; continue ;;
316                                         -)      break 2 ;;
317                                         esac
318                                         test -x \$bin/\$1 && break
319                                 done
320                                 case $std in
321                                 1)      cmd=\$1 ;;
322                                 *)      cmd=\$bin/\$1 ;;
323                                 esac
324                                 seq=
325                                 rm -f ${_tmp_}0.exe
326                                 \$cmd -o ${_tmp_}0.exe ${_tmp_}0.c && ./${_tmp_}0.exe &&
327                                 for opt in \
328                                 '' \
329                                 -D_ALL_SOURCE \
330                                 -D_ANSI_SOURCE \
331                                 -D_ANSI_C_SOURCE \
332                                 -D_POSIX_SOURCE \
333                                 -D_XOPEN_SOURCE \
334                                 '-D_ANSI_SOURCE -D_POSIX_SOURCE' \
335                                 '-D_ANSI_SOURCE -D_XOPEN_SOURCE' \
336                                 '-D_ANSI_C_SOURCE -D_POSIX_SOURCE' \
337                                 '-D_ANSI_C_SOURCE -D_XOPEN_SOURCE' \
338                                 '-D_POSIX_SOURCE -D_XOPEN_SOURCE' \
339                                 '-D_ANSI_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE' \
340                                 '-D_ANSI_C_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE' \
341                                 -posix
342                                 do      seq=x$seq
343                                         xxx=$cmd
344                                         case \$opt in
345                                         '')     tie=1 ;;
346                                         *)      xxx=\"\$xxx \$opt\" tie=0 ;;
347                                         esac
348                                         \$xxx $_tmp_.c -o $_tmp_.exe && ./$_tmp_.exe \"\$2#\$tie# \$seq#\$xxx\"
349                                 done
350                                 shift
351                                 shift
352                         done 2>/dev/null | sort +0r -1 +1 | grep '^#ccflags#' | sed -e '2,$d' -e 's/.*#//'`"
353                         rm -f ${_tmp_}*.*
354                         ;;
355                 esac
356                 case $CC in
357                 "")     CC=cc ;;
358                 esac
359                 echo 'int x;' > $_tmp_.c
360                 rm -f $_tmp_.o 2>/dev/null
361                 if      $CC -c $_tmp_.c >/dev/null 2>&1 && test -f $_tmp_.o
362                 then    : ok
363                 else    echo "$_command_: must have CC=\"$CC\" to continue" >&2
364                         exit 1
365                 fi
366                 _ship_probe_CC=$CC
367                 _ship_probe_CCFLAGS=
368         
369                 #
370                 # commit the wimps
371                 #
372         
373                 echo "#if !defined(TEST) && (defined(__STDC__) || defined(__cplusplus))
374 (
375 #else
376 #include <stddef.h>
377 #include <stdlib.h>
378 #include <stdarg.h>
379 #include <sys/types.h>
380 #if defined(TEST)
381 #define glue(a,b)       a ## b
382 glue(i, nt)
383 #else
384 int
385 #endif
386 main(int argc, char** argv) { return 0; }
387 #endif
388 " > $_tmp_.c
389                 if      $CC $CCFLAGS -c $_tmp_.c >/dev/null 2>&1
390                 then    if      $CC $CCFLAGS -DTEST -c $_tmp_.c >/dev/null 2>&1
391                         then    : ok
392                         elif    $CC -D__STDC__ $CCFLAGS -DTEST -c $_tmp_.c >/dev/null 2>&1
393                         then    CC="$CC -D__STDC__"
394                                 case $_ship_probe_CCFLAGS in
395                                 ?*)     _ship_probe_CCFLAGS="$_ship_probe_CCFLAGS " ;;
396                                 esac
397                                 _ship_probe_CCFLAGS="${_ship_probe_CCFLAGS}-D__STDC__"
398                         fi
399                 fi
400                 echo "#include <sys/types.h>
401 #include <sys/socket.h>
402 #include <netinet/in.h>
403 main() { return socket(0, 0, 0); }" > $_tmp_.c
404                 for i in "" "-systype bsd43"
405                 do      if      $CC $CCFLAGS $i -o $_tmp_.exe $_tmp_.c >/dev/null 2>&1
406                         then    case $i in
407                                 ?*)     CC="$CC $i"
408                                         case $_ship_probe_CCFLAGS in
409                                         ?*)     _ship_probe_CCFLAGS="$_ship_probe_CCFLAGS " ;;
410                                         esac
411                                         _ship_probe_CCFLAGS="${_ship_probe_CCFLAGS}$i"
412                                         ;;
413                                 esac
414                                 break
415                         fi
416                 done
417                 rm -f $_tmp_.*
418                 {
419                 echo _ship_probe_PATH="'$_ship_probe_PATH'"
420                 echo _ship_probe_CC="'$_ship_probe_CC'"
421                 echo _ship_probe_CCFLAGS="'$_ship_probe_CCFLAGS'"
422                 } > $_ship_probe_
423                 ;;
424         esac
425         ;;
426 esac
427
428 for i in $_export_
429 do      eval d='"$'$i'"'
430         case $d in
431         ?*)     export $i ;;
432         esac
433 done
434
435 #
436 # check the manifest and then copy from the spool area to $SHIP
437 #
438
439 case $_debug_ in
440 ?*)     SHIPSPOOL= ;;
441 esac
442 for UUSHIP in $SHIPSPOOL
443 do      if      test -d $UUSHIP
444         then    cd $UUSHIP
445                 case $_trace_ in
446                 ?*)     $_trace_ cd $UUSHIP ;;
447                 esac
448                 for f in ${SHIPDATE}*.*
449                 do      if      test -f $f/manifest
450                         then    _manifest_=`cat $f/manifest`
451                                 d=
452                                 for i in $_manifest_
453                                 do      if      test ! -f $i
454                                         then    case $i in 
455                                                 */*/*)  case $i in
456                                                         *.???)  p=`echo $i | sed -e 's/\....$//'` ;;
457                                                         *)      p=$i ;;
458                                                         esac
459                                                         if      test -d $SHIP/$p
460                                                         then    continue
461                                                         fi
462                                                         ;;
463                                                 esac
464                                                 echo "$f: $i has not arrived yet" >&2
465                                                 d=1
466                                         fi
467                                 done
468                                 case $d in
469                                 ?*)     continue ;;
470                                 esac
471                                 _unspool_=
472                                 for i in $_manifest_
473                                 do      case $i in
474                                         $f/unspool)     _unspool_=$i ;;
475                                         esac
476                                 done
477                                 if      test "" != "$_unspool_" -a -f $_unspool_ && $_trace_ . $_unspool_
478                                 then    : ok
479                                 else    echo "$f: cannot unspool shipment" >&2; continue
480                                 fi
481                                 d=
482                                 for i in $_manifest_
483                                 do      case $i in
484                                         $f/*)   ;;
485                                         *.000)  d="$d $i" ;;
486                                         */*.*)  ;;
487                                         */*/*)  d="$d $i" ;;
488                                         esac
489                                 done
490                                 d=`echo "$d " | sed -e 's,//*[^/ ]* , ,g'`
491                                 $_trace_ rm -rf $f $d
492                         fi
493                 done
494                 cd $INSTALLROOT
495                 case $_trace_ in
496                 ?*)     $_trace_ cd $INSTALLROOT ;;
497                 esac
498         fi
499 done
500
501 #
502 # check for shipment support update
503 #
504 #       B       install in $BIN
505 #       M       must exist
506 #       P       must exist on PATH
507 #
508
509 _path_=`echo $PATH | sed -e 's/:/ /g' -e 's,///*,/,g'`
510 _stamp_='`sed -e /@(#)$c'\''.* (AT.T.*).* [0-9][0-9]\\/[0-9][0-9]\\/[0-9][0-9]/!d'\'' -e '\''s/.*@(#).* (.*).* \\(..\\)\\/\\(..\\)\\/\\(..\\).*/\\3\\1\\2/'\'' -e q $f 2>/dev/null`'
511 _update_=
512 cd $SHIP
513 set     iffe    .sh             BM      \
514         in      ''              M       \
515         op      .c              M       \
516         proto   .c              BM      \
517         ar      /usr/ccs/bin    P       \
518         -- ${1+"$@"}
519 while   :
520 do      case $1 in
521         --)     shift; break ;;
522         esac
523         _cmd_=$1
524         _suf_=$2
525         _flg_=$3
526         shift; shift; shift
527         case $_flg_ in
528         *B*)    c=$_cmd_ ;;
529         *)      c=ship$_cmd_ ;;
530         esac
531         case $_flg_ in
532         *P*)    for i in $_path_
533                 do      if      test -x $i/$_cmd_
534                         then    _flg_=
535                                 break
536                         fi
537                 done
538                 case $_flg_ in
539                 *P*)    for i in $_suf_
540                         do      if      test -x $i/$_cmd_
541                                 then    PATH=$PATH:$i
542                                         _path_="$_path_ $i"
543                                         _flg_=
544                                         break
545                                 fi
546                         done
547                         case $_flg_ in
548                         *P*)    echo "$_command_: must have $_cmd_ to continue" >&2
549                                 exit 1
550                                 ;;
551                         esac
552                         ;;
553                 esac
554                 continue
555                 ;;
556         esac
557         eval _ship${_cmd_}_=$SHIP/ship$_cmd_
558         case $_trace_ in
559         ?*)     continue ;;
560         esac
561         if      test -f ship$_cmd_$_suf_
562         then    f=ship$_cmd_$_suf_; eval new=$_stamp_
563                 if      test -f SHIP$_cmd_$_suf_
564                 then    f=SHIP$_cmd_$_suf_; eval old=$_stamp_
565                 else    old=0
566                 fi
567         else    case $_flg_ in
568                 *M*)    echo "$_command_: must have ship$_cmd_$_suf_ to continue" >&2
569                         exit 1
570                         ;;
571                 esac
572                 eval _ship${_cmd_}_=
573                 continue
574         fi
575         # the variable "old" can be empty, to avoid "arithmetic syntax error" from ksh, set it to 0
576         if      test "$new" -gt "${old:-0}"
577         then    case $_suf_ in
578                 ?*)     cp ship$_cmd_$_suf_ SHIP$_cmd_$_suf_ ;;
579                 esac
580         elif    test "$new" -lt "$old"
581         then    cp SHIP$_cmd_$_suf_ ship$_cmd_$_suf_
582                 new=$old
583                 _update_="$_update_ $_cmd_$_suf_"
584         fi
585         case $_suf_ in
586         ?*)     f=ship$_cmd_; eval old=$_stamp_
587                 case $_suf_ in
588                 .c)     test -f $f && ./$f </dev/null >/dev/null 2>&1 || old=0 ;;
589                 esac
590                 # the variable "old" can be empty, to avoid "arithmetic syntax error" from ksh, set it to 0
591                 if      test "$new" -gt "${old:-0}"
592                 then    case $old in
593                         ""|0)   ;;
594                         *)      cp ship$_cmd_ SHIP$_cmd_ ;;
595                         esac
596                         case $_suf_ in
597                         .c)     if      $CC $CCFLAGS -o SHIPa.out ship$_cmd_$_suf_
598                                 then    mv SHIPa.out ship$_cmd_
599                                 else    case $old in
600                                         ""|0)   case $_flg_ in
601                                                 *M*)    echo "$_command_: must have ship$_cmd_ to continue" >&2
602                                                         exit 1
603                                                         ;;
604                                                 esac
605                                                 eval _ship${_cmd_}_=
606                                                 continue
607                                                 ;;
608                                         esac
609                                 fi
610                                 ;;
611                         .sh)    cp ship$_cmd_$_suf_ ship$_cmd_
612                                 chmod +x ship$_cmd_
613                                 ;;
614                         esac
615                 else    new=$old
616                 fi
617         esac
618         case $_flg_ in
619         *B*)    f=$BIN/$_cmd_; eval old=$_stamp_
620                 # the variable "old" can be empty, to avoid "arithmetic syntax error" from ksh, set it to 0
621                 if      test "$new" -gt "${old:-0}"
622                 then    if      test ! -d $BIN
623                         then    mkdir $BIN
624                         fi
625                         cp ship$_cmd_ $BIN/$_cmd_
626                 fi
627                 ;;
628         esac
629 done
630 case $_trace_ in
631 "")     test -x $BIN/feature || ln $BIN/iffe $BIN/feature ;;
632 esac
633 case $_proto_ in
634 "")     _shipproto_= ;;
635 esac
636 cd $INSTALLROOT
637 case " $_update_ " in
638 *" in "*)       $_trace_ exec $_command_ $_options_ ${1+"$@"} ;;
639 esac
640
641 #
642 # intermediate unpacking from spool area done
643 #
644
645 case $_debug_$_intermediate_ in
646 ?*)     exit 0 ;;
647 esac
648
649 #
650 # grab the select args
651 #
652
653 SELECT=" "
654 while   :
655 do      case $# in
656         0)      break ;;
657         esac
658         case $1 in
659         *=*)    break ;;
660         esac
661         SELECT="$SELECT$1 "
662         shift
663 done
664
665 #
666 # handle character class botch -- it's hard to believe 9th edition
667 # did this, easier to believe BSD never added it
668 #
669
670 cclasstype='^'
671 case a in
672 [${cclasstype}0]) ;;
673 [!0])   cclasstype='!' ;;
674 *)      cclasstype='' ;;
675 esac
676
677 #
678 # set up and verify the default directory hierarchy
679 #
680
681 hierarchy="src src/cmd src/lib ship/shipslog"
682 case $_uncrate_ in
683 "")     hierarchy="$hierarchy bin fun include lib man man/man1 man/man3 man/man8" ;;
684 esac
685 for d in $hierarchy
686 do      if      test ! -d $d
687         then    $_trace_ mkdir $d
688         fi
689 done
690 if      test ! -f src/Makefile
691 then    case $_trace_ in
692         "")     echo ":MAKE: lib - cmd" > src/Makefile ;;
693         *)      $_trace_ echo ":MAKE: lib - cmd" "> src/Makefile" ;;
694         esac
695 fi
696 if      test ! -f src/lib/Makefile
697 then    case $_trace_ in
698         "")     echo ':MAKE: lib[0-9]* - libast - *' > src/lib/Makefile ;;
699         *)      $_trace_ echo ':MAKE: lib[0-9]* - libast - *' '> src/lib/Makefile' ;;
700         esac
701 fi
702 if      test ! -f src/cmd/Makefile
703 then    case $_trace_ in
704         "")     echo ':MAKE: probe - cpp - *' > src/cmd/Makefile ;;
705         *)      $_trace_ echo ':MAKE: probe - cpp - *' '> src/cmd/Makefile' ;;
706         esac
707 fi
708
709 #
710 # ignore and silent may be used by nmake generated bootstraps
711 #
712
713 case $_trace_$_uncrate_ in
714 "")     if      test ! -f bin/ignore
715         then    cat > bin/ignore <<'!'
716 :
717 "$@"
718 exit 0
719 !
720                 chmod +x bin/ignore
721         fi
722         if      test ! -f bin/silent
723         then    cat > bin/silent <<'!'
724 :
725 case $1 in
726 +|-|"") exit 0 ;;
727 esac
728 "$@"
729 !
730                 chmod +x bin/silent
731         fi
732         ;;
733 esac
734 trap 'exit 2' 1 2
735
736 #
737 # check if we can use nmake from the start
738 # if so then limit proto to notices only
739 #
740
741 ACCEPT=nmake
742 _make_=
743 for p in $_path_
744 do      if      test -f $p/nmake && test "`$p/nmake -n -f - 'error 0 \$(MAKEVERSION:@/.*\\(..\\)\\/\\(..\\)\\/\\(..\\)\$/\\3\\1\\2/)' 'nop:' nop </dev/null 2>&1`" -ge "$OLDEST_nmake" 2>/dev/null
745         then    l=`echo $p | sed 's,[^/]*\$,lib,'`
746                 _make_="$p/nmake MAKEPP=$l/cpp MAKERULES=$l/make/makerules"
747                 ACCEPT=
748                 _proto_default_=d$_proto_default_
749                 break
750         fi
751 done
752 _proto_default_=$_proto_default_$_proto_opt_
753
754 #
755 # some context for nohup.out
756 #
757
758 if      test -f nohup.out
759 then    _nohup_="==============================================================================="
760         echo "$_nohup_"
761         id="`(uname -a) 2>/dev/null`"
762         case $id in
763         ?*)     echo "system           $id" ;;
764         esac
765         echo "installroot      $INSTALLROOT"
766         case $SHIPSPOOL in
767         *"*"*)  ;;
768         *)      echo "shipspool        $SHIPSPOOL" ;;
769         esac
770         case $INSTALLER in
771         $RECIPIENT)     echo "by               $FROMSYS!$INSTALLER" ;;
772         *)              echo "by               $FROMSYS!$INSTALLER for $RECIPIENT" ;;
773         esac
774         echo "archive          $AR_PATH $AR_DELTA"
775         case $_make_ in
776         ?*)     x=$_make_ ;;
777         *)      x=mamexec ;;
778         esac
779         echo "build            $x"
780         echo "cc               $CC $CCFLAGS"
781         case $CCS in
782         ?*)     echo "preroot          $CCS" ;;
783         esac
784         echo "start            `date`"
785         echo "$_nohup_"
786 else    _nohup_=
787 fi
788
789 #
790 # finish up initialization
791 #
792
793 case $_trace_ in
794 ?*)     $_trace_ cd $SHIP ;;
795 esac
796 cd $SHIP
797
798 #
799 # uncrate the archives into the source tree
800 #
801
802 COMPONENTS_SELECT=" "
803 for NAME in *
804 do      case $_exclude_ in
805         *" $NAME "*)    continue ;;
806         esac
807         if      test -f $NAME/items
808         then    # don't rebuild items under local control
809                 echo "$_command_: warning: $NAME: delete ship/$NAME/items to build" >&2
810                 continue
811         fi
812         case $cclasstype in
813         '!'|'^')
814                 case $NAME in
815                 *[${cclasstype}a-zA-Z_0-9]*)
816                         continue ;;
817                 esac
818                 ;;
819         '')     case "`echo $NAME | grep '[^a-zA-Z_0-9]'`" in
820                 ?*)     continue ;;
821                 esac
822                 ;;
823         esac
824         if      test -d $NAME
825         then    _release_=
826                 _state_=found
827                 case $NAME in
828                 *_*)    eval `echo $NAME | sed 's/\([^_]*\)_\(.*\)/_system_=\1 _tool_=\2/'`
829                         _root_=$INSTALLROOT/$_system_
830                         if      test ! -d $_root_
831                         then    $_trace_ mkdir $_root_
832                         fi
833                         for d in $hierarchy
834                         do      case $d in
835                                 ship/*) ;;
836                                 *)      if      test ! -d $_root_/$d
837                                         then    $_trace_ mkdir $_root_/$d
838                                         fi
839                                         ;;
840                                 esac
841                         done
842                         ;;
843                 *)      _root_=$INSTALLROOT
844                         _tool_=$NAME
845                         ;;
846                 esac
847                 case $_tool_ in
848                 lib*)   _type_=lib ;;
849                 *)      _type_=cmd ;;
850                 esac
851                 _source_=$_root_/src/$_type_/$_tool_
852                 if      test ! -d $_source_
853                 then    $_trace_ mkdir $_source_
854                 fi
855                 cd $NAME
856                 base=   # newest base
857                 delta=  # newest delta for newest base [not in dlist]
858                 dlist=  # list of deltas for newest base [no delta]
859                 need=   # pax needed to uncrate
860                 new=    # delta shipments requiring new base
861                 old=    # first base for new chain
862                 remove= # old shipments to be removed
863                 type=   # base|delete|delta|patch
864                 for d in $SHIPMENT
865                 do      case $d in
866                         "$SHIPMENT") continue ;;
867                         esac
868                         if      test -f $d/base -o -f $d/delete
869                         then    remove="$remove $base $dlist $delta $need $new"
870                                 base=$d
871                                 delta=
872                                 need=
873                                 new=
874                                 if      test -f $d/delete
875                                 then    type=delete
876                                 else    type=base
877                                 fi
878                         else    if      test "" != "$base" -a -f $d/$base && egrep 'DELTA!!!|!PAX!D!' $d/$base >/dev/null
879                                 then    case $AR_DELTA in
880                                         "")     need="$need $d"
881                                                 continue
882                                                 ;;
883                                         esac
884                                         type=delta
885                                 else    type=patch
886                                 fi
887                                 case $base in
888                                 "")     dlist="$dlist $d"
889                                         ;;
890                                 *)      if      test -f $d/$base
891                                         then    dlist="$dlist $delta"
892                                                 delta=$d
893                                         elif    test "" != "$delta" -a -f $d/$delta
894                                         then    dlist="$dlist $base"
895                                                 case $new in
896                                                 "")     old=$base ;;
897                                                 esac
898                                                 new="$new $delta"
899                                                 base=$delta
900                                                 delta=$d
901                                         else    dlist="$dlist $d"
902                                         fi
903                                         ;;
904                                 esac
905                         fi
906                 done
907                 case $type in
908                 delete) case $NAME in
909                         lib*)   i=lib ;;
910                         *)      i=cmd ;;
911                         esac
912                         cd $SHIP
913                         $_trace_ rm -rf $SHIP/$NAME $INSTALLROOT/src/$i/$NAME
914                         continue
915                         ;;
916                 esac
917                 for i in $new
918                 do      echo generate $NAME $i base from $old >&2
919                         case $_trace_ in
920                         "")     echo "generate $NAME $i base from $old [`date`]" >> $SHIP/$NAME/$LOG
921                                 case $type in
922                                 delta)  $AR_DELTA -rf $i/$old -z $old/base -wf $i/base
923                                         _code_=$?
924                                         ;;
925                                 patch)  mkdir /tmp/ship.$$
926                                         cd /tmp/ship.$$
927                                         $AR_READ < $SHIP/$NAME/$old/base &&
928                                         $AR_READ < $SHIP/$NAME/$i/$old &&
929                                         {
930                                         $AR_LIST < $SHIP/$NAME/$old/base 
931                                         $AR_LIST < $SHIP/$NAME/$i/$old 
932                                         } | sort -u | $AR_WRITE > $SHIP/$NAME/$i/base
933                                         _code_=$?
934                                         cd $SHIP/$NAME
935                                         rm -rf /tmp/ship.$$
936                                         ;;
937                                 esac
938                                 case $_code_ in
939                                 0)      touch $i/GENERATED
940                                         ;;
941                                 *)      echo "cannot generate $i base from $old" >&2
942                                         echo "cannot generate $i base from $old" >> $SHIP/$NAME/$LOG
943                                         break
944                                         ;;
945                                 esac
946                                 ;;
947                         *)      $_trace_ $AR_DELTA -rf $SHIP/$NAME/$i/$old -z $SHIP/$NAME/$old/base -wf $i/base
948                                 $_trace_ touch $SHIP/$NAME/$i/GENERATED
949                                 ;;
950                         esac
951                         old=$i
952                 done
953                 case $base in
954                 "")     echo "$_command_: warning: $NAME: no base archive" >&2
955                         cd $SHIP
956                         continue
957                         ;;
958                 esac
959                 case $_preserve_ in
960                 ?*)     case `echo $remove $dlist` in
961                         ?*)     case $_trace_ in
962                                 "")     rm -rf $remove $dlist 2>/dev/null ;;
963                                 *)      $_trace_ "(cd $NAME; rm -rf" $remove $dlist")" ;;
964                                 esac
965                                 ;;
966                         esac
967                         ;;
968                 esac
969                 $_trace_ cd $_source_
970                 case $delta in
971                 "")     _release_=$base ;;
972                 *)      _release_=$delta ;;
973                 esac
974                 if      test 11 = "$_force_$_uncrate_" -o ! -f $SHIP/$NAME/$_release_/UNCRATED
975                 then    echo uncrate $NAME $_release_ $type >&2
976                         case $_trace_ in
977                         "")     echo "uncrate $NAME $_release_ $type [`date`]" >> $SHIP/$NAME/$LOG ;;
978                         esac
979                         error=
980                         if      test -f $SHIP/$NAME/$_release_/delete
981                         then    cd $SHIP
982                                 rm -rf $NAME
983                                 continue
984                         fi
985                         if      test ! -f $SHIP/$NAME/$_release_/items
986                         then    echo "$_command_: warning: $NAME: no items file" >&2
987                         fi
988                         _proto_options_="-${_proto_default_}c`cat $SHIP/$NAME/$_release_/copyright 2>/dev/null`"
989                         if      test "" = "$AAR_LIST" -o "delta" = "$type" || $OAR_LIST < $SHIP/$NAME/$base/base >/dev/null 2>&1
990                         then    AR_PATH=$OAR_PATH
991                                 AR_LIST=$OAR_LIST
992                                 AR_READ=$OAR_READ
993                                 AR_WRITE=$OAR_WRITE
994                         else    AR_PATH=$AAR_PATH
995                                 AR_LIST=$AAR_LIST
996                                 AR_READ=$AAR_READ
997                                 AR_WRITE=$AAR_WRITE
998                         fi
999                         for i in base $base
1000                         do      case $type in
1001                                 base|patch)
1002                                         case $type in
1003                                         base)   if      test ! -f $SHIP/$NAME/$_release_/GENERATED
1004                                                 then    case $_trace_ in
1005                                                         "")     rm -rf * ;;
1006                                                         *)      $_trace_ "(cd $_source_; rm -rf *)" ;;
1007                                                         esac
1008                                                 fi
1009                                                 ;;
1010                                         esac
1011                                         _base_=$i
1012                                         case $_base_ in
1013                                         base)   _release_=$base ;;
1014                                         *)      _release_=$delta ;;
1015                                         esac
1016                                         case $_trace_ in
1017                                         "")     if      $AR_READ < $SHIP/$NAME/$_release_/$_base_
1018                                                 then    case $_shipproto_ in
1019                                                         ?*)     $AR_LIST <$SHIP/$NAME/$_release_/$_base_ 2>/dev/null | grep '\.[chlyY]$' | $_shipproto_ -l - "${_proto_options_}"
1020                                                                 ;;
1021                                                         esac
1022                                                         if      test -d features && test ! -d feature
1023                                                         then    ln -s features feature 2>/dev/null
1024                                                         elif    test -d feature && test ! -d features
1025                                                         then    ln -s feature features 2>/dev/null
1026                                                         fi
1027                                                 else    error="$AR_PATH $type read failed"
1028                                                 fi
1029                                                 ;;
1030                                         *)      $_trace_ "$AR_READ < $SHIP/$NAME/$_release_/$_base_"
1031                                                 case $_shipproto_ in
1032                                                 ?*)     $_trace_ "$AR_LIST <$SHIP/$NAME/$_release_/$_base_ 2>/dev/null | grep '\.[chlyY]\$' | $_shipproto_ -l - ${_proto_options_}" ;;
1033                                                 esac
1034                                                 ;;
1035                                         esac
1036                                         case $type in
1037                                         base)   break ;;
1038                                         esac
1039                                         ;;
1040                                 delta)  if      $_trace_ $AR_DELTA -rf $SHIP/$NAME/$_release_/$base -z $SHIP/$NAME/$base/base
1041                                         then    $_trace_ touch $SHIP/$NAME/$base/UNCRATED
1042                                                 case $_shipproto_ in
1043                                                 ?*)     case $_trace_ in
1044                                                         "")     ($AR_DELTA -f $SHIP/$NAME/$base/base '*.[chlyY]'; $AR_DELTA -f $SHIP/$NAME/$_release_/$base '*.[chlyY]') 2>/dev/null | sort -u | $_shipproto_ -l - "${_proto_options_}" ;;
1045                                                         *)      $_trace_ "($AR_DELTA -f $SHIP/$NAME/$base/base '*.[chlyY]'; $AR_DELTA -f $SHIP/$NAME/$_release_/$base '*.[chlyY]') 2>/dev/null | sort -u | $_shipproto_ -l - ${_proto_options_}" ;;
1046                                                         esac
1047                                                         ;;
1048                                                 esac
1049                                                 case $_trace_ in
1050                                                 "")     if      test -d features && test ! -d feature
1051                                                         then    ln -s features feature 2>/dev/null
1052                                                         elif    test -d feature && test ! -d features
1053                                                         then    ln -s feature features 2>/dev/null
1054                                                         fi
1055                                                         ;;
1056                                                 esac
1057                                         else    error="$AR_DELTA $type read failed"
1058                                         fi
1059                                         break
1060                                         ;;
1061                                 esac
1062                         done
1063                         case $error in
1064                         "")     $_trace_ touch $SHIP/$NAME/$_release_/UNCRATED ;;
1065                         *)      echo "$_command_: $NAME: $_release_: uncrate error: $error" >&2
1066                                 case $_trace_ in
1067                                 "")     echo "uncrate $NAME $_release_ $type error: $error" >> $SHIP/$NAME/$LOG ;;
1068                                 esac
1069                                 _state_=error
1070                                 ;;
1071                         esac
1072                 fi
1073                 cd $SHIP
1074                 eval STATE_$NAME=$_state_
1075                 case $_state_ in
1076                 error)  ;;
1077                 *)      case $need in
1078                         ?*)     for i in $need
1079                                 do      NEED_pax="$NEED_pax $NAME/$i"
1080                                 done
1081                                 ;;
1082                         *)      eval RELEASE_$NAME=$_release_ SOURCE_$NAME=$_source_ TOOL_$NAME=$_tool_
1083                                 COMPONENTS_SELECT="$COMPONENTS_SELECT$NAME "
1084                                 ;;
1085                         esac
1086                         ;;
1087                 esac
1088         fi
1089 done
1090 case $COMPONENTS_SELECT in
1091 " ")    exit 0 ;;
1092 esac
1093 case $_uncrate_ in
1094 ?*)     case $NEED_pax in
1095         ?*)     case $STATE_pax in
1096                 found)  ;;
1097                 *)      echo $_command_: pax required to uncrate$NEED_pax >&2 ;;
1098                 esac
1099                 ;;
1100         esac
1101         exit 0
1102         ;;
1103 esac
1104
1105 #
1106 # determine the ordered list of components to (re)build
1107 #
1108
1109 case $SELECT in
1110 " ")    COMPONENTS="$ORDER $COMPONENTS_SELECT" ;;
1111 *)      COMPONENTS=
1112         for NAME in $COMPONENTS_SELECT
1113         do      case $SELECT in
1114                 *" $NAME "*)    COMPONENTS="$COMPONENTS $NAME" ;;
1115                 esac
1116         done
1117         ;;
1118 esac
1119
1120 #
1121 # get the component closure
1122 #
1123
1124 case $_closure_ in
1125 "")     ORDER=$COMPONENTS
1126         ;;
1127 *)      ORDER=
1128         for NAME in $COMPONENTS
1129         do      old=
1130                 new=$NAME
1131                 while :
1132                 do      case $new in
1133                         $old)   break ;;
1134                         esac
1135                         dup=
1136                         for _item_ in $new
1137                         do      # we assume ITEMS_* not in environment
1138                                 eval _items_='"$'ITEMS_$_item_'"'
1139                                 case $_items_ in
1140                                 "")     eval _release_='$'RELEASE_$_item_
1141                                         _items_=`cat $_item_/$_release_/items 2>/dev/null`" $_item_"
1142                                         eval ITEMS_$_item_='"$'_items_'"'
1143                                         ;;
1144                                 esac
1145                                 dup="$dup $_items_"
1146                         done
1147                         old=$new
1148                         new=
1149                         for _item_ in $dup
1150                         do      eval SEEN_$_item_=
1151                         done
1152                         for _item_ in $dup
1153                         do      eval seen='$'SEEN_$_item_
1154                                 case $seen in
1155                                 "")     eval SEEN_$_item_=1
1156                                         new="$new $_item_"
1157                                         ;;
1158                                 esac
1159                         done
1160                 done
1161                 eval ITEMS_$NAME='"'$new'"'
1162                 ORDER="$ORDER $new"
1163         done
1164         dup=$ORDER
1165         ORDER=
1166         for NAME in $dup
1167         do      eval SEEN_$NAME=
1168         done
1169         for NAME in $dup
1170         do      eval seen='$'SEEN_$NAME
1171                 case $seen in
1172                 "")     eval SEEN_$NAME=1
1173                         ORDER="$ORDER $NAME"
1174                         ;;
1175                 esac
1176         done
1177         ;;
1178 esac
1179 _built_=
1180 COMPONENTS=
1181
1182 for NAME in $ORDER
1183 do      case $_exclude_ in
1184         *" $NAME "*)    continue ;;
1185         esac
1186         eval _release_='$'RELEASE_$NAME
1187         test -f $NAME/$_release_/items || continue
1188         case $_force_ in
1189         "")     _built_=$NAME/$_release_/BUILT
1190                 eval _items_='$'ITEMS_$NAME
1191                 for i in $_items_
1192                 do      case " $COMPONENTS " in
1193                         *" $i "*)       _built_=; break ;;
1194                         esac
1195                         case $i in
1196                         $NAME)  ;;
1197                         *)      eval _built_='"'$_built_ $i/'$'RELEASE_$i/BUILT'"' ;;
1198                         esac
1199                 done
1200                 case $_built_ in
1201                 ?*)     if      $_shipop_ newer $_built_
1202                         then    continue
1203                         fi
1204                         ;;
1205                 esac
1206                 ;;
1207         esac
1208         $_trace_ rm -f $NAME/$_release_/BUILT
1209         if      test "" != "$_force_" -o "" != "$_ignore_" -o ! -f $NAME/$_release_/ERROR
1210         then    COMPONENTS="$COMPONENTS $NAME"
1211                 $_trace_ rm -f $NAME/$_release_/ERROR
1212         elif    test ! -f $NAME/$_release_/BYPASS
1213         then    echo "$_command_: $NAME/$_release_: new shipment required" >&2
1214         fi
1215 done
1216
1217 #
1218 # tame the environment
1219 #
1220
1221 case $_make_ in
1222 ?*)     STATE_nmake=installed ;;
1223 esac
1224 case $_make_ in
1225 ""|$BIN/nmake)
1226         MAKEPP=$INSTALLROOT/lib/cpp
1227         MAKERULES=$INSTALLROOT/lib/make/makerules
1228         export MAKEPP MAKERULES
1229         _make_=$BIN/nmake
1230         ;;
1231 esac
1232 COSHELL_OPTIONS=nodevfd
1233 ENV=
1234 MAKE_OPTIONS="clobber compare link=lib*.a*"
1235 MAKEPATH=
1236 PATH=:$INSTALLROOT/bin:$PATH
1237 VPATH=
1238 export COSHELL_OPTIONS ENV MAKE_OPTIONS MAKEPATH PATH VPATH
1239 case $_AST_FEATURES in
1240 "")     _AST_FEATURES='UNIVERSE - att PATH_RESOLVE - logical'
1241         export _AST_FEATURES
1242         ;;
1243 esac
1244
1245 #
1246 # (re)build the components
1247 #
1248
1249 cd $INSTALLROOT
1250 for NAME in $COMPONENTS
1251 do      case $_exclude_ in
1252         *" $NAME "*)    continue ;;
1253         esac
1254         eval _items_='$'ITEMS_$NAME
1255         case $_trace_ in
1256         "")     for i in $_items_
1257                 do      case $i in
1258                         $NAME)  ;;
1259                         *)      eval r='$'RELEASE_$i
1260                                 if      test ! -f $SHIP/$i/$r/BUILT
1261                                 then    if      test -f $SHIP/$i/$r/ERROR
1262                                         then    m="had build errors"
1263                                         elif    test -f $SHIP/$i/$r/UNCRATED
1264                                         then    m="was not built"
1265                                         else    m="was not shipped"
1266                                         fi
1267                                         m="$NAME requires $i but $i $m"
1268                                         echo "$m" >&2
1269                                         echo "$m" >> $SHIP/$NAME/$LOG
1270                                         continue 2
1271                                 fi
1272                                 ;;
1273                         esac
1274                 done
1275                 ;;
1276         esac
1277         eval _release_='$'RELEASE_$NAME _source_='$'SOURCE_$NAME _tool_='$'TOOL_$NAME
1278         case $_total_ in
1279         ?*)     _components_="$_components_ $NAME/$_release_"
1280                 continue
1281                 ;;
1282         esac
1283         echo build $NAME $_release_ >&2
1284         $_trace_ cd $_source_
1285         case $_trace_ in
1286         "")     start="`date`"
1287                 if      test -f $_bypass_
1288                 then    touch $SHIP/$NAME/$_release_/BYPASS
1289                 else    case $STATE_nmake in
1290                         installed|ok)
1291                                 case $NAME in
1292                                 nmake)  $_make_ -o "ignorelock mismatch" ${1+"$@"}
1293                                         MAKEPP=$INSTALLROOT/lib/cpp ./nmake -o "ignorelock mismatch" -bcf Makerules.mk
1294                                         MAKEPP=$INSTALLROOT/lib/cpp MAKERULES=./Makerules.mo ./nmake -o "ignorelock mismatch" install ${1+"$@"}
1295                                         ;;
1296                                 *)      $_make_ -o "ignorelock mismatch" install ${1+"$@"}
1297                                         ;;
1298                                 esac
1299                                 error=$?
1300                                 ;;
1301                         *)      if      test -f Mamfile
1302                                 then    # here it is -- make+state in v7 shell
1303 case $_read_ in
1304 "")     case `(echo ok | (read -r a; echo $a) 2>/dev/null)` in
1305         ok)     _read_='read -r' ;;
1306         *)      _read_=read ;;
1307         esac
1308         eval `(
1309         mkdir /tmp/mam$$
1310         cd /tmp/mam$$
1311         echo 'main(){return 0;}' > main.c
1312         if      $CC -c main.c >/dev/null 2>&1
1313         then    if      $CC -L. main.o -lc >/dev/null 2>&1
1314                 then    $CC -L. main.o -lc > libc.a >/dev/null 2>&1 || echo "mam_cc_L=' '"
1315                 fi
1316         fi
1317         echo "int f(){return(0);} main(){return(f());}" > pic.c
1318         if      $CC -c pic.c >/dev/null 2>e
1319         then    e=\`wc -l e\`
1320                 s=\`wc pic.o\`
1321                 set x -Kpic -fpic -pic +z '-G 0'
1322                 while   :
1323                 do      shift
1324                         case $# in
1325                         0)      break ;;
1326                         esac
1327                         rm -f pic.o pic.exe
1328                         $CC $1 -c pic.c >/dev/null 2>e && test -f pic.o && $CC $1 -o ./pic.exe pic.o >/dev/null 2>&1 && test -f pic.exe || continue
1329                         case \`wc -l e\` in
1330                         $e)     ;;
1331                         *)      continue ;;
1332                         esac
1333                         case $1 in
1334                         ???*)   os=\`wc pic.o\`
1335                                 case $os in
1336                                 $s)     continue ;;
1337                                 esac
1338                                 m=\`echo " $1" | sed -e 's/^ [-+]//g' -e 's/./-& /g' -e 's/[-+] //g'\`
1339                                 rm -f pic.o pic.exe
1340                                 if      $CC $m -c pic.c >/dev/null 2>e && test -f pic.o && $CC $m -o ./pic.exe pic.o >/dev/null 2>&1 && test -f pic.exe
1341                                 then    case \`wc -l e\` in
1342                                         $e)     continue
1343                                                 ;;
1344                                         *)      case \`wc pic.o\` in
1345                                                 $s|$os) continue ;;
1346                                                 esac
1347                                                 ;;
1348                                         esac
1349                                 fi
1350                                 echo "mam_cc_PIC='$1'"
1351                                 break
1352                                 ;;
1353                         *)      case \`wc pic.o\` in
1354                                 $s)     ;;
1355                                 *)      echo "mam_cc_PIC='$1'"
1356                                         break
1357                                         ;;
1358                                 esac
1359                                 ;;
1360                         esac
1361                 done
1362         fi
1363         cd /
1364         rm -rf /tmp/mam$$
1365         )`
1366         ;;
1367 esac
1368 case $_redirect_ in
1369 "")     case `(a=old; eval a=new </dev/null; echo $a) 2>/dev/null` in
1370         new)    _redirect_=new ;;
1371         *)      _redirect_=old ;;
1372         esac
1373         ;;
1374 esac
1375 (
1376 _code_=1
1377 _list_=
1378 _main_=0
1379 _mam_=MAM
1380 _targ_=install
1381
1382 trap "
1383         mv $_mam_.list.tmp $_mam_.list
1384         rm -f $_mam_.*.tmp
1385         $_shipop_ state $_mam_.list < $_mam_.list | sort > $_mam_.time
1386         trap 0 1 2
1387         exit \$_code_
1388 " 0 1 2
1389 # some shells die with diff,next,same in vars
1390 : > $_mam_.diff.tmp
1391 exec 9> $_mam_.list.tmp
1392 if      test -f $_mam_.list -a -f $_mam_.time
1393 then    $_shipop_ state $_mam_.list < $_mam_.list | sort > $_mam_.sort.tmp
1394         comm -12 $_mam_.time $_mam_.sort.tmp | sed 's/ .*//' > $_mam_.same.tmp
1395         rm -f $_mam_.sort.tmp
1396 else    : > $_mam_.same.tmp
1397 fi
1398
1399 _index_=_
1400 _ifs_=$IFS
1401 case $_read_ in
1402 "read") # read strips \ -- thanks a lot
1403         # tmp file avoids char at a time read
1404         sed 's/\\/\\\\/g' Mamfile > $_mam_.read.tmp
1405         exec < $_mam_.read.tmp
1406         ;;
1407 *)      exec < Mamfile
1408         ;;
1409 esac
1410 eval `sed -e '1,/^make /d' -e '/^setv /!d' -e 's/^setv \([^     ]*\).*/\1= /' Mamfile`
1411 for _data_
1412 do      eval `echo $_data_ | sed -e 's/\"/\\\\"/g' -e 's/=/=\\"/' -e 's/\$/\\"/'`
1413 done
1414 _old_=1
1415 while   IFS=' '; $_read_ _op_ _arg_ _val_
1416 do      IFS=$_ifs_
1417         case $_op_ in
1418         "note") continue
1419                 ;;
1420         "info") case $_arg_ in
1421                 "mam")  _old_= ;;
1422                 esac
1423                 continue
1424                 ;;
1425         "setv") eval _data_='$'$_arg_
1426                 case $_index_:$_data_ in
1427                 __*:*|*:)
1428                         case $_redirect_ in
1429                         new)    eval $_arg_="$_val_" </dev/null
1430                                 ;;
1431                         old)    exec 8<&0 0</dev/null
1432                                 eval $_arg_="$_val_"
1433                                 exec 0<&8 8<&-
1434                                 ;;
1435                         esac
1436                         ;;
1437                 esac
1438                 continue
1439                 ;;
1440         "make") eval _name_$_index_=$_name_
1441                 eval _prev_$_index_=$_prev_
1442                 eval _cmds_$_index_='"$_cmds_"'
1443                 eval _attr_$_index_=$_attr_
1444                 eval _name_=$_arg_
1445                 _prev_=$_index_
1446                 _cmds_=
1447                 _attr_=u
1448                 case $_main_ in
1449                 0)      case $_name_ in
1450                         $_targ_)_main_=1 ;;
1451                         *)      _attr_= ;;
1452                         esac
1453                         ;;
1454                 1)      case $_force_ in
1455                         "")     grep "^$_name_\$" $_mam_.same.tmp >/dev/null && _attr_= ;;
1456                         esac
1457                         ;;
1458                 *)      _attr_=
1459                         ;;
1460                 esac
1461                 case " $_val_ " in
1462                 *" metarule "*) _attr_=M$_attr_ ;;
1463                 esac
1464                 case $_attr_ in
1465                 *u*)    echo $_name_ >> $_mam_.diff.tmp ;;
1466                 esac
1467                 _index_=_$_index_
1468                 eval _name_$_index_=$_name_
1469                 eval _prev_$_index_=$_prev_
1470                 eval _cmds_$_index_=$_cmds_
1471                 eval _attr_$_index_=$_attr_
1472                 echo $_name_ >&9
1473                 continue
1474                 ;;
1475         "prev") case $_attr_ in
1476                 *u*)    ;;
1477                 *)      case $_force_ in
1478                         "")     eval _arg_=$_arg_
1479                                 if      grep "^$_arg_\$" $_mam_.diff.tmp >/dev/null
1480                                 then    _attr_=u$_attr_
1481                                 elif    grep "^$_arg_\$" $_mam_.same.tmp >/dev/null
1482                                 then    :
1483                                 else    _attr_=u$_attr_
1484                                 fi
1485                                 ;;
1486                         *)      _attr_=u$_attr_
1487                                 ;;
1488                         esac
1489                         ;;
1490                 esac
1491                 continue
1492                 ;;
1493         esac
1494         case $_index_ in
1495         _)      echo $_op_: missing make op >&2; continue ;;
1496         esac
1497         case $_op_ in
1498         "attr") case $_arg_ in
1499                 "meta"|"suff")  _attr_=M ;;
1500                 esac
1501                 ;;
1502         "exec"|"....")
1503                 case $_old_ in
1504                 "")     _arg_=$_val_
1505                         ;;
1506                 *)      case $_val_ in
1507                         ?*)     _arg_="$_arg_ $_val_" ;;
1508                         esac
1509                         ;;
1510                 esac
1511                 case $_cmds_ in
1512                 "")     _cmds_=$_arg_
1513                         ;;
1514                 *)      _cmds_="$_cmds_
1515 $_arg_"
1516                         ;;
1517                 esac
1518                 ;;
1519         "done") eval _arg_=$_arg_
1520                 _prop_=
1521                 case $_arg_ in
1522                 $_targ_)        _main_=2 ;;
1523                 esac
1524                 case $_arg_ in
1525                 $_name_)case $_attr_ in
1526                         *M*)    ;;
1527                         *u*)    case $_cmds_ in
1528                                 "")     case $_attr_ in
1529                                         *u*)    _prop_=u ;;
1530                                         esac
1531                                         ;;
1532                                 *)      eval "($_set_$_cmds_) </dev/null" ||
1533                                         {
1534                                         _status_=$?
1535                                         case $_set_ in
1536                                         *-*e*)  ;;
1537                                         *)      case $_cmds_ in
1538                                                 *if*then*fi*|"||")      _status_=0 ;;
1539                                                 esac
1540                                                 ;;
1541                                         esac
1542                                         case $_status_ in
1543                                         0)      ;;
1544                                         *)      echo "*** exit code $_status_ making $_name_" >&2
1545                                                 _code_=$_status_
1546                                                 exit $_code_
1547                                                 ;;
1548                                         esac
1549                                         }
1550                                         _prop_=u
1551                                         echo $_name_ >> $_mam_.diff.tmp
1552                                         ;;
1553                                 esac
1554                                 ;;
1555                         esac
1556                         _index_=$_prev_
1557                         eval _name_='$'_name_$_index_
1558                         eval _prev_='$'_prev_$_index_
1559                         eval _cmds_='$'_cmds_$_index_
1560                         eval _attr_='$'_attr_$_index_
1561                         case $_attr_ in
1562                         *u*)    ;;
1563                         *)      _attr_=$_prop_$_attr_ ;;
1564                         esac
1565                         ;;
1566                 *)      echo $_arg_: $_op_ $_name_ expected >&2
1567                         ;;
1568                 esac
1569                 ;;
1570         esac
1571 done
1572 exec 9>&-
1573 case $_main_ in
1574 2)      _code_=0 ;;
1575 *)      echo "*** don't know how to make $_targ_" >&2 ;;
1576 esac
1577 exit $_code_
1578 ); error=$?
1579                                         # ... indent
1580                                 elif    test -f makefile
1581                                 then    make -f makefile install ${1+"$@"}; error=$?
1582                                 elif    test -f Makescript
1583                                 then    ./Makescript ${1+"$@"}; error=$?
1584                                 elif    test -f $_tool_.bs
1585                                 then    ./$_tool_.bs ${1+"$@"}; error=$?
1586                                 else    echo "$_command_: cannot build $NAME" >&2; error=1
1587                                 fi
1588                                 ;;
1589                         esac
1590                         case $error+$NAME in
1591                         0+nmake) $BIN/nmake -n -f /dev/null debug </dev/null >/dev/null 2>&1 || error=1 ;;
1592                         esac
1593                         case $error in
1594                         0)      touch $SHIP/$NAME/$_release_/BUILT ;;
1595                         *)      touch $SHIP/$NAME/$_release_/ERROR ;;
1596                         esac
1597                 fi 2>&1 | (PATH=$OPATH; tee $SHIP/$NAME/$TMP 1>&2)
1598                 if      test -f $SHIP/$NAME/$_release_/BUILT
1599                 then    state=ok
1600                 elif    test -f $SHIP/$NAME/$_release_/BYPASS
1601                 then    state=bypass
1602                 else    state=error
1603                 fi
1604                 {
1605                         echo "build $NAME $_release_ $state [$start] [`date`]"
1606                         case $CCS in
1607                         ?*)     echo preroot CCS = $CCS ;;
1608                         esac
1609                         # some egreps blow this
1610                         sed \
1611                         -e '/^$/d' \
1612                         -e '/^[         ]/d' \
1613                         -e '/^+ /d' \
1614                         -e '/^[^        ]*:$/d' \
1615                         -e '/^[a-z] - /d' \
1616                         -e '/^[a-zA-Z_][a-zA-Z_0-9]*$/d' \
1617                         -e '/^[a-zA-Z_][a-zA-Z_0-9]*=/d' \
1618                         -e '/[Cc]opyright/d' \
1619                         -e '/: warning: assignment .* == was expected/d' \
1620                         -e '/: warning: if .* no effect/d' \
1621                         -e '/: warning: Symbol .* multiply defined/d' \
1622                                 $SHIP/$NAME/$TMP
1623                         rm -f $SHIP/$NAME/$TMP
1624                 } >> $SHIP/$NAME/$LOG 2> /dev/null
1625                 eval STATE_$NAME=$state
1626                 ;;
1627         *)      if      test -f $_source_/$_bypass_
1628                 then    $_trace_ "refer to $_source_/$_bypass_ to install $NAME"
1629                 else    case $STATE_nmake in
1630                         installed|ok)
1631                                 case $NAME in
1632                                 nmake)  $_trace_ $_make_ -o "ignorelock mismatch" ${1+"$@"}
1633                                         $_trace_ ./nmake -o "ignorelock mismatch" -bcf Makerules.mk
1634                                         $_trace_ ./nmake -o "ignorelock mismatch" install ${1+"$@"}
1635                                         ;;
1636                                 *)      $_trace_ $_make_ -o "ignorelock mismatch" install ${1+"$@"}
1637                                         ;;
1638                                 esac
1639                                 ;;
1640                         *)      if      test -f $_source_/Mamfile
1641                                 then    $_trace_ "mamexec < Mamfile"
1642                                 elif    test -f $_source_/Makescript
1643                                 then    $_trace_ ./Makescript ${1+"$@"}
1644                                 elif    test -f $_source_/$_tool_.bs
1645                                 then    $_trace_ ./$_tool_.bs ${1+"$@"}
1646                                 else    $_trace_ install $NAME
1647                                 fi
1648                                 ;;
1649                         esac
1650                 fi
1651                 ;;
1652         esac
1653         $_trace_ cd $INSTALLROOT
1654
1655         #
1656         # accept stuff built before nmake to sync the state files
1657         #
1658
1659         case $NAME in
1660         $ACCEPT)
1661                 for NAME in $COMPONENTS
1662                 do      eval state='$'STATE_$NAME _source_='$'SOURCE_$NAME
1663                         case $state in
1664                         ok)     case $_trace_ in
1665                                 "")     cd $_source_
1666                                         {
1667                                                 $BIN/nmake -o "accept ignorelock mismatch touch" install force_shared=1
1668                                                 case $NAME in
1669                                                 lib*)   $BIN/nmake -o "accept" install ;;
1670                                                 esac
1671                                         } 2>&1 | (PATH=$OPATH; tee $SHIP/$NAME/$TMP 1>&2)
1672                                         {
1673                                                 echo "accept $NAME"
1674                                                 egrep -v '^([^  ]*:$|   |\+ |[a-z] - |[a-zA-Z_][a-zA-Z_0-9]*=|$)' $SHIP/$NAME/$TMP
1675                                                 rm -f $SHIP/$NAME/$TMP
1676                                         } 2>&1 >> $SHIP/$NAME/$LOG
1677                                         cd $INSTALLROOT
1678                                         ;;
1679                                 *)      $_trace_ cd $_source_
1680                                         $_trace_ $BIN/nmake -o "accept ignorelock mismatch touch" install force_shared=1
1681                                         case $NAME in
1682                                         lib*)   $_trace_ $BIN/nmake -o "accept" install ;;
1683                                         esac
1684                                         $_trace_ cd $INSTALLROOT
1685                                         ;;
1686                                 esac
1687                                 ;;
1688                         esac
1689                 done
1690                 case $NAME in
1691                 $ACCEPT)        break ;;
1692                 esac
1693                 ;;
1694         esac
1695 done
1696 case $_total_ in
1697 ?*)     case $RANDOM in
1698         $RANDOM)cd $SHIP
1699                 ls -Cd $_components_
1700                 ;;
1701         *)      PS3=''
1702                 eval '  select i in $_components_
1703                         do      :
1704                         done </dev/null'
1705                 ;;
1706         esac
1707         exit 0
1708         ;;
1709 esac
1710
1711 #
1712 # nohup.out again
1713 #
1714
1715 case $_nohup_ in
1716 ?*)     echo "$_nohup_"
1717         echo "done             `date`"
1718         echo "$_nohup_"
1719         ;;
1720 esac
1721
1722 #
1723 # check for installation reports
1724 #
1725
1726 bypass=
1727 owners=
1728
1729 for NAME in $COMPONENTS
1730 do      eval state='$'STATE_$NAME _release_='$'RELEASE_$NAME _source_='$'SOURCE_$NAME
1731         case $state in
1732         bypass) bypass="$bypass
1733         $_source_/$_bypass_"
1734                         ;;
1735         esac
1736         o=$SHIP/$NAME/$_release_/$OWNER
1737         if      test -s $o
1738         then    r=`cat $SHIP/$NAME/$_release_/$REPORT 2>/dev/null`
1739                 case $r in
1740                 *\[no\]*)       r= ;;
1741                 esac
1742                 case $r' + '$state in
1743                 ?*' + '*|*' + 'error)
1744                         address=`cat $o`
1745                         owner=`echo $address | sed -e 's/.*\(.............\)/\1/' -e 's/^[^a-zA-Z_]/_/' -e 's/[^a-zA-Z_0-9]/_/g'`
1746                         eval f='$'built_$owner
1747                         eval built_$owner='"$'f $NAME'"'
1748                         report=
1749                         for f in $SHIP/$NAME/$LOG $r
1750                         do      case `ls -dt $f $SHIPSLOG/!$owner 2>/dev/null` in
1751                                 $f*)    report="$report $f" ;;
1752                                 esac
1753                         done
1754                         case $report in
1755                         ?*)     eval f='$'address_$owner
1756                                 case $f in
1757                                 "")     owners="$owners $owner"
1758                                         eval address_$owner=$address
1759                                         ;;
1760                                 esac
1761                                 eval eval report_$owner=\\\"\$report_$owner \\\[$NAME\\\] $report\\\"
1762                                 ;;
1763                         esac
1764                         ;;
1765                 esac
1766         fi
1767 done
1768
1769 #
1770 # check if any components required pax to uncrate
1771 #
1772
1773 case $NEED_pax in
1774 ?*)     AR_DELTA=$INSTALLROOT/bin/pax
1775         ($AR_DELTA -f /dev/null -z /dev/null) >/dev/null 2>&1 || STATE_pax=error
1776         case $STATE_pax in
1777         ok)     $_trace_ exec $_command_ $_options_ $SELECT ${1+"$@"} ;;
1778         *)      echo $_command_: pax required to uncrate$NEED_pax >&2 ;;
1779         esac
1780         ;;
1781 esac
1782
1783 #
1784 # done
1785 #
1786
1787 exit 0