* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)mkmakefile.c 5.10 (Berkeley) %G%";
* 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) \
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 */
#define NUSERS (sizeof (users) / sizeof (users[0]))
* Build the makefile from the skeleton
strcpy(line
, "../conf/Makefile.");
(void) strcat(line
, machinename
);
ofp
= fopen(path("Makefile"), "w");
perror(path("Makefile"));
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",
timezone
, dst
, maxusers
);
for (op
= mkopt
; op
; op
= op
->op_next
)
fprintf(ofp
, "%s=%s\n", op
->op_name
, op
->op_value
);
while (fgets(line
, BUFSIZ
, ifp
) != 0) {
if (profiling
&& strncmp(line
, "COPTS=", 6) == 0) {
"GPROF.EX=/usr/src/lib/libc/%s/csu/gmon.ex\n",
while (*cp
&& (*cp
== ' ' || *cp
== '\t'))
COPTS
= malloc((unsigned)(strlen(cp
) + 1));
printf("config: out of memory\n");
fprintf(ofp
, "%s -pg\n", line
);
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
, *devorprof
;
int nreqs
, first
= 1, configdep
, isdup
;
(void) strcpy(fname
, "files");
* filename [ standard | optional ] [ config-dependent ]
* [ dev* | profiling-routine ] [ device-driver]
(void) sprintf(fname
, "files.%s", machinename
);
(void) sprintf(fname
, "files.%s", raise(ident
));
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",
if (!eq(wd
, "optional")) {
printf("%s: %s must be optional or standard\n", fname
, this);
if (eq(wd
, "config-dependent")) {
if (eq(wd
, "device-driver") || eq(wd
, "profiling-routine")) {
if (needs
== 0 && nreqs
== 1)
for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
)
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)
printf("%s: what is %s optional on?\n",
if (eq(wd
, "config-dependent")) {
printf("%s: syntax error describing %s\n",
if (eq(devorprof
, "profiling-routine") && profiling
== 0)
if (eq(devorprof
, "device-driver"))
else if (eq(devorprof
, "profiling-routine"))
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
)
sprintf(swapname
, "swap%s.c", fl
->f_fn
);
cp
= sp
+ (len
= strlen(sp
)) - 1;
register struct file_list
*tp
;
for (tp
= ftab
; tp
!= 0; tp
= tp
->f_next
) {
if (tp
->f_type
== INVISIBLE
)
if (tp
->f_fn
[strlen(tp
->f_fn
)-1] != 'c')
if ((len
= 3 + strlen(tp
->f_fn
)) + lpos
> 72) {
fprintf(fp
, "../%s ", tp
->f_fn
);
* 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 ../%so .\n", tail(np
), np
);
fprintf(f
, "%so: ../%s%c\n", tail(np
), np
, och
);
fprintf(f
, "\t-ln -s ../%ss %sc\n", np
, tp
);
fprintf(f
, "\t${CC} -E ${COPTS} %sc | ${AS} -o %so\n",
fprintf(f
, "\trm -f %sc\n\n", tp
);
if (ftp
->f_flags
& CONFIGDEP
)
fprintf(f
, "\t${CC} -c -S ${COPTS} %s../%sc\n",
fprintf(f
, "\t${C2} %ss | ${INLINE} | ${AS} -o %so\n",
fprintf(f
, "\trm -f %ss\n\n", tp
);
fprintf(f
, "\t${CC} -c -S ${COPTS} %s../%sc\n",
fprintf(f
,"\t${C2} -i %ss | ${INLINE} | ${AS} -o %so\n",
fprintf(f
, "\trm -f %ss\n\n", tp
);
"config: COPTS undefined in generic makefile");
fprintf(f
, "\t${CC} -c -S %s %s../%sc\n",
fprintf(f
, "\tex - %ss < ${GPROF.EX}\n", tp
);
fprintf(f
,"\t${C2} %ss | ${INLINE} | ${AS} -o %so\n",
fprintf(f
, "\trm -f %ss\n\n", tp
);
fprintf(f
, "\t${CC} -c -S %s %s../%sc\n",
fprintf(f
, "\tex - %ss < ${GPROF.EX}\n", tp
);
fprintf(f
, "\t${INLINE} %ss | ${AS} -o %so\n", tp
, tp
);
fprintf(f
, "\trm -f %ss\n\n", tp
);
printf("Don't know rules for %s\n", np
);
* Create the load strings
register struct file_list
*fl
;
struct file_list
*do_systemspec();
if (fl
->f_type
!= SYSTEMSPEC
) {
fl
= do_systemspec(f
, fl
, first
);
for (fl
= conf_list
; fl
!= 0; 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: Makefile", fl
->f_needs
);
if (machine
== MACHINE_VAX
|| machine
== MACHINE_TAHOE
)
fprintf(f
, " ${INLINE}", machinename
);
fprintf(f
, " locore.o ${OBJS} param.o ioconf.o swap%s.o\n", fl
->f_fn
);
fprintf(f
, "\t@echo loading %s\n\t@rm -f %s\n",
fl
->f_needs
, fl
->f_needs
);
fprintf(f
, "\t@sh ../conf/newvers.sh\n");
fprintf(f
, "\t@${CC} $(CFLAGS) -c vers.c\n");
fprintf(f
, "\t@${LD} -n -o %s -e start -x -T 80000000 ",
"locore.o emulate.o ${OBJS} vers.o ioconf.o param.o ");
fprintf(f
, "\t@${LD} -n -o %s -e start -x -T C0000800 ",
fprintf(f
, "locore.o ${OBJS} vers.o ioconf.o param.o ");
fprintf(f
, "swap%s.o\n", fl
->f_fn
);
fprintf(f
, "\t@echo rearranging symbols\n");
fprintf(f
, "\t@-symorder ../%s/symbols.sort %s\n",
machinename
, fl
->f_needs
);
fprintf(f
, "\t@size %s\n", fl
->f_needs
);
fprintf(f
, "\t@chmod 755 %s\n\n", fl
->f_needs
);
do_swapspec(f
, fl
->f_fn
);
for (fl
= fl
->f_next
; fl
->f_type
== SWAPSPEC
; fl
= fl
->f_next
)
if (!eq(name
, "generic")) {
fprintf(f
, "swap%s.o: swap%s.c\n", name
, name
);
fprintf(f
, "\t${CC} -c -O ${COPTS} swap%s.c\n\n", name
);
fprintf(f
, "swapgeneric.o: ../%s/swapgeneric.c\n", machinename
);
fprintf(f
, "\t${CC} -c -S ${COPTS} ");
fprintf(f
, "../%s/swapgeneric.c\n", machinename
);
fprintf(f
, "\t${C2} swapgeneric.s | ${INLINE}");
fprintf(f
, " | ${AS} -o swapgeneric.o\n");
fprintf(f
, "\trm -f swapgeneric.s\n\n");