#
# Makefile for the iBCS emulator files
#
# $Id: Makefile,v 1.47 1995/07/03 12:51:46 mike Exp $
# $Source: /u3/CVS/ibcs/iBCSemul/Makefile,v $
#

######## You should not need to change anything in this file ########

# Build the compile flags etc. based on the selected options in ../CONFIG.
# Edit ../CONFIG if you don't want the defaults!

include ../CONFIG

MODULEDIR = /usr/lib/modules

EMUOPTS	=
OBJS	= emulate.o map.o coff.o hrtsys.o ioctl.o ipc.o mmap.o open.o \
	secureware.o socket.o poll.o ptrace.o signal.o stat.o sysconf.o \
	sysi86.o syslocal.o socksys.o ulimit.o utsname.o \
	wysev386.o \
	xnx.o xstat.o stream.o sysinfo.o sysisc.o sysfs.o vtkd.o

ifeq ($(EMU_SCO),yes)
EMUOPTS := $(EMUOPTS) -DEMU_SCO
endif
ifeq ($(EMU_ISC),yes)
EMUOPTS := $(EMUOPTS) -DEMU_ISC
endif
ifeq ($(EMU_SVR4),yes)
EMUOPTS := $(EMUOPTS) -DEMU_SVR4
OBJS	:= $(OBJS) svr4.o
endif
ifeq ($(EMU_BSD),yes)
EMUOPTS	:= $(EMUOPTS) -DEMU_BSD
OBJS	:= $(OBJS) bsd.o bsdioctl.o bsdsignal.o bsdsocket.o bsdstat.o
endif
ifeq ($(EMU_WYSE),yes)
EMUOPTS := $(EMUOPTS) -DEMU_WYSE
endif
ifeq ($(EMU_WYSEMP),yes)
EMUOPTS := $(EMUOPTS) -DEMU_WYSEMP
endif
ifeq ($(EMU_X286),yes)
EMUOPTS	:= $(EMUOPTS) -DEMU_X286
endif

ifeq ($(EMU_XTI),yes)
EMUOPTS	:= $(EMUOPTS) -DEMU_XTI
OBJS	:= $(OBJS) timod.o
endif

ifeq ($(EMU_BINFMT_ELF),yes)
EMUOPTS	:= $(EMUOPTS) -DEMU_BINFMT_ELF
OBJS	:= $(OBJS) binfmt_elf.o
endif
ifeq ($(EMU_BINFMT_COFF),yes)
EMUOPTS	:= $(EMUOPTS) -DEMU_BINFMT_COFF
OBJS	:= $(OBJS) binfmt_coff.o
endif
ifeq ($(EMU_BINFMT_XOUT),yes)
EMUOPTS	:= $(EMUOPTS) -DEMU_BINFMT_XOUT
OBJS	:=$(OBJS) binfmt_xout.o
endif

ifeq ($(IBCS_TRACE),yes)
EMUOPTS	:= $(EMUOPTS) -DIBCS_TRACE
endif
ifeq ($(VERBOSE_ERRORS),yes)
EMUOPTS	:= $(EMUOPTS) -DVERBOSE_ERRORS
endif
ifeq ($(COFF_TRACE),yes)
EMUOPTS	:= $(EMUOPTS) -DCOFF_TRACE
endif
ifeq ($(XOUT_DEBUG),yes)
EMUOPTS	:= $(EMUOPTS) -DXOUT_DEBUG
endif
ifeq ($(XOUT_TRACE),yes)
EMUOPTS := $(EMUOPTS) -DXOUT_TRACE
endif

ifneq (${ELFMODULE},)
LDMODFLAGS=-m elf_i386
endif


CFLAGS = -D__KERNEL__=1 -DMODULE \
	-I../include -Wall -Wstrict-prototypes \
	-O2 -fomit-frame-pointer -m486 \
	-DSOCKSYS_MAJOR=$(SOCKSYS_MAJOR) $(EMUOPTS)


.S.s:
	$(CPP) -traditional $< -o $*.s
.c.s:
	$(CC) $(CFLAGS) -S $<
.s.o:
	$(AS) -c -o $*.o $<
.c.o:
	$(CC) $(CFLAGS) -c $<


all:	iBCS

install: all
	-mkdir -p "$(MODULEDIR)"
	cp iBCS "$(MODULEDIR)"/iBCS


iBCS:	$(OBJS)
	$(LD) -r $(LDMODFLAGS) -o iBCS $(OBJS)


clean:
	rm -f core *.o *.a *.s .depend

dep:
	$(CPP) -M -I../include $(OPTIONS) *.c > .depend

dummy:

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
