# Makefile for uutraf  - an UUCP traffic analyzer
#                                                             -*- Makefile -*-

# If you want to obtain news articles statistics by default, uncomment the
# following line.
DEFS 	= -DDEFAULT_NEWSSTATS
 
# If you do *not* want to have each transfer rounded up to the next kB when
# applying kB fees (ie if you want to apply this fee to the real transfer
# volume), uncomment the following line.
DEFS 	+= -DDEFAULT_PROVFEEPERKBMULT=0
DEFS	+= -DCFGFILE=\"$(LIBDIR)/uutraf.cf\" -DVERSION=\"$(VERSION)\"

CFLAGS  = -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
CFLAGS += -Wall -Wformat -Wmissing-prototypes\
 -Wmissing-declarations -Wwrite-strings\
 -Wbad-function-cast -Wstrict-prototypes -Wpointer-arith -Wcast-align\
 -Wnested-externs -Wshadow

INSTOPT=
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTOPT += -s
endif

LIBS    = -lm
LDFLAGS =

BIN     = uutraf
MAN1    = $(BIN).1
MAN5    = $(BIN).5
SRCS	= config.c stats.c utils.c
OBJS	= $(SRCS:.c=.o)
HEADER  = $(BIN).h
CFFILE  = uutraf.cf

VERSION = 1.1
prefix  = 
LIBDIR  = $(prefix)/etc/uucp
BINDIR  = $(prefix)/usr/bin
MAN1DIR = $(prefix)/usr/share/man/man1
MAN5DIR = $(prefix)/usr/share/man/man5

all:	$(BIN)

source:	$(SRCS) $(HEADER) $(MAN1) $(MAN5) $(CFFILE)
# implicit rules.

$(MAN1):
$(MAN5):
	co -kk $(MAN1) $(MAN5)
	mv $(MAN1) $(MAN1).sed
	mv $(MAN5) $(MAN5).sed
	sed "s/\\\$$Date\\\$$/`date +'%B %_d, %Y'`/g" $(MAN1).sed > $(MAN1)
	sed "s/\\\$$Date\\\$$/`date +'%B %_d, %Y'`/g" $(MAN5).sed > $(MAN5)
	-$(RM) $(MAN1).sed $(MAN5).sed
	chmod 644 $(MAN1) $(MAN5)

.c.o:	$(HEADER) $(SRCS) $(OBJS)
	$(CC) $(CFLAGS) $(DEFS) -c -o $@ $<

$(BIN):	$(BIN).c $(HEADER) $(SRCS) $(OBJS) $(MAN)
	$(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -o $(BIN) $(BIN).c $(OBJS) $(LIBS)

clean:
	$(RM) *.o *~ *.bak \#*\# errors core* a.out TAGS

distclean:	clean
	$(RM) $(BIN)

realclean:	distclean
	-rcsclean
	-$(RM) *.[ch15]

install: 	$(MAN1) $(MAN5) $(BIN) $(CFFILE)
	install -d -m 755 $(BINDIR) $(MAN1DIR) $(MAN5DIR) $(LIBDIR)
	install $(INSTOPT) -m 755 $(BIN)     $(BINDIR)
	install -m 644 $(MAN1)    $(MAN1DIR)
	install -m 644 $(MAN5)    $(MAN5DIR)
	install -m 644 $(CFFILE)  $(LIBDIR)/$(CFFILE)
