This repository has been archived by the owner on Apr 29, 2018. It is now read-only.
forked from mvpmc/mvpmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
176 lines (153 loc) · 4.33 KB
/
SConstruct
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
#!/usr/bin/python
#
# SCons build script for mvpmc
# http://www.mvpmc.org/
#
import os
import sys
pwd = os.getcwd()
os.environ['TOPLEVEL'] = pwd
sys.path.append('%s/scons' % pwd)
import mvpmc
env = Environment (ENV = os.environ)
target = ARGUMENTS.get('TARGET', Platform())
kernver = ARGUMENTS.get('KERNVER', Platform())
env.Replace(CCFLAGS = '-O3 -g -Wall -Werror')
env.Replace(TOPDIR = os.getcwd())
home = os.environ['HOME']
crosstool = '/opt/crosstool'
toolchains = '/opt/toolchains/'
if os.path.exists(toolchains) == 0:
toolchains = home + '/toolchains/'
#
# parse the TARGET= option
# mvp
# host
# kernel
#
if target == 'mvp':
powerpc = 'powerpc-405-linux-uclibc'
gcc = 'gcc-3.4.5-uClibc-0.9.28'
prefix = powerpc + '-'
crossroot = toolchains + '/' + powerpc + '/' + gcc + '/'
cross = crossroot + '/bin/' + prefix
cc = cross + 'gcc'
cppflags = ''
elif target == 'host':
cppflags = '-DMVPMC_HOST'
crossroot='';
env.Replace(CROSS = '')
elif target == 'kernel':
print "kernel build"
powerpc = 'powerpc-405-linux-uclibc'
gcc = 'gcc-3.4.5-uClibc-0.9.28'
crossroot = toolchains + '/' + powerpc + '/' + gcc + '/'
prefix = powerpc + '-'
cross = crossroot + '/bin/' + prefix
cc = cross + 'gcc'
cppflags = ''
else:
print "Unknown target %s"%target
sys.exit(1)
#
# Rebuilding the cross-compiler should be done in ~/toolchains
#
if (target != 'host') and (os.path.exists(cc) == 0):
toolchains = home + '/toolchains/'
crossroot = toolchains + '/' + powerpc + '/' + gcc + '/'
cross = crossroot + '/bin/' + prefix
cc = cross + 'gcc'
#
# build binaries in the obj/TARGET directory
#
env.Replace(INCDIR = pwd + '/include')
env.Replace(INSTDIR = pwd + '/dongle/install/' + target)
env.Replace(INSTINCDIR = pwd + '/dongle/install/' + target + '/include')
env.Replace(INSTLIBDIR = pwd + '/dongle/install/' + target + '/lib')
env.Replace(INSTBINDIR = pwd + '/dongle/install/' + target + '/bin')
env.Replace(INSTSHAREDIR = pwd + '/dongle/install/' + target + '/usr/share/mvpmc')
env.Replace(BUILD_DIR = 'obj/' + target)
env.Replace(TARG = target)
env.Replace(DOWNLOADS = home + '/downloads')
env.Replace(TOPLEVEL = pwd)
env.Replace(CPPFLAGS = cppflags)
if target != 'host':
env.Replace(CROSS = cross)
env.Replace(CC = cross + 'gcc')
env.Replace(CROSSPATH = crossroot + '/' + powerpc + '/bin')
Export('env','crossroot')
#
# ensure the download directory exits
#
downloads = env['DOWNLOADS']
if os.path.exists(downloads) == 0:
os.mkdir(downloads)
if target == 'kernel':
#
# do the kernel build
#
cc = env['CC']
kern = env.SConscript('dongle/kernel/linux-2.4.31/SConscript')
gccbuild = 'tools/toolchains/uclibc/SConscript'
if os.path.exists(cc) == 0:
print "build kernel cross-compiler"
gcc = env.SConscript(gccbuild)
env.Depends(kern, gcc)
else:
#
# do the application build
#
inc = env.SConscript('include/SConscript')
dir = env['BUILD_DIR']
#
# Only build the apps for the mvp.
#
if target == 'mvp':
apps = env.SConscript('dongle/apps/SConscript')
libs = env.SConscript('dongle/libs/SConscript')
mvplibs = env.SConscript('libs/SConscript')
mvpmc = env.SConscript('src/SConscript',
variant_dir='src/'+dir, duplicate=0)
themes = env.SConscript('themes/SConscript')
images = env.SConscript('images/SConscript')
env.Depends(mvpmc, libs)
env.Depends(mvplibs, libs)
#
# Install the cross compilation tools, if needed.
#
if target == 'mvp':
cc = env['CC']
if os.path.exists(cc) == 0:
print "build application cross-compiler"
gcc = env.SConscript('tools/toolchains/uclibc/SConscript')
env.Depends(libs, gcc)
env.Depends(apps, gcc)
env.Depends(mvplibs, gcc)
env.Depends(mvpmc, gcc)
#
# Build the dongle.bin file
#
if target == 'mvp':
dongle = env.SConscript('dongle/SConscript')
env.Depends(dongle, mvpmc)
env.Depends(dongle, mvplibs)
env.Depends(dongle, apps)
env.Depends(dongle, libs)
env.Depends(dongle, themes)
env.Depends(dongle, images)
#
# Build squashfs and mktree and mvprelay
#
if target == 'mvp':
cc = env['CC']
squashfs = env.SConscript('tools/squashfs/SConscript')
mktree = env.SConscript('tools/mktree/SConscript')
mvprelay = env.SConscript('tools/mvprelay/SConscript')
env.Depends(dongle, squashfs)
env.Depends(dongle, mktree)
#
# Misc tools
#
if target == 'mvp':
misc = env.SConscript('tools/misc/SConscript')
passwd = env.SConscript('tools/dongle_passwd/SConscript')