######################################################################
# Makefile                                                 August 2005
#
# KSSLD: 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		= crypto include key_tool asym kssld patches

DISTFILE = 	AUTHORS COPYING ChangeLog Makefile Makefile.base \
		NEWS README INSTALL INSTALL.aep TODO

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

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

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

.PHONY: clean
clean:
		rm -f *.o *~ *.bak *.orig *.rej
		@for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit 1; done

.PHONY: distclean
distclean:	clean
		rm -f $(PACKAGE)-$(VERSION).tar.bz2 cscope.out tags

.PHONY: dist
dist:
		rm -rf $(PACKAGE)-$(VERSION)/ $(PACKAGE)-$(VERSION).tar.bz2
		mkdir $(PACKAGE)-$(VERSION)/
		@for i in $(SUBDIRS); do \
			$(MAKE) DISTDIR="../$(PACKAGE)-$(VERSION)/$$i" \
				-C $$i dist || exit 1;\
		done
		install -m 644 $(DISTFILE) $(PACKAGE)-$(VERSION)/
		tar -jcf $(PACKAGE)-$(VERSION).tar.bz2 $(PACKAGE)-$(VERSION)/
		rm -rf $(PACKAGE)-$(VERSION)/

.PHONY: distcheck
distcheck:      dist
		rm -rf build.root/
		mkdir -p build.root/tmp/
		cd build.root/ ; tar -jxf ../$(PACKAGE)-$(VERSION).tar.bz2
		cd build.root/tmp/ ; \
			make -C ../$(PACKAGE)-$(VERSION)/ clean all dist
		rm -r build.root/
		@echo "##################################################"
		@echo "# $(PACKAGE)-$(VERSION).tar.bz"
		@echo "# ready for distribution"
		@echo "##################################################"

.PHONY: cscope
cscope:
	cscope -b -I include/ -k -R -s asym/ -s crypto/ -s kssld/ -s key_tool/

.PHONY: tags
tags:
	ctags -R include/ asym/ crypto/ kssld/ key_tool/

