root/ossiedev/branches/sriramk/build.py @ 8852

Revision 8852, 5.7 KB (checked in by mcarrick, 4 years ago)

copying 0.7.x for sriram

  • Property svn:executable set to *
Line 
1#!/usr/bin/python
2'''Usage: %s [OPTIONS]
3OSSIE build script
4'''
5
6## Copyright 2007 Virginia Polytechnic Institute and State University
7##
8## This file is part of the OSSIE Installer.
9##
10## OSSIE Installer is free software; you can redistribute it and/or modify
11## it under the terms of the GNU General Public License as published by
12## the Free Software Foundation; either version 2 of the License, or
13## (at your option) any later version.
14##
15## OSSIE Installer is distributed in the hope that it will be useful,
16## but WITHOUT ANY WARRANTY; without even the implied warranty of
17## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18## GNU General Public License for more details.
19##
20## You should have received a copy of the GNU General Public License
21## along with OSSIE Installer; if not, write to the Free Software
22## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
24import os
25import sys
26
27# Global variables
28ossieversion = "0.7.2"
29
30def usageString():
31    '''Construct program usage string'''
32    return __doc__ % sys.argv[0]
33
34def Usage( problem = None):
35    '''print usage'''
36    if problem is None:
37        print usageString()
38        sys.exit(0)
39    else:
40        sys.stderr.write( usageString() )
41        Abort(problem)
42
43def Abort(problem):
44    '''Print error message and exit'''
45    sys.stderr.write('\n')
46    sys.stderr.write(problem)
47    sys.stderr.write('\n\n')
48    sys.exit(2)
49
50def BuildDirectory(installasroot=False):
51    '''Try to rebuild directory'''
52    if not os.access('.doNotBuild', os.F_OK):
53
54        if (os.system('./reconf') != 0):
55            print 'FAILED: reconf'
56            return False
57        if (os.system('./configure') != 0):
58            print 'FAILED: configure'
59            return False
60        if (os.system('make -j2') != 0):
61            print 'FAILED: make -j2'
62            return False
63        if installasroot:
64            if (os.system('sudo make install') != 0):
65                print 'FAILED: sudo make install'
66                return False
67        else:
68            if (os.system('make install') != 0):
69                problemstr  = 'FAILED: make install\n'
70                problemstr += '  Try changing permissions on install directory, e.g.\n'
71                problemstr += '  # chown -R myusername.myusername /sdr'
72                Abort(problemstr)
73        print "\nPackage installed\n"
74        return True
75    else:
76        print "Ignoring directory\n"
77        return True
78
79
80
81if __name__ == '__main__':
82    if len(sys.argv) != 1:
83        Usage()
84
85    # check for existence, ownership of /sdr
86    if not os.path.exists(os.path.sep + 'sdr'):
87        # /sdr does not exist
88        problemstr  = "  ERROR: directory " + os.path.sep + "sdr does not exist\n"
89        problemstr += "  Create with root permissions, and change ownership:\n"
90        problemstr += "    # mkdir /sdr\n"
91        problemstr += "    # chown -R myusername.myusername /sdr"
92        Abort(problemstr)
93    elif os.stat(os.path.sep + 'sdr')[5] == 0:
94        # /sdr exists but owned by root
95        problemstr  = "  ERROR: directory " + os.path.sep + "sdr is owned by root\n"
96        problemstr += "  Change ownership:\n"
97        problemstr += "    # chown -R myusername.myusername /sdr"
98        Abort(problemstr)
99
100    cwd = os.getcwd()
101   
102    # build system
103    system_dirs = ['ossie', 'standardInterfaces', 'customInterfaces', 'nodebooter', 'wavLoader', 'SigProc',]
104    for dir in system_dirs:
105        path = 'system' + os.path.sep + dir
106        os.chdir(cwd + os.path.sep + path)
107        print "building " + path + "..."
108
109        if not BuildDirectory( True ):
110            Abort("ERROR: building " + path + " failed")
111
112    # build platform
113    platform_dirs = ['GPP', 'domain', 'dtd', 'Sound_in', 'Sound_out', 'USRP', 'nodes/default_GPP_node', 'nodes/default_GPP_sound_node', 'nodes/default_GPP_USRP_node', 'nodes/default_GPP_USRP_sound_node', ]
114    for dir in platform_dirs:
115        path = 'platform' + os.path.sep + dir
116        os.chdir(cwd + os.path.sep + path)
117        print "building " + path + "..."
118
119        if not BuildDirectory( False ):
120            Abort("ERROR: building " + path + " failed")
121
122    # build components
123    components_dirs = ['TxDemo', 'ChannelDemo', 'RxDemo', 'am_demod', 'amplifier', 'AutomaticGainControl', 'Decimator', 'JPEG_VideoViewer', 'USRP_Commander', 'WebCamCapture', 'WFMDemod',]
124    for dir in components_dirs:
125        path = 'components' + os.path.sep + dir
126        os.chdir(cwd + os.path.sep + path)
127        print "building " + path + "..."
128
129        if not BuildDirectory( False ):
130            Abort("ERROR: building " + path + " failed")
131
132    # build waveforms
133    waveforms_dirs = ['ossie_demo', ]
134    for dir in waveforms_dirs:
135        path = 'waveforms' + os.path.sep + dir
136        os.chdir(cwd + os.path.sep + path)
137        print "building " + path + "..."
138
139        if not BuildDirectory( False ):
140            Abort("ERROR: building " + path + " failed")
141
142    # build pass_data component and waveform
143    os.chdir(cwd + os.path.sep + 'components/pass_data')
144    if (os.system('python setup.py install') != 0):
145        Abort("ERROR: building pass_data component failed")
146    print "building pass_data ..."
147
148    os.chdir(cwd + os.path.sep + 'waveforms/pass_data_waveform')
149    if (os.system('python setup.py install') != 0):
150        Abort("ERROR: building pass_data_waveform failed")
151    print "building pass_data_waveform ..."
152
153    # successful install message
154    print "\n" + "*"*60 + "\n"
155    print "    Complete installation of OSSIE " + ossieversion + " finished!"
156    print "\n" + "*"*60 + "\n"
157
158    print "    NOTE: If this is your first time installing OSSIE you will"
159    print "    need to link the libraries.  Edit /etc/ld.so.conf and add"
160    print "      /usr/local/lib"
161    print "    As root run /sbin/ldconfig\n"
162    os.system('date')
163    sys.exit(0)
164
165
166
167
Note: See TracBrowser for help on using the browser.