#
# Copyright (c)  1998 - 2000, Amnon Barak, The Hebrew University of Jerusalem.
# All rights reserved.
#
# Permission to use, copy and distribute this software is hereby granted
# under the terms of version 2 or any later version of the GNU General
# Public License, as published by the Free Software Foundation.
#
# THE HEBREW UNIVERSITY OF JERUSALEM  PROVIDES THIS SOFTWARE IN ITS "AS IS"
# CONDITION. THE HEBREW UNIVERSITY OF JERUSALEM DISCLAIMS  ANY LIABILITY OF
# ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#
#
# Makefile for MOS permanent interface.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#

O_TARGET := mos.o
O_OBJS   := kernel.o prequest.o mosproc.o mosadmin.o calcmem.o \
	    mosmodule.o mosdecay.o link.o alternate.o interface.o service.o \
	    auto_syscalls.o comm.o config.o mig.o deputy.o remote.o \
	    log.o syscalls.o rinode.o cache.o div.o

ifdef CONFIG_MOSIX_DFSA
O_OBJS += dfsa.o badops.o
endif

OX_OBJS += auto_export.o export.o export2.o

include $(TOPDIR)/Rules.make

first_rule: $(TOPDIR)/include/mos/shorthand.h $(TOPDIR)/include/mos/fill.h

mkext: mkext.c
	$(HOSTCC) $(HOSTCFLAGS) -o mkext mkext.c

auto_syscalls.c: mkdefcalls $(TOPDIR)/arch/i386/kernel/entry.S syscalls.c
	./mkdefcalls

mkdefcalls: mkdefcalls.c $(TOPDIR)/include/linux/config.h $(TOPDIR)/include/linux/types.h $(TOPDIR)/include/linux/sched.h $(TOPDIR)/include/linux/signal.h $(TOPDIR)/include/linux/sys.h $(TOPDIR)/include/linux/kernel.h
	$(HOSTCC) $(HOSTCFLAGS) -o mkdefcalls -DENTRY_IN=\"$(TOPDIR)/arch/i386/kernel/entry.S\" -DSYSCALLS_IN=\"$(TOPDIR)/mos/syscalls.c\" -DSYSCALLS_OUT=\"$(TOPDIR)/mos/auto_syscalls.c\" mkdefcalls.c

link.S $(TOPDIR)/include/mos/shorthand.h $(TOPDIR)/include/mos/fill.h auto_export.c: extlist mkext
	./mkext extlist link.S $(TOPDIR)/include/mos/fill.h $(TOPDIR)/include/mos/shorthand.h auto_export.c

alternate.c: copy_unconf $(TOPDIR)/fs/binfmt_aout.c $(TOPDIR)/.config
	/bin/sh ./copy_unconf "$(CONFIG_BINFMT_AOUT)" $(TOPDIR)/fs/binfmt_aout.c > alternate.c
