INST_ROOT=$(prefix)

EXECUTABLES=axattach axl beacon call listen mheard axassociate
LISTEN_OBJS=arpdump.o ax25dump.o icmpdump.o ipdump.o kissdump.o \
	listen.o nrdump.o tcpdump.o udpdump.o

all: $(EXECUTABLES)

CC = gcc
LD = gcc
CFLAGS = -g -I. -Wall
CXXFLAGS = $(CFLAGS)
LDFLAGS=

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

MAN_INST=install -m 644 -o root -g root

install: all
	install -d -m 755 -o root -g root $(INST_ROOT)/etc
	install -d -m 755 -o root -g root $(INST_ROOT)/usr/sbin
	install -d -m 755 -o root -g root $(INST_ROOT)/usr/bin
	install -d -m 755 -o root -g root $(INST_ROOT)/usr/man/man1
	install -d -m 755 -o root -g root $(INST_ROOT)/usr/man/man4
	install -d -m 755 -o root -g root $(INST_ROOT)/usr/man/man8
	install -d -m 755 -o root -g root $(INST_ROOT)/usr/doc/ax25util
	install -m 755 -s -o bin -g bin axattach $(INST_ROOT)/usr/sbin
	install -m 755 -s -o bin -g bin axassociate $(INST_ROOT)/usr/sbin
	install -m 755 -s -o bin -g bin axl $(INST_ROOT)/usr/sbin
	install -m 755 -s -o bin -g bin beacon $(INST_ROOT)/usr/sbin
	install -m 755 -s -o bin -g bin call $(INST_ROOT)/usr/bin
	install -m 4755 -s -o root -g bin listen $(INST_ROOT)/usr/bin
	install -m 755 -s -o bin -g bin mheard $(INST_ROOT)/usr/bin
	$(MAN_INST) call.1 $(INST_ROOT)/usr/man/man1
	$(MAN_INST) listen.1 $(INST_ROOT)/usr/man/man1
	$(MAN_INST) mheard.1 $(INST_ROOT)/usr/man/man1
	$(MAN_INST) ax25.4 $(INST_ROOT)/usr/man/man4
	$(MAN_INST) ax25-ports.4 $(INST_ROOT)/usr/man/man4
	$(MAN_INST) axattach.8 $(INST_ROOT)/usr/man/man8
	$(MAN_INST) axassociate.8 $(INST_ROOT)/usr/man/man8
	$(MAN_INST) axl.8 $(INST_ROOT)/usr/man/man8
	$(MAN_INST) beacon.8 $(INST_ROOT)/usr/man/man8
	$(MAN_INST) yappxfer.doc $(INST_ROOT)/usr/doc/ax25util
	$(MAN_INST) yappxfer.pas $(INST_ROOT)/usr/doc/ax25util
	$(MAN_INST) README $(INST_ROOT)/usr/doc/ax25util

clean:
	rm -f *.o *~ $(EXECUTABLES)

distclean: clean
	rm -f *.o *~ axattach axl beacon call listen mheard

axattach: axattach.o convert.o speed.o
	$(CC) $(LDFLAGS) axattach.o convert.o speed.o -o axattach

AXL_OBJS= axl.o convert.o config.o pseudo_tty.o execute.o speed.o bridge.o

axl: $(AXL_OBJS)
	$(CC) $(LDFLAGS) $(AXL_OBJS) -o axl

beacon: beacon.o convert.o config.o
	$(CC) $(LDFLAGS) beacon.o convert.o config.o -o beacon

call: call.o yapp.o convert.o dostime.o config.o
	$(CC) $(LDFLAGS) call.o yapp.o convert.o config.o dostime.o -o call

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

axassociate: axassociate.o convert.o
	$(CC) axassociate.o convert.o -o axassociate
