##################################################################
#   Copyright  2004, Sebastian Heutling. All rights reserved.
#   $Id: Makefile,v 1.6 2004/09/11 15:03:24 basti Exp $
#
#   Descr. : Makefile for the console plugin
#   Authors: Sebastian Heutling, sheutlin@gmx.de
##################################################################
TOP      := ../../..
include $(TOP)/config/make.tmpl
include $(TOP)/server/config/make.cfg

USE_TUNNEL:=yes

LD       :=$(CXX)
FILES    := init InputDevPlugin InputDevice WatchSource

ifeq ($(USE_TUNNEL),yes)
FILES += MsgPorts ComPort
endif

LIBNAME  := inputdev.so
OBJECTS  := $(foreach f, $(FILES), .$(f).o)
DEPENDS  := $(foreach f, $(FILES), .$(f).d)
cleanobjects=$(OBJECTS) $(LIBNAME) $(DEPENDS) MsgPorts.* ComPort.*

INCLUDES := -I$(TOP)/server/include -I$(TOP)/inputtunnel/include -I. -I$(XERCESINCLUDES)
DEFINES  := -DDATADIR=\"$(datadir)\"
ifeq ($(USE_TUNNEL),yes)
DEFINES  += -DUSE_TUNNEL
endif
CXXFLAGS += $(INCLUDES) $(DEFINES)
LDLIBS   := -L$(XERCESLIBS) -lxerces-c
LDFLAGS  := $(LDLIBS) -Wl,--no-undefined
subdirs  := locale

.PHONY: all depend clean

all: $(LIBNAME)
	@$(call multimake,$(subdirs))

$(eval $(call link_so,$(LIBNAME),$(OBJECTS),$(LDFLAGS)))
$(eval $(call compile_source,cpp,Makefile,$(CXXFLAGS)))
$(eval $(call build_depends,cpp,Makefile,$(CXXFLAGS)))
$(eval $(call clean,$(subdirs),$(cleanobjects)))
$(eval $(call distclean,$(subdirs),$(cleanobjects)))
$(eval $(call link_source,MsgPorts,$(TOP)/shared))
$(eval $(call link_source,ComPort,$(TOP)/shared))

install:
	@$(INSTALL) -d $(DESTDIR)$(PLUGINDIR)
	@$(INSTALL) -d $(DESTDIR)/etc/keyman
	@$(INSTALL_DATA) $(LIBNAME) $(DESTDIR)$(PLUGINDIR)
	@$(INSTALL_DATA) .inputdev $(DESTDIR)/etc/keyman/inputdev
	@$(call multimake,$(subdirs),install)

ifeq (,$(filter clean distclean depend install,$(MAKECMDGOALS)))
-include $(DEPENDS)
endif

