summaryrefslogtreecommitdiff
path: root/setup.py
blob: b4730ab6f7059bb1cdb0adb63e67b1506d00a659 (plain)
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
# $Id$
# Creates build/lib.linux-${arch}-${pyvers}/gpspacket.so,
# where ${arch} is an architecture and ${pyvers} is a Python version.

from distutils.core import setup, Extension

import os
import sys

# For VPATH builds, this script must be run from $(srcdir) with the
# abs_builddir environment variable set to the location of the build
# directory.  This is necessary because Python's distutils package
# does not have built-in support for VPATH builds.

# These dependencies are enforced here and not in the Makefile to make
# it easier to build the Python parts without building everything else
# (the user can run 'python setup.py' without having to run 'make').
needed_files = ['gpsd.h', 'packet_names.h', 'gpscat.1', 'gpsfake.1', 'gpsprof.1']
created_files = []

if not 'clean' in sys.argv:
    abs_builddir = ("abs_builddir" in os.environ) and os.environ["abs_builddir"] or ""
    if not os.path.exists(os.path.join(abs_builddir, 'gpsd_config.h')):
        sys.stderr.write('\nPlease run configure first!\n')
        sys.exit(1)

    cdcmd = abs_builddir and ("cd '" + abs_builddir + "' && ") or ""
    MAKE = ("MAKE" in os.environ) and os.environ["MAKE"] or "make"
    for f_name in needed_files:
        # TODO:  Shouldn't make be run unconditionally in case a
        # dependency of f_name has been updated?
        if not os.path.exists(os.path.join(abs_builddir, f_name)):
            cmd = cdcmd + MAKE + " '" + f_name + "'"
            print cmd
            make_out = os.popen(cmd)
            print make_out.read()
            if make_out.close():
                sys.exit(1)
            created_files.append(f_name)

gpspacket_sources = ["gpspacket.c", "packet.c", "isgps.c",
            "driver_rtcm2.c", "strl.c", "hex.c", "crc24q.c"]

setup( name="gpsd",
       version="1.0",
       ext_modules=[
    	Extension("gpspacket", gpspacket_sources),
    	Extension("gpslib", ["gpslib.c", "geoid.c"])
        ],
       py_modules = ['gpsfake','gps', 'leapsecond'],
       data_files=[('bin', ['gpscat','gpsfake','gpsprof']),
           ('share/man/man1', ['gpscat.1', 'gpsfake.1','gpsprof.1'])]
     )