SUBDIRS = . tests

EXTRA_DIST= $(platform_dist) $(rgen_srcs)

## Generated code

# Note: generated soure and makefiles included in distribution so a
# distribution can be built without code generation tools and XML
# sources.

# This phony target is needed by generated makefile fragments:
force:

if GENERATE

# AMQP_FINAL_XML is defined in ../configure.ac
amqp_0_10_xml=@AMQP_FINAL_XML@
specs=$(amqp_0_10_xml) $(top_srcdir)/xml/cluster.xml

# Ruby generator.
rgen_dir=$(top_srcdir)/rubygen
rgen_cmd=ruby -I $(rgen_dir) $(rgen_dir)/generate gen $(specs) all $(srcdir)/rubygen.mk

$(rgen_srcs) $(srcdir)/rubygen.mk: rgen.timestamp
rgen.timestamp: $(rgen_generator) $(specs)
	$(rgen_cmd); touch $@
$(rgen_generator):

# Management generator.
mgen_dir=$(top_srcdir)/managementgen
mgen_cmd=$(mgen_dir)/main.py -m $(srcdir)/managementgen.mk \
	$(top_srcdir)/../specs/management-schema.xml \
	$(top_srcdir)/../specs/management-types.xml \
	$(mgen_dir)/templates gen/qpid/management

$(srcdir)/managementgen.mk $(mgen_broker_cpp) $(dist_qpid_management_HEADERS): mgen.timestamp
mgen.timestamp: $(mgen_generator)
	$(mgen_cmd); touch $@
$(mgen_generator):

endif # GENERATE

include $(srcdir)/rubygen.mk
include $(srcdir)/managementgen.mk

DISTCLEANFILES=$(srcdir)/rubygen.mk $(srcdir)/managementgen.mk

# Code generated by C++
noinst_PROGRAMS=generate_MaxMethodBodySize_h
generate_MaxMethodBodySize_h_SOURCES=gen/generate_MaxMethodBodySize_h.cpp
qpid/framing/MaxMethodBodySize.h: generate_MaxMethodBodySize_h
	./generate_MaxMethodBodySize_h
BUILT_SOURCES=qpid/framing/MaxMethodBodySize.h
DISTCLEANFILES+=qpid/framing/MaxMethodBodySize.h


## Compiler flags

AM_CXXFLAGS = $(WARNING_CFLAGS)
AM_LDFLAGS = -version-info $(LIBTOOL_VERSION_INFO_ARG)
INCLUDES = -Igen -I$(srcdir)/gen

## Automake macros to build libraries and executables.

qpidd_LDADD =					\
  libqpidbroker.la				\
  libqpidcommon.la

sbin_PROGRAMS = qpidd
qpidd_SOURCES = qpidd.cpp

posix_plat_src = \
  qpid/sys/posix/IOHandle.cpp \
  qpid/sys/posix/Socket.cpp \
  qpid/sys/posix/AsynchIO.cpp \
  qpid/sys/posix/Time.cpp \
  qpid/sys/posix/Thread.cpp \
  qpid/sys/posix/Shlib.cpp \
  qpid/sys/posix/Mutex.cpp \
  qpid/sys/posix/Fork.cpp \
  qpid/sys/posix/StrError.cpp

posix_plat_hdr = \
  qpid/sys/posix/check.h \
  qpid/sys/posix/Condition.h \
  qpid/sys/posix/PrivatePosix.h \
  qpid/sys/posix/Mutex.h \
  qpid/sys/posix/Fork.h \
  qpid/sys/posix/LockFile.h

if HAVE_EPOLL 
  poller = qpid/sys/epoll/EpollPoller.cpp
endif

if HAVE_ECF
  poller = qpid/sys/solaris/ECFPoller.cpp
endif

platform_src = $(posix_plat_src) $(poller)
platform_hdr = $(posix_plat_hdr)

lib_LTLIBRARIES = libqpidcommon.la libqpidbroker.la libqpidclient.la 

include cluster.mk
include acl.mk

# The logger library uses boost::date_time to format time.
# We have to disable the unused parameters warning to get around
# unused parameters in boost::date_time headers. So we build it
# in a convenience library to link into libqpid_common.
# 
noinst_LTLIBRARIES=libLogger.la # libqpidamqp_0_10.la
libLogger_la_SOURCES=qpid/log/Logger.cpp qpid/log/Logger.h
libLogger_la_CXXFLAGS=$(AM_CXXFLAGS) -Wno-unused-parameter

