#
# MICO --- a free CORBA implementation
# Copyright (C) 1997 Kay Roemer & Arno Puder
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Send comments and/or bug reports to:
#                mico@informatik.uni-frankfurt.de
#

include ../MakeVars

SUBDIRS = naming events streams relship property
LDFLAGS := -L../orb -lmico$(VERSION) $(LDFLAGS)

STATIC_OBJS = \
  naming/naming.o \
  events/CosEventComm.o events/CosEventChannelAdmin.o \
  streams/stream.o streams/stream_impl.o \
  relship/CosObjectIdentity.o relship/CosRelationships.o \
  relship/IdentifiableObject_impl.o relship/Random.o \
  relship/RelationshipIterator_impl.o relship/Relationship_impl.o \
  relship/Role_impl.o \
  property/PropertyService_impl.o \
  property/PropertyService.o
SHARED_OBJS = $(STATIC_OBJS:.o=.pic.o)


all: lib prg


lib:

ifeq ($(HAVE_SHARED_EXCEPTS), yes)
ifeq ($(HAVE_STATIC), yes)
prg: sublib libmicocoss$(VERSION).a libmicocoss$(VERSION).$(SOEXT) subprg
else
prg: sublib libmicocoss$(VERSION).$(SOEXT) subprg
endif
else
prg: sublib libmicocoss$(VERSION).a subprg
endif

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

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


# shared 

ifeq ($(HAVE_SHARED_EXCEPTS), yes)
libmicocoss$(VERSION).$(SOEXT): $(SHARED_OBJS)
ifeq ($(HAVE_REPO), yes)
	-$(CXX) $(CXXFLAGS) $(SHARED_OBJS) $(LDFLAGS) $(CONFLIBS)
endif
	rm -f $@
	$(LDSO) -o libmicocoss$(VERSION) $(SHARED_OBJS) \
		-L../libs -lmico$(VERSION)
	$(IDIRCMD) ../libs
	cd ../libs; rm -f $@; ln -f -s ../coss/$@ .
endif

# static

libmicocoss$(VERSION).a: $(STATIC_OBJS)
ifeq ($(HAVE_REPO), yes)
	-$(CXX) $(CXXFLAGS) $(STATIC_OBJS) $(LDFLAGS) $(CONFLIBS)
endif
	$(AR) $(ARFLAGS) $@ $(STATIC_OBJS)
	$(RANLIB) $@
	$(IDIRCMD) ../libs
	cd ../libs; rm -f $@; ln -f -s ../coss/$@ .


clean:
	for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit 1; done
	rm -f *.a *.$(SOEXT)

install:
	$(IDIRCMD) $(INSTDIR)/lib
ifeq ($(HAVE_SHARED_EXCEPTS), yes)
	$(ILIBCMD) libmicocoss$(VERSION).$(SOEXT) $(INSTDIR)/lib
ifeq ($(HAVE_STATIC), yes)
	$(ILIBCMD) libmicocoss$(VERSION).a $(INSTDIR)/lib
endif
else
	$(ILIBCMD) libmicocoss$(VERSION).a $(INSTDIR)/lib
endif
	for i in $(SUBDIRS); do $(MAKE) -C $$i install || exit 1; done	

install-cd: install

