XCOMM $Xorg: ibmLib.rules,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
XCOMM $XdotOrg: xc/config/cf/ibmLib.rules,v 1.1.4.3 2003/12/15 16:42:40 kaleb Exp $

/*
 * AIX shared library rules
 */

XCOMM $XFree86: xc/config/cf/ibmLib.rules,v 3.5 2000/02/13 06:15:18 dawes Exp $
#ifndef HasSharedLibraries
# define HasSharedLibraries YES
#endif
#ifndef ForceNormalLib
# define ForceNormalLib NO
#endif
#ifndef SharedDataSeparation
# define SharedDataSeparation NO
#endif
#ifndef SharedCodeDef
# define SharedCodeDef -DSHAREDCODE
#endif
#if OSMajorVersion < 5
# ifndef SharedLibraryDef
#  define SharedLibraryDef -DAIXSHLIB
# endif
#else
# define SharedLibraryDef /**/
#endif
#ifndef ShLibIncludeFile
# define ShLibIncludeFile <ibmLib.tmpl>
#endif
#ifndef PositionIndependentCFlags
# define PositionIndependentCFlags -bM\:SRE
#endif
#ifndef ExtraLoadFlags
# define ExtraLoadFlags -bnodelcsect
#endif
#if !defined(LdPostLib) && !defined(UseInstalled) && OSMajorVersion > 3
# if ThreadedX
#  define LdPostLib -bnoipath -blibpath:$(USRLIBDIRPATH):/usr/lib/threads:/usr/lib:/lib
# else
#  define LdPostLib -bnoipath -blibpath:$(USRLIBDIRPATH):/usr/lib:/lib
# endif
# define SharedLibPostRef $(LDPOSTLIBS)
#endif
#ifndef SharedLibPostRef
# define SharedLibPostRef $(LDPOSTLIBS)
#endif
#if ThreadedX
# define BaseShLibReqs -lc_r -lm
#else
# define BaseShLibReqs -lc -lm
#endif
#ifndef UseExportLists
# define UseExportLists YES
#endif

/*
 * MakeExportList - generate an export list file for linking libraries.
 */
#ifndef MakeExportList
# if UseExportLists
#  define MakeExportList(libname,result) \
	@-RemoveFile(result)						@@\
	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
		echo "#! $@ ($${shr4obj:-shr.o})" > result		@@\
	if [ -f Concat(lib,libname.elist) ]; then \			@@\
	    $(CPP) $(ALLINCLUDES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES) Concat(lib,libname.elist) | CppSedMagic > $@.list; \	@@\
	    $(EXPORTLISTGEN) $@~ $@.list >> result; \			@@\
	    RemoveFile($@.list); \					@@\
	else \								@@\
	    dump -g $@~ | sed -n -e 's/^[ 	]*[0-9][0-9]*[	 ]*\([^	 .][^	 ]*\)$$/\1/p' >> result; \	@@\
	fi;
# else
#  define MakeExportList(libname,result) \
	@-RemoveFile(result)						@@\
	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
		echo "#! $@ ($${shr4obj:-shr.o})" > result		@@\
	dump -g $@~ | sed -n -e 's/^[ 	]*[0-9][0-9]*[	 ]*\([^	 .][^	 ]*\)$$/\1/p' >> result;
# endif
#endif /* MakeExportList */


#if !defined(UseInstalled) && !defined(UseInstalledX11) \
    && !defined(UseImports) && !defined(ImportX11)
   /* we want this to be defined only when building X */

# if OSMajorVersion < 5
#  if OSMajorVersion < 4
/*
 * SharedLibReferences - variables for shared libraries
 */

#   ifndef SharedLibReferences
#    define SharedLibReferences(varname,libname,libsource,revname,rev)	@@\
Concat3(DEP,varname,LIB) = /**/						@@\
Concat(varname,LIB) = _Use(Concat(-l,libname),Concat(libsource/lib,libname.a)) @@\
LintLibReferences(varname,libname,libsource)
#   endif

