# -- do not change these two ---
PACKAGE=ax25spyd
VERSION=0.20pre
#-------------------- you may want to edit these ----------------------------
ifeq  "$(AX25LIB)" ""
# -- Enter the path to your ax25-util-libs here; (you can
# -- set env. AX25LIB instead):
AX25LIB=/usr/local/ax25-utils/lib
endif

# -- The path to your ax25 data directory (without trailing slash)
AX25VARDIR=/var/ax25

# -- The path to your ax25 conf directory (without trailing slash)
AX25CONFDIR=/etc/ax25


# -- Nothing to edit by the user below here
#----------------------------------------------------------------------------

CC = gcc
LD = gcc

CFLAGS = -Wall -Wstrict-prototypes -O2 -I/usr/include/ncurses -I$(AX25LIB)
CFLAGS += -DAX25SPY_VERSION=\"$(VERSION)\" \
	  -DAX25VARDIR=\"$(AX25VARDIR)\" \
	  -DAX25CONFDIR=\"$(AX25CONFDIR)\"

# --- Debug it?
#CFLAGS += -g

LDFLAGS = -L$(AX25LIB)
LIBS = -lax25

DISTDIR = $(PACKAGE)-$(VERSION)
DISTNAME = $(PACKAGE)-$(VERSION)
#----------------------------------------------------------------------------

DOCS = README INSTALL COPYING BUGS services history.txt ChangeLog ax25spy.shtml

CONF = ax25spyd.conf.example

MAN = ax25spy.1 ax25spyd.8 ax25spyd.conf.5

AX25SPYD_OBJS = sockets.o monutil.o spy.o mheard.o \
	kissdump.o ax25dump.o nrdump.o arpdump.o ipdump.o icmpdump.o \
	udpdump.o dnsdump.o tcpdump.o rspfdump.o ripdump.o rosedump.o \
	flexnetdump.o  monixd.o

AX25SPY_OBJS = sockets.o monutil.o  monix.o

#---------------------------------------------------------------------------

.c.o:
	$(CC) $(CFLAGS) -c $<


all: ax25spyd ax25spy

ax25spyd: $(AX25SPYD_OBJS) Makefile
	$(LD) $(LDFLAGS) -o ax25spyd $(AX25SPYD_OBJS) $(LIBS)

ax25spy:  $(AX25SPY_OBJS) Makefile
	$(LD) $(LDFLAGS) -o ax25spy $(AX25SPY_OBJS) $(LIBS) -lncurses

#test:	test.o
#	$(LD) $(LDFLAGS) -o test test.o

#.depend: dep
dep:
	$(CPP) -M $(CFLAGS) *.c > .depend

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif

#----------------------------------------------------------------------------

install:	all
	install -m 755 -o 0 -g 0 -s ax25spyd /usr/sbin/ax25spyd
	install -m 755 -o 0 -g 0 ax25spy /usr/bin/ax25spy
#	install -m 755 -o 0 -g 0 -d /etc/ax25/
#	install -m 644 -o 0 -g 0 ax25spyd.conf.example /etc/ax25/ax25spyd.conf.example
	install -m 644 -o 0 -g 0 ax25spyd.8 /usr/man/man8/ax25spyd.8
	install -m 644 -o 0 -g 0 ax25spy.1 /usr/man/man1/ax25spy.1
	install -m 644 -o 0 -g 0 ax25spyd.conf.5 /usr/man/man5/ax25spyd.conf.5


clean:
	rm -f *.o *~ *.bak *.orig core .depend

distclean: clean
	rm -f ax25spy ax25spyd

distdir:
	mkdir $(DISTDIR)
	cp *.[ch] Makefile $(DOCS) $(MAN) $(CONF)   $(DISTDIR)


dist: distdir
	-chmod -R a+r $(DISTDIR)
	tar chozf $(DISTNAME).tar.gz $(DISTDIR)
	-rm -rf $(DISTDIR)

# -- For internal use only :-)
distall: dist
	-cp $(DISTNAME).tar.gz ../up
	-cp $(DISTNAME).tar.gz /home/walter/public_html/$(PACKAGE).tgz

cvs:
	cvs commit
	cvs tag $(DISTNAME)
	make all

