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


default: all

include ../Makefile.conf


SOURCES		= build.c extract.c info.c main.c

OBJECTS		= $(patsubst %.c, %.o, $(SOURCES))
GENFILES	= $(OBJECTS) dpkg-deb dpkg-deb-static

.PHONY: all
all:: dpkg-deb
ifdef ALSO_STATIC
all:: dpkg-deb-static
endif

.PHONY: install
install:: all

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

.PHONY: distclean
cvslean:: clean
	$(RM) Makefile

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

.PHONY: install-program
install-program:
	$(mkinstalldirs) $(DESTDIR)$(bindir)
	$(INSTALL) dpkg-deb $(DESTDIR)$(bindir)
ifdef ALSO_STATIC
	$(INSTALL) dpkg-deb-static $(DESTDIR)$(bindir)
endif

.PHONY: install-doc
install-doc:
	$(mkinstalldirs) $(DESTDIR)$(man1dir)
	$(INSTALL_DATA) $(srcdir)/dpkg-deb.1 $(DESTDIR)$(man1dir)

dpkg-deb-static: LDFLAGS += -static
dpkg-deb-static: ZLIB_LIBS = $(ZLIB_LIBS_ALSO_STATIC)
dpkg-deb-static: BZ2LIB_LIBS = $(BZ2LIB_LIBS_ALSO_STATIC)
dpkg-deb dpkg-deb-static: $(OBJECTS) ../lib/libdpkg.a
	$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS) $(NLS_LIBS)

