########### -*- mode: Makefile -*- ###################################
##                
## Copyright (C) 2002,  Karlsruhe University
##                
## File path:     kdb/Makeconf
## Description:   
##                
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## 1. Redistributions of source code must retain the above copyright
##    notice, this list of conditions and the following disclaimer.
## 2. Redistributions in binary form must reproduce the above copyright
##    notice, this list of conditions and the following disclaimer in the
##    documentation and/or other materials provided with the distribution.
## 
## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##                
## $Id: Makeconf,v 1.8.4.2 2005/01/28 15:55:12 skoglund Exp $
##                
######################################################################

$(BUILDDIR)/include/kdb_class_helper.h:	$(filter kdb/%,$(SOURCES)) $(SRCDIR)/include/kdb/cmd.h $(SRCDIR)/kdb/Makeconf $(BUILDDIR)/config/.config
	@if [ ! -d $(dir $@) ]; then $(MKDIRHIER) $(dir $@); fi
	@echo "/* Machine-generated file - DO NOT EDIT!	*/" > $@.new
	@echo "/*   will be included from kdb/kdb.h	*/" >> $@.new
	@grep -h "^ *DECLARE_CMD *(" $(filter %.cc %.h, $^) | perl -pe 's/^ *DECLARE_CMD *\(([^,]+).*/static cmd_ret_t \1(cmd_group_t*);/' >> $@.new
	@cmp -s $@ $@.new && rm -f $@.new || mv $@.new $@
# Workaround for broken dependencies with cpp-3.3
kdb_class_helper.h: $(BUILDDIR)/include/kdb_class_helper.h

$(BUILDDIR)/include/kdb_autogenerated_protos.h: $(filter kdb/%,$(SOURCES)) $(SRCDIR)/include/kdb/cmd.h $(SRCDIR)/kdb/Makeconf $(BUILDDIR)/config/.config
	@if [ ! -d $(dir $@) ]; then $(MKDIRHIER) $(dir $@); fi
	@echo "/* Machine-generated file - DO NOT EDIT! */" > $@.new
	@echo "/* File will be included from kdb/kdb.h  */" >> $@.new
	@grep -h " kdb_t::.*(" $(filter %.cc, $^) | \
		 perl -pe 's/kdb_t::(.*)\).*/\1);/' >> $@.new
	@cmp -s $@ $@.new && rm -f $@.new || mv $@.new $@
# Workaround for broken dependencies with cpp-3.3
kdb_autogenerated_protos.h: $(BUILDDIR)/include/kdb_autogenerated_protos.h


-include kdb/arch/$(ARCH)/Makeconf \
	 kdb/api/$(API)/Makeconf \
	 kdb/glue/$(API)-$(ARCH)/Makeconf

clean::
	@rm -f $(BUILDDIR)/include/kdb_class_helper.h
