#####################################################################
# Makefile                                                August 2005
# 
# KSSLD(key_tool): An implementation of SSL/TLS in the Linux Kernel
# Copyright (C) 2005  NTT COMWARE Corporation.
#
# This file based in part on code from LVS www.linuxvirtualserver.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
#####################################################################

include ../Makefile.base

SUBDIRS = 

DISTFILE = 	Makefile asym_method.c asym_method.h cipher.c cipher.h \
		from_kernel.c key_tool.c key_tool.h log.h to_kernel.c
PROGFILE =	kssl_key_gen


LDADD =		-L/usr/kerberos/lib/ -lkrb5 -lgssapi_krb5 -lk5crypto -lcom_err -lssl -lcrypto -lvanessa_logger -lvanessa_socket -lvanessa_adt
#LDADD =		-lssl -lcrypto -lvanessa_logger -lvanessa_socket -lvanessa_adt

INCLUDE = -I/usr/kerberos/include/ -I../include/kssl

.PHONY: all install unintall clean distclean dist static

all: 	kssl_key_tool  kssl_key_tool.static
	@for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit 1; done

kssl_key_tool: key_tool.o to_kernel.o from_kernel.o cipher.o asym_method.o
	$(LINK.o) $^ $(LDADD) -o $@

kssl_key_tool.static: key_tool.o to_kernel.o from_kernel.o cipher.o asym_method.o
	$(LINK.o) -static $^ $(LDADD) -o $@

%.o: %.c
	$(COMPILE.c) $(INCLUDE) -DVERSION=\"$(VERSION)\"  $^ -o $@

install:
		@for i in $(SUBDIRS); do $(MAKE) -C $$i install || exit 1; done

uninstall:
		@for i in $(SUBDIRS); do $(MAKE) -C $$i uninstall || exit 1; \
			done

clean:
		rm -f *.o kssl_key_tool kssl_key_tool.static
		@for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit 1; done

distclean:      clean
		rm -f $(PACKAGE)-$(VERSION).tar.bz2

dist:
		mkdir $(DISTDIR)/
		@for i in $(SUBDIRS); do \
			$(MAKE) DISTDIR="../$(DISTDIR)/$$i" -C $$i dist \
				|| exit 1; done
		install -m 644 $(DISTFILE) $(DISTDIR)   
		install -m 755 $(PROGFILE) $(DISTDIR)   

