      SUBROUTINE MAIN
      LOGICAL*1 SOURCE(40), OBJECT(40), ARG(40), EXT(4), LISTFL(40), LDA
     *RGS(256), DESCR(7), SPATH(80)
      INTEGER I, GETARG, SSPAWN, K, FORTRN, LOCCOM, INDEX
      COMMON /FLIST/ FLEVEL, FFILES(40, 25)
      INTEGER FLEVEL
      LOGICAL*1 FFILES
      COMMON / CFC / LOAD, VERBOS, LIST, ERRCNT, DEBUG
      INTEGER LOAD
      INTEGER VERBOS
      INTEGER LIST
      INTEGER ERRCNT
      INTEGER DEBUG
      LOGICAL*1 MINUSV(4)
      LOGICAL*1 MINUSD(4)
      LOGICAL*1 EXTO(4)
      LOGICAL*1 EXTL(2)
      LOGICAL*1 LD(3)
      DATA MINUSV(1)/45/,MINUSV(2)/118/,MINUSV(3)/32/,MINUSV(4)/0/
      DATA MINUSD(1)/45/,MINUSD(2)/100/,MINUSD(3)/32/,MINUSD(4)/0/
      DATA EXTO(1)/111/,EXTO(2)/98/,EXTO(3)/106/,EXTO(4)/0/
      DATA EXTL(1)/108/,EXTL(2)/0/
      DATA LD(1)/108/,LD(2)/100/,LD(3)/0/
      FLEVEL = 0
      LOAD = 1
      VERBOS = 0
      LIST = 0
      DEBUG = 0
      ERRCNT = 0
      I=1
23000 IF(.NOT.(GETARG(I, ARG, 40) .NE. -1))GOTO 23002
      IF(.NOT.(ARG(1) .EQ. 45 .OR. ARG(1) .EQ. 43 .OR. ARG(1) .EQ. 63))G
     *OTO 23003
      CALL FCCMD(ARG)
      GOTO 23004
23003 CONTINUE
      CALL FSTACK(ARG)
23004 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      K=1
23005 IF(.NOT.(K.LE.FLEVEL))GOTO 23007
      CALL GETEXT(FFILES(1,K), EXT)
      IF(.NOT.(FFILES(1,K) .NE. 45 .AND. EXT(1) .EQ. 102 .AND. EXT(2) .E
     *Q. 0))GOTO 23008
      IF(.NOT.(INDEX(FFILES(1,K), 47) .GT. 0))GOTO 23010
      CALL MKLOCL(FFILES(1,K), SOURCE)
      GOTO 23011
23010 CONTINUE
      CALL SCOPY(FFILES(1,K), 1, SOURCE, 1)
23011 CONTINUE
      CALL GENFIL(SOURCE, EXTO, OBJECT)
      IF(.NOT.(LIST .EQ. 1))GOTO 23012
      CALL GENFIL(SOURCE, EXTL, LISTFL)
      GOTO 23013
23012 CONTINUE
      LISTFL(1) = 0
23013 CONTINUE
      IF(.NOT.(FORTRN(SOURCE, OBJECT, LISTFL, VERBOS, DEBUG) .EQ. -3))GO
     *TO 23014
      ERRCNT = ERRCNT + 1
23014 CONTINUE
23008 CONTINUE
23006 K=K+1
      GOTO 23005
23007 CONTINUE
      IF(.NOT.(LOAD .EQ. 1 .AND. ERRCNT .EQ. 0))GOTO 23016
      I = 1
      CALL STCOPY(LD, 1, LDARGS, I)
      CALL CHCOPY(32, LDARGS, I)
      IF(.NOT.(VERBOS .EQ. 1))GOTO 23018
      CALL STCOPY(MINUSV, 1, LDARGS, I)
23018 CONTINUE
      IF(.NOT.(DEBUG .EQ. 1))GOTO 23020
      CALL STCOPY(MINUSD, 1, LDARGS, I)
