|
1 #!/bin/ksh93 |
|
2 # |
|
3 # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. |
|
4 # |
|
5 # Permission is hereby granted, free of charge, to any person obtaining a |
|
6 # copy of this software and associated documentation files (the "Software"), |
|
7 # to deal in the Software without restriction, including without limitation |
|
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
9 # and/or sell copies of the Software, and to permit persons to whom the |
|
10 # Software is furnished to do so, subject to the following conditions: |
|
11 # |
|
12 # The above copyright notice and this permission notice (including the next |
|
13 # paragraph) shall be included in all copies or substantial portions of the |
|
14 # Software. |
|
15 # |
|
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
22 # DEALINGS IN THE SOFTWARE. |
|
23 # |
|
24 # |
|
25 |
|
26 LINKDIR=/var/run/opengl |
|
27 |
|
28 PATH=/usr/bin:/usr/sbin |
|
29 |
|
30 ARCH="$(uname -p)" |
|
31 |
|
32 case "${ARCH}" in |
|
33 sparc) DIR64="sparcv9" ;; |
|
34 i386) DIR64="amd64" ;; |
|
35 *) exit 1 ;; # Unknown architecture |
|
36 esac |
|
37 |
|
38 if [[ $# -eq 1 ]]; then |
|
39 # If this is just a probe, identify ourself and leave. |
|
40 if [[ $1 == "identify" ]]; then |
|
41 if [[ "${ARCH}" == "i386" ]] ; then |
|
42 print "SUNWtext mesa" |
|
43 fi |
|
44 # Already is the default fallback for all platforms |
|
45 return 0 |
|
46 fi |
|
47 # Build links under an alternate root if root=/path is passed |
|
48 if [[ "$1" =~ root=.* ]] ; then |
|
49 LINKDIR="${1#root=}${LINKDIR}" |
|
50 fi |
|
51 fi |
|
52 |
|
53 # Make a directory. $1 is the pathname. |
|
54 function make_dir { |
|
55 if [[ $# != 1 ]]; then |
|
56 return |
|
57 fi |
|
58 if [[ ! -d $1 ]]; then |
|
59 mkdir -p $1 |
|
60 fi |
|
61 chmod 755 $1 |
|
62 } |
|
63 |
|
64 # Make a file link. $1 is the source path, $2 is the target path |
|
65 function make_link { |
|
66 if [[ $# != 2 ]]; then |
|
67 return |
|
68 fi |
|
69 if [[ -h $2 ]]; then |
|
70 rm -f $2 |
|
71 fi |
|
72 ln -sf $1 $2 |
|
73 } |
|
74 |
|
75 # Create directories |
|
76 make_dir ${LINKDIR} |
|
77 make_dir ${LINKDIR}/lib |
|
78 make_dir ${LINKDIR}/lib/${DIR64} |
|
79 make_link ${DIR64} ${LINKDIR}/lib/64 |
|
80 make_dir ${LINKDIR}/include |
|
81 make_dir ${LINKDIR}/server |
|
82 |
|
83 if [[ -d /usr/lib/mesa/modules/extensions/${DIR64} ]] ; then |
|
84 make_dir ${LINKDIR}/server/${DIR64} |
|
85 fi |
|
86 |
|
87 # User libraries |
|
88 make_link ../../../../usr/lib/mesa/libGL.so.1 ${LINKDIR}/lib/libGL.so.1 |
|
89 make_link ../../../../../usr/lib/mesa/${DIR64}/libGL.so.1 \ |
|
90 ${LINKDIR}/lib/${DIR64}/libGL.so.1 |
|
91 |
|
92 # Server modules |
|
93 make_link ../../../../usr/lib/mesa/modules/extensions/libglx.so \ |
|
94 ${LINKDIR}/server/libglx.so |
|
95 if [[ -d /usr/lib/mesa/modules/extensions/${DIR64} ]] ; then |
|
96 make_link \ |
|
97 ../../../../../usr/lib/mesa/modules/extensions/${DIR64}/libglx.so \ |
|
98 ${LINKDIR}/server/${DIR64}/libglx.so |
|
99 fi |
|
100 |
|
101 # Includes |
|
102 make_link ../../../../usr/include/mesa/gl.h ${LINKDIR}/include/gl.h |
|
103 make_link ../../../../usr/include/mesa/glext.h ${LINKDIR}/include/glext.h |
|
104 make_link ../../../../usr/include/mesa/glx.h ${LINKDIR}/include/glx.h |
|
105 make_link ../../../../usr/include/mesa/glxext.h ${LINKDIR}/include/glxext.h |
|
106 |
|
107 return 0 |