/* mkmakefile.c 1.26 83/02/21 */
* 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 make.
register struct file_list
*fp
;
for (fp
= ftab
; fp
!= 0; fp
= fp
->f_next
) {
* Make a new file list entry
register struct file_list
*fp
;
fp
= (struct file_list
*) malloc(sizeof *fp
);
* Build the makefile from the skeleton
strcpy(line
, "../conf/makefile.");
(void) strcat(line
, machinename
);
ofp
= fopen(path("makefile"), "w");
perror(path("makefile"));
printf("maxusers not specified; 24 assumed\n");
} else if (maxusers
< 8) {
printf("minimum of 8 maxusers assumed\n");
} else if (maxusers
> 128) {
printf("maxusers truncated to 128\n");
printf("maxusers not specified; 8 assumed\n");
} else if (maxusers
< 2) {
printf("minimum of 2 maxusers assumed\n");
} else if (maxusers
> 32) {
printf("maxusers truncated to 32\n");
fprintf(ofp
, "IDENT=-D%s", raise(ident
));
fprintf(ofp
, " -DGPROF");
fprintf(ofp
, " -DMAXUSERS=%d", maxusers
);
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");
fprintf(ofp
, "PARAM=-DTIMEZONE=%d -DDST=%d\n",
while (fgets(line
, BUFSIZ
, ifp
) != 0) {
if (profiling
&& strncmp(line
, "COPTS=", 6) == 0) {
fprintf(ofp
, "GPROF.EX=/usr/src/lib/libc/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
;
register struct device
*dp
;
char *wd
, *this, *needs
, *devorprof
;
(void) strcpy(fname
, "files");
/* filename [ standard | optional dev* ] [ device-driver ] */
(void) sprintf(fname
, "files.%s", machinename
);
printf("%s: No type for %s.\n",
printf("%s: Duplicate file %s.\n",
if (!eq(wd
, "optional")) {
printf("%s: %s must be optional or standard\n",
if (eq(wd
, "device-driver") || eq(wd
, "profiling-routine")) {
for (dp
= dtab
; dp
!= 0; dp
= dp
->d_next
)
while ((wd
= get_word(fp
)) != 0)
printf("%s: what is %s optional on?\n",
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"))
register struct file_list
*tp
;
register char *cp
, och
, *sp
;
for (tp
= ftab
; tp
!= 0; tp
= tp
->f_next
) {
if (tp
->f_type
== INVISIBLE
)
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: ../%s%c\n", tail(np
), np
, och
);
fprintf(f
, "\t${AS} -o %so ../%ss\n\n", tp
, np
);
fprintf(f
, "\t${CC} -I. -c -S ${COPTS} ../%sc\n", np
);
fprintf(f
, "\t${C2} %ss | sed -f ../%s/asm.sed |",
fprintf(f
, " ${AS} -o %so\n", tp
);
fprintf(f
, "\trm -f %ss\n\n", tp
);
fprintf(f
, "\t${CC} -I. -c -O ${COPTS} ../%sc\n\n", np
);
fprintf(f
, "\t${CC} -I. -c -S ${COPTS} ../%sc\n", np
);
fprintf(f
,"\t${C2} -i %ss | sed -f ../%s/asm.sed |",
fprintf(f
, " ${AS} -o %so\n", tp
);
fprintf(f
, "\trm -f %ss\n\n", tp
);
fprintf(f
, "\t${CC} -I. -c -O ${COPTS} ../%sc\n\n", np
);
"config: COPTS undefined in generic makefile");
fprintf(f
, "\t${CC} -I. -c -S %s ../%sc\n", COPTS
, np
);
fprintf(f
, "\tex - %ss < ${GPROF.EX}\n", tp
);
"\tsed -f ../vax/asm.sed %ss | ${AS} -o %so\n",
fprintf(f
, "\trm -f %ss\n\n", tp
);
"config: don't know how to profile kernel on sun\n");
printf("Don't know rules for %s", np
);
* Create the load strings
register struct file_list
*fl
;
for (fl
= conf_list
; fl
!= 0; fl
= fl
->f_next
) {
fprintf(f
, "%s: makefile locore.o ${OBJS} param.o",
fprintf(f
, " 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 ",
fprintf(f
, "locore.o ${OBJS} vers.o ioconf.o param.o ");
fprintf(f
, "swap%s.o\n", fl
->f_fn
);
fprintf(f
, "\t@${LD} -o %s -e start -x -T 4000 ",
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
);
for (fl
= conf_list
; fl
!= 0; fl
= fl
->f_next
) {
fprintf(f
, "swap%s.o: ../%s/swap%s.c\n",
fl
->f_fn
, machinename
, fl
->f_fn
);
fprintf(f
, "\t${CC} -I. -c -S ${COPTS}");
fprintf(f
, " ../%s/swap%s.c\n", machinename
, fl
->f_fn
);
fprintf(f
, "\t${C2} swap%s.s | sed -f ../%s/asm.sed",
fprintf(f
, " | ${AS} -o swap%s.o\n",
fprintf(f
, "\trm -f swap%s.s\n\n", fl
->f_fn
);
fprintf(f
, "\t${CC} -I. -c -O ${COPTS} ");
fprintf(f
, "../%s/swap%s.c\n\n", machinename
, fl
->f_fn
);
for (fl
= conf_list
; fl
!= 0; fl
= fl
->f_next
)
fprintf(f
, " %s", fl
->f_needs
);