#dli

#
# Layer Two Tunneling Protocol Daemon
# Copyright (C)1998 Adtran, Inc.
#
# Mark Spencer <markster@marko.net>
#
# This is free software.  You may distribute it under
# the terms of the GNU General Public License,
# version 2, or at your option any later version.
#
# Note on debugging flags:
# -DDEBUG_ZLB shows all ZLB exchange traffic
# -DDEBUG_CONTROL debugs the /var/run/l2tp-control pipe interface
# -DDEBUG_HELLO debugs when hello messages are sent
# -DDEBUG_CLOSE debugs call and tunnel closing
# -DDEBUG_FLOW debugs flow control system
# -DDEBUG_FILE debugs file format
# -DDEBUG_AAA debugs authentication, accounting, and access control
# -DDEBUG_PAYLOAD shows info on every payload packet
# -DDEBUG_CONTROL shows info on every control packet
# -DDEBUG_PPPD shows the command line of pppd
# -DDEBUG_HIDDEN debugs hidden AVP's
# -DDEBUG_ENTROPY debug entropy generation
# -DTEST_HIDDEN makes Assigned Call ID sent as a hidden AVP
#
# Also look at the top of network.c for some other (eventually to 
# become runtime options) debugging flags
#
#DFLAGS= -g -O2 -DDEBUG_PPPD
DFLAGS= -g -O2 -DDEBUG_PPPD -DDEBUG_CONTROL -DDEBUG_ENTROPY 

DFLAGS+=-DDEBUG_CLOSE

DFLAGS+=-I$(LIBS_DIR)

# -DDEBUG_ZLB shows all ZLB exchange traffic
# -DDEBUG_CONTROL debugs the /var/run/l2tp-control pipe interface
# -DDEBUG_HELLO debugs when hello messages are sent
# -DDEBUG_CLOSE debugs call and tunnel closing
# -DDEBUG_FLOW debugs flow control system
# -DDEBUG_FILE debugs file format
# -DDEBUG_AAA debugs authentication, accounting, and access control
# -DDEBUG_PAYLOAD shows info on every payload packet
# -DDEBUG_CONTROL shows info on every control packet
# -DDEBUG_PPPD shows the command line of pppd
# -DDEBUG_HIDDEN debugs hidden AVP's
# -DDEBUG_ENTROPY debug entropy generation
# -DTEST_HIDDEN makes Assigned Call ID sent as a hidden AVP







#
# Uncomment the next line for Linux
#
OSFLAGS= -DLINUX 
#
# Uncomment the following to use the kernel interface under Linux
#
#OSFLAGS+= -DUSE_KERNEL
#
# Uncomment the next line for FreeBSD
#
#OSFLAGS= -DFREEBSD
#
# Uncomment the next line for Solaris. For solaris, at least,
# we don't want to specify -I/usr/include because it is in
# the basic search path, and will over-ride some gcc-specific
# include paths and cause problems.
#
#OSFLAGS= -DSOLARIS
#OSLIBS= -lnsl -lsocket
#
# Feature flags
#
# Comment the following line to disable l2tpd maintaining IP address
# pools to pass to pppd to control IP address allocation

FFLAGS= -DIP_ALLOCATION 

CFLAGS= $(DFLAGS) -Wall -DSANITY $(OSFLAGS) $(FFLAGS) -include $(TOPDIR)/build_utils/autoconf.h -g
HDRS=l2tp.h avp.h misc.h control.h call.h scheduler.h file.h aaa.h md5.h
OBJS=l2tpd.o pty.o misc.o control.o avp.o call.o network.o avpsend.o scheduler.o file.o aaa.o md5.o
LIBS= $(OSLIB) # -lefence # efence for malloc checking
LIBS+=-L$(LIBS_DIR) -lwfc -lconf -lcommon 
BIN=l2tpd
BINDIR=/usr/sbin
ifeq ("$(CONFIG_THOMSONCOMPONENT)","y")
ETCDIR=/etc_ro_fs/wifi-community
LIBS+=-lrip -lcrypto -ldl  -L$(TOPDIR)/cm4/fsn/build/libraries
else
ETCDIR=/usr/etc_ro_fs/wifi-community
endif

options-l2tpd-$(CONFIG_SUPPORT_WIFICOMMUNITY)=options.l2tpd.wifi-community
options-l2tpd-$(CONFIG_HOTSPOT)=options.l2tpd.hotspot
all: $(BIN)

release : all
	$(INSTALL) -o root -g root -m 755 l2tpd $(ROOT_FS_DIR)/usr/sbin
#	$(INSTALL) -d $(ROOT_FS_DIR)$(ETCDIR)
	$(INSTALL) -d $(ROOT_FS_DIR)$(ETCDIR)/l2tp
	$(INSTALL) -o root -g root -m 644 $(options-l2tpd-y) $(ROOT_FS_DIR)$(ETCDIR)/l2tp/options.l2tpd
	$(INSTALL) -o root -g root -m 600 l2tpd.conf l2tp-secrets $(ROOT_FS_DIR)$(ETCDIR)/l2tp

clean:
	rm -f $(OBJS) $(BIN)

$(BIN): $(OBJS) $(HDRS) 
	$(CC) -o $(BIN) $(DFLAGS) $(OBJS) $(LIBS)
	$(STRIP) $(BIN)
