
# Copyright (C) 2000 Avaya Labs, Avaya Inc.
# Copyright (C) 1999 Bell Labs, Lucent Technologies.
# Copyright (C) Arash Baratloo, Timothy Tsai, and Navjot Singh.
# 
# This file is part of the Libsafe library.
# Libsafe version 2.x: protecting against stack smashing attacks.
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# For more information, 
# 
#   visit http://www.research.avayalabs.com/project/libsafe/index.html
#   or email libsafe@research.avayalabs.com


LIBNAME		= libsafe.so.2.0
LIBLINK		= libsafe.so.2
LIBDIR		= /lib

MANNAME		= ../doc/libsafe.8
MANDIR		= /usr/man/man8

CC		= gcc
CPP		= g++
DEPEND		= gcc -M
RANLIB		= ranlib
INSTALL		= install
LDFLAGS		= -shared -Wl,-soname,${LIBLINK} -ldl
SRCS		= util.c intercept.c vfscanf.c vfprintf.c reg-printf.c
OBJECTS		= util.o intercept.o vfscanf.o vfprintf.o reg-printf.o
HEADERS		= log.h util.h

# DEBUGGING OPTIONS
#
# Use
# 	-DDEBUG_TURN_OFF_SYSLOG to temporarily turn off logging violations to
#	 	syslog.  ONLY USE THIS FOR DEBUGGING!
#	-DDUMP_STACK to see a printout of the stack contents when a violation
#		is detected (dumps to LIBSAFE_DUMP_STACK_FILE or stderr if that
#		file can't be created)
#	-DDUMP_CORE to create a core dump when terminating the program.
#	-DNOTIFY_WITH_EMAIL if you wish to be notified via email of security
#		violations that are caught with libsafe.
DEBUG_FLAGS	= -O2 -Wall -DNDEBUG -fPIC \
			-DDEBUG_TURN_OFF_SYSLOG \
			-DDUMP_STACK \
			-DLIBSAFE_DUMP_STACK_FILE=\"/tmp/libsafe_stack_dump\" \
			-DDUMP_CORE \
			-DNOTIFY_WITH_EMAIL
CCFLAGS		= -O2 -Wall -DNDEBUG -fPIC
# Uncomment the following line to enable all debugging options.
#CCFLAGS		= -O2 -Wall -DNDEBUG -fPIC $(DEBUG_FLAGS)

all	::	$(LIBNAME)

# The glibc-2.1/stdio-common/Makefile specifies that vfprintf.c be compiled
# with the -Wno-uninitialized flag.
vfprintf.o	:	vfprintf.c
		$(CC) -c -o $@ $(CCFLAGS) -Wno-uninitialized $<

%.o	:	%.c
		$(CC) -c -o $@ $(CCFLAGS) $<

#%.o	:	%.cpp
#		$(CPP) -c -o $@ $(CCFLAGS) $<

${LIBNAME}:	dep $(OBJECTS)
		$(CC) -o ${LIBNAME} $(LDFLAGS) ${OBJECTS}

dep	::	$(SRCS) $(HEADERS)
		$(DEPEND) $(CFLAGS) $(SRCS) > dep

clean	::
		rm -f core *.bak *% *~ *.o a.out dep
		rm -f ${LIBNAME}

purge	::	clean
		rm -f $(LIBNAME)

install	::	all
		$(INSTALL) $(LIBNAME) $(LIBDIR)
		/sbin/ldconfig

# If you have man pages in some other directory  add it here.

		if [  -d $(MANDIR) ];  then \
		 $(INSTALL) $(MANNAME) $(MANDIR); \
		elif [  -d /usr/share/man/man8 ];  then \
		  $(INSTALL) $(MANNAME) /usr/share/man/man8; \
		else echo "***** Error: Cannot find man directories"; \
		fi

