#
# Makefile for vkeybd
# copyright (c) 1997-1999 by Takashi Iwai
#

#
# installation directory -- binary and Tcl script are put there
#
INSTALL_DIR = /usr/local/bin

#
# preset and keyboard file are put here
#
ETC_DIR = /etc

#
# device selections -- multiple avaialble
# to disable it, set value 0 (do not undefine it)
#
USE_AWE = 1
USE_MIDI = 1
USE_ALSA = 0

#
# Tcl/Tk library -- depends on your distribution
#
TCLLIB = -ltcl7.6
TCLINC =
TKLIB = -L/usr/X11R6/lib -ltk4.2
TKINC =
XLIB = -L/usr/X11R6/lib -lX11
XINC = -I/usr/X11R6/include
EXTRALIB = -ldl

#----------------------------------------------------------------
# device definitions
#----------------------------------------------------------------

# AWE device
ifeq (1,$(USE_AWE))
DEVICES += -DVKB_USE_AWE
DEVOBJS += oper_awe.o
EXTRAOBJS = oss_misc.o
endif

# MIDI device
ifeq (1,$(USE_MIDI))
DEVICES += -DVKB_USE_MIDI
DEVOBJS += oper_midi.o
EXTRAOBJS = oss_misc.o
endif

# ALSA sequencer
ifeq (1,$(USE_ALSA))
DEVICES += -DVKB_USE_ALSA
DEVOBJS += oper_alsa.o
endif


#----------------------------------------------------------------
# dependencies
#----------------------------------------------------------------

VKB_TCLFILE = $(INSTALL_DIR)/vkeybd.tcl

CFLAGS = -Wall -O -DVKB_TCLFILE=\"$(VKB_TCLFILE)\" $(DEVICES)\
	$(XINC) $(TCLINC) $(TKINC)

TARGETS = vkeybd sftovkb

all: $(TARGETS)

vkeybd: vkb.o vkb_device.o $(DEVOBJS) $(EXTRAOBJS)
	$(CC) -o $@ $^ $(TKLIB) $(TCLLIB) $(XLIB) $(EXTRALIB) -lm

sftovkb: sftovkb.o sffile.o malloc.o fskip.o
	$(CC) -o $@ $^ -lm

install: $(TARGETS) vkeybd.tcl vkeybd.list
	install -c -s vkeybd $(INSTALL_DIR)
	install -c -s sftovkb $(INSTALL_DIR)
	install -c -m 444 vkeybd.tcl $(INSTALL_DIR)
	install -c -m 444 vkeybd.list $(ETC_DIR)

clean:
	rm -f *.o $(TARGETS)
