#       @(#)cf.mk	1.9 - 85/09/13

SYS = unix
NODE = unix
REL = 2
VER = 1
MACH = iAPX286

ROOT=/

INSDIR = $(ROOT)

TYPE = iAPX286

INCRT = /usr/include
CFLAGS = -I$(INCRT) -Ml
CC = cc
AR = ar
LD = ld
LDFLAGS = -i
STRIP = $(PFX)strip
FRC =

FILES = linesw.o       \
	conf.o         \
	handlers.o     \
	buffers.o      \
	gdt.o          \
	name.o

.IGNORE:
all:	flop wini

current.wini:
	-@if [ ! -r current.wini ] ;\
	then\
		rm -f $(FILES) ;\
		echo unix.w: ;\
		$(PFX)config -t -m master dfile.w ;\
	fi

current.flop:
	-@if [ ! -r current.flop ] ;\
	then\
		rm -f $(FILES) ;\
		echo unix.f: ;\
		$(PFX)config -t -m master dfile.f ;\
	fi

buffers.o:
	$(CC) $(CFLAGS) -S buffers.c;\
	ed buffers.s < commtobss;\
	$(CC) $(CFLAGS) -c buffers.s

conf.o:
	$(CC) $(CFLAGS) -S conf.c;\
	ed conf.s < commtobss;\
	$(CC) $(CFLAGS) -c conf.s

.s.o:
	$(CC) $(CFLAGS) -c $*.s

wini: newname current.wini $(FILES)
	-$(LD) $(LDFLAGS) -x -o ../unix.w -e strt -K\
		 gdt.o ../ml.o conf.o linesw.o buffers.o handlers.o name.o\
		 ../lib[0-9] ifile -la
		 -rm -f current*
		 -touch current.wini
		-chgrp bin ../unix.w
		-chmod 664 ../unix.w
		-chown bin ../unix.w

flop: newname current.flop $(FILES)
	-$(LD) $(LDFLAGS) -x -o ../unix.f -e strt -K\
		gdt.o ../ml.o conf.o linesw.o buffers.o handlers.o name.o\
		../lib[0-9] ifile -la
		-rm -f current*
		-touch current.flop
		-nm -x ../unix.f > ../nlist.f
		-$(STRIP) ../unix.f
		-chgrp bin ../unix.f
		-chmod 664 ../unix.f
		-chown bin ../unix.f

newname:
	rm -f name.o

name.o: name.c
	$(CC) $(CFLAGS) -c \
		-DSYS=\"`expr $(SYS) : '\(.\{1,8\}\)'`\" \
		-DNODE=\"`expr $(NODE) : '\(.\{1,8\}\)'`\" \
		-DREL=\"`expr $(REL) : '\(.\{1,8\}\)'`\" \
		-DVER=\"`expr $(VER) : '\(.\{1,8\}\)'`\" \
		-DMACH=\"`expr $(MACH) : '\(.\{1,8\}\)'`\" \
		name.c

install:
	mv /unix /unix-
	cp ../unix.w /unix

clean:
	-rm -f *.o current*

clobber:
	-rm -f *.o current*
	-rm -f config.h conf.c handlers.c
	-rm -f ../unix.f ../unix.w


