Clean up most of the "XXX"-tagged items:

- The code that creates hints.c and env.c from the skeleton files
  moved into separate functions.

- Sanity checks for missing "ident" and "cputype" directives moved
  into main(), alongside the existing check for "machine".

PR:		bin/90310
Submitted by:	Matt Emmerton <matt@gsicomp.on.ca>
This commit is contained in:
Ruslan Ermilov 2005-12-30 15:29:50 +00:00
parent fde4d5083c
commit 22025511b4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153888
4 changed files with 39 additions and 17 deletions

View File

@ -144,6 +144,8 @@ int yyparse(void);
int yylex(void);
void options(void);
void makefile(void);
void makeenv(void);
void makehints(void);
void headers(void);
extern STAILQ_HEAD(device_head, device) dtab;

View File

@ -162,10 +162,23 @@ main(int argc, char **argv)
STAILQ_INIT(&ftab);
if (yyparse())
exit(3);
/*
* Ensure that required elements (machine, cpu, ident) are present.
*/
if (machinename == NULL) {
printf("Specify machine type, e.g. ``machine i386''\n");
exit(1);
}
if (ident == NULL) {
printf("no ident line specified\n");
exit(1);
}
if (SLIST_EMPTY(&cputype)) {
printf("cpu type must be specified\n");
exit(1);
}
/*
* make symbolic links in compilation directory
* for "sys" (to make genassym.c work along with #include <sys/xxx>)
@ -194,6 +207,8 @@ main(int argc, char **argv)
}
options(); /* make options .h files */
makefile(); /* build Makefile */
makeenv(); /* build env.c */
makehints(); /* build hints.c */
headers(); /* make a lot of .h files */
configfile(); /* put config file into kernel*/
cleanheaders(p);

View File

@ -113,7 +113,6 @@ makefile(void)
char line[BUFSIZ];
struct opt *op;
int versreq;
char *s;
read_files();
snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename);
@ -125,12 +124,6 @@ makefile(void)
if (ifp == 0)
err(1, "%s", line);
/* XXX this check seems to be misplaced. */
if (SLIST_EMPTY(&cputype)) {
printf("cpu type must be specified\n");
exit(1);
}
ofp = fopen(path("Makefile.new"), "w");
if (ofp == 0)
err(1, "%s", path("Makefile.new"));
@ -181,8 +174,18 @@ makefile(void)
(void) fclose(ifp);
(void) fclose(ofp);
moveifchanged(path("Makefile.new"), path("Makefile"));
}
/*
* Build hints.c from the skeleton
*/
void
makehints(void)
{
FILE *ifp, *ofp;
char line[BUFSIZ];
char *s;
/* XXX makefile() should make the Makefile, not hints.c. */
if (hints) {
ifp = fopen(hints, "r");
if (ifp == NULL)
@ -234,8 +237,18 @@ makefile(void)
fclose(ifp);
fclose(ofp);
moveifchanged(path("hints.c.new"), path("hints.c"));
}
/*
* Build env.c from the skeleton
*/
void
makeenv(void)
{
FILE *ifp, *ofp;
char line[BUFSIZ];
char *s;
/* XXX makefile() should make the Makefile, not env.c. */
if (env) {
ifp = fopen(env, "r");
if (ifp == NULL)
@ -518,10 +531,6 @@ read_files(void)
char fname[MAXPATHLEN];
struct files_name *nl, *tnl;
if (ident == NULL) {
printf("no ident line specified\n");
exit(1);
}
(void) snprintf(fname, sizeof(fname), "../../conf/files");
read_file(fname);
(void) snprintf(fname, sizeof(fname),

View File

@ -290,10 +290,6 @@ read_options(void)
char genopt[MAXPATHLEN];
SLIST_INIT(&otab);
if (ident == NULL) {
printf("no ident line specified\n");
exit(1);
}
(void) snprintf(fname, sizeof(fname), "../../conf/options");
openit:
fp = fopen(fname, "r");