if RDMA

# RDMA (Infiniband) protocol code
libqpidrdma_la_SOURCES = \
  qpid/sys/rdma/rdma_exception.h \
  qpid/sys/rdma/rdma_factories.cpp \
  qpid/sys/rdma/RdmaIO.cpp \
  qpid/sys/rdma/RdmaIO.h \
  qpid/sys/rdma/rdma_wrap.h
libqpidrdma_la_LIBADD = \
  -lrdmacm \
  -libverbs
libqpidrdma_la_CXXFLAGS = \
  $(AM_CXXFLAGS) -Wno-missing-field-initializers
noinst_LTLIBRARIES += \
  libqpidrdma.la
qpidd_LDADD += \
  libqpidrdma.la

noinst_PROGRAMS += RdmaServer RdmaClient
RdmaServer_SOURCES = qpid/sys/rdma/RdmaServer.cpp
RdmaServer_CXXFLAGS = \
  $(AM_CXXFLAGS) -Wno-missing-field-initializers
RdmaServer_LDADD = \
  libqpidrdma.la libqpidcommon.la
RdmaClient_SOURCES = qpid/sys/rdma/RdmaClient.cpp
RdmaClient_CXXFLAGS = \
  $(AM_CXXFLAGS) -Wno-missing-field-initializers
RdmaClient_LDADD = \
  libqpidrdma.la libqpidcommon.la

endif

# New 0-10 codec, to be integrated in future.
# libqpidamqp_0_10_la_SOURCES= 
EXTRA_DIST +=\
  $(rgen_amqp_0_10_srcs) \
  qpid/amqp_0_10/apply.h \
  qpid/amqp_0_10/built_in_types.h \
  qpid/amqp_0_10/complex_types.cpp \
  qpid/amqp_0_10/Array.h \
  qpid/amqp_0_10/Array.cpp \
  qpid/amqp_0_10/Body.h \
  qpid/amqp_0_10/Command.h \
  qpid/amqp_0_10/CommmandPacker.h \
  qpid/amqp_0_10/Control.h \
  qpid/amqp_0_10/Header.h \
  qpid/amqp_0_10/Header.cpp \
  qpid/amqp_0_10/FrameHeader.h \
  qpid/amqp_0_10/FrameHeader.cpp \
  qpid/amqp_0_10/Holder.h \
  qpid/amqp_0_10/Codec.h \
  qpid/amqp_0_10/Packer.h \
  qpid/amqp_0_10/Decimal.h \
  qpid/amqp_0_10/SerializableString.h \
  qpid/amqp_0_10/Map.h \
  qpid/amqp_0_10/Map.cpp \
  qpid/amqp_0_10/Struct.h \
  qpid/amqp_0_10/Struct32.h \
  qpid/amqp_0_10/Struct32.cpp \
  qpid/amqp_0_10/Unit.h \
  qpid/amqp_0_10/Unit.cpp \
  qpid/amqp_0_10/UnitHandler.h \
  qpid/amqp_0_10/UnknownType.h \
  qpid/amqp_0_10/UnknownType.cpp \
  qpid/amqp_0_10/UnknownStruct.h \
  qpid/amqp_0_10/UnknownStruct.cpp 

libqpidcommon_la_LIBADD = \
  -lboost_program_options \
  -lboost_filesystem \
  -luuid \
  libLogger.la \
  $(LIB_DLOPEN) \
  $(LIB_CLOCK_GETTIME)

