all: call listen mheard pms

CC = gcc
LD = gcc
CFLAGS = -Wall -Wstrict-prototypes -O2 -I../lib
LDFLAGS =
LIBS = ../lib/axlib.a

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

install: installbin installman installconf

installbin: all
	install -m 755 -s -o bin -g bin call      /usr/local/bin
	install -m 4755 -s -o root -g bin listen  /usr/local/bin
	install -m 755 -s -o bin -g bin mheard    /usr/local/bin
	install -m 755 -s -o bin -g bin pms       /usr/local/bin

installconf:
	install -m 644 -o bin -g bin ../etc/loggedin    /usr/local/pms

installman:
	install -m 644 -o bin -g bin ../man/call.1     /usr/local/man/man1
	install -m 644 -o bin -g bin ../man/listen.1   /usr/local/man/man1
	install -m 644 -o bin -g bin ../man/mheard.1   /usr/local/man/man1

clean:
	rm -f *.o *~

distclean:
	rm -f *.o *~ call listen mheard pms

call: call.o menu.o crc.o yapp.o dostime.o
	$(LD) $(LDFLAGS) -o call call.o yapp.o menu.o crc.o dostime.o $(LIBS) -lncurses

mheard: mheard.o
	$(LD) $(LDFLAGS) -o mheard mheard.o

pms: pms.o
	$(LD) $(LDFLAGS) -o pms pms.o

LISTEN_OBJS = listen.o kissdump.o bpqdump.o ax25dump.o nrdump.o arpdump.o \
	ipdump.o icmpdump.o udpdump.o tcpdump.o rspfdump.o ripdump.o

listen:	$(LISTEN_OBJS)
	$(LD) $(LDFLAGS) -o listen $(LISTEN_OBJS)

listen.o:	listen.h listen.c
kissdump.o:	listen.h kissdump.c
bpqdump.o:	listen.h bpqdump.c
ax25dump.o:	listen.h ax25dump.c
nrdump.o:	listen.h nrdump.c
arpdump.o:	listen.h arpdump.c
ipdump.o:	listen.h ipdump.c
icmpdump.o:	listen.h icmpdump.c
udpdump.o:	listen.h udpdump.c
tcpdump.o:	listen.h tcpdump.c
rspfdump.o:	listen.h rspfdump.c
ripdump.o:	listen.h ripdump.c

call.o:		call.h crc.h menu.h call.c
crc.o:		crc.c
dostime.o:	dostime.c
mheard.o:	mheard.c
menu.o:		menu.h menu.c
pms.o:		pms.c
yapp.o:		yapp.c