#  else /* OSMajorVersion < 4 */

#   ifndef SharedLibReferences
#    define SharedLibReferences(varname,libname,libsource,revname,rev)	@@\
Concat3(DEP,varname,LIB) = /**/						@@\
Concat(varname,LIB) = _Use(Concat(-l,libname),Concat($(BUILDLIBDIR),/libname.imp) Concat3($(BUILDLIBDIR),/lib,libname.a)) @@\
LintLibReferences(varname,libname,libsource)
#   endif

#  endif
# else /* OSMajorVersion < 5 */

#  ifndef SharedLibReferences
#   define SharedLibReferences(varname,libname,libsource,revname,rev)	@@\
Concat3(DEP,varname,LIB) = /**/						@@\
Concat(varname,LIB) = _Use(Concat(-l,libname), Concat3($(BUILDLIBDIR),/lib,libname.so)) @@\
LintLibReferences(varname,libname,libsource)
#  endif

# endif

# if OSMajorVersion < 5
#  if OSMajorVersion < 4
/*
 * SharedFontLibReferences - shared font libraries
 */

#   ifndef SharedFontLibReferences
#    define SharedFontLibReferences()					@@\
DEPFONTLIB = /**/							@@\
FONTLIB = -L$(FREETYPELIBDIR) _Use(-lXfont,$(FONTLIBSRC)/libXfont.a)	@@\
LintLibReferences(XFONT,Xfont,$(FONTLIBSRC))
#   endif
#  else
#   ifndef SharedFontLibReferences
#    define SharedFontLibReferences()					@@\
DEPFONTLIB = /**/							@@\
FONTLIB = -L$(FREETYPELIBDIR) _Use(-lXfont,$(BUILDLIBDIR)/font.imp) $(BUILDLIBDI)/libXfont.a)) @@\
LintLibReferences(XFONT,Xfont,$(FONTLIBSRC))
#   endif
#  endif
# else /* OSMajorVersion < 5 */
#  ifndef SharedFontLibReferences
#   define SharedFontLibReferences()					@@\
DEPFONTLIB = /**/							@@\
FONTLIB = -L$(FREETYPELIBDIR) _Use(-lXfont,$(BUILDLIBDI)/libXfont.so)) @@\
LintLibReferences(XFONT,Xfont,$(FONTLIBSRC))
#  endif

# endif

/*
 * SharedDSLibReferences - variables for shared libraries
 */
# ifndef SharedDSLibReferences
#  define SharedDSLibReferences(varname,libname,libsource,revname,rev)	@@\
SharedLibReferences(varname,libname,libsource,revname,rev)
# endif

# if OSMajorVersion == 4
/*
 * UnsharedLibReferences - variables for unshared libraries
 */
#  ifndef UnsharedLibReferences
#   define UnsharedLibReferences(varname,libname,libsource)		@@\
Concat3(DEP,varname,LIB) = _UseCat($(USRLIBDIR)/lib,$(BUILDLIBDIR)/lib,libname.a)	@@\
Concat(varname,LIB) = _Use(Concat(-l,libname),Concat($(BUILDLIBDIR)/lib,libname.a))	@@\
LintLibReferences(varname,libname,libsource)
#  endif
# endif

#endif /* !defined(UseInstalled) && !defined(UseInstalledX11) ... */


/*
 * InstallSharedLibrary - generate rules to install the shared library.
 */
#ifndef InstallSharedLibrary
# if OSMajorVersion < 5
#  define InstallSharedLibrary(libname,rev,dest)			@@\
InstallLibrary(libname,dest)
# else /* OSMajorVersion < 5 */
#  define InstallSharedLibrary(libname,rev,dest)			@@\
install:: Concat(lib,libname.so)					@@\
	MakeDir($(DESTDIR)dest)						@@\
	$(INSTALL) $(INSTALLFLAGS) $(INSTBINFLAGS) Concat(lib,libname.so) $(DESTDIR)dest