23020 CONTINUE
      K=1
23022 IF(.NOT.(K.LE.FLEVEL))GOTO 23024
      CALL GETEXT(FFILES(1,K), EXT)
      IF(.NOT.(FFILES(1,K) .NE. 45 .AND. EXT(1) .EQ. 102 .AND. EXT(2) .E
     *Q. 0))GOTO 23025
      CALL GENFIL(FFILES(1,K), EXTO, ARG)
      GOTO 23026
23025 CONTINUE
      CALL SCOPY(FFILES(1,K), 1, ARG, 1)
23026 CONTINUE
      CALL STCOPY(ARG, 1, LDARGS, I)
      CALL CHCOPY(32, LDARGS, I)
23023 K=K+1
      GOTO 23022
23024 CONTINUE
      LDARGS(I-1) = 0
      CALL IMPATH(SPATH)
      IF(.NOT.(LOCCOM(LD, SPATH, ARG) .NE. 60))GOTO 23027
      CALL ERROR(28HCannot locate ld image file.)
23027 CONTINUE
      IF(.NOT.(VERBOS .EQ. 1))GOTO 23029
      CALL REMARK(LDARGS)
23029 CONTINUE
      IF(.NOT.(SSPAWN(ARG, LDARGS, DESCR, 119) .EQ. -3))GOTO 23031
      CALL REMARK(24HError in linking process)
23031 CONTINUE
23016 CONTINUE
      RETURN
      END
      SUBROUTINE FCCMD(ARG)
      LOGICAL*1 ARG(40)
      COMMON / CFC / LOAD, VERBOS, LIST, ERRCNT, DEBUG
      INTEGER LOAD
      INTEGER VERBOS
      INTEGER LIST
      INTEGER ERRCNT
      INTEGER DEBUG
      IF(.NOT.(ARG(1) .EQ. 45 .AND. (ARG(2) .EQ. 99 .OR. ARG(2) .EQ. 67)
     *))GOTO 23033
      LOAD = 0
      GOTO 23034
23033 CONTINUE
      IF(.NOT.(ARG(1) .EQ. 63 .AND. ARG(2) .EQ. 0))GOTO 23035
      CALL FCERR
      GOTO 23036
23035 CONTINUE
      IF(.NOT.(ARG(1) .EQ. 45 .AND. (ARG(2) .EQ. 118 .OR. ARG(2) .EQ. 86
     *)))GOTO 23037
      VERBOS = 1
      GOTO 23038
23037 CONTINUE
      IF(.NOT.(ARG(1) .EQ. 45 .AND. (ARG(2) .EQ. 111 .OR. ARG(2) .EQ. 79
     *)))GOTO 23039
      LIST = 1
      GOTO 23040
23039 CONTINUE
      IF(.NOT.(ARG(1) .EQ. 45 .AND. (ARG(2) .EQ. 100 .OR. ARG(2) .EQ. 68
     *)))GOTO 23041
      DEBUG = 1
      GOTO 23042
23041 CONTINUE
      IF(.NOT.(ARG(1) .EQ. 45 .AND. (ARG(2) .EQ. 112 .OR. ARG(2) .EQ. 80
     * .OR. ARG(2) .EQ. 108 .OR. ARG(2) .EQ. 76)))GOTO 23043
      CALL FSTACK(ARG)
      GOTO 23044
23043 CONTINUE
      CALL REMARK(26HIgnoring invalid argument.)
23044 CONTINUE
23042 CONTINUE
23040 CONTINUE
23038 CONTINUE
23036 CONTINUE
23034 CONTINUE
      RETURN
      END
      SUBROUTINE GENFIL(IN, EXT, OUT)
      INTEGER I, J
      LOGICAL*1 IN(40), EXT(4), OUT(40)
      I=1
23045 IF(.NOT.(IN(I) .NE. 46 .AND. IN(I) .NE. 0))GOTO 23047
      OUT(I) = IN(I)
