clean up install entry to use install script
[unix-history] / usr / src / usr.sbin / config / main.c
index 0ca4e59..5f2f362 100644 (file)
@@ -1,43 +1,53 @@
-/*
- * main.c      1.2     81/02/25
- * Config
- *     Do system configuration for VAX/UNIX
- *             1) Build system data structures
- *             2) Build makefile
- *             3) Create header files for devices
- *     Michael Toy -- Berkeley -- 1981
- */
+/*     main.c  1.8     82/12/09        */
 
 #include <stdio.h>
 #include <ctype.h>
 #include "y.tab.h"
 #include "config.h"
 
 
 #include <stdio.h>
 #include <ctype.h>
 #include "y.tab.h"
 #include "config.h"
 
+/*
+ * Config builds a set of files for building a UNIX
+ * system given a description of the desired system.
+ */
 main(argc, argv)
 main(argc, argv)
-int argc;
-char **argv;
+       int argc;
+       char **argv;
 {
 {
-    if (argc != 2)
-    {
-       fprintf(stderr, "usage: config <sysname>\n");
-       exit(1);
-    }
-    PREFIX = argv[1];
-    if (freopen(argv[1], "r", stdin) == NULL)
-    {
-       perror(argv[1]);
-       exit(2);
-    }
-    dtab = NULL;
-    if (yyparse())
-       exit(3);
-    else
-    {
-       ioconf();                       /* Print ioconf.c */
-       ubglue();                       /* Create ubglue.s */
+
+       if (argc > 1 && eq("-p", argv[1])) {
+               profiling++;
+               argc--, argv++;
+       }
+       if (argc != 2) {
+               fprintf(stderr, "usage: config [ -p ] sysname\n");
+               exit(1);
+       }
+       PREFIX = argv[1];
+       if (freopen(argv[1], "r", stdin) == NULL) {
+               perror(argv[1]);
+               exit(2);
+       }
+       dtab = NULL;
+       if (yyparse())
+               exit(3);
+       switch (machine) {
+
+       case MACHINE_VAX:
+               vax_ioconf();           /* Print ioconf.c */
+               ubglue();               /* Create ubglue.s */
+               break;
+
+       case MACHINE_SUN:
+               sun_ioconf();
+               break;
+
+       default:
+               printf("Specify machine type, e.g. ``machine vax''\n");
+               exit(1);
+       }
        makefile();                     /* build Makefile */
        headers();                      /* make a lot of .h files */
        makefile();                     /* build Makefile */
        headers();                      /* make a lot of .h files */
-    }
+       printf("Don't forget to run \"make depend\"\n");
 }
 
 /*
 }
 
 /*
@@ -46,48 +56,48 @@ char **argv;
  *     NULL on end of line
  *     pointer to the word otherwise
  */
  *     NULL on end of line
  *     pointer to the word otherwise
  */
-
-char *get_word(fp)
-register FILE *fp;
+char *
+get_word(fp)
+       register FILE *fp;
 {
 {
-    static char line[80];
-    register int ch;
-    register char *cp;
+       static char line[80];
+       register int ch;
+       register char *cp;
 
 
-    while((ch = getc(fp)) != EOF)
-       if (ch != ' ' && ch != '\t')
-           break;
-    if (ch == EOF)
-       return EOF;
-    if (ch == '\n')
-       return NULL;
-    cp = line;
-    *cp++ = ch;
-    while((ch = getc(fp)) != EOF)
-    {
-       if (isspace(ch))
-           break;
+       while ((ch = getc(fp)) != EOF)
+               if (ch != ' ' && ch != '\t')
+                       break;
+       if (ch == EOF)
+               return ((char *)EOF);
+       if (ch == '\n')
+               return (NULL);
+       cp = line;
        *cp++ = ch;
        *cp++ = ch;
-    }
-    *cp = '\0';
-    if (ch == EOF)
-       return EOF;
-    ungetc(ch, fp);
-    return line;
+       while ((ch = getc(fp)) != EOF) {
+               if (isspace(ch))
+                       break;
+               *cp++ = ch;
+       }
+       *cp = 0;
+       if (ch == EOF)
+               return ((char *)EOF);
+       (void) ungetc(ch, fp);
+       return (line);
 }
 
 /*
 }
 
 /*
- * path:
- *     Prepend the path to a filename
+ * prepend the path to a filename
  */
  */
-
+char *
 path(file)
 path(file)
-char *file;
+       char *file;
 {
 {
-    register char *cp;
+       register char *cp;
 
 
-    cp = malloc(strlen(PREFIX)+strlen(file)+1);
-    strcpy(cp, PREFIX);
-    strcpy(cp, file);
-    return cp;
+       cp = malloc((unsigned)(strlen(PREFIX)+strlen(file)+5));
+       (void) strcpy(cp, "../");
+       (void) strcat(cp, PREFIX);
+       (void) strcat(cp, "/");
+       (void) strcat(cp, file);
+       return (cp);
 }
 }