# endif /* OSMajorVersion < 5 */
#endif /* InstallSharedLibrary */

/*
 * InstallSharedLibraryData - generate rules to install the shared library data
 */
#ifndef InstallSharedLibraryData
# define InstallSharedLibraryData(libname,rev,dest)
#endif /* InstallSharedLibraryData */

/*
 * SharedLibraryTarget - generate rules to create a shared library;
 * build it into a different name so that the we do not hose people by having
 * the library gone for long periods.
 *
 * IBM uses an unusual shared object file name (shr4.o) in some libraries.
 * Duplicate this behavior to preserve compatibility with IBM's libraries.
 */
#if OSMajorVersion < 5
# if OSMajorVersion < 4

#  ifndef SharedLibraryTarget
#   define SharedLibraryTarget(libname,rev,solist,down,up)		@@\
AllTarget(Concat(lib,libname.a))					@@\
									@@\
Concat(lib,libname.a):  solist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
	$(RM) $@~ shr.o shr4.o						@@\
	(cd down; $(AR) up/$@~ solist)					@@\
	dump -g $@~ | sed -n -e 's/^[ 	]*[0-9][0-9]*[	 ]*\([^	 .][^	 ]*\)$$/\1/p' > $@.syms	@@\
	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:$@.syms $(REQUIREDLIBS) BaseShLibReqs SharedLibPostRef	@@\
	$(LN) shr.o shr4.o						@@\
	$(RM) $@~							@@\
	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
	$(RM) $@.syms $@ shr.o shr4.o					@@\
	$(MV) $@~ $@							@@\
	LinkBuildLibrary($@)						@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.a)
#  endif /* SharedLibraryTarget */

# else /* OSMajorVersion < 4 */

#  ifndef SharedLibraryTarget
#   define SharedLibraryTarget(libname,rev,solist,down,up)		@@\
AllTarget(Concat(lib,libname.a))					@@\
									@@\
Concat(lib,libname.a):  solist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
	RemoveFiles($@~ shr.o shr4.o)					@@\
	(cd down; $(AR) up/$@~ solist)					@@\
	MakeExportList(libname,libname.imp)				@@\
	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:libname.imp -bnoentry $(REQUIREDLIBS) BaseShLibReqs $(LDPOSTLIBS)	@@\
	$(LN) shr.o shr4.o						@@\
	RemoveFile($@~)							@@\
	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
	RemoveFile($@)							@@\
	$(MV) $@~ $@							@@\
	LinkBuildLibrary($@)						@@\
	LinkBuildLibrary(libname.imp)					@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.a)
#  endif /* SharedLibraryTarget */
# endif /* OSMajorVersion < 4 */
#else /* OSMajorVersion < 5 */
# ifndef SharedLibraryTarget
#  define SharedLibraryTarget(libname,rev,solist,down,up)		@@\
AllTarget(Concat(lib,libname.so))					@@\
									@@\
Concat(lib,libname.so): solist $(EXTRALIBRARYDEPS)			@@\
	$(RM) $@~							@@\
	$(AR) $*.a solist						@@\
	dump -g $*.a | sed -n -e 's/^[  ]*[0-9][0-9]*[[:space:]]*\([_[:alpha:]][[:alnum:]]*\)/\1/p' | egrep -v \\\. | sort | uniq > $*.syms	@@\
	$(LD) -bnoipath -bnoentry -bM\:SRE -bE\:$*.syms -o $@~ solist $(REQUIREDLIBS) BaseShLibReqs -lc	@@\
	$(RM) $@ $*.a $*.syms						@@\
	$(MV) $@~ $@							@@\
	LinkBuildLibrary($@)						@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.so.rev) Concat(lib,libname.so)

# endif /* SharedLibraryTarget */
#endif /* OSMajorVersion < 5 */

