# # Makefile for building the unix kernel and disk images. # # important targets: # all - make kernel and disk images # images - make disk images # tape - make a tape image for a "cold" kernel # loadfile - make a simh loadfile containing the kernel # unix - make the kernel # clean - delete intermediate files # clobber - delete all generated files # # settings: # EXTRAPATCHES - list of extra patches to apply # USECOREPATCHES - "yes" or "no", use the core set of patches # # Examples: # make # build disk images and unix and run unix in simh # make unix tape EXTRAPATCHES=cold # build a "cold" kernel and a tape to boot it with. USECOREPATCHES = yes EXTRAPATCHES = ALL = loadfile rf0.dsk rk0.dsk ML= ../tools/ml MKFS = ../tools/mkfs MKTAPE = ../tools/mktape.py APOUT_ROOT = ../fs/root APOUT = APOUT_ROOT=$(APOUT_ROOT) ../tools/apout/apout AS = $(APOUT) $(APOUT_ROOT)/bin/as NM = $(APOUT) $(APOUT_ROOT)/bin/nm TREECOPY = rsync -a --exclude .svn KSRCS = u0.s u1.s u2.s u3.s u4.s u5.s u6.s u7.s u8.s u9.s ux.s ALLSRCS = $(KSRCS) init.s sh.s CLEANSRCS = $(ALLSRCS:.s=.clean) PAGES = ../pages/e00-01 ../pages/e00-02 ../pages/e00-03 ../pages/e00-04 \ ../pages/e00-05 ../pages/e00-06 ../pages/e00-07 ../pages/e00-08 \ ../pages/e00-09 ../pages/e00-10 ../pages/e01-01 ../pages/e01-02 \ ../pages/e01-03 ../pages/e01-04 ../pages/e01-05 ../pages/e01-06 \ ../pages/e01-07 ../pages/e01-08 ../pages/e01-09 ../pages/e01-10 \ ../pages/e02-01 ../pages/e02-02 ../pages/e02-03 ../pages/e02-04 \ ../pages/e02-05 ../pages/e02-06 ../pages/e02-07 ../pages/e02-08 \ ../pages/e02-09 ../pages/e02-10 ../pages/e03-01 ../pages/e03-02 \ ../pages/e03-03 ../pages/e03-04 ../pages/e04-01 ../pages/e04-02 \ ../pages/e04-03 ../pages/e04-04 ../pages/e04-05 ../pages/e04-06 \ ../pages/e04-07 ../pages/e05-01 ../pages/e05-02 ../pages/e05-03 \ ../pages/e05-04 ../pages/e05-05 ../pages/e05-06 ../pages/e06-01 \ ../pages/e06-02 ../pages/e06-03 ../pages/e06-04 ../pages/e06-05 \ ../pages/e06-06 ../pages/e07-01 ../pages/e07-02 ../pages/e07-03 \ ../pages/e07-04 ../pages/e07-05 ../pages/e07-06 ../pages/e07-07 \ ../pages/e07-08 ../pages/e08-01 ../pages/e08-02 ../pages/e08-03 \ ../pages/e08-04 ../pages/e08-05 ../pages/e08-06 ../pages/e08-07 \ ../pages/e08-08 ../pages/e08-09 ../pages/e09-01 ../pages/e09-02 \ ../pages/e09-03 ../pages/e09-04 ../pages/e09-05 ../pages/e09-06 \ ../pages/e09-07 ../pages/e09-08 ../pages/e10-01 ../pages/e10-02 \ ../pages/e11-01 ../pages/e11-02 ../pages/e11-03 ../pages/e11-04 \ ../pages/e11-05 ../pages/e11-06 ../pages/e11-07 ../pages/e12-01 \ ../pages/e12-02 ../pages/e12-03 ../pages/e12-04 # make the important stuff all : $(ALL) # reconstitute sources from ocr'd pages $(CLEANSRCS) cleansrc : $(PAGES) @echo Building clean source... @r() { cat ../pages/$$1-* >$$2.clean ; } ; \ r e00 u0; \ r e01 u1; \ r e02 u2; \ r e03 u3; \ r e04 u4; \ r e05 u5; \ r e06 u6; \ r e07 u7; \ r e08 u8; \ r e09 u9; \ r e10 ux; \ r e11 sh; \ r e12 init @touch cleansrc # patch the clean sources # XXX what if we do USECOREPATCHES=no and we want to apply # one of the cores as an EXTRAPATCH? $(ALLSRCS) patched : $(CLEANSRCS) @echo Patching... @for src in $(CLEANSRCS) ; do \ cp $$src `basename $$src .clean`.s; \ done @if [ $(USECOREPATCHES) = "yes" ] ; then \ for p in ../patches/core/*.patch ; do \ echo ' ' `basename $$p .patch`; \ patch -s -p1 < $$p; \ done; \ fi @for p in $(EXTRAPATCHES) ; do \ echo ' ' $$p; \ patch -s -p1 < ../patches/$$p.patch; \ done @touch patched # build the unix kernel from the KSRCS using the v2 assembler. # XXX make ml take cmd line args for input and output file. unix loadfile usyms : $(KSRCS) @echo Building kernel... @$(AS) u?.s @$(NM) a.out | sort > usyms @$(ML) @mv a.out unix # build init from sources # XXX make fixaout.py overwrite a.out instead of write b.out init : init.s @echo Building init... @$(AS) init.s @../tools/fixaout.py @rm a.out @mv b.out init # build sh from sources # XXX make fixaout.py overwrite a.out instead of write b.out sh : sh.s @echo Building sh... @$(AS) sh.s @../tools/fixaout.py @rm a.out @mv b.out sh # build a prototype filesystems # XXX shell is not quite ready for prime time. works partially but # not from login. root usr protofs : init sh @echo Building filesystems... @$(TREECOPY) ../fs/root . @$(TREECOPY) ../fs/new/etc root @$(TREECOPY) ../fs/usr . @cp init root/etc/init @cp sh root/bin/xsh @touch protofs # build filesystem images rf0.dsk rk0.dsk images : protofs @echo Building disk images... @$(MKFS) -p ../fs/Readme root rf0.dsk rf @$(MKFS) -p ../fs/Readme usr rk0.dsk rk @touch images # build a tape image tape : protofs @echo Building tape image... @$(MKTAPE) root root/bin/* root/etc/* install : rf0.dsk rk0.dsk loadfile tape @echo Installing... @cp rf0.dsk rk0.dsk loadfile tape ../images # clean intermediate files clean : rm -f $(CLEANSRCS) cleansrc rm -f $(ALLSRCS) patched *.orig rm -f unix usyms rm -rf usr root protofs rm -f init sh rm -f images # clean intermediate and target files clobber : clean rm -f tape rm -f loadfile rm -f rf0.dsk rk0.dsk