#
# Makefile for the kernel character device drivers.
#
# 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).
#
# Note 2! The CFLAGS definitions are now inherited from the
# parent makes..
#

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

OBJS	= tty_io.o n_tty.o console.o keyboard.o \
	  tty_ioctl.o pty.o vt.o mem.o vc_screen.o \
	  defkeymap.o consolemap.o selection.o fbmem.o \
	  serial.o

SRCS	= tty_io.c n_tty.c console.c keyboard.c \
	  tty_ioctl.c pty.c vt.c mem.c vc_screen.c \
	  defkeymap.c consolemap.c selection.c fbmem.c \
	  serial.c

SYMTAB_OBJS = serial.o

ifdef CONFIG_AMIGAMOUSE
M = y
OBJS := $(OBJS) amigamouse.o
SRCS := $(SRCS) amigamouse.c
else
ifdef CONFIG_AMIGA
MODULES += amigamouse.o
MM = m
endif
endif

ifdef CONFIG_ATARIMOUSE
M = y
OBJS := $(OBJS) atarimouse.o
SRCS := $(SRCS) atarimouse.c
else
ifdef CONFIG_ATARI
MODULES += atarimouse.o
MM = m
endif
endif

ifdef CONFIG_CYCLADES
OBJS := $(OBJS) cyclades.o
SRCS := $(SRCS) cyclades.c
endif

ifdef CONFIG_ATIXL_BUSMOUSE
M = y
OBJS := $(OBJS) atixlmouse.o
SRCS := $(SRCS) atixlmouse.c
endif

ifdef CONFIG_BUSMOUSE
M = y
OBJS := $(OBJS) busmouse.o
SRCS := $(SRCS) busmouse.c
endif

ifdef CONFIG_PRINTER
OBJS := $(OBJS) lp.o lp_intern.o
SRCS := $(SRCS) lp.c lp_intern.c
ifdef CONFIG_MULTIFACE_III_LP
OBJS := $(OBJS) lp_mfc.o
SRCS := $(SRCS) lp_mfc.c
endif
endif

ifdef CONFIG_MS_BUSMOUSE
M = y
OBJS := $(OBJS) msbusmouse.o
SRCS := $(SRCS) msbusmouse.c
endif

ifdef CONFIG_82C710_MOUSE
CONFIG_PSMOUSE = CONFIG_PSMOUSE
endif

ifdef CONFIG_PSMOUSE
M = y
OBJS := $(OBJS) psaux.o
SRCS := $(SRCS) psaux.c
endif

ifdef CONFIG_QIC02_TAPE
OBJS := $(OBJS) tpqic02.o 
SRCS := $(SRCS) tpqic02.c
endif

ifdef M
SYMTAB_OBJS := $(SYMTAB_OBJS) mouse.o
OBJS := $(OBJS) mouse.o
SRCS := $(SRCS) mouse.c
else
ifdef MM
MODULES += mouse.o
SYMTAB_OBJS += mouse.o
endif
endif

ifdef CONFIG_ATARI_MFPSER
OBJS := $(OBJS) atari_MFPser.o
SRCS := $(SRCS) atari_MFPser.c
else
ifdef CONFIG_ATARI
MODULES += atari_MFPser.o
endif
endif

ifdef CONFIG_ATARI_SCC
OBJS := $(OBJS) atari_SCC.o
SRCS := $(SRCS) atari_SCC.c
else
ifdef CONFIG_ATARI
MODULES += atari_SCC.o
endif
endif

ifdef CONFIG_ATARI_MIDI
OBJS := $(OBJS) atari_MIDI.o
SRCS := $(SRCS) atari_MIDI.c
else
ifdef CONFIG_ATARI
MODULES += atari_MIDI.o
endif
endif

ifdef CONFIG_AMIGA_BUILTIN_SERIAL
OBJS := $(OBJS) amiga_ser.o
SRCS := $(SRCS) amiga_ser.c
else
ifdef CONFIG_AMIGA
MODULES += amiga_ser.o
endif
endif

ifdef CONFIG_GVPIOEXT
OBJS := $(OBJS) io-extender.o
SRCS := $(SRCS) io-extender.c
endif

ifdef CONFIG_MULTIFACE_III_TTY
OBJS := $(OBJS) ser_mfc.o
SRCS := $(SRCS) ser_mfc.c
else
ifdef CONFIG_AMIGA
MODULES += ser_mfc.o
endif
endif

all: char.a

include ../../versions.mk

char.a: $(OBJS)
	rm -f char.a
	$(AR) rcs char.a $(OBJS)
	sync

ifdef MODULES

modules: $(MODULES)
	(cd ../../modules;for i in $(MODULES); do ln -sf ../drivers/char/$$i .; done)
	echo $(MODULES) >../../modules/CHAR_MODULES
else

modules:

endif

dep:
	$(CPP) -M $(SRCS) > .depend
ifdef MODULES
	$(CPP) -M -DMODULE $(MODULES:.o=.c) >> .depend
endif

dummy:

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