# add -DSYSV as appropriate, -DPW_QUOTA if your passwd struct has one
CFLAGS=-O2 -fomit-frame-pointer -m486 -pipe -DBSD43

# may need to -lBSD, -lbsd, or some such
LIBS=-lm

# include these if necessary
#XOBJS=syslog.o strerror.o

# Uncomment these to add ARAP support
# ARAP_FLAGS=-DARAP_SUPPORT
# ARAP_OBJS=arap_des.o

# Uncomment these to add CHAP support
# Add -DMD5_NEED_MEM_FUNCS if your system doesn't have memcpy() and memset()
CHAP_FLAGS=-DCHAP_SUPPORT
CHAP_OBJS=md5.o

all:	xtacacsd tacpasswd changetac

xtacacsd: xtacacsd.c inet_ntoa.o $(SYSLOG) ${ARAP_OBJS} ${CHAP_OBJS}
	${CC} -Iinclude ${CFLAGS} ${ARAP_FLAGS} ${CHAP_FLAGS} -o $@ \
		xtacacsd.c inet_ntoa.o $(SYSLOG) ${LIBS} \
		${ARAP_OBJS} ${CHAP_OBJS}

inet_ntoa.o: inet_ntoa.c
	${CC} -Iinclude ${CFLAGS} -c -o $@ inet_ntoa.c

syslog.o: syslog.c
	${CC} -Iinclude ${CFLAGS} -c -o $@ syslog.c

strerror.o: strerror.c
	${CC} ${CFLAGS} -c -o $@ strerror.c

arap_des.o: arap_des.c arap_des.h
	${CC} ${CFLAGS} ${ARAP_FLAGS} -c -o $@ arap_des.c

md5.o: md5.c md5.h
	${CC} ${CFLAGS} ${CHAP_FLAGS} -c -o $@ md5.c

tacpasswd: tacpasswd.c
	${CC} ${CFLAGS} -o $@ tacpasswd.c ${LIBS}

changetac: changetac.c
	${CC} ${CFLAGS} -o $@ changetac.c ${LIBS}

clean:
	rm -f xtacacsd tacpasswd changetac a.out core *.o
