#	START NEW ARIX SCCS HEADER
#
#	@(#) Makefile: version 25.1 created on 11/27/91 at 14:52:12
#
#	Copyright (c) 1990 by Arix Corporation
#	All Rights Reserved
#
#	@(#)Makefile	25.1	11/27/91 Copyright (c) 1990 by Arix Corporation
#
#	END NEW ARIX SCCS HEADER

# Makefile for new config program

SHELL=/bin/sh
include $(IROOT)/macdefs

# SECOPT, PERFOPT & DEBUGOPT come from the main pm Makefile
LOCAL_LCFLAGS	= $(SECOPT) $(PERFOPT) $(DEBUGOPT)

MASTERDIR= m.d

MASTERS	= $(MASTERDIR)/*

NOTINCL	= $(MASTERDIR)/nfs $(MASTERDIR)/rfs
SYSTEM	= system
RSYSTEM	= $(SYSTEM).rfs

VERSION=`../month_day`

all:	conf.o conf.rfs.o localcf.mker

config:	config.o util.o in_data.h
	$(LCC) -o config config.o util.o

config.o: config.c
	$(LCC) $(LCFLAGS) -DS3000 -I$(PMINC) -c config.c

util.o: util.c
	$(LCC) $(LCFLAGS) -DS3000 -I$(PMINC) -c util.c

conf.o:	config $(SYSTEM) $(MASTERDIR)/kernel $(MASTERS)
	./config -m $(MASTERDIR) $(SYSTEM)
	$(CC) -I. $(CFLAGS) -DVERSION=\"$(VERSION)\" -c conf.c

conf.rfs.o:	config $(RSYSTEM) $(MASTERS) $(EXLAN)
	./config -c conf.rfs.c -h config.rfs.h -m $(MASTERDIR) $(RSYSTEM)
	$(CC) -I. $(CFLAGS) -DVERSION=\"$(VERSION)\" -c conf.rfs.c

$(MASTERDIR)/kernel:	release
	echo '/^struct utsname/+3\ns/"[^"]*"/"$(RELEASE)"/p\nw' | \
		ed $(MASTERDIR)/kernel

release_check:		/tmp localcf.mker
	krel=`sed -n -e '/^struct utsname/{ n' -e n -e n \
		-e 's/^.*"\([^"]*\)".*$$/\1/p' -e '}' $(MASTERDIR)/kernel` ; \
	if [ ! -f release -o "$(RELEASE)" != "$$krel" ] ; \
	then : > release ; \
	fi ; \
	if [ ! -w m.d/kernel ] ; \
	then chmod u+w m.d/kernel ; \
	fi ; \
	exit 0

chmagic:	chmagic.c
	$(CC) -o chmagic chmagic.c

localcf.mker: 
	sed -e \
	    '/^UMACH =/s/$$/ $(UMACH)/; /^MACH =/s/$$/ $(MACH)/;' \
	    loc.cf.mk > localcf.mk

.c.s:
	$(CC) $(CFLAGS) -S $(<F)
