if BUILD_CAL
usrbin_exec_PROGRAMS += cal
dist_man_MANS += misc-utils/cal.1
cal_SOURCES = misc-utils/cal.c
cal_CFLAGS = $(AM_CFLAGS)
cal_LDADD = $(LDADD) libcommon.la libtcolors.la
# tinfo or ncurses are optional
if HAVE_TINFO
cal_LDADD += $(TINFO_LIBS)
cal_CFLAGS += $(TINFO_CFLAGS)
else
if HAVE_NCURSES
cal_LDADD += $(NCURSES_LIBS)
cal_CFLAGS += $(NCURSES_CFLAGS)
endif
endif # !HAVE_TINFO

check_PROGRAMS += test_cal
test_cal_SOURCES = $(cal_SOURCES)
test_cal_LDADD = $(cal_LDADD)
test_cal_CFLAGS = -DTEST_CAL $(cal_CFLAGS)
endif # BUILD_CAL


if BUILD_LOGGER
usrbin_exec_PROGRAMS += logger
dist_man_MANS += misc-utils/logger.1
logger_SOURCES = misc-utils/logger.c lib/strutils.c lib/strv.c
logger_LDADD = $(LDADD)
logger_CFLAGS = $(AM_CFLAGS)
if HAVE_SYSTEMD
logger_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS) $(SYSTEMD_JOURNAL_LIBS)
logger_CFLAGS += $(SYSTEMD_CFLAGS) $(SYSTEMD_DAEMON_CFLAGS) $(SYSTEMD_JOURNAL_CFLAGS)
endif

check_PROGRAMS += test_logger
test_logger_SOURCES = $(logger_SOURCES)
test_logger_LDADD = $(logger_LDADD)
test_logger_CFLAGS = -DTEST_LOGGER $(logger_CFLAGS)
endif # BUILD_LOGGER


if BUILD_LOOK
usrbin_exec_PROGRAMS += look
dist_man_MANS += misc-utils/look.1
look_SOURCES = misc-utils/look.c
endif

if BUILD_MCOOKIE
usrbin_exec_PROGRAMS += mcookie
dist_man_MANS += misc-utils/mcookie.1
mcookie_SOURCES = misc-utils/mcookie.c lib/md5.c
mcookie_LDADD = $(LDADD) libcommon.la
endif

if BUILD_NAMEI
usrbin_exec_PROGRAMS += namei
dist_man_MANS += misc-utils/namei.1
namei_SOURCES = misc-utils/namei.c lib/strutils.c lib/idcache.c
endif

if BUILD_WHEREIS
usrbin_exec_PROGRAMS += whereis
dist_man_MANS += misc-utils/whereis.1
whereis_SOURCES = misc-utils/whereis.c
whereis_LDADD = $(LDADD) libcommon.la
endif

if BUILD_LSLOCKS
usrbin_exec_PROGRAMS += lslocks
dist_man_MANS += misc-utils/lslocks.8
lslocks_LDADD = $(LDADD) libcommon.la libmount.la libsmartcols.la
lslocks_SOURCES = misc-utils/lslocks.c
lslocks_CFLAGS = $(AM_CFLAGS) -I$(ul_libmount_incdir) -I$(ul_libsmartcols_incdir)
endif

if BUILD_LSBLK
bin_PROGRAMS += lsblk
dist_man_MANS += misc-utils/lsblk.8
lsblk_SOURCES = misc-utils/lsblk.c
lsblk_LDADD = $(LDADD) libblkid.la libmount.la libcommon.la libsmartcols.la
lsblk_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir) -I$(ul_libmount_incdir) -I$(ul_libsmartcols_incdir)
if HAVE_UDEV
lsblk_LDADD += -ludev
endif
endif # BUILD_LSBLK

if BUILD_UUIDGEN
usrbin_exec_PROGRAMS += uuidgen
dist_man_MANS += misc-utils/uuidgen.1
uuidgen_SOURCES = misc-utils/uuidgen.c
uuidgen_LDADD = $(LDADD) libuuid.la
uuidgen_CFLAGS = $(AM_CFLAGS) -I$(ul_libuuid_incdir)
endif

if BUILD_UUIDPARSE
usrbin_exec_PROGRAMS += uuidparse
dist_man_MANS += misc-utils/uuidparse.1
uuidparse_SOURCES = misc-utils/uuidparse.c
uuidparse_LDADD = $(LDADD) libcommon.la libuuid.la libsmartcols.la
uuidparse_CFLAGS = $(AM_CFLAGS) -I$(ul_libuuid_incdir) -I$(ul_libsmartcols_incdir)
endif