libqpidcommon_la_SOURCES = \
  $(rgen_framing_srcs) \
  $(platform_src) \
  qpid/amqp_0_10/SessionHandler.h \
  qpid/amqp_0_10/SessionHandler.cpp \
  qpid/Serializer.h \
  qpid/SessionState.h \
  qpid/SessionState.cpp \
  qpid/SessionId.cpp \
  qpid/framing/AccumulatedAck.cpp \
  qpid/framing/AMQBody.cpp \
  qpid/framing/AMQMethodBody.cpp \
  qpid/framing/AMQContentBody.cpp \
  qpid/framing/AMQFrame.cpp \
  qpid/framing/AMQHeaderBody.cpp \
  qpid/framing/AMQHeartbeatBody.cpp \
  qpid/framing/Array.cpp \
  qpid/framing/BodyHolder.cpp \
  qpid/framing/BodyHandler.cpp \
  qpid/framing/Buffer.cpp \
  qpid/framing/FieldTable.cpp \
  qpid/framing/FieldValue.cpp \
  qpid/framing/FrameSet.cpp \
  qpid/framing/ProtocolInitiation.cpp \
  qpid/framing/ProtocolVersion.cpp \
  qpid/framing/SendContent.cpp \
  qpid/framing/SequenceNumber.cpp \
  qpid/framing/SequenceNumberSet.cpp \
  qpid/framing/SequenceSet.cpp \
  qpid/framing/Proxy.cpp \
  qpid/framing/Uuid.cpp \
  qpid/framing/AMQP_HighestVersion.h \
  qpid/framing/Blob.cpp \
  qpid/framing/MaxMethodBodySize.h \
  qpid/framing/TransferContent.cpp \
  qpid/assert.cpp qpid/assert.h \
  qpid/Exception.cpp \
  qpid/Plugin.cpp \
  qpid/StringUtils.cpp \
  qpid/Url.cpp \
  qpid/management/Manageable.cpp \
  qpid/management/ManagementObject.cpp \
  qpid/sys/AggregateOutput.cpp \
  qpid/sys/AsynchIOHandler.cpp \
  qpid/sys/Dispatcher.cpp \
  qpid/sys/Runnable.cpp \
  qpid/sys/SystemInfo.cpp \
  qpid/sys/Shlib.cpp \
  qpid/DataDir.cpp \
  qpid/Options.cpp \
  qpid/log/Options.cpp \
  qpid/log/Selector.cpp \
  qpid/log/Statement.cpp \
  qpid/pointer_to_other.h

libqpidbroker_la_LIBADD = libqpidcommon.la -luuid
if HAVE_XML
libqpidbroker_la_LIBADD += -lxerces-c -lxqilla
endif
if HAVE_SASL
libqpidbroker_la_LIBADD += -lsasl2
endif

libqpidbroker_la_SOURCES = \
  $(mgen_broker_cpp) \
  qpid/amqp_0_10/Connection.h \
  qpid/amqp_0_10/Connection.cpp \
  qpid/broker/Broker.cpp \
  qpid/broker/BrokerSingleton.cpp \
  qpid/broker/Exchange.cpp \
  qpid/broker/Queue.cpp \
  qpid/broker/PersistableMessage.cpp \
  qpid/broker/Bridge.cpp \
  qpid/broker/Connection.cpp \
  qpid/broker/ConnectionHandler.cpp \
  qpid/broker/ConnectionFactory.cpp \
  qpid/broker/Daemon.cpp \
  qpid/broker/DeliverableMessage.cpp \
  qpid/broker/DeliveryRecord.cpp \
  qpid/broker/DirectExchange.cpp \
  qpid/broker/DtxAck.cpp \
  qpid/broker/DtxBuffer.cpp \
  qpid/broker/DtxManager.cpp \
  qpid/broker/DtxTimeout.cpp \
  qpid/broker/DtxWorkRecord.cpp \
  qpid/broker/ExchangeRegistry.cpp \
  qpid/broker/FanOutExchange.cpp \
  qpid/broker/HeadersExchange.cpp \
  qpid/broker/IncomingExecutionContext.cpp \
  qpid/broker/IncompleteMessageList.cpp \
  qpid/broker/Link.cpp \
  qpid/broker/LinkRegistry.cpp \
  qpid/broker/Message.cpp \
  qpid/broker/MessageAdapter.cpp \
  qpid/broker/MessageBuilder.cpp \
  qpid/broker/MessageDelivery.cpp \
  qpid/broker/MessageStoreModule.cpp \
  qpid/broker/NameGenerator.cpp \
  qpid/broker/NullMessageStore.cpp \
  qpid/broker/QueueBindings.cpp \
  qpid/broker/QueuePolicy.cpp \
  qpid/broker/QueueRegistry.cpp \
  qpid/broker/RecoveryManagerImpl.cpp \
  qpid/broker/RecoveredEnqueue.cpp \
  qpid/broker/RecoveredDequeue.cpp \
  qpid/broker/SaslAuthenticator.cpp \
  qpid/broker/SemanticState.h \
  qpid/broker/SemanticState.cpp \
  qpid/broker/SessionAdapter.cpp \
  qpid/broker/SessionState.h \
  qpid/broker/SessionState.cpp \
  qpid/broker/SessionManager.h \
  qpid/broker/SessionManager.cpp \
  qpid/broker/SessionContext.h \
  qpid/broker/SessionHandler.h \
  qpid/broker/SessionHandler.cpp \
  qpid/broker/SignalHandler.h \
  qpid/broker/SignalHandler.cpp \
  qpid/broker/System.cpp \
  qpid/broker/Timer.cpp \
  qpid/broker/TopicExchange.cpp \
  qpid/broker/TxAccept.cpp \
  qpid/broker/TxBuffer.cpp \
  qpid/broker/TxPublish.cpp \
  qpid/broker/Vhost.cpp \
  qpid/management/ManagementBroker.cpp \
  qpid/management/ManagementExchange.cpp \
  qpid/sys/TCPIOPlugin.cpp

