--- /export/alanc/X.org/release1/cvs-ro/xc/config/cf/host.def Tue Apr 6 16:28:32 2004 +++ xc/config/cf/host.def Wed Apr 7 15:02:18 2004 @@ -1,0 +1,29 @@ +#define MakeDllModules YES + +/* Hackery for building modules as Solaris shared objects with dependencies */ +#if MakeDllModules && DoLoadableServer + +/* If you change this, you will need to change find-deps.pl to match */ +#define DlModuleDependencyName(module) Concat(module,_deps) + +#define DlModuleTarget(module,deplist,modlist) @@\ +DepDynamicModuleTarget(module,deplist DlModuleDependencyName(module),modlist -z lazyload `cat DlModuleDependencyName(module)`) @@\ + @@\ +DlModuleDependencyName(module): @@\ + touch $@ @@\ + @@\ +clean:: @@\ + RemoveFile(DlModuleDependencyName(module)) + +#define ObjectModuleTarget(module,objects) @@\ +DlModuleTarget(Concat(module,_drv.so), objects, objects) + +#define LibraryModuleTarget(module,objects) @@\ +NormalLibraryTarget(module, objects) @@\ +DlModuleTarget(Concat3(lib,module,.so), objects, objects) + +#define DepLibraryModuleTarget(module,deplist,objects) @@\ +NormalDepLibraryTarget(module, deplist, objects) @@\ +DlModuleTarget(Concat3(lib,module,.so), deplist, objects) + +#endif --- /export/alanc/X.org/release1/cvs-ro/xc/programs/Xserver/localmacros 1969-12-31 16:00:00.000000000 -0800 +++ xc/programs/Xserver/localmacros 2004-03-25 13:42:26.299020000 -0800 @@ -0,0 +1,24 @@ +XCOMM +XCOMM Copyright 2004 Sun Microsystems, Inc. All rights reserved. +XCOMM Use is subject to license terms. +XCOMM +XCOMM ident "@(#)localmacros 1.1 04/03/16 SMI" +XCOMM +XCOMM Sun customization for Xserver to use dlopen() .so modules + +#if MakeDllModules && DoLoadableServer && \ + (defined(SunArchitecture) && defined(SVR4Architecture) && HasSunC) +XCOMM Hackery for building dlopen-able .so modules on Solaris + +AllTarget(linker-deps) + +LINKER_DEPS_DIRS = $(SUBDIRS) $(FONTLIBSRC) + +XCOMM After everything is built, run through and generate linker dependencies +linker-deps: + RunPerlScript($(XF86SRC)/os-support/sunos/find_deps.pl,$(LINKER_DEPS_DIRS)) + for i in $(LINKER_DEPS_DIRS) ; do \ + echo "relinking with dependency flags in $(CURRENT_DIR)/$$i..."; \ + MakeNamedTargetSubdir($$i,NullParameter,all) ; \ + done +#endif --- /export/alanc/X.org/release1/cvs-ro/xc/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl 1969-12-31 16:00:00.000000000 -0800 +++ xc/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl 2004-03-25 13:42:26.332863000 -0800 @@ -0,0 +1,103 @@ +#!/usr/bin/perl -w +# +# $XdotOrg$ +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# This script scans the X server, it's libraries, and shared object drivers +# and generates the linker flags necessary to allow the shared object modules +# to load via dlopen(). +# +# WARNING: Do not try this at home boys and girls! Only trained professionals +# should try this stunt. This script is not intended to serve as an example of +# proper use of the linker or associated tools, but merely as an unfortunately +# necessary bit of hackery to get Xserver modules to load via Solaris dlopen +# instead of the XFree86 custom loader/runtime linker. +# +# No guarantee of usability or suitablity is made - in fact it's almost +# guaranteed this is not suitable for any other use, and maybe not even +# for the one it was intended. + +use strict; +use File::Find; + +my @objlist = (); +my %symtable = (); + +if (-f "XFree86") { + $File::Find::name = "XFree86"; + $_ = "XFree86"; + &scanobjs; +} + +find({wanted => \&scanobjs, preprocess => \&filterobjs}, @ARGV); + +for my $f (@objlist) { + open(ELFDUMP, "/usr/ccs/bin/elfdump -r $f|") || die "Cannot open file"; + my $edline; + my %deps = (); + while ($edline = ) { + next unless $edline =~ /(GLOB_DAT|R_386_32)/; + my @edpart = split /\s+/, $edline; + if (exists $symtable{$edpart[4]}) { +# print "$f : $edpart[4] - $symtable{$edpart[4]}\n"; + $deps{$symtable{$edpart[4]}} += 1; + } else { + print "$f : $edpart[4] - not found\n"; + } + } + close(ELFDUMP); + + my $depslist = ""; + + for my $d (sort keys %deps) { + next if ($f =~ /$d/ || $d !~ /\.so$/); + $depslist .= " -Wl,-N,$d"; + } + print "$f : $depslist\n"; + my $depsfile = $f ."_deps"; + if ($depslist ne "") { + my $dirlist = "-R /usr/X11R6/lib/modules"; + if ($f =~ /drivers/) { + $dirlist .= " -R /usr/X11R6/lib/modules/drivers"; + } + if ($depslist =~ /libfbdevhw.so/) { + $dirlist .= " -R /usr/X11R6/lib/modules/linux/"; + } + if ($depslist =~ /libGLcore.so/) { + $dirlist .= " -R /usr/X11R6/lib/modules/extensions/"; + } + + open(MODDEPSFILE, '>', $depsfile) || die "Cannot write to $depsfile"; + print MODDEPSFILE $dirlist, $depslist, "\n"; + close(MODDEPSFILE); + } elsif (! -z $depsfile) { + unlink($depsfile); + system("touch $depsfile"); + } +} + + +sub filterobjs { + return (grep( ($_ =~ /\.so$/) || (-d $_) , @_)); +} + +sub scanobjs { + return if /libXfont.so/; + return if (-d $_); + print "Scanning $File::Find::name ...\n"; + push @objlist, $File::Find::name; + open(NMOUT, "/usr/ccs/bin/nm $_|") || die "Cannot nm file $_"; + my $nmline; + while ($nmline = ) { + next unless $nmline =~ /\|/; + my @nmpart = split(/\s*\|\s*/, $nmline); + next unless ($nmpart[4] eq "GLOB") && ($nmpart[6] ne "UNDEF"); + chomp($nmpart[7]); + if (! exists $symtable{$nmpart[7]}) { + $symtable{$nmpart[7]} = $_; + } + } + close(NMOUT); +}