home *** CD-ROM | disk | FTP | other *** search
- /* basupd.c -- BASTOC update program
-
- Copyright (c) 1984 by JMI Software Consultants, Inc.
- */
- #include "upd.h"
- GLOBAL TEXT xeq[64] = {0};
-
- INT main(argc, argv)
- INT argc;
- TEXT **argv;
- {
- IMPORT BITS errors;
- IMPORT BOOL work_mode[];
- INT mode;
-
- if (valid(argc, argv))
- for (mode = 0; mode < NMODE; ++mode)
- if (work_mode[mode])
- {
- if (!errors)
- compile(argc, argv, mode);
- if (!errors)
- archive(argc, argv, mode);
- if (!errors)
- linkedit(mode);
- }
- return (errors);
- }
-
- /* Validate command - returns YES if all files on command line
- exist and all required libraries also exist. Prints error
- messages when files can not be found.
- */
- BOOL valid(ac, av)
- INT ac;
- TEXT **av;
- {
- IMPORT TEXT *upd_modes[], *tran_files[], *lib_files[];
- IMPORT TEXT *tran_libs[], *lib_libs[], *c_libs[];
- IMPORT TEXT *c_objs[], *tran_objs[];
- IMPORT BITS errors;
- IMPORT BOOL file_type[], work_mode[];
- INT mode, n;
- BOOL any_mode;
-
- while (--ac)
- if (**++av == '+')
- if (0 <= (n = lookup(*av + 1, upd_modes)))
- work_mode[n] = YES;
- else
- {
- puts("Unknown flag ", *av, "\n", NULL);
- errors |= BADFLAG;
- }
- else if (!exists(*av))
- {
- puts("Can't access input file ", *av, "\n", NULL);
- errors |= BADFILE;
- }
- else if (0 <= (n = lookup(*av, tran_files)))
- file_type[0] = YES;
- else if (0 <= (n = lookup(*av, lib_files)))
- file_type[1] = YES;
- else
- file_type[2] = YES;
- any_mode = 0;
- for (mode = 0; mode < NMODE; ++mode)
- any_mode += work_mode[mode];
- for (mode = 0; mode < NMODE; ++mode)
- {
- if (!any_mode)
- work_mode[mode] = YES;
- if (work_mode[mode])
- {
- if (file_type[0] || file_type[1])
- {
- if (!exists(tran_libs[mode]))
- {
- puts("Can't access library file ", tran_libs[mode], "\n", NULL);
- errors |= BADLIBR;
- }
- if (!exists(tran_objs[mode]))
- {
- puts("Can't access object file ", tran_objs[mode], "\n", NULL);
- errors |= BADLIBR;
- }
- if (!exists(c_objs[mode]))
- {
- puts("Can't access object file ", c_objs[mode], "\n", NULL);
- errors |= BADLIBR;
- }
- }
- if (!exists(lib_libs[mode]))
- {
- puts("Can't access library file ", lib_libs[mode], "\n", NULL);
- errors |= BADLIBR;
- }
- if (!exists(c_libs[mode]))
- {
- puts("Can't access library file ", c_libs[mode], "\n", NULL);
- errors |= BADLIBR;
- }
- }
- }
- return (!errors);
- }
-
- /* write a series of strings to standard out
- */
- /*VARARGS1*/
- LOCAL VOID puts(s)
- TEXT *s;
- {
- TEXT **ss;
-
- for (ss = &s; *ss; ++ss)
- write(1, *ss, strlen(*ss));
- }
-
- /* put object files into appropriate libraries
- */
- VOID archive(ac, av, mode)
- INT ac, mode;
- TEXT **av;
- {
- IMPORT TEXT *tran_files[], *tran_libs[], *lib_libs[], *tran_pgms[];
-
- while (--ac)
- if ( (**++av != '+') && (**av != '-') )
- {
- if (0 <= lookup(*av, tran_files))
- {
- if (tran_pgms[mode])
- arch(*av, tran_libs[mode]);
- }
- else
- arch(*av, lib_libs[mode]);
- }
- }
-
- /* compile files using the indicated mode
- */
- VOID compile(ac, av, mode)
- INT ac, mode;
- TEXT **av;
- {
- IMPORT TEXT *tran_files[], *tran_pgms[];
-
- while (--ac)
- if ( (**++av != '+') && (**av != '-') )
- {
- if (lookup(*av, tran_files) < 0 || tran_pgms[mode])
- cc(*av, mode);
- }
- }
-
- /* rebuild BASTOC translator
- */
- VOID linkedit(mode)
- INT mode;
- {
- IMPORT TEXT *tran_pgms[];
- IMPORT BOOL file_type[];
-
- if (!(file_type[0] || file_type[1]))
- return;
- if (!tran_pgms[mode])
- return;
- ld(mode);
- }