XCOMM $XFree86: xc/config/cf/scoLib.rules,v 1.13 2004/06/01 00:16:53 dawes Exp $

#ifndef UseExportLists
# define UseExportLists NO
#endif

#ifndef ExtraLoadFlags
#define ExtraLoadFlags -R $(USRLIBDIRPATH)
#endif

#ifndef SCOAbsShlibPath
# define SCOAbsShlibPath NO
#endif

#if SCOAbsShlibPath
# define SCOShlibFlags -h $(SHLIBDIR)/$@
#else
# define SCOShlibFlags -R $(DESTDIR)$(SHLIBDIR) -h $@
#endif

/*
 * SharedLibraryTarget3 - generate rules to create a shared library;
 * build it into a different name so that we do not hose people by having
 * the library gone for long periods.  
 *
 * Work around SCO sh enviroment size problem.
 */
#ifndef SharedLibraryTarget3
#define SharedLibraryTarget3(libname,rev,solist1,solist2,solist3,down,up)	@@\
AllTarget(Concat($(LIBPREFIX),libname.so.rev))				@@\
									@@\
Concat($(LIBPREFIX),libname.so.rev): solist1 solist2 solist3 $(EXTRALIBRARYDEPS) @@\
	$(RM) $@~							@@\
	echo -n $(LD) -o up/$@~ $(SHLIBLDFLAGS) SCOShlibFlags solist1 " " > Concat(down/lib,cmd) 	@@\
	echo -n solist2 " " >> Concat(down/lib,cmd)			@@\
	echo -n solist3 " " >> Concat(down/lib,cmd)			@@\
	echo -n $(REQUIREDLIBS) >> Concat(down/lib,cmd)			@@\
	(cd down; $(SHELL) Concat(./lib,cmd))				@@\
	$(RM) $@ Concat(lib,tmp1) Concat(lib,tmp2)			@@\
	$(MV) $@~ $@							@@\
	@if $(SOSYMLINK); then (set -x; \				@@\
	  $(RM) Concat($(LIBPREFIX),libname.so); \			@@\
	  $(LN) $@ Concat($(LIBPREFIX),libname.so)); fi			@@\
	LinkBuildLibrary($@)						@@\
	LinkBuildLibraryMaybe(Concat($(LIBPREFIX),libname.so),$(SOSYMLINK)) @@\
									@@\
clean::									@@\
	$(RM) Concat($(LIBPREFIX),libname.so.rev) Concat($(LIBPREFIX),libname.so)

#endif /* SharedLibraryTarget */

#ifndef LinkWithExports
# if UseExportLists
#  define LinkWithExports(libname,rev,solist,down,up) \
	(cd down; $(CCENVSETUP) $(LD) -o up/$@~ $(SHLIBLDFLAGS) SCOShlibFlags solist $(REQUIREDLIBS))	@@\
	if [ -f Concat(lib,libname.elist) ]; then \			@@\
	    $(RM) down/$@.exports $@.list; \				@@\
	    $(CPP) $(ALLINCLUDES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES) Concat(lib,libname.elist) | CppSedMagic >$@.list; \	@@\
	    $(EXPORTLISTGEN) $@~ $@.list > down/$@.exports; \		@@\
	    (cd down; $(CCENVSETUP) $(LD) -o up/$@~ $(SHLIBLDFLAGS) SCOShlibFlags ShlibExportListOpt($@.exports) solist $(REQUIREDLIBS)); \	@@\
	    $(RM) down/$@.exports $@.list; \				@@\
	fi;
# else
#  define LinkWithExports(libname,rev,solist,down,up) \
	(cd down; $(CCENVSETUP) $(LD) -o up/$@~ $(SHLIBLDFLAGS) SCOShlibFlags solist $(REQUIREDLIBS))
# endif
#endif
