bash_completiondir = $(sysconfdir)/bash_completion.d
bash_completion_DATA = $(srcdir)/bash_completion/ceph

bin_SCRIPTS += \
	ceph \
	ceph-post-file

python_PYTHON += \
	pybind/ceph_argparse.py \
	pybind/ceph_daemon.py

ceph_syn_SOURCES = ceph_syn.cc
ceph_syn_SOURCES += client/SyntheticClient.cc # uses g_conf.. needs cleanup
ceph_syn_LDADD = $(LIBCLIENT) $(CEPH_GLOBAL)
bin_PROGRAMS += ceph-syn

# assemble Python script with global version variables
# NB: depends on format of ceph_ver.h

ceph: ceph.in ./ceph_ver.h Makefile
	rm -f $@ $@.tmp
	cp $@.in $@.tmp
	sed -ie "s|@PYTHON_EXECUTABLE@|/usr/bin/env python|" $@.tmp
	grep CEPH_GIT_NICE_VER ./ceph_ver.h | cut -f 3 -d " " | sed s/\"//g | xargs -I "{}" sed -ie "s/@CEPH_GIT_NICE_VER@/{}/g" $@.tmp
	grep CEPH_GIT_VER ./ceph_ver.h | cut -f 3 -d " " | sed s/\"//g | xargs -I "{}" sed -ie "s/@CEPH_GIT_VER@/{}/g" $@.tmp
	chmod a+x $@.tmp
	chmod a-w $@.tmp
	mv $@.tmp $@


if WITH_RADOS

bash_completion_DATA += \
	$(srcdir)/bash_completion/rados \
	$(srcdir)/bash_completion/radosgw-admin

librados_config_SOURCES = librados-config.cc
librados_config_LDADD = $(LIBRADOS) $(CEPH_GLOBAL)
bin_PROGRAMS += librados-config

if WITH_RBD

bash_completion_DATA += \
	$(srcdir)/bash_completion/rbd

bin_SCRIPTS += \
	ceph-rbdnamer \
	rbd-replay-many \
        rbdmap

libkrbd_la_SOURCES = krbd.cc
libkrbd_la_LIBADD = $(LIBSECRET) $(LIBCOMMON) -lblkid -ludev
if LINUX
noinst_LTLIBRARIES += libkrbd.la
endif # LINUX

endif # WITH_RBD

# Fuse targets

if WITH_FUSE
ceph_fuse_SOURCES = ceph_fuse.cc
ceph_fuse_LDADD = $(LIBCLIENT_FUSE) $(CEPH_GLOBAL)
bin_PROGRAMS += ceph-fuse
sbin_SCRIPTS += mount.fuse.ceph

if WITH_RBD
rbd_fuse_SOURCES = rbd_fuse/rbd-fuse.cc
rbd_fuse_CXXFLAGS = $(AM_CXXFLAGS) $(LIBFUSE_CFLAGS)
rbd_fuse_LDADD = $(LIBFUSE_LIBS) $(LIBRBD) $(LIBRADOS) $(CEPH_GLOBAL)
bin_PROGRAMS += rbd-fuse
endif # WITH_RBD
endif # WITH_FUSE


if WITH_CEPHFS
cephfs_SOURCES = cephfs.cc
cephfs_LDADD = $(LIBCOMMON)
bin_PROGRAMS += cephfs

mount_ceph_SOURCES = mount/mount.ceph.c
mount_ceph_LDADD = $(LIBSECRET) $(LIBCOMMON)
if LINUX
sbin_PROGRAMS += mount.ceph
endif # LINUX

python_PYTHON += pybind/ceph_volume_client.py

# libcephfs (this should go somewhere else in the future)

libcephfs_la_SOURCES = libcephfs.cc
libcephfs_la_LIBADD = $(LIBCLIENT) $(LIBCOMMON) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(EXTRALIBS)
libcephfs_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0 -export-symbols-regex '^ceph_.*'
if LINUX
libcephfs_la_LDFLAGS += -Xcompiler -Xlinker -Xcompiler '--exclude-libs=libcommon.a'
endif # LINUX
lib_LTLIBRARIES += libcephfs.la

# jni library (java source is in src/java)

if ENABLE_CEPHFS_JAVA
libcephfs_jni_la_SOURCES = \
	java/native/libcephfs_jni.cc \
	java/native/ScopedLocalRef.h \
	java/native/JniConstants.cpp \
	java/native/JniConstants.h
libcephfs_jni_la_LIBADD = $(LIBCEPHFS) $(LIBCOMMON) $(EXTRALIBS)
libcephfs_jni_la_CPPFLAGS = $(JDK_CPPFLAGS) $(AM_CPPFLAGS)
libcephfs_jni_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0
lib_LTLIBRARIES += libcephfs_jni.la
endif # ENABLE_CEPHFS_JAVA

endif # WITH_CEPHFS

endif # WITH_RADOS