if HAVE_XML
libqpidbroker_la_SOURCES +=  qpid/broker/XmlExchange.cpp
endif


libqpidclient_la_LIBADD = libqpidcommon.la  -luuid

libqpidclient_la_SOURCES =			\
  $(rgen_client_srcs)				\
  qpid/agent/ManagementAgentImpl.cpp \
  qpid/client/AckPolicy.cpp			\
  qpid/client/Bounds.cpp			\
  qpid/client/ConnectionImpl.cpp		\
  qpid/client/Connector.cpp			\
  qpid/client/Connection.cpp			\
  qpid/client/ConnectionHandler.cpp		\
  qpid/client/ConnectionSettings.cpp		\
  qpid/client/Demux.cpp				\
  qpid/client/Dispatcher.cpp			\
  qpid/client/Future.cpp			\
  qpid/client/FutureCompletion.cpp		\
  qpid/client/FutureResult.cpp			\
  qpid/client/LocalQueue.cpp			\
  qpid/client/Message.cpp			\
  qpid/client/MessageListener.cpp		\
  qpid/client/Results.cpp			\
  qpid/client/SessionBase_0_10.cpp		\
  qpid/client/SessionBase_0_10.h		\
  qpid/client/SessionBase_0_10Access.h		\
  qpid/client/SessionImpl.cpp			\
  qpid/client/StateManager.cpp			\
  qpid/client/SubscriptionManager.cpp

