blob: 520f20e2ed6ee426b20ec052e3b009d8a0047935 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
# What is LIBGL_DRIVERS_PATH used for?
# TODO gentoo removes some tools because there are xorg sources (?)
source $stdenv/setup
set -x
die(){ echo $@; exit 1; }
# custom unpack:
mkdir fglrx
cd fglrx
unzip $src
cd ..
run_file=$(echo fglrx/amd-driver-installer-*)
sh $run_file --extract .
eval "$patchPhase"
case "$system" in
x86_64-linux)
arch=x86_64
lib_arch=lib64
DIR_DEPENDING_ON_XORG_VERSION=xpic_64a
;;
i686-linux)
arch=x86
lib_arch=lib
DIR_DEPENDING_ON_XORG_VERSION=xpic
;;
*) exit 1;;
esac
# Handle/Build the kernel module.
if test -z "$libsOnly"; then
kernelVersion=$(cd ${kernel}/lib/modules && ls)
kernelBuild=$(echo ${kernel}/lib/modules/$kernelVersion/build)
linuxsources=$(echo ${kernel}/lib/modules/$kernelVersion/source)
# note: maybe the .config file should be used to determine this ?
# current kbuild infrastructure allows using CONFIG_* defines
# but ati sources don't use them yet..
# copy paste from make.sh
setSMP(){
linuxincludes=$kernelBuild/include
# copied and stripped. source: make.sh:
# 3
# linux/autoconf.h may contain this: #define CONFIG_SMP 1
# Before 2.6.33 autoconf.h is under linux/.
# For 2.6.33 and later autoconf.h is under generated/.
if [ -f $linuxincludes/generated/autoconf.h ]; then
autoconf_h=$linuxincludes/generated/autoconf.h
else
autoconf_h=$linuxincludes/linux/autoconf.h
fi
src_file=$autoconf_h
[ -e $src_file ] || die "$src_file not found"
if [ `cat $src_file | grep "#undef" | grep "CONFIG_SMP" -c` = 0 ]; then
SMP=`cat $src_file | grep CONFIG_SMP | cut -d' ' -f3`
echo "file $src_file says: SMP=$SMP"
fi
if [ "$SMP" = 0 ]; then
echo "assuming default: SMP=$SMP"
fi
# act on final result
if [ ! "$SMP" = 0 ]; then
smp="-SMP"
def_smp=-D__SMP__
fi
}
setModVersions(){
! grep CONFIG_MODVERSIONS=y $kernelBuild/.config ||
def_modversions="-DMODVERSIONS"
# make.sh contains much more code to determine this whether its enabled
}
# ==============================================================
# resolve if we are building for a kernel with a fix for CVE-2010-3081
# On kernels with the fix, use arch_compat_alloc_user_space instead
# of compat_alloc_user_space since the latter is GPL-only
COMPAT_ALLOC_USER_SPACE=arch_compat_alloc_user_space
for src_file in \
$kernelBuild/arch/x86/include/asm/compat.h \
$linuxsources/arch/x86/include/asm/compat.h \
$kernelBuild/include/asm-x86_64/compat.h \
$linuxsources/include/asm-x86_64/compat.h \
$kernelBuild/include/asm/compat.h;
do
if [ -e $src_file ];
then
break
fi
done
if [ ! -e $src_file ];
then
echo "Warning: x86 compat.h not found in kernel headers"
echo "neither arch/x86/include/asm/compat.h nor include/asm-x86_64/compat.h"
echo "could be found in $kernelBuild or $linuxsources"
echo ""
else
if [ `cat $src_file | grep -c arch_compat_alloc_user_space` -gt 0 ]
then
COMPAT_ALLOC_USER_SPACE=arch_compat_alloc_user_space
fi
echo "file $src_file says: COMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE"
fi
# make.sh contains some code figuring out whether to use these or not..
PAGE_ATTR_FIX=0
setSMP
setModVersions
CC=gcc
MODULE=fglrx
LIBIP_PREFIX=$TMP/arch/$arch/lib/modules/fglrx/build_mod
[ -d $LIBIP_PREFIX ]
GCC_MAJOR="`gcc --version | grep -o -e ") ." | head -1 | cut -d " " -f 2`"
{ # build .ko module
cd ./common/lib/modules/fglrx/build_mod/2.6.x
echo .lib${MODULE}_ip.a.GCC${GCC_MAJOR}.cmd
echo 'This is a dummy file created to suppress this warning: could not find /lib/modules/fglrx/build_mod/2.6.x/.libfglrx_ip.a.GCC4.cmd for /lib/modules/fglrx/build_mod/2.6.x/libfglrx_ip.a.GCC4' > lib${MODULE}_ip.a.GCC${GCC_MAJOR}.cmd
sed -i -e "s@COMPAT_ALLOC_USER_SPACE@$COMPAT_ALLOC_USER_SPACE@" ../kcl_ioctl.c
make CC=${CC} \
LIBIP_PREFIX=$(echo "$LIBIP_PREFIX" | sed -e 's|^\([^/]\)|../\1|') \
MODFLAGS="-DMODULE -DATI -DFGL -DPAGE_ATTR_FIX=$PAGE_ATTR_FIX -DCOMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE $def_smp $def_modversions" \
KVER=$kernelVersion \
KDIR=$kernelBuild \
PAGE_ATTR_FIX=$PAGE_ATTR_FIX \
-j4
cd $TMP
}
fi
{ # install
mkdir -p $out/lib/xorg
cp -r common/usr/include $out
cp -r common/usr/sbin $out
cp -r common/usr/share $out
cp -r common/usr/X11R6 $out
# cp -r arch/$arch/lib $out/lib
# what are those files used for?
cp -r common/etc $out
cp -r $DIR_DEPENDING_ON_XORG_VERSION/usr/X11R6/$lib_arch/* $out/lib/xorg
# install kernel module
if test -z "$libsOnly"; then
t=$out/lib/modules/${kernelVersion}/kernel/drivers/misc
mkdir -p $t
cp ./common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko $t
fi
# should this be installed at all?
# its used by the example fglrx_gamma only
# don't use $out/lib/modules/dri because this will cause the kernel module
# aggregator code to see both: kernel version and the dri direcotry. It'll
# fail saying different kernel versions
cp -r $TMP/arch/$arch/usr/X11R6/$lib_arch/modules/dri $out/lib
cp -r $TMP/arch/$arch/usr/X11R6/$lib_arch/modules/dri/* $out/lib
cp -r $TMP/arch/$arch/usr/X11R6/$lib_arch/*.so* $out/lib
cp -r $TMP/arch/$arch/usr/X11R6/$lib_arch/fglrx/fglrx-libGL.so.1.2 $out/lib/fglrx-libGL.so.1.2
cp -r $TMP/arch/$arch/usr/$lib_arch/* $out/lib
# cp -r $TMP/arch/$arch/usr/$lib_arch/* $out/lib
ln -s libatiuki.so.1.0 $out/lib/libatiuki.so.1
ln -s fglrx-libGL.so.1.2 $out/lib/libGL.so.1
ln -s fglrx-libGL.so.1.2 $out/lib/libGL.so
ln -s libfglrx_gamma.so.1.0 $out/lib/libfglrx_gamma.so.1
# make xorg use the ati version
ln -s $out/lib/xorg/modules/extensions/{fglrx/fglrx-libglx.so,libglx.so}
# Correct some paths that are hardcoded into binary libs.
if [ "$arch" == "x86_64" ]; then
for lib in \
lib/xorg/modules/extensions/fglrx/fglrx-libglx.so \
lib/xorg/modules/glesx.so \
lib/dri/fglrx_dri.so \
lib/fglrx_dri.so \
lib/fglrx-libGL.so.1.2
do
oldPaths="/usr/X11R6/lib/modules/dri"
newPaths="/run/opengl-driver/lib/dri"
sed -i -e "s|$oldPaths|$newPaths|" $out/$lib
done
else
oldPaths="/usr/X11R6/lib32/modules/dri\x00/usr/lib32/dri"
newPaths="/run/opengl-driver-32/lib/dri\x00/dev/null/dri"
sed -i -e "s|$oldPaths|$newPaths|" \
$out/lib/xorg/modules/extensions/fglrx/fglrx-libglx.so
for lib in \
lib/dri/fglrx_dri.so \
lib/fglrx_dri.so \
lib/xorg/modules/glesx.so
do
oldPaths="/usr/X11R6/lib32/modules/dri/"
newPaths="/run/opengl-driver-32/lib/dri"
sed -i -e "s|$oldPaths|$newPaths|" $out/$lib
done
oldPaths="/usr/X11R6/lib32/modules/dri\x00"
newPaths="/run/opengl-driver-32/lib/dri"
sed -i -e "s|$oldPaths|$newPaths|" $out/lib/fglrx-libGL.so.1.2
fi
# libstdc++ and gcc are needed by some libs
patchelf --set-rpath $gcc/$lib_arch $out/lib/libatiadlxx.so
patchelf --set-rpath $gcc/$lib_arch $out/lib/xorg/modules/glesx.so
}
if test -z "$libsOnly"; then
{ # build samples
mkdir -p $out/bin
mkdir -p samples
cd samples
tar xfz ../common/usr/src/ati/fglrx_sample_source.tgz
eval "$patchPhaseSamples"
( # build and install fgl_glxgears
cd fgl_glxgears;
gcc -DGL_ARB_texture_multisample=1 -g \
-I$mesa/include \
-I$out/include \
-L$mesa/lib -lGL -lGLU -lX11 -lm \
-o $out/bin/fgl_glxgears -Wall fgl_glxgears.c
)
true || ( # build and install
# doesn't build undefined reference to `FGLRX_X11SetGamma'
# wich should be contained in -lfglrx_gamma
cd programs/fglrx_gamma
gcc -fPIC -I${libXxf86vm}/include \
-I${xf86vidmodeproto}/include \
-I$out/X11R6/include \
-L$out/lib \
-Wall -lm -lfglrx_gamma -lX11 -lXext -o fglrx_xgamma fglrx_xgamma.c
)
{ # copy binaries and wrap them:
BIN=$TMP/arch/$arch/usr/X11R6/bin
cp $BIN/* $out/bin
for prog in $BIN/*; do
patchelf --set-interpreter $(echo $glibc/lib/ld-linux*.so.2) $out/bin/$(basename $prog)
wrapProgram $out/bin/$(basename $prog) --prefix LD_LIBRARY_PATH : $out/lib:$gcc/lib:$qt4/lib:$LD_LIBRARY_PATH
done
}
rm -fr $out/lib/modules/fglrx # don't think those .a files are needed. They cause failure of the mod
}
fi
for p in $extraDRIlibs; do
for lib in $p/lib/*.so*; do
ln -s $lib $out/lib/
done
done
|