c36e92dd0d7a9f0d291829e973ba138b56c55430
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / sconscript
1 #
2 # (C) COPYRIGHT 2010-2016 ARM Limited. All rights reserved.
3 #
4 # This program is free software and is provided to you under the terms of the
5 # GNU General Public License version 2 as published by the Free Software
6 # Foundation, and any use by you of this program is subject to the terms
7 # of such GNU licence.
8 #
9 # A copy of the licence is included with the program, and can also be obtained
10 # from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
11 # Boston, MA  02110-1301, USA.
12 #
13 #
14
15
16
17 import os
18 import re
19 import sys
20 Import('env')
21
22
23 if Glob('tests/sconscript'):
24         SConscript( 'tests/sconscript' )
25
26 mock_test = 0
27
28 # Fake platform is a transient solution for GPL drivers running in kernel that does not provide configuration via platform data.
29 # For such kernels fake_platform_device should be set to 1. For kernels providing platform data fake_platform_device should be set to 0.
30 if env['platform_config']=='devicetree':
31         fake_platform_device = 0
32 else:
33         fake_platform_device = 1
34
35 # Source files required for kbase.
36 kbase_src = [Glob('#kernel/drivers/gpu/arm/midgard/*.c'),
37              Glob('#kernel/drivers/gpu/arm/midgard/*.c'),
38              Glob('#kernel/drivers/gpu/arm/midgard/backend/*/*.c'),
39              Glob('#kernel/drivers/gpu/arm/midgard/backend/*/*.h'),
40              Glob('#kernel/drivers/gpu/arm/midgard/platform/%s/*.c' % (env['platform_config'])),
41              Glob('#kernel/drivers/gpu/arm/midgard/*.h'),
42              Glob('#kernel/drivers/gpu/arm/midgard/*.h'),
43              Glob('#kernel/drivers/gpu/arm/midgard/Makefile',
44              Glob('#kernel/drivers/gpu/arm/midgard/K*'))
45              ]
46
47 kbase_src += [Glob('#kernel/drivers/gpu/arm/midgard/internal/*/*.c')]
48
49 if Glob('#kernel/drivers/gpu/arm/midgard/tests/internal/src/mock') and env['unit'] == '1':
50         kbase_src += [Glob('#kernel/drivers/gpu/arm/midgard/tests/internal/src/mock/*.c')]
51         mock_test = 1
52
53 # we need platform config for GPL version using fake platform
54 if fake_platform_device==1:
55         # Check if we are compiling for PBX
56         linux_config_file = os.path.normpath(os.environ['KDIR']) + '/.config'
57         search_term = '^[\ ]*CONFIG_MACH_REALVIEW_PBX[\ ]*=[\ ]*y'
58         REALVIEW_PBX = 0
59         for line in open(linux_config_file, 'r'):
60                 if re.search(search_term, line):
61                         REALVIEW_PBX = 1
62                         break
63         if REALVIEW_PBX == 1 and (env['platform_config'] == 'vexpress' or env['platform_config'] == 'vexpress_6xvirtex7_10mhz'):
64                 sys.stderr.write("WARNING: Building for a PBX kernel but with platform_config=vexpress*\n")
65         # if the file platform config file is in the tpip directory then use that, otherwise use the default config directory
66         if Glob('#kernel/drivers/gpu/arm/midgard/config/tpip/*%s.c' % (env['platform_config'])):
67                 kbase_src += Glob('#kernel/drivers/gpu/arm/midgard/config/tpip/*%s.c' % (env['platform_config']))
68         else:
69                 kbase_src += Glob('#kernel/drivers/gpu/arm/midgard/config/*%s.c' % (env['platform_config']))
70         
71 # Note: cleaning via the Linux kernel build system does not yet work
72 if env.GetOption('clean') :
73         env.Execute(Action("make clean", '[clean] kbase'))
74         cmd = env.Command(['$STATIC_LIB_PATH/mali_kbase.ko', '$STATIC_LIB_PATH/mali_platform_fake.ko'], kbase_src, [])
75 else:
76         if env['os'] == 'android':
77                 env['android'] = 1
78         else:
79                 env['android'] = 0
80
81         if env['unit'] == '1':
82                 env['kernel_test'] = 1
83         else:
84                 env['kernel_test'] = 0
85
86         #Extract environment options, note the trailing spaces are important
87         env_options = \
88         "PLATFORM=${platform} " +\
89         "MALI_ERROR_INJECT_ON=${error_inject} " +\
90         "MALI_ANDROID=${android} " +\
91         "MALI_KERNEL_TEST_API=${kernel_test} " +\
92         "MALI_UNIT_TEST=${unit} " +\
93         "MALI_RELEASE_NAME=\"${mali_release_name}\" "+\
94         "MALI_MOCK_TEST=%s " % mock_test +\
95         "MALI_CUSTOMER_RELEASE=${release} " +\
96         "MALI_INSTRUMENTATION_LEVEL=${instr} " +\
97         "MALI_COVERAGE=${coverage} " +\
98         "MALI_BUS_LOG=${buslog} "
99
100         make_action_start = "cd ${SOURCE.dir} && make -j%d " % GetOption('num_jobs')
101         make_action_end = "%s && cp mali_kbase.ko $STATIC_LIB_PATH/mali_kbase.ko" % env.kernel_get_config_defines(fake_platform_device)
102         make_action = make_action_start + env_options + make_action_end
103
104         makeAction=Action(make_action, '$MAKECOMSTR')
105         cmd = env.Command('$STATIC_LIB_PATH/mali_kbase.ko', kbase_src, [makeAction])
106
107 # Add a dependency on kds.ko.
108 # Only necessary when KDS is not built into the kernel.
109 #
110 if env['os'] != 'android':
111         linux_config_file = os.path.normpath(os.environ['KDIR']) + '/.config'
112         search_term = '^[\ ]*CONFIG_KDS[\ ]*=[\ ]*y'
113         kds_in_kernel = 0
114         for line in open(linux_config_file, 'r'):
115                 if re.search(search_term, line):
116                 # KDS in kernel.
117                         kds_in_kernel = 1
118         if not kds_in_kernel:
119                 env.Depends('$STATIC_LIB_PATH/mali_kbase.ko', '$STATIC_LIB_PATH/kds.ko')
120
121 # need Module.symvers from ump.ko build
122 if int(env['ump']) == 1:
123         env.Depends('$STATIC_LIB_PATH/mali_kbase.ko', '$STATIC_LIB_PATH/ump.ko')
124
125 env.KernelObjTarget('kbase', cmd)
126
127 env.AppendUnique(BASE=['cutils_linked_list'])