if BUILD_UUIDD
usrsbin_exec_PROGRAMS += uuidd
dist_man_MANS += misc-utils/uuidd.8
uuidd_LDADD = $(LDADD) libuuid.la libcommon.la $(REALTIME_LIBS)
uuidd_CFLAGS = $(DAEMON_CFLAGS) $(AM_CFLAGS) -I$(ul_libuuid_incdir)
uuidd_LDFLAGS = $(DAEMON_LDFLAGS) $(AM_LDFLAGS)
uuidd_SOURCES = misc-utils/uuidd.c lib/monotonic.c lib/timer.c
if HAVE_SYSTEMD
uuidd_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS)
uuidd_CFLAGS += $(SYSTEMD_CFLAGS) $(SYSTEMD_DAEMON_CFLAGS)
systemdsystemunit_DATA += \
	misc-utils/uuidd.service \
	misc-utils/uuidd.socket
endif

check_PROGRAMS += test_uuidd
test_uuidd_SOURCES = misc-utils/test_uuidd.c
test_uuidd_LDADD =  $(LDADD) libcommon.la libuuid.la -lpthread
test_uuidd_CFLAGS = $(AM_CFLAGS) -I$(ul_libuuid_incdir)
endif # BUILD_UUIDD

PATHFILES += \
	misc-utils/uuidd.8 \
	misc-utils/uuidd.rc \
	misc-utils/uuidd.service \
	misc-utils/uuidd.socket

if BUILD_BLKID
sbin_PROGRAMS += blkid
dist_man_MANS += misc-utils/blkid.8
blkid_SOURCES = misc-utils/blkid.c
blkid_LDADD = $(LDADD) libblkid.la libcommon.la
blkid_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)

if HAVE_STATIC_BLKID
sbin_PROGRAMS += blkid.static
blkid_static_SOURCES = $(blkid_SOURCES)
blkid_static_LDFLAGS = -all-static
blkid_static_LDADD = $(LDADD) libblkid.la
blkid_static_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
endif
endif # BUILD_BLKID


if BUILD_FINDFS
sbin_PROGRAMS += findfs
dist_man_MANS += misc-utils/findfs.8
findfs_LDADD = $(LDADD) libblkid.la
findfs_SOURCES = misc-utils/findfs.c
findfs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir)
endif

if BUILD_WIPEFS
sbin_PROGRAMS += wipefs
dist_man_MANS += misc-utils/wipefs.8
wipefs_SOURCES = misc-utils/wipefs.c
wipefs_LDADD = $(LDADD) libblkid.la libcommon.la libsmartcols.la
wipefs_CFLAGS = $(AM_CFLAGS) -I$(ul_libblkid_incdir) -I$(ul_libsmartcols_incdir)
endif

if BUILD_FINDMNT
bin_PROGRAMS += findmnt
dist_man_MANS += misc-utils/findmnt.8
findmnt_LDADD = $(LDADD) libmount.la \
		libcommon.la \
		libsmartcols.la \
		libblkid.la
findmnt_CFLAGS = $(AM_CFLAGS) \
		-I$(ul_libmount_incdir) \
		-I$(ul_libsmartcols_incdir) \
		-I$(ul_libblkid_incdir)
findmnt_SOURCES = misc-utils/findmnt.c \
		  misc-utils/findmnt-verify.c \
		  misc-utils/findmnt.h
if HAVE_UDEV
findmnt_LDADD += -ludev
endif
endif # BUILD_FINDMNT


if BUILD_KILL
bin_PROGRAMS += kill
kill_SOURCES = misc-utils/kill.c
kill_LDADD = $(LDADD) libcommon.la
dist_man_MANS += misc-utils/kill.1
endif

if BUILD_RENAME
usrbin_exec_PROGRAMS += rename
dist_man_MANS += misc-utils/rename.1
rename_SOURCES = misc-utils/rename.c
endif

if BUILD_GETOPT
usrbin_exec_PROGRAMS += getopt
dist_man_MANS += misc-utils/getopt.1
getopt_SOURCES = misc-utils/getopt.c
getoptexampledir = $(docdir)/getopt/
dist_getoptexample_SCRIPTS = \
	misc-utils/getopt-parse.bash \
	misc-utils/getopt-parse.tcsh
endif

if BUILD_FINCORE
usrbin_exec_PROGRAMS += fincore
dist_man_MANS += misc-utils/fincore.1
fincore_SOURCES = misc-utils/fincore.c
fincore_LDADD = $(LDADD) libsmartcols.la libcommon.la
fincore_CFLAGS = $(AM_CFLAGS) -I$(ul_libsmartcols_incdir)
endif