/*
 * SharedDepLibraryTarget - generate rules to create a shared library.
 */
#if OSMajorVersion < 5
# if OSMajorVersion < 4

#  ifndef SharedDepLibraryTarget
#   define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
AllTarget(Concat(lib,libname.a))					@@\
									@@\
Concat(lib,libname.a):  deplist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
	$(RM) $@~ shr.o shr4.o						@@\
	(cd down; $(AR) up/$@~ solist)					@@\
	dump -g $@~ | sed -n -e 's/^[   ]*[0-9][0-9]*[   ]*\([^  .][^    ]*\)$$/\1/p' > $@.syms	@@\
	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:$@.syms $(REQUIREDLIBS) BaseShLibReqs SharedLibPostRef	@@\
	$(LN) shr.o shr4.o						@@\
	$(RM) $@~							@@\
	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
	$(RM) $@.syms $@ shr.o shr4.o					@@\
	$(MV) $@~ $@							@@\
	LinkBuildLibrary($@)						@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.a)
#  endif /* SharedDepLibraryTarget */

# else /* OSMajorVersion < 4 */

#  ifndef SharedDepLibraryTarget
#   define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
AllTarget(Concat(lib,libname.a))					@@\
									@@\
Concat(lib,libname.a):  deplist $(UNSHAREDOBJS) $(EXTRALIBRARYDEPS)	@@\
	RemoveFiles($@~ shr.o shr4.o)					@@\
	(cd down; $(AR) up/$@~ solist)					@@\
	MakeExportList(libname,libname.imp)				@@\
	$(LD) -o shr.o $@~ -H512 -T512 -bM\:SRE -bE\:libname.imp -bnoentry $(REQUIREDLIBS) BaseShLibReqs $(LDPOSTLIBS)	@@\
	$(LN) shr.o shr4.o						@@\
	RemoveFile($@~)							@@\
	case ,$(SHR4OBJLIBS), in *,libname,*) shr4obj=shr4.o;; esac &&\	@@\
		$(AR) $@~ $${shr4obj} shr.o $(UNSHAREDOBJS)		@@\
	RemoveFile($@)							@@\
	$(MV) $@~ $@							@@\
	LinkBuildLibrary($@)						@@\
	LinkBuildLibrary(libname.imp)					@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.a)
#  endif /* SharedDepLibraryTarget */

# endif /* OSMajorVersion < 4 */
#else /* OSMajorVersion < 5 */
# ifndef SharedDepLibraryTarget
#  define SharedDepLibraryTarget(libname,rev,deplist,solist,down,up)	@@\
AllTarget(Concat(lib,libname.so))					@@\
									@@\
Concat(lib,libname.so):  deplist $(EXTRALIBRARYDEPS)			@@\
	$(RM) $@~							@@\
	$(AR) $*.a solist						@@\
	dump -g $*.a | sed -n -e 's/^[  ]*[0-9][0-9]*[[:space:]]*\([_[:alpha:]][[:alnum:]]*\)/\1/p' | egrep -v \\\. | sort | uniq > $*.syms	@@\
	$(LD) -bnoipath -bnoentry -bsymbolic -bM\:SRE -bE\:$*.syms -o $@~ solist $(REQUIREDLIBS) BaseShLibReqs -lc	@@\
	$(RM) $@ $*.a $*.syms						@@\
	$(MV) $@~ $@							@@\
	LinkBuildLibrary($@)						@@\
									@@\
clean::									@@\
	$(RM) Concat(lib,libname.so) Concat(lib,libname.so)

# endif /* SharedDepLibraryTarget */
#endif /* OSMajorVersion < 5 */

/*
 * SharedLibraryDataTarget - generate rules to create shlib data file;
 */
#ifndef SharedLibraryDataTarget
# define SharedLibraryDataTarget(libname,rev,salist)
#endif /* SharedLibraryTarget */