23046 I=I+1
      GOTO 23045
23047 CONTINUE
      CALL CHCOPY(46, OUT, I)
      CALL SCOPY(EXT, 1, OUT, I)
      RETURN
      END
      SUBROUTINE FSTACK (IARG)
      INTEGER I
      LOGICAL*1 IARG(40)
      COMMON /FLIST/ FLEVEL, FFILES(40, 25)
      INTEGER FLEVEL
      LOGICAL*1 FFILES
      IF(.NOT.(FLEVEL .LT. 25))GOTO 23048
      FLEVEL = FLEVEL + 1
      I=1
23050 IF(.NOT.(I.LE.40))GOTO 23052
      FFILES(I,FLEVEL) = IARG(I)
23051 I=I+1
      GOTO 23050
23052 CONTINUE
      CALL FOLD(FFILES(1, FLEVEL))
23048 CONTINUE
      RETURN
      END
      SUBROUTINE GETEXT(FILE, EXT)
      LOGICAL*1 FILE(40), EXT(4)
      INTEGER I, J
      I=1
23053 IF(.NOT.(FILE(I) .NE. 46 .AND. FILE(I) .NE. 0))GOTO 23055
23054 I=I+1
      GOTO 23053
23055 CONTINUE
      IF(.NOT.(FILE(I) .EQ. 46))GOTO 23056
      I = I + 1
23056 CONTINUE
      J=1
23058 IF(.NOT.(FILE(I) .NE. 0 .AND. FILE(I) .NE. 59 .AND. FILE(I) .NE. 4
     *6))GOTO 23060
      EXT(J) = FILE(I)
      I = I + 1
23059 J=J+1
      GOTO 23058
23060 CONTINUE
      EXT(J) = 0
      CALL FOLD(EXT)
      RETURN
      END
      INTEGER FUNCTION FORTRN(SOURCE, OBJECT, LIST, VERBOS, DEBUG)
      LOGICAL*1 SOURCE(100), OBJECT(100), LIST(100), ARG(80), PID(7)
      INTEGER SSPAWN, I, VERBOS, DEBUG
      LOGICAL*1 SRCSW(16)
      DATA SRCSW(1)/47/,SRCSW(2)/110/,SRCSW(3)/111/,SRCSW(4)/115/,SRCSW(
     *5)/110/,SRCSW(6)/47/,SRCSW(7)/110/,SRCSW(8)/111/,SRCSW(9)/118/,SRC
     *SW(10)/97/,SRCSW(11)/47/,SRCSW(12)/110/,SRCSW(13)/111/,SRCSW(14)/1
     *08/,SRCSW(15)/111/,SRCSW(16)/0/
      I = 1
      CALL STCOPY(4Hfor , 1, ARG, I)
      CALL REMOVE(OBJECT)
      CALL STCOPY(OBJECT, 1, ARG, I)
      IF(.NOT.(LIST(1) .NE. 0))GOTO 23061
      CALL CHCOPY(44, ARG, I)
      CALL REMOVE(LIST)
      CALL STCOPY(LIST, 1, ARG, I)
      CALL STCOPY(4H/-sp, 1, ARG, I)
23061 CONTINUE
      CALL CHCOPY(61, ARG, I)
      CALL STCOPY(SOURCE, 1, ARG, I)
      CALL SCOPY(SRCSW, 1, ARG, I)
      CALL FOLD(ARG)
      IF(.NOT.(VERBOS .EQ. 1))GOTO 23063
      CALL REMARK(ARG)
23063 CONTINUE
      FORTRN = SSPAWN(5Hlocal, ARG, PID, 119)
      RETURN
      END
      SUBROUTINE FCERR
      CALL ERROR(59Husage:  fc [-c] [-v] [-o] [-d] [-l[libr]] [-pproc] f
     *ile ...)
      RETURN
      END
