
VPATH		= @srcdir@
srcdir		= @srcdir@
top_srcdir	= @top_srcdir@
top_builddir	= ..

include ../Makefile.conf

CFLAGS			+= -I$(top_srcdir)/optlib

SSD_SOURCES		= start-stop-daemon.c
SSD_OBJECTS		= $(patsubst %.c, %.o, $(SSD_SOURCES))
SSD_MANPAGES		= start-stop-daemon.8

MD5_SOURCES		= md5sum.c
MD5_OBJECTS		= $(patsubst %.c, %.o, $(MD5_SOURCES))
MD5_MANPAGES		= md5sum.1

GENFILES		= $(MD5_OBJECTS) md5sum
ifeq (@USE_START_STOP_DAEMON@, true)
GENFILES		+= $(SSD_OBJECTS) start-stop-daemon
endif

.PHONY: all
ifeq (@USE_START_STOP_DAEMON@, true)
all:: start-stop-daemon md5sum
else
all:: md5sum
endif

.PHONY: install
install:: all

.PHONY: clean
clean::
	$(RM) $(GENFILES)

.PHONY: distclean
cvslean:: clean
	$(RM) Makefile confdefs.h config.log

.PHONY: install
install:: install-program install-doc

.PHONY: install-program
install-program:
ifeq (@USE_START_STOP_DAEMON@, true)
	$(mkinstalldirs) $(DESTDIR)/$(sbindir)
	$(INSTALL) start-stop-daemon $(DESTDIR)/$(sbindir)
endif
	$(mkinstalldirs) $(DESTDIR)/$(bindir)
	$(INSTALL) md5sum $(DESTDIR)/$(bindir)

.PHONY: install-doc
install-doc:
ifeq (@USE_START_STOP_DAEMON@, true)
	$(mkinstalldirs) $(DESTDIR)/$(man8dir)
	$(INSTALL_DATA) $(srcdir)/$(SSD_MANPAGES) $(DESTDIR)/$(man8dir)
endif
	$(mkinstalldirs) $(DESTDIR)/$(man1dir)
	$(INSTALL_DATA) $(srcdir)/$(MD5_MANPAGES) $(DESTDIR)/$(man1dir)

start-stop-daemon: $(SSD_OBJECTS) ../lib/libdpkg.a
	$(CC) $(LDFLAGS) -o $@ $^ $(SSD_LIBS)

md5sum: $(MD5_OBJECTS) ../lib/libdpkg.a
	$(CC) $(LDFLAGS) -o $@ $^ $(NLS_LIBS)