nobase_include_HEADERS = \
  $(platform_hdr) \
  qpid/amqp_0_10/apply.h \
  qpid/assert.h \
  qpid/DataDir.h \
  qpid/Exception.h \
  qpid/sys/ExceptionHolder.h \
  qpid/amqp_0_10/Exception.h \
  qpid/Msg.h \
  qpid/Options.h \
  qpid/Plugin.h \
  qpid/ptr_map.h \
  qpid/RangeSet.h \
  qpid/RefCounted.h \
  qpid/SessionId.h \
  qpid/SessionState.h \
  qpid/SharedObject.h \
  qpid/StringUtils.h \
  qpid/Url.h \
  qpid/InlineVector.h \
  qpid/InlineAllocator.h \
  qpid/memory.h \
  qpid/shared_ptr.h \
  qpid/agent/ManagementAgent.h \
  qpid/agent/ManagementAgentImpl.h \
  qpid/broker/Broker.h \
  qpid/broker/AclModule.h \
  qpid/broker/SessionAdapter.h \
  qpid/broker/Exchange.h \
  qpid/broker/Queue.h \
  qpid/broker/BrokerSingleton.h \
  qpid/broker/Bridge.h \
  qpid/broker/Connection.h \
  qpid/broker/ConnectionState.h \
  qpid/broker/ConnectionFactory.h \
  qpid/broker/ConnectionHandler.h \
  qpid/broker/ConnectionToken.h \
  qpid/broker/OwnershipToken.h \
  qpid/broker/Consumer.h \
  qpid/broker/Daemon.h \
  qpid/broker/Deliverable.h \
  qpid/broker/DeliverableMessage.h \
  qpid/broker/DeliveryAdapter.h \
  qpid/broker/DeliveryId.h \
  qpid/broker/DeliveryRecord.h \
  qpid/broker/DeliveryToken.h \
  qpid/broker/DirectExchange.h \
  qpid/broker/DtxAck.h \
  qpid/broker/DtxBuffer.h \
  qpid/broker/DtxManager.h \
  qpid/broker/DtxTimeout.h \
  qpid/broker/DtxWorkRecord.h \
  qpid/broker/ExchangeRegistry.h \
  qpid/broker/FanOutExchange.h \
  qpid/broker/HandlerImpl.h \
  qpid/broker/HeadersExchange.h \
  qpid/broker/IncomingExecutionContext.h \
  qpid/broker/IncompleteMessageList.h \
  qpid/broker/Link.h \
  qpid/broker/LinkRegistry.h \
  qpid/broker/Message.h \
  qpid/broker/MessageAdapter.h \
  qpid/broker/MessageBuilder.h \
  qpid/broker/MessageDelivery.h \
  qpid/broker/MessageStore.h \
  qpid/broker/MessageStoreModule.h \
  qpid/broker/NameGenerator.h \
  qpid/broker/NullMessageStore.h \
  qpid/broker/Persistable.h \
  qpid/broker/PersistableConfig.h \
  qpid/broker/PersistableExchange.h \
  qpid/broker/PersistableMessage.h \
  qpid/broker/PersistableQueue.h \
  qpid/broker/Prefetch.h \
  qpid/broker/QueueBindings.h \
  qpid/broker/QueuePolicy.h \
  qpid/broker/QueueRegistry.h \
  qpid/broker/RecoverableConfig.h \
  qpid/broker/RecoverableExchange.h \
  qpid/broker/RecoverableMessage.h \
  qpid/broker/RecoverableQueue.h \
  qpid/broker/RecoverableTransaction.h \
  qpid/broker/RecoveredDequeue.h \
  qpid/broker/RecoveredEnqueue.h \
  qpid/broker/RecoveryManager.h \
  qpid/broker/RecoveryManagerImpl.h \
  qpid/broker/SaslAuthenticator.h \
  qpid/broker/SessionAdapter.h \
  qpid/broker/SessionManager.h \
  qpid/broker/System.h \
  qpid/broker/Timer.h \
  qpid/broker/TopicExchange.h \
  qpid/broker/TransactionalStore.h \
  qpid/broker/TxAccept.h \
  qpid/broker/TxBuffer.h \
  qpid/broker/TxOp.h \
  qpid/broker/TxPublish.h \
  qpid/broker/Vhost.h \
  qpid/client/AckMode.h \
  qpid/client/AckPolicy.h			\
  qpid/client/Bounds.h \
  qpid/client/ChainableFrameHandler.h		\
  qpid/client/Completion.h \
  qpid/client/Connection.h \
  qpid/client/ConnectionHandler.h \
  qpid/client/ConnectionImpl.h \
  qpid/client/ConnectionSettings.h \
  qpid/client/Connector.h \
  qpid/client/Demux.h \
  qpid/client/Dispatcher.h \
  qpid/client/Execution.h \
  qpid/client/FlowControl.h \
  qpid/client/Future.h \
  qpid/client/FutureCompletion.h \
  qpid/client/FutureResult.h \
  qpid/client/LocalQueue.h \
  qpid/client/Message.h \
  qpid/client/MessageListener.h \
  qpid/client/MessageQueue.h \
  qpid/client/Results.h \
  qpid/client/SessionBase_0_10.h \
  qpid/client/Session.h \
  qpid/client/AsyncSession.h \
  qpid/client/SessionImpl.h \
  qpid/client/StateManager.h \
  qpid/client/SubscriptionManager.h \
  qpid/client/TypedResult.h \
  qpid/framing/AMQBody.h \
  qpid/framing/AMQCommandControlBody.h \
  qpid/framing/AMQContentBody.h \
  qpid/framing/AMQDataBlock.h \
  qpid/framing/AMQFrame.h \
  qpid/framing/AMQHeaderBody.h \
  qpid/framing/AMQHeartbeatBody.h \
  qpid/framing/AMQMethodBody.h \
  qpid/framing/AMQP_HighestVersion.h \
  qpid/framing/AccumulatedAck.h \
  qpid/framing/Array.h \
  qpid/framing/Blob.h \
  qpid/framing/BodyHandler.h \
  qpid/framing/Buffer.h \
  qpid/framing/ChannelHandler.h \
  qpid/framing/FieldTable.h \
  qpid/framing/FieldValue.h \
  qpid/framing/FrameDefaultVisitor.h \
  qpid/framing/FrameHandler.h \
  qpid/framing/FrameHandler.h \
  qpid/framing/FrameSet.h \
  qpid/framing/Handler.h \
  qpid/framing/HeaderProperties.h \
  qpid/framing/Invoker.h \
  qpid/framing/InputHandler.h \
  qpid/framing/InitiationHandler.h \
  qpid/framing/MethodContent.h \
  qpid/framing/BodyHolder.h \
  qpid/framing/MaxMethodBodySize.h \
  qpid/framing/ModelMethod.h \
  qpid/framing/OutputHandler.h \
  qpid/framing/ProtocolInitiation.h \
  qpid/framing/ProtocolVersion.h \
  qpid/framing/Proxy.h \
  qpid/framing/SendContent.h \
  qpid/framing/SequenceNumber.h \
  qpid/framing/SequenceSet.h \
  qpid/framing/SequenceNumberSet.h \
  qpid/framing/StructHelper.h \
  qpid/framing/TransferContent.h \
  qpid/framing/TypeFilter.h \
  qpid/framing/Uuid.h \
  qpid/framing/Visitor.h \
  qpid/framing/amqp_framing.h \
  qpid/framing/amqp_types.h \
  qpid/framing/amqp_types_full.h \
  qpid/framing/frame_functors.h \
  qpid/framing/variant.h \
  qpid/log/Helpers.h \
  qpid/log/Options.h \
  qpid/log/Logger.h \
  qpid/log/Selector.h \
  qpid/log/Statement.h \
  qpid/management/Args.h \
  qpid/management/Manageable.h \
  qpid/management/ManagementBroker.h \
  qpid/management/ManagementExchange.h \
  qpid/management/ManagementObject.h \
  qpid/sys/AggregateOutput.h \
  qpid/sys/AsynchIO.h \
  qpid/sys/AsynchIOHandler.h \
  qpid/sys/AtomicCount.h \
  qpid/sys/AtomicValue.h \
  qpid/sys/AtomicValue_gcc.h \
  qpid/sys/AtomicValue_mutex.h \
  qpid/sys/BlockingQueue.h \
  qpid/sys/Condition.h \
  qpid/sys/ConnectionCodec.h \
  qpid/sys/ConnectionInputHandler.h \
  qpid/sys/ConnectionInputHandlerFactory.h \
  qpid/sys/ConnectionOutputHandler.h \
  qpid/sys/DeletionManager.h \
  qpid/sys/Dispatcher.h \
  qpid/sys/IOHandle.h \
  qpid/sys/Monitor.h \
  qpid/sys/Mutex.h \
  qpid/sys/OutputControl.h \
  qpid/sys/OutputTask.h \
  qpid/sys/Poller.h \
  qpid/sys/ProtocolFactory.h \
  qpid/sys/Runnable.h \
  qpid/sys/Fork.h \
  qpid/sys/LockFile.h \
  qpid/sys/ScopedIncrement.h \
  qpid/sys/Semaphore.h \
  qpid/sys/SystemInfo.h \
  qpid/sys/Shlib.h \
  qpid/sys/ShutdownHandler.h \
  qpid/sys/Socket.h \
  qpid/sys/StateMonitor.h \
  qpid/sys/StrError.h \
  qpid/sys/Waitable.h \
  qpid/sys/Thread.h \
  qpid/sys/Time.h \
  qpid/sys/TimeoutHandler.h

if HAVE_XML
nobase_include_HEADERS += qpid/broker/XmlExchange.h
endif


# Force build of qpidd during dist phase so help2man will work.
dist-hook: $(BUILT_SOURCES)
	$(MAKE) qpidd

# Create the default data directory
install-data-local:
	$(mkinstalldirs) $(DESTDIR)/$(localstatedir)/lib/qpidd

