updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / catalyst-firepro / ati_make.sh
blobcf69da66abe891bf0158ca273c25ac1e154f8ea0
1 #!/bin/bash
2 ### Vi0L0: it is ati's code from their make.sh file, modified a bit to fit our arch linux system, used inside catalyst_build_module script
4 # Copyright 1999-2005 ATI Technologies Inc., Markham, Ontario, CANADA.
5 # All Rights Reserved.
6 #
7 # Your use and or redistribution of this software in source and \ or
8 # binary form, with or without modification, is subject to: (i) your
9 # ongoing acceptance of and compliance with the terms and conditions of
10 # the ATI Technologies Inc. software End User License Agreement; and (ii)
11 # your inclusion of this notice in any version of this software that you
12 # use or redistribute. A copy of the ATI Technologies Inc. software End
13 # User License Agreement is included with this software and is also
14 # available by contacting ATI Technologies Inc. at http://www.ati.com
17 function _ati_check()
19 # ==============================================================
20 # resolve if we are running a SMP enabled kernel
22 SMP=0
24 # 1
25 # grep in OsVersion string for SMP specific keywords
26 OsVersion=`uname -v`
28 if [ `echo $OsVersion | grep [sS][mM][pP] -c` -ne 0 ]; then
29 SMP=1
30 echo "OsVersion says: SMP=$SMP"
33 # 2
34 # grep in /proc/ksyms for SMP specific kernel symbols
35 # use triggerlevel of 10 occurences
36 # (UP kernels might have 0-1, SMP kernels might have 32-45 or much more)
38 src_file=/proc/kallsyms
40 if [ -e $src_file ]; then
41 if [ `fgrep smp $src_file -c` -gt 10 ]; then
42 SMP=1
43 echo "file $src_file says: SMP=$SMP"
47 # 3
48 # linux/autoconf.h may contain this: #define CONFIG_SMP 1
50 # Before 2.6.33 autoconf.h is under linux/.
51 # For 2.6.33 and later autoconf.h is under generated/.
52 if [ -f /lib/modules/${kernver}/build/include/generated/autoconf.h ]; then
53 autoconf_h=/lib/modules/${kernver}/build/include/generated/autoconf.h
54 else
55 autoconf_h=/lib/modules/${kernver}/build/include/linux/autoconf.h
57 src_file=$autoconf_h
59 if [ ! -e $src_file ]; then
60 echo "Warning:"
61 echo "kernel includes at /lib/modules/${kernver}/build/include not found or incomplete"
62 echo "file: $src_file"
63 echo ""
64 else
65 if [ `cat $src_file | grep "#undef" | grep "CONFIG_SMP" -c` = 0 ]; then
66 SMP=`cat $src_file | grep CONFIG_SMP | cut -d' ' -f3`
67 echo "file $src_file says: SMP=$SMP"
71 if [ "$SMP" = 0 ]; then
72 echo "assuming default: SMP=$SMP"
75 # act on final result
76 if [ ! "$SMP" = 0 ]; then
77 smp="-SMP"
78 def_smp=-D__SMP__
80 # ==============================================================
81 # resolve whether we need to set PAGE_ATTR_FIX
82 PAGE_ATTR_FIX=0
84 src_file=/proc/kallsyms
86 if [ -e $src_file ]; then
87 if [ `fgrep " change_page_attr\$" $src_file -c` -gt 0 ]; then
88 PAGE_ATTR_FIX=1
89 echo "file $src_file says: PAGE_ATTR_FIX=$PAGE_ATTR_FIX"
92 # ==============================================================
93 # resolve if we are running a MODVERSIONS enabled kernel
95 MODVERSIONS=0
97 # autoconf.h may contain this: #define CONFIG_MODVERSIONS 1
98 src_file=$autoconf_h
99 if [ ! -e $src_file ];
100 then
101 echo "Warning:"
102 echo "kernel includes at /lib/modules/${kernver}/build/include not found or incomplete"
103 echo "file: $src_file"
104 echo ""
105 else
106 if [ `cat $src_file | grep "#undef" | grep "CONFIG_MODVERSIONS" -c` = 0 ]
107 then
108 MODVERSIONS=`cat $src_file | grep CONFIG_MODVERSIONS | cut -d' ' -f3`
109 echo "file $src_file says: MODVERSIONS=$MODVERSIONS"
113 if [ "$MODVERSIONS" = 0 ]
114 then
115 echo "assuming default: MODVERSIONS=$MODVERSIONS"
118 # act on final result
119 if [ ! "$MODVERSIONS" = 0 ]
120 then
121 def_modversions="-DMODVERSIONS"
124 # ==============================================================
125 # resolve if we are building for a kernel with a fix for CVE-2010-3081
126 # On kernels with the fix, use arch_compat_alloc_user_space instead
127 # of compat_alloc_user_space since the latter is GPL-only
129 COMPAT_ALLOC_USER_SPACE=compat_alloc_user_space
131 src_file=/lib/modules/${kernver}/build/arch/x86/include/asm/compat.h
132 if [ ! -e $src_file ];
133 then
134 echo "Warning:"
135 echo "kernel includes at /lib/modules/${kernver}/build/include not found or incomplete"
136 echo "file: $src_file"
137 echo ""
138 else
139 if [ `cat $src_file | grep -c arch_compat_alloc_user_space` -gt 0 ]
140 then
141 COMPAT_ALLOC_USER_SPACE=arch_compat_alloc_user_space
143 echo "file $src_file says: COMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE"