* Copyright (c) 1980,1990 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
* -------------------- ----- ----------------------
* CURRENT PATCH LEVEL: 2 00096
* -------------------- ----- ----------------------
* 29 Jun 92 Chris G. Demetriou Fix Version number update
* 15 Feb 93 Julian Elischer allow comments (leading #) in
static char sccsid
[] = "@(#)mkmakefile.c 5.33 (Berkeley) 7/1/91";
* Build the makefile for the system, from
* the information in the files files and the
* additional files for the machine being compiled to.
#define next_word(fp, wd) \
{ register char *word = get_word(fp); \
if (word == (char *)EOF) \
#define next_quoted_word(fp, wd) \
{ register char *word = get_quoted_word(fp); \
if (word == (char *)EOF) \
static struct file_list
*fcur
;
* Lookup a file, by name.
register struct file_list
*fp
;
for (fp
= ftab
; fp
!= 0; fp
= fp
->f_next
) {
* Lookup a file, by final component name.
register struct file_list
*fp
;
for (fp
= ftab
; fp
!= 0; fp
= fp
->f_next
) {
if (eq(tail(fp
->f_fn
), tail(file
)))
* Make a new file list entry
register struct file_list
*fp
;
fp
= (struct file_list
*) malloc(sizeof *fp
);
{ 24, 8, 1024 }, /* MACHINE_VAX */
{ 4, 2, 128 }, /* MACHINE_TAHOE */
{ 8, 2, 64 }, /* MACHINE_HP300 */
{ 8, 2, 64 }, /* MACHINE_I386 */
#define NUSERS (sizeof (users) / sizeof (users[0]))
* Build the makefile from the skeleton
strcpy(line
, "Makefile.");
(void) strcat(line
, machinename
);
ofp
= fopen(path("Makefile"), "w");
perror(path("Makefile"));
fprintf(ofp
, "KERN_IDENT=%s\n", raise(ident
)); /* 29 Jun 92*/
fprintf(ofp
, "IDENT=-D%s", raise(ident
));
fprintf(ofp
, " -DGPROF");
printf("cpu type must be specified\n");
for (cp
= cputype
; cp
; cp
= cp
->cpu_next
)
fprintf(ofp
, " -D%s", cp
->cpu_name
);
for (op
= opt
; op
; op
= op
->op_next
)
fprintf(ofp
, " -D%s=\"%s\"", op
->op_name
, op
->op_value
);
fprintf(ofp
, " -D%s", op
->op_name
);
printf("timezone not specified; gmt assumed\n");
if ((unsigned)machine
> NUSERS
) {
printf("maxusers config info isn't present, using vax\n");
up
= &users
[MACHINE_VAX
-1];
printf("maxusers not specified; %d assumed\n", up
->u_default
);
maxusers
= up
->u_default
;
} else if (maxusers
< up
->u_min
) {
printf("minimum of %d maxusers assumed\n", up
->u_min
);
} else if (maxusers
> up
->u_max
)
printf("warning: maxusers > %d (%d)\n", up
->u_max
, maxusers
);
fprintf(ofp
, "PARAM=-DTIMEZONE=%d -DDST=%d -DMAXUSERS=%d\n",
for (op
= mkopt
; op
; op
= op
->op_next
)
fprintf(ofp
, "%s=%s\n", op
->op_name
, op
->op_value
);
fprintf(ofp
, "DEBUG=-g\n");
fprintf(ofp
, "PROF=-pg\n");
while (fgets(line
, BUFSIZ
, ifp
) != 0) {
fprintf(ofp
, "%s", line
);
else if (eq(line
, "%CFILES\n"))
else if (eq(line
, "%RULES\n"))
else if (eq(line
, "%LOAD\n"))
"Unknown %% construct in generic makefile: %s",
* Read in the information about files used in making the system.
* Store it in the ftab linked list.
register struct file_list
*tp
, *pf
;
register struct device
*dp
;
char *wd
, *this, *needs
, *special
;
int nreqs
, first
= 1, configdep
, isdup
, std
, filetype
;
(void) strcpy(fname
, "../../conf/files");
* filename [ standard | optional ] [ config-dependent ]
* [ dev* | profiling-routine ] [ device-driver]
* [ compile-with "compile rule" ]
(void) sprintf(fname
, "files.%s", machinename
);
(void) sprintf(fname
, "files.%s", raise(ident
));
/*************************************************\
* If it's a comment ignore to the end of the line *
\*************************************************/
while( ((wd
= get_word(fp
)) != (char *)EOF
) && wd
)
printf("%s: No type for %s.\n",
if ((pf
= fl_lookup(this)) && (pf
->f_type
!= INVISIBLE
|| pf
->f_flags
))
if (first
== 3 && (tp
= fltail_lookup(this)) != 0)
printf("%s: Local file %s overrides %s.\n",
else if (!eq(wd
, "optional")) {
printf("%s: %s must be optional or standard\n", fname
, this);
if (eq(wd
, "config-dependent")) {
if (eq(wd
, "compile-with")) {
next_quoted_word(fp
, wd
);
printf("%s: %s missing compile command string.\n",
if (eq(wd
, "device-driver")) {
if (eq(wd
, "profiling-routine")) {
if (needs
== 0 && nreqs
== 1)
for (dp
= dtab
; dp
!= 0; save_dp
= dp
, dp
= dp
->d_next
)
if (eq(dp
->d_name
, wd
)) {
if (std
&& dp
->d_type
== PSEUDO_DEVICE
&&
dp
= (struct device
*) malloc(sizeof *dp
);
dp
->d_type
= PSEUDO_DEVICE
;
for (op
= opt
; op
!= 0; op
= op
->op_next
)
if (op
->op_value
== 0 && opteq(op
->op_name
, wd
)) {
while ((wd
= get_word(fp
)) != 0)
if (std
== 0 && nreqs
== 0) {
printf("%s: what is %s optional on?\n",
printf("%s: syntax error describing %s\n",
if (filetype
== PROFILING
&& profiling
== 0)
tp
->f_flags
|= CONFIGDEP
;
if (pf
&& pf
->f_type
== INVISIBLE
)
pf
->f_flags
= 1; /* mark as duplicate */
c
= isupper(*cp
) ? tolower(*cp
) : *cp
;
d
= isupper(*dp
) ? tolower(*dp
) : *dp
;
register struct file_list
*tp
, *fl
;
register char *cp
, och
, *sp
;
for (tp
= ftab
; tp
!= 0; tp
= tp
->f_next
) {
if (tp
->f_type
== INVISIBLE
)
for (fl
= conf_list
; fl
; fl
= fl
->f_next
) {
if (fl
->f_type
!= SWAPSPEC
)
(void) sprintf(swapname
, "swap%s.c", fl
->f_fn
);
cp
= sp
+ (len
= strlen(sp
)) - 1;
register struct file_list
*tp
, *fl
;
for (tp
= ftab
; tp
; tp
= tp
->f_next
)
if (tp
->f_type
!= INVISIBLE
) {
if (tp
->f_fn
[len
- 1] != 'c')
if ((len
= 3 + len
) + lpos
> 72) {
fprintf(fp
, "$S/%s ", tp
->f_fn
);
for (fl
= conf_list
; fl
; fl
= fl
->f_next
)
if (fl
->f_type
== SYSTEMSPEC
) {
(void) sprintf(swapname
, "swap%s.c", fl
->f_fn
);
if ((len
= 3 + strlen(swapname
)) + lpos
> 72) {
if (eq(fl
->f_fn
, "generic"))
fprintf(fp
, "$S/%s/%s/%s ",
machinename
, machinename
, swapname
);
fprintf(fp
, "%s ", swapname
);
* Create the makerules for each file
* which is part of the system.
* Devices are processed with the special c2 option -i
* which avoids any problem areas with i/o addressing
* (e.g. for the VAX); assembler files are processed by as.
register char *cp
, *np
, och
, *tp
;
register struct file_list
*ftp
;
for (ftp
= ftab
; ftp
!= 0; ftp
= ftp
->f_next
) {
if (ftp
->f_type
== INVISIBLE
)
cp
= (np
= ftp
->f_fn
) + strlen(ftp
->f_fn
) - 1;
fprintf(f
, "%so:\n\t-cp $S/%so .\n\n", tail(np
), np
);
fprintf(f
, "%so: $S/%s%c\n", tail(np
), np
, och
);
special
= ftp
->f_special
;
printf("config: don't know rules for %s\n", np
);
(void)sprintf(cmd
, "${%s_%c%s}", ftype
, toupper(och
),
ftp
->f_flags
& CONFIGDEP
? "_C" : "");
fprintf(f
, "\t%s\n\n", special
);
* Create the load strings
register struct file_list
*fl
;
struct file_list
*do_systemspec();
for (first
= 1, fl
= conf_list
; fl
; first
= 0)
fl
= fl
->f_type
== SYSTEMSPEC
?
do_systemspec(f
, fl
, first
) : fl
->f_next
;
for (fl
= conf_list
; fl
; fl
= fl
->f_next
)
if (fl
->f_type
== SYSTEMSPEC
)
fprintf(f
, " %s", fl
->f_needs
);
do_systemspec(f
, fl
, first
)
register struct file_list
*fl
;
fprintf(f
, "%s: ${SYSTEM_DEP} swap%s.o", fl
->f_needs
, fl
->f_fn
);
if (first
) /* 29 Jun 92*/
fprintf(f
, "\n\t${SYSTEM_LD_HEAD}\n");
fprintf(f
, "\t${SYSTEM_LD} swap%s.o\n", fl
->f_fn
);
fprintf(f
, "\t${SYSTEM_LD_TAIL}\n\n");
do_swapspec(f
, fl
->f_fn
);
for (fl
= fl
->f_next
; fl
&& fl
->f_type
== SWAPSPEC
; fl
= fl
->f_next
)
if (!eq(name
, "generic"))
fprintf(f
, "swap%s.o: swap%s.c\n", name
, name
);
/* 29 Jun 92*/ fprintf(f
, "swapgeneric.o: ../../%s/%s/swapgeneric.c\n",
machinename
, machinename
);
fprintf(f
, "\t${NORMAL_C}\n\n");