#ident "@(#)rules.shl	1.15 10/10/03 "
###########################################################################
# Written 1996 by J. Schilling
###########################################################################
#
# Rules for shared (dynamic) libraries
#
# SUBARCHDIR must be before any other definitions
#
###########################################################################
# Copyright (c) J. Schilling
###########################################################################
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# See the file CDDL.Schily.txt in this distribution for details.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file CDDL.Schily.txt from this distribution.
###########################################################################

SUBARCHDIR=		/pic
COPTS +=		$(COPTDYN)
C++OPTS +=		$(C++OPTDYN)
LDOPTS +=		$(LDOPTDYN)
LDLIBS +=		$(LDLIBDYN)

###########################################################################
include		$(SRCROOT)/$(RULESDIR)/rules.obj
###########################################################################
TARGET=		$(LIB_PREFIX)$(TARGETLIB)$(SHL_SUFFIX)
TARGET_BASE=	$(LIB_PREFIX)$(TARGETLIB)
TARGET_PATH=	$(OLIBSDIR)
PTARGET=	$(OLIBSDIR)/$(TARGET)
PTARGET_BASE=	$(OLIBSDIR)/$(TARGET_BASE)

_MAPVERS=	lib$(TARGETLIB)-mapvers
#MAPVERS=	$(_MAPVERS)	# Use this in *-os-*cc*.rul to enable mapfiles
PMAPVERS=	$(MAPVERS:%=$(ARCHDIR)/$(MAPVERS))

$(PTARGET):	$(PMAPVERS)

#
# $(PMAPVERS) may be empty and POSIX does not permit empty target lists.
# We add an impossible target to make sure there is no empty target.
#
$(PMAPVERS) No/TaR/GeT:	$(MAPVERS)
			@echo "	==> LOCALIZING mapfile \"$@\""; \
			$(CPPX) $(CPPFLAGS) $^ > $@ || $(RM) $(RM_FORCE) $@

_INSMODEI=	$(_UNIQ)$(INSMODE)
__INSMODEI=	$(_INSMODEI:$(_UNIQ)=$(INSMODEF))
INSMODEI=	$(__INSMODEI:$(_UNIQ)%=%)

__DYNLD.o=	$(_UNIQ)$(DYNLD.o)
___DYNLD.o=	$(__DYNLD.o:$(_UNIQ)=$(DYNLD) -o $@ $(LDFLAGS) `$(LORDER) $(POFILES) | $(TSORT)` $(LDLIBS))
_DYNLD.o=	$(___DYNLD.o:$(_UNIQ)%=%)

all:		$(TARGET_PATH) $(PTARGET)

$(TARGET_PATH):
		$(MKDIR) -p $@

$(PTARGET):	$(OFILES)
			$(_DYNLD.o)
			-$(LNDYNLIB)

SYMLINKS +=	$(TARGET_BASE).so

#			@$(RM) $(RM_FORCE) $(PTARGET_BASE).so; $(SYMLINK) $(TARGET) $(PTARGET_BASE).so

###########################################################################
include		$(SRCROOT)/$(RULESDIR)/sub.htm
include		$(SRCROOT)/$(RULESDIR)/rules.clr
include		$(SRCROOT)/$(RULESDIR)/rules.ins
include		$(SRCROOT)/$(RULESDIR)/rules.tag
include		$(SRCROOT)/$(RULESDIR)/rules.hlp
include		$(SRCROOT)/$(RULESDIR)/rules.dep
###########################################################################
