################################################################
##
## Config time.
##

##
# General settings (these shouldn't be changed)
##

BIN=gnarwl
SBIN=damnit
MAN_SEC=8
VER=$(shell basename `pwd` | sed s\\$(BIN)-\\\\)

##
# Path settings (no trailing slashes!)
##

prefix=@prefix@
exec_prefix=@exec_prefix@

HOMEDIR=@homedir@
BLOCKDIR=$(HOMEDIR)/block
BINDIR=@bindir@
SBINDIR=@sbindir@
DOCDIR=@docdir@
MANDIR=@mandir@
CONFDIR=@sysconfdir@
DATAROOTDIR=@datarootdir@

##
# Adding system accounts
##
USERADD_PROG=@useradd_prog@
USERADD_ARGS=@useradd_args@

##
# Compiler settings
##

CC=@CC@
CFLAGS=-DLDAP_DEPRECATED -DBLOCKDIR=\"$(BLOCKDIR)\" -DCFGFILE=\"$(CONFDIR)/gnarwl.cfg\" -DVERSION=\"$(VER)\" -g -Wall -O2 -I..
LFLAGS=-lldap -lgdbm -ldl -lresolv

##
## No serviceable parts below
##
################################################################









export VER BIN SBIN CC CFLAGS LFLAGS HOMEDIR BINDIR SBINDIR DOCDIR MANDIR CONFDIR MAN_SEC

all:
	$(MAKE) -C src all
	$(MAKE) -C doc all
	$(MAKE) -C data all

clean:
	rm -f DEADJOE
	$(MAKE) -C src clean
	$(MAKE) -C doc clean
	$(MAKE) -C data clean

distclean: clean
	rm -f Makefile config.* conf.h
	rm -rf autom4te.cache
	
docs:
	$(MAKE) -C doc all
	
tarball: distclean
	cd ..; tar -czf $(BIN)-$(VER).tgz $(shell basename $(shell pwd))

install:
	$(MAKE) -C src install
	$(MAKE) -C doc install
	$(MAKE) -C data install
	$(MAKE) -C contrib install

perm:
	grep $(BIN) /etc/passwd > /dev/null || $(USERADD_PROG) $(USERADD_ARGS)
	chown -R $(BIN) $(HOMEDIR)
	chown $(BIN) $(CONFDIR)/gnarwl.cfg
