#
# Mach Operating System
# Copyright (c) 1991,1990 Carnegie Mellon University
# All Rights Reserved.
# 
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
# 
# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 
# CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
# 
# Carnegie Mellon requests users of this software to return to
# 
#  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
#  School of Computer Science
#  Carnegie Mellon University
#  Pittsburgh PA 15213-3890
# 
# any improvements or extensions that they make and grant Carnegie the
# rights to redistribute these changes.
#
#
# HISTORY
# $Log:	Makefile,v $
# Revision 1.2  92/01/20  13:53:07  dwm
# 	Modifications to build in OSF environment.  Also removed the "make
# 	dependencies", because either -MD or the "md" command is not working
# 	correctly.  Creates a trashed Makedep file.
# 
# Revision 1.1.1.1  92/01/07  12:04:51  dwm
# mach3.0 MK67 distribution
# 
# Revision 1.1  92/01/07  12:04:50  dwm
# Initial revision
# 
# Revision 2.8  91/12/13  14:42:05  jsb
# 	Changed to reflect new directory structure.
# 	[91/12/12            mrt]
# 
# Revision 2.7  91/09/12  16:54:12  bohman
# 	Added mac2.
# 	[91/09/11  17:22:34  bohman]
# 
# Revision 2.6  91/08/24  12:29:43  af
# 	Fine tuning: ... -if vs if
# 	[91/08/14            rvb]
# 	Fixed release to actually link each time.
# 	[91/07/23            danner]
# 
# Revision 2.5.3.1  91/08/19  13:49:07  danner
# 	Fine tuning: ... -if vs if
# 	[91/08/14            rvb]
# 	Fixed release to actually link each time.
# 	[91/07/23            danner]
# 
# Revision 2.5  91/02/05  17:54:02  mrt
# 	Changed to new Mach copyright
# 	[91/02/01  17:53:29  mrt]
# 
# Revision 2.4  90/12/14  11:02:05  jsb
# 	Use $(atsys) (as defined in Makeconf) instead of @sys.
# 	[90/12/13  21:42:30  jsb]
# 
# Revision 2.3  90/11/05  14:32:28  rpd
# 	SUN->SUN3.
# 	[90/10/31            rwd]
# 	Change MACHINE to TARGET_MACHINE.
# 	[90/10/29            rwd]
# 
# Revision 2.2  90/06/02  15:04:16  rpd
# 	Don't use /usr/cs/etc/install; 386 doesn't have it.
# 	[90/06/01            rpd]
# 
# 	Created for new IPC.
# 	[90/03/26  21:09:47  rpd]
# 
#

INSTALL	=	/usr/cs/etc/install -q -c

all:		mig.sh migcom.x

install:	mig.install

mig.install:	$(DDIR)/mig

$(DDIR)/mig:	mig.sh
	cp -p mig.sh $(DDIR)/mig
	chmod 755 $(DDIR)/mig

migcom.install:	$(DDIR)/migcom

$(DDIR)/migcom:	migcom.x
	cp -p migcom.x $(DDIR)/migcom
#	strip $(DDIR)/migcom
	chmod 755 $(DDIR)/migcom


OBJS	 =	mig.o parser.o lexxer.o error.o string.o type.o routine.o \
		statement.o global.o header.o user.o server.o utils.o

INCS	=	alloc.h global.h routine.h string.h utils.h \
		error.h lexxer.h statement.h type.h write.h

# Base of source tree.  Look here for include files.
IDIR = ${VPATH}/../..

PMAXCFLAGS = -Dvoid=int
SUN3CFLAGS = -Dvoid=int
MAC2CFLAGS = -traditional
CFLAGS= $(CDEBUGFLAGS) $($(TARGET_MACHINE)CFLAGS) -traditional -I$(IDIR)

migcom.x:	$(INCS) $(OBJS)
	$(CC) -o migcom.x $(CFLAGS) $(OBJS) -ll

.c.o:
#  Don't do dependencies yet because something is broken (I think "md" command)
#	$(CC) -c -MD $(CFLAGS) $*.c
#	/usr/mach/bin/md -u Makedep -d $*.d
	$(CC) -c $(CFLAGS) $*.c

parser.c parser.h:	parser.y
	yacc -d parser.y &&		\
	mv y.tab.c parser.c &&		\
	mv y.tab.h parser.h

lexxer.c:	lexxer.l
	lex lexxer.l &&			\
	mv lex.yy.c lexxer.c

$(INCS):
	@cp ${VPATH}/$@ .

LIBBASE = $(MAKECONF:h)/../../../release/$(atsys)/lib
BINBASE = $(MAKECONF:h)/../../../release/$(atsys)/bin
OBJBASE = $(MAKECONF:h)/../../../obj/$(atsys)/mk/kernel

release:
	-if [ -f $(LIBBASE)/migcom ]; then mv $(LIBBASE)/migcom $(LIBBASE)/migcom.bak; else true ; fi
	ln -s $(OBJBASE)/lib/migcom $(LIBBASE) 
	-if [ -f $(LIBBASE)/migcom.bak ]; then rm -f $(LIBBASE)/migcom.bak; else true; fi
	-if [ -f $(BINBASE)/mig ]; then mv $(BINBASE)/mig $(BINBASE)/mig.bak; else true ; fi
	ln -s $(OBJBASE)/bin/mig $(BINBASE) 
	-if [ -f $(BINBASE)/mig.bak ]; then rm -f $(BINBASE)/mig.bak; else true; fi


-include Makedep
