1 # This file is Copyright (c) 2010 by the GPSD project
2 # BSD terms apply: see the file COPYING in the distribution root for details.
4 # Creates build/lib.linux-${arch}-${pyvers}/gpspacket.so,
5 # where ${arch} is an architecture and ${pyvers} is a Python version.
7 from distutils.core import setup, Extension
12 # For VPATH builds, this script must be run from $(srcdir) with the
13 # abs_builddir environment variable set to the location of the build
14 # directory. This is necessary because Python's distutils package
15 # does not have built-in support for VPATH builds.
17 # These dependencies are enforced here and not in the Makefile to make
18 # it easier to build the Python parts without building everything else
19 # (the user can run 'python setup.py' without having to run 'make').
20 needed_files = ['gpsd.h', 'packet_names.h']
25 where = sys.argv.index('--mangenerator')
26 # Doesn't matter what it is, just that we have one
28 manpages=[('share/man/man1', ['gpscat.1', 'gpsfake.1','gpsprof.1',
29 'xgps.1', 'xgpsspeed.1'])]
30 print("Installing manual pages, generator is %s" %( sys.argv[where+1]))
31 sys.argv = sys.argv[:where] + sys.argv[where+2:]
35 print("No XML processor, omitting manual-page installation.")
37 MAKE = ("MAKE" in os.environ) and os.environ["MAKE"] or "make"
38 if not 'clean' in sys.argv:
39 abs_builddir = ("abs_builddir" in os.environ) and os.environ["abs_builddir"] or ""
40 if not os.path.exists(os.path.join(abs_builddir, 'gpsd_config.h')):
41 sys.stderr.write('\nPlease run configure first!\n')
44 cdcmd = abs_builddir and ("cd '" + abs_builddir + "' && ") or ""
45 for f_name in needed_files:
46 # TODO: Shouldn't make be run unconditionally in case a
47 # dependency of f_name has been updated?
48 if not os.path.exists(os.path.join(abs_builddir, f_name)):
49 cmd = cdcmd + MAKE + " '" + f_name + "'"
51 make_out = os.popen(cmd)
52 print(make_out.read())
55 created_files.append(f_name)
57 gpspacket_sources = ["gpspacket.c", "packet.c", "isgps.c",
58 "driver_rtcm2.c", "strl.c", "hex.c", "crc24q.c"]
59 include_dirs = [ os.path.realpath(os.path.dirname(__file__)) ]
60 version_out = os.popen(MAKE + " -s version")
61 version = version_out.read()
63 if version_out.close():
65 version = version.split('\n')[-2]
66 version = version.strip()
70 description='Python libraries for the gpsd service daemon',
71 url="http://gpsd.berlios.de/",
72 author='the GPSD project',
73 author_email="gpsd-dev@lists.berlios.de",
76 Extension("gps.packet", gpspacket_sources, include_dirs=include_dirs),
77 Extension("gps.clienthelpers", ["gpsclient.c", "geoid.c", "gpsdclient.c", "strl.c"], include_dirs=include_dirs)
80 scripts = ['gpscat','gpsfake','gpsprof', 'xgps', 'xgpsspeed'],