TOPDIR=$(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)

DEBUG=0
PREFIX=/usr/local
BINDIR=${PREFIX}/bin
MANDIR=${PREFIX}/share/man
PPPDIR=/etc/ppp/peers

ifeq ($(PKGINC),)
   PKGINC:=$(shell for LOCATION in /usr/include/wvstreams /usr/local/include/wvstreams ; \
		do if [ -d $$LOCATION ]; then \
		echo $$LOCATION; \
		fi; done)
endif

export TOPDIR DEBUG CC CXX PKGINC
include wvrules.mk

CC=${CXX}

SUBDIRS=src

ifeq ($(PKGINC),)
   all:
	@echo "The WvStreams Library Development files have not been installed."
	@echo "Please install them first, and then compile WvDial"
	@echo "If your distribution or platform doesn't have a prepackaged version"
	@echo "you can obtain it from http://open.nit.ca/download"
	@echo "if you have installed WvStreams in a non-standard location, please"
	@echo "set an environment variable called PKGINC to the location for the WvStreams"
	@echo "include files."
else
   all: $(SUBDIRS)
endif

install: all
	[ -d ${BINDIR}      ] || install -d ${BINDIR}
	[ -d ${MANDIR}/man1 ] || install -d ${MANDIR}/man1
	[ -d ${MANDIR}/man5 ] || install -d ${MANDIR}/man5
	[ -d ${PPPDIR}      ] || install -d ${PPPDIR}
	install -m 0755 --strip src/wvdial src/wvdialconf ${BINDIR}
	install -m 0644 wvdial.1 wvdialconf.1 ${MANDIR}/man1
	install -m 0644 wvdial.conf.5 ${MANDIR}/man5
	cp ppp.provider ${PPPDIR}/wvdial
	cp ppp.provider-pipe ${PPPDIR}/wvdial-pipe

uninstall:
	rm -f ${BINDIR}/wvdial ${BINDIR}/wvdialconf
	rm -f ${MANDIR}/man1/wvdial.1 ${MANDIR}/man1/wvdialconf.1
	rm -f ${MANDIR}/man5/wvdial.conf.5
	rm -f ${PPPDIR}/wvdial
	rm -f ${PPPDIR}/wvdial-pipe

clean:
	$(subdirs)
