# Copyright (C) 1991, 1992 Free Software Foundation, Inc.
# This file is part of the GNU Hurd.
# 
# The GNU Hurd is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# The GNU Hurd is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with the GNU Hurd; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.


MK_INCLUDES=/usr1/gnu/DIST/include
C_INCLUDE_SPEC=-I/usr1/gnu/DIST/hurd/include -I/usr1/gnu/DIST/lib/gcc-lib/i386-compaq-bsd4.3/2.2.2/include
CC=gcc
MACHSA_LIB=/usr1/gnu/DIST/lib/libmach_sa.a
MIGCOM=/usr1/gnu/DIST/lib/migcom
CTHREAD_LIB=/usr1/gnu/DIST/lib/libthreads.a
C_LIB=/usr1/gnu/DIST/hurd/lib/libc.a
CPPFLAGS=-nostdinc -I. -I.. -I${MK_INCLUDES} $(C_INCLUDE_SPEC)
CFLAGS=-Wall -Wno-parentheses -O -g
CPP=/usr1/gnu/DIST/lib/gcc-cpp

VPATH=.:../machine

FSMIGOPTS="-DFILE_INTRAN=protid_t convert_port_to_protid (file_t)" \
	"-DFILE_OUTTRAN=file_t convert_protid_to_port (protid_t)" \
	"-DFILE_DESTRUCTOR=release_protidport (protid_t)" \
	"-DUSERPREFIX=U_" \
	"-DFILE_IMPORTS=import \"ufs.h\";"

IOMIGOPTS="-DIO_INTRAN=protid_t convert_port_to_protid (io_t)" \
	"-DIO_OUTTRAN=io_t convert_protid_to_port (protid_t)" \
	"-DIO_DESTRUCTOR=release_protidport (protid_t)" \
	"-DUSERPREFIX=U_" \
	"-DIO_IMPORTS=import \"ufs.h\";"

FSYSMIGOPTS="-DFSYS_INTRAN=fsys_t verify_fsys_port (fsys_t)" \
	"-DUSERPREFIX=U_" \
	"-DFSYS_IMPORTS=import \"ufs.h\";"

OFILES = ufs_alloc.o ufs_fsops.o ufs_inode.o ufs_ioops.o ufs_pager2.o \
	ufs_tables.o ufs_subr.o ufs_lookup2.o ufs_exception.o \
	ufs_main.o ufs_devio.o ufs_machdep.o ioUser.o memory_objectServer.o \
	ioServer.o fsServer.o default_pager_objectUser.o ufs_fsysops.o \
	fsysServer.o authUser.o execUser.o bootUser.o notifyServer.o \
	fsysUser.o ufs_notify.o fsUser.o devstream.o excUser.o

test: $(OFILES)
	$(CC) $(LDFOOD) -nostdlib -e __start -o ufs $(CFLAGS) $(OFILES) \
	$(CTHREAD_LIB) $(MACHSA_LIB) $(C_LIB) ../lib/error_codes.o  \
	../lib/mach_error.o -lgcc $(C_LIB)

devstream.o: /usr1/gnu/distribs/glibc-1.05/mach/devstream.c
	$(COMPILE.c) -o $@ $<

#$(OFILES): force
force:

$(OFILES): ufs.h
ufs_fsops.o: fsdefs.h ioudefs.h authdefs.h execdefs.h fsysudefs.h
ufs_pager.o: memory_object.h
ufs_pager2.o: memory_object.h
ufs_ioops.o: iodefs.h 
ufs_fsysops.o: fsysdefs.h
ufs_main.o: bootdefs.h ioudefs.h fsudefs.h
ufs_notify.o: notify.h

fsdefs.h fsServer.c fsUser.c fsudefs.h: ../hurd/fs.defs ../hurd/hurd_types.defs
	$(CPP) $(CPPFLAGS) $(FSMIGOPTS) ../hurd/fs.defs \
	| $(MIGCOM) -sheader fsdefs.h -header fsudefs.h

fsysUser.c fsysudefs.h fsysdefs.h fsysServer.c: ../hurd/fsys.defs ../hurd/hurd_types.defs
	$(CPP) $(CPPFLAGS) $(FSYSMIGOPTS) ../hurd/fsys.defs \
	| $(MIGCOM) -sheader fsysdefs.h -header fsysudefs.h

memory_object.h memory_objectServer.c:
	$(CPP) $(CPPFLAGS) -DSEQNOS \
	 $(MK_INCLUDES)/mach/memory_object.defs \
	 | $(MIGCOM) -sheader memory_object.h -header /dev/null -user /dev/null

notify.h notifyServer.c:
	$(CPP) $(CPPFLAGS) -DSEQNOS \
	 $(MK_INCLUDES)/mach/notify.defs \
	 | $(MIGCOM) -sheader notify.h -header /dev/null -user /dev/null

ioudefs.h iodefs.h ioUser.c ioServer.c: ../hurd/io.defs ../hurd/hurd_types.defs
	$(CPP) $(CPPFLAGS) $(IOMIGOPTS) ../hurd/io.defs \
	| $(MIGCOM) -sheader iodefs.h -header ioudefs.h

default_pager_objectUser.c:
	$(CPP) $(CPPFLAGS) \
		$(MK_INCLUDES)/mach/default_pager_object.defs \
	| $(MIGCOM) -header /dev/null -server /dev/null

authdefs.h authUser.c: ../hurd/auth.defs ../hurd/hurd_types.defs
	$(CPP) $(CPPFLAGS) ../hurd/auth.defs \
	| $(MIGCOM) -header authdefs.h -server /dev/null

execdefs.h execUser.c: ../hurd/exec.defs ../hurd/hurd_types.defs
	$(CPP) $(CPPFLAGS) ../hurd/exec.defs \
	| $(MIGCOM) -header execdefs.h -server /dev/null

bootdefs.h bootUser.c: ../hurd/boot.defs
	$(CPP) $(CPPFLAGS) ../hurd/boot.defs \
	| $(MIGCOM) -header bootdefs.h -server /dev/null

excUser.c:
	$(CPP) $(CPPFLAGS) $(MK_INCLUDES)/mach/exc.defs \
	| $(MIGCOM) -header /dev/null -server /dev/null

clean:
	rm -f *.o *Server.c *User.c *defs.h memory_object.h ufs
