5 # Search for a.out libraries and move them to an aout subdirectory of
6 # the elf library directory.
8 # The arguments are the directories to search.
12 # Create a temporary tool to get the timestamp of libraries. No, I don't
13 # want to use perl or whatever.
14 create_get_time_stamp ( )
16 echo "#include <stdio.h>" > /tmp/get_time_stamp.c
17 echo "#include <sys/stat.h>" >> /tmp/get_time_stamp.c
18 echo "int main(int argc, char *argv[]) {" >> /tmp/get_time_stamp.c
19 echo "int ierr; struct stat fs;" >> /tmp/get_time_stamp.c
20 echo "if ((ierr = stat(argv[1],&fs)) == 0)" >> /tmp/get_time_stamp.c
21 echo "printf(\"%ld\n\",(long) fs.st_mtime);" >> /tmp/get_time_stamp.c
22 echo "return (ierr); }" >> /tmp/get_time_stamp.c
23 gcc -o /tmp/get_time_stamp /tmp/get_time_stamp.c
24 rm /tmp/get_time_stamp.c
28 # Move an a.out library to the aout subdirectory of the elf directory.
31 if test -d $dir/aout; then
33 echo "Creating directory $dir/aout"
38 if test -f $dir/aout/$fname; then
39 if test -x /tmp/get_time_stamp; then
43 t1=`/tmp/get_time_stamp $dir/aout/$fname`
44 t2=`/tmp/get_time_stamp $file`
45 if test $t1 -gt $t2; then
46 echo $file is older than $dir/aout/$fname
48 while test "$answer" != "y" -a "$answer" != "n"; do
49 read -p "OK to delete the older file? (y/n) " answer
51 if test $answer = "y"; then
56 echo "You need to move $file out of $dir because that's an elf directory"
59 echo $dir/aout/$fname is older than $file
61 while test "$answer" != "y" -a "$answer" != "n"; do
62 read -p "OK to overwrite the older file? (y/n) " answer
64 if test $answer = "y"; then
65 echo Overwriting $dir/aout/$fname with $file
67 mv $file $dir/aout/$fname
70 echo "You need to move $file out of $dir because that's an elf directory"
74 echo Move $fname from $dir to $dir/aout
76 mv $file $dir/aout/$fname
82 # Given a list of files in a directory, find those that are a.out
83 # libraries and move them.
89 # Don't touch symbolic links yet. It's not clear how
90 # they should be handled.
91 if test -L $file; then
93 # Check that this is a normal file.
94 if test -f $file; then
95 # Identify the file by magic
96 filemagic=`file $file`
98 # Check if the file is an a.out library
99 if expr "$filemagic" : ".*$aoutmagic"; then
100 # Move the a.out library
109 # Only search the directories specified.
112 # Make sure the directory exists, or ldconfig will choke later.
113 mkdir -p $dir $dir/aout
115 echo "Searching library directory $dir for a.out libraries..."
117 # Get a list of archive libraries.
118 files=`ls $dir/*.a 2> /dev/null`
120 # a.out archive libraries look like this:
121 aoutmagic="current ar archive random library"
123 # Move each a.out archive library:
126 # Get a list of shared libraries
127 files=`ls $dir/*.so.*.* 2> /dev/null`
129 # a.out shared libraries look like this:
130 aoutmagic="FreeBSD/i386 compact demand paged shared library"
132 # Move each a.out shared library:
136 # If we created the time stamp program, delete it:
137 if test -x /tmp/get_time_stamp; then
138 rm /tmp/get_time_stamp