#!/usr/bin/perl # # This script will allow you to easily swap between different library # types for various libraries. # # Mark A. Brown # Rhythm and Hues Studios # 4/12/2000 # # Root directories for the source and destination library trees. my $srcroot = "."; my $destroot = "/"; # Define the specific library you want to install for each library type. my %libs = ( "GL" => "ATI-1.9.20", "GLU" => "oss-opengl-glu-20000925-1", # "GL" => "Mesa-3.4.2-7", # "GLU" => "Mesa-3.4.2-7", ); # # Utility variables # my $RM = "/bin/rm"; my $TAR = "/bin/tar"; my $PWD = "/bin/pwd"; my $LDCONFIG = "/sbin/ldconfig"; # # Obtain the full path of the location of the source library trees # chdir($srcroot); chop(my $fullroot = `$PWD`); # # Validate that *all* the libraries we need actually exist before starting. # my $errors = 0; foreach my $libtype (keys %libs) { # # If the cleaning subroutine doesn't exist, complain. # if (! exists &{"clean_${libtype}"}) { print STDERR "Error: Subroutine \"clean_${libtype}\" must exist to prepare for installation of $libtype libraries\n"; $error++; } # # If the tree we will be copying files from doesn't exist, complain. # my $libdir = "${fullroot}/${libtype}/$libs{$libtype}"; if (! -d $libdir) { print STDERR "Error: Need directory tree \"$libdir\" to populate $libtype libraries.\n"; $error++; } } exit(1) if $error; # Clean up and copy the appropriate files to the appropriate places # for each library type. foreach my $libtype (keys %libs) { my $libdir = "${fullroot}/${libtype}/$libs{$libtype}"; &{"clean_${libtype}"}(); # Run the cleaning subroutine. print STDERR "Populating $libtype libraries using $libs{$libtype}\n"; chdir($libdir); # Go to source tree directory. my $out = `$TAR -cf - . | (cd $destroot;$TAR -xvpBf -)`; `$LDCONFIG`; } # # Routine to get rid of all GL related libraries rooted at $destroot # sub clean_GL() { chop(my $curdir = `$PWD`); # Remember current directory my @zap = ( "usr/X11R6/lib/libGL.so*", "usr/X11R6/lib/modules/dri/firegl*", "usr/X11R6/lib/modules/drivers/firegl*", "usr/X11R6/lib/modules/linux/libfgl*", "usr/lib/libGL.so*", "usr/lib/libfgl_gamma.a", "usr/X11R6/lib/libfgl_gamma.a", ); chdir($destroot); `$RM -f @zap`; chdir($curdir); # Get back to where we started. } # # Routine to get rid of all GLU releated libraries rooted at $destroot # sub clean_GLU() { chop(my $curdir = `$PWD`); # Remember current directory. my @zap = ( "usr/lib/libGLU.so*", "usr/include/GL/glu.h", ); chdir($destroot); `$RM -f @zap`; chdir($curdir); # Get back to where we started. }