#
# Makefile         [LGMP-library] 
#
# This file is part of
#
# LGMP -- Local Group based Multicast Protocol
#
# (C) 1996, 1997, 1998, 1999 Markus Hofmann and Jochen Schlick
#     (hofmann@acm.org)
#
# 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.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#      This product includes software developed by Markus Hofmann,
#      Jochen Schlick and other contributors.
# 4. Neither the name of the Authors nor the names of other contributors
#    may be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
#
# 
# (schlick@telematik.informatik.uni-karlsruhe.de)
#
#
# "$Id: Makefile,v 1.7 1999/02/20 13:54:58 schlick Exp $"
###############################################################################

#................................... include system/compiler dependant Rules ..
include ../Rules.Make


###############################################################################

SRCRUNDIR	= ../$(RUNDIR)

#............................................................ static library ..
LIBRARY		= liblgmp.a

#............................................................ shared library ..
SHAREDLIBRARY   = liblgmp.so

#..............................................................................
LIBRARYOBJS	= compat_thrd.o  \
		  timeout.o      \
		  checksum.o     \
		  sockstuff.o    \
		  sharedmem.o    \
		  rundcp.o       \
		  log.o          \
		  memory.o       \
		  memberctrl.o   \
		  lgmp.o         \
	          getmcastaddr.o \
		  protocolf.o    \
		  protocolt.o    \
		  proccntl.o 

#........................................................... progs / subdirs ..


#............................................ additional include-directories ..
INCLUDEDIRS	= -I.

#................................................................. libraries ..
#................ additional libraries 
LOADLIBDIRS	= -L.
LOADLIBS	= $(SYSTHRDLIBS) $(SYSDEPLIBS) 

#..................................................................... shell ..
SHELL		= /bin/sh

#.............................................................	preprocessor ..
CPP		= $(COMPILER) $(INCLUDEDIRS) -E


###############################################################################
all:		lib

#............................................................ implicit rules ..

.c.o:
	$(COMPILER) $(CFLAGS) $(SYSLIBCFLAGS) $(INCLUDEDIRS) -c $*.c



#.............................................................. static library 
lgmplib:	lib

lib:		$(LIBRARY)


$(LIBRARY):	$(LIBRARYOBJS)
	@echo "**************** make static $(LIBRARY) ......................."
	$(AR) $(ARFLAGS) $@ $?
	$(RANLIB) $@


#............................ shared library (when supported by Rules.Make.XXX)
sharedlgmplib:	sharedlib

sharedlib:	$(SHAREDLIBRARY)

libshared:	sharedlib


$(SHAREDLIBRARY):	$(LIBRARYOBJS)
	@echo "**************** make shred $(SHAREDLIBRARY) ..............."
	$(SHAREDLIBCREATE) $(SHAREDLIBFLAGS) -o $(SHAREDLIBRARY) $(LOADLIBDIRS) $(LOADLIBS) $?



#..............................................................................
install: lgmp
	@echo "**************** install $(LIBRARY) --> $(SRCRUNDIR) ......."
	-mkdir -p $(SRCRUNDIR)
	-cp -f $(LIBRARY) $(SRCRUNDIR)
	-cp -f $(SHAREDLIBRARY) $(SRCRUNDIR)


#..............................................................................
clean:
	@echo "**************** clean $(LIBRARY) .........................."
	-rm -f $(LIBRARY) $(SHAREDLIBRARY) *.o core* *~

osclean: clean
	@echo "**************** cleanup dependencies ......................"
	sed '/\#\#\# Dependencies/q' < Makefile > .makedep
	cp .makedep Makefile
	rm -f .makedep

installclean:
	@echo "**************** remove installed $(LIBRARY) ..............."
	-rm -f $(SRCRUNDIR)$(LIBRARY)
	-rm -f $(SRCRUNDIR)$(SHAREDLIBRARY)


mrproper: installclean osclean
	@echo "**************** mrproper/distclean library ................"



#..............................................................................
dep: depend

.depend: depend

depend:
	@echo "**************** cleanup dependencies ......................"
	sed '/\#\#\# Dependencies/q' < Makefile > .makedep
	@echo "**************** create dependencies ......................."
	(for i in *.c ;do $(CPP) -M $$i;done) >> .makedep
	cp .makedep Makefile
	rm -f .makedep



#.................................................. phony targets(gnu make) ..
.PHONY: install installclean dep lgmp depend all clean mrproper dist distclean examples



########################## end of Makefile ####################################
###############################################################################
### Do not remove the following line. We need this for depend #################
### Dependencies:
