diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-11-19 13:04:57 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-19 13:04:57 -0500 |
commit | 6225e45cbd1346ddf314ff47895d1a8796a1f74b (patch) | |
tree | 982f4ba4ac3aaf50b2a9dc098251de066fc8fbfa /SConstruct | |
parent | 05a650e7f1ad07bd7ae6f89dcc221e5bc2421b56 (diff) | |
download | gpsd-6225e45cbd1346ddf314ff47895d1a8796a1f74b.tar.gz |
Skip configuration when cleaning,
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 461 |
1 files changed, 237 insertions, 224 deletions
@@ -455,219 +455,232 @@ def CheckCompilerDefines(context, define): context.Result(ret) return ret -config = Configure(env, custom_tests = { 'CheckPKG' : CheckPKG, - 'CheckExecutable' : CheckExecutable, - 'CheckXsltproc' : CheckXsltproc, - 'CheckCompilerOption' : CheckCompilerOption, - 'CheckCompilerDefines' : CheckCompilerDefines, - 'CheckHeaderDefines' : CheckHeaderDefines}) - - -# If supported by the compiler, enable all warnings except uninitialized and -# missing-field-initializers, which we can't help triggering because -# of the way some of the JSON-parsing code is generated. -# Also not including -Wcast-qual and -Wimplicit-function-declaration, -# because we can't seem to keep scons from passing it to g++. -for option in ('-Wextra','-Wall', '-Wno-uninitialized','-Wno-missing-field-initializers', - '-Wcast-align','-Wmissing-declarations', '-Wmissing-prototypes', - '-Wstrict-prototypes', '-Wpointer-arith', '-Wreturn-type'): - config.CheckCompilerOption(option) - - -env.Prepend(LIBPATH=[os.path.realpath(os.curdir)]) -if env["shared"]: - if env["chrpath"] and config.CheckExecutable('chrpath -v', 'chrpath'): - # Tell generated binaries to look in the current directory for - # shared libraries so we can run regression tests without - # hassle. Should be handled sanely by scons on all systems. Not - # good to use '.' or a relative path here; it's a security risk. - # At install time we use chrpath to edit this out of RPATH. - env.Prepend(RPATH=[os.path.realpath(os.curdir)]) - else: - print "chrpath is not available or use of it has been disabled." +if env.GetOption("clean"): + cxx = qt_network = None + dbus_libs = [] + rtlibs = [] + usblibs = [] + bluezlibs = [] + caplibs = [] + ncurseslibs = [] + confdefs = [] + manbuilder = False + regress_driver_options = '' + htmlbuilder = False +else: + config = Configure(env, custom_tests = { 'CheckPKG' : CheckPKG, + 'CheckExecutable' : CheckExecutable, + 'CheckXsltproc' : CheckXsltproc, + 'CheckCompilerOption' : CheckCompilerOption, + 'CheckCompilerDefines' : CheckCompilerDefines, + 'CheckHeaderDefines' : CheckHeaderDefines}) + + + # If supported by the compiler, enable all warnings except uninitialized and + # missing-field-initializers, which we can't help triggering because + # of the way some of the JSON-parsing code is generated. + # Also not including -Wcast-qual and -Wimplicit-function-declaration, + # because we can't seem to keep scons from passing it to g++. + for option in ('-Wextra','-Wall', '-Wno-uninitialized','-Wno-missing-field-initializers', + '-Wcast-align','-Wmissing-declarations', '-Wmissing-prototypes', + '-Wstrict-prototypes', '-Wpointer-arith', '-Wreturn-type'): + config.CheckCompilerOption(option) + + + env.Prepend(LIBPATH=[os.path.realpath(os.curdir)]) + if env["shared"]: + if env["chrpath"] and config.CheckExecutable('chrpath -v', 'chrpath'): + # Tell generated binaries to look in the current directory for + # shared libraries so we can run regression tests without + # hassle. Should be handled sanely by scons on all systems. Not + # good to use '.' or a relative path here; it's a security risk. + # At install time we use chrpath to edit this out of RPATH. + env.Prepend(RPATH=[os.path.realpath(os.curdir)]) + else: + print "chrpath is not available or use of it has been disabled." -confdefs = ["/* gpsd_config.h. Generated by scons, do not hand-hack. */\n"] + confdefs = ["/* gpsd_config.h. Generated by scons, do not hand-hack. */\n"] -confdefs.append('#define VERSION "%s"\n' % gpsd_version) + confdefs.append('#define VERSION "%s"\n' % gpsd_version) -confdefs.append('#define GPSD_URL "%s"\n' % website) + confdefs.append('#define GPSD_URL "%s"\n' % website) -cxx = config.CheckCXX() + cxx = config.CheckCXX() -# define a helper function for pkg-config - we need to pass -# --static for static linking, too. -if env["shared"]: - pkg_config = lambda pkg: ['!%s --cflags --libs %s' %(env['PKG_CONFIG'], pkg, )] -else: - pkg_config = lambda pkg: ['!%s --cflags --libs --static %s' %(env['PKG_CONFIG'], pkg, )] - -# The actual distinction here is whether the platform has ncurses in the -# base system or not. If it does, pkg-config is not likely to tell us -# anything useful. FreeBSD does, Linux doesn't. Most likely other BSDs -# are like FreeBSD. -ncurseslibs= [] -if env['ncurses']: - if config.CheckPKG('ncurses'): - ncurseslibs = pkg_config('ncurses') - elif config.CheckExecutable('ncurses5-config --version', 'ncurses5-config'): - ncurseslibs = ['!ncurses5-config --libs --cflags'] - elif config.CheckExecutable('ncursesw5-config --version', 'ncursesw5-config'): - ncurseslibs = ['!ncursesw5-config --libs --cflags'] - elif sys.platform.startswith('freebsd'): - ncurseslibs= [ '-lncurses' ] - elif sys.platform.startswith('openbsd'): - ncurseslibs= [ '-lcurses' ] - elif sys.platform.startswith('darwin'): - ncurseslibs= [ '-lcurses' ] - -if env['usb']: - # In FreeBSD except version 7, USB libraries are in the base system - if config.CheckPKG('libusb-1.0'): - confdefs.append("#define HAVE_LIBUSB 1\n") - try: - usblibs = pkg_config('libusb-1.0') - except OSError: - announce("pkg_config is confused about the state of libusb-1.0.") + # define a helper function for pkg-config - we need to pass + # --static for static linking, too. + if env["shared"]: + pkg_config = lambda pkg: ['!%s --cflags --libs %s' %(env['PKG_CONFIG'], pkg, )] + else: + pkg_config = lambda pkg: ['!%s --cflags --libs --static %s' %(env['PKG_CONFIG'], pkg, )] + + # The actual distinction here is whether the platform has ncurses in the + # base system or not. If it does, pkg-config is not likely to tell us + # anything useful. FreeBSD does, Linux doesn't. Most likely other BSDs + # are like FreeBSD. + ncurseslibs= [] + if env['ncurses']: + if config.CheckPKG('ncurses'): + ncurseslibs = pkg_config('ncurses') + elif config.CheckExecutable('ncurses5-config --version', 'ncurses5-config'): + ncurseslibs = ['!ncurses5-config --libs --cflags'] + elif config.CheckExecutable('ncursesw5-config --version', 'ncursesw5-config'): + ncurseslibs = ['!ncursesw5-config --libs --cflags'] + elif sys.platform.startswith('freebsd'): + ncurseslibs= [ '-lncurses' ] + elif sys.platform.startswith('openbsd'): + ncurseslibs= [ '-lcurses' ] + elif sys.platform.startswith('darwin'): + ncurseslibs= [ '-lcurses' ] + + if env['usb']: + # In FreeBSD except version 7, USB libraries are in the base system + if config.CheckPKG('libusb-1.0'): + confdefs.append("#define HAVE_LIBUSB 1\n") + try: + usblibs = pkg_config('libusb-1.0') + except OSError: + announce("pkg_config is confused about the state of libusb-1.0.") + usblibs = [] + elif sys.platform.startswith("freebsd"): + confdefs.append("#define HAVE_LIBUSB 1\n") + usblibs = [ "-lusb"] + else: + confdefs.append("/* #undef HAVE_LIBUSB */\n") usblibs = [] - elif sys.platform.startswith("freebsd"): - confdefs.append("#define HAVE_LIBUSB 1\n") - usblibs = [ "-lusb"] else: confdefs.append("/* #undef HAVE_LIBUSB */\n") usblibs = [] -else: - confdefs.append("/* #undef HAVE_LIBUSB */\n") - usblibs = [] - env["usb"] = False + env["usb"] = False -if config.CheckLib('librt'): - confdefs.append("#define HAVE_LIBRT 1\n") - # System library - no special flags - rtlibs = ["-lrt"] -else: - confdefs.append("/* #undef HAVE_LIBRT */\n") - rtlibs = [] - -if config.CheckLib('libcap'): - confdefs.append("#define HAVE_LIBCAP 1\n") - # System library - no special flags - caplibs = ["-lcap"] -else: - confdefs.append("/* #undef HAVE_LIBCAP */\n") - caplibs = [] + if config.CheckLib('librt'): + confdefs.append("#define HAVE_LIBRT 1\n") + # System library - no special flags + rtlibs = ["-lrt"] + else: + confdefs.append("/* #undef HAVE_LIBRT */\n") + rtlibs = [] -if env['dbus_export'] and config.CheckPKG('dbus-1'): - confdefs.append("#define HAVE_DBUS 1\n") - dbus_libs = pkg_config('dbus-1') -else: - confdefs.append("/* #undef HAVE_DBUS */\n") - dbus_libs = [] - env["dbus_export"] = False + if config.CheckLib('libcap'): + confdefs.append("#define HAVE_LIBCAP 1\n") + # System library - no special flags + caplibs = ["-lcap"] + else: + confdefs.append("/* #undef HAVE_LIBCAP */\n") + caplibs = [] -if env['bluez'] and config.CheckPKG('bluez'): - confdefs.append("#define HAVE_BLUEZ 1\n") - bluezlibs = pkg_config('bluez') -else: - confdefs.append("/* #undef HAVE_BLUEZ */\n") - bluezlibs = [] - env["bluez"] = False + if env['dbus_export'] and config.CheckPKG('dbus-1'): + confdefs.append("#define HAVE_DBUS 1\n") + dbus_libs = pkg_config('dbus-1') + else: + confdefs.append("/* #undef HAVE_DBUS */\n") + dbus_libs = [] + env["dbus_export"] = False -# ntpshm is required for pps support -if env['pps'] and env['ntpshm'] and config.CheckHeader("sys/timepps.h"): - confdefs.append("#define HAVE_SYS_TIMEPPS_H 1\n") - announce("You have kernel PPS available.") -else: - confdefs.append("/* #undef HAVE_SYS_TIMEPPS_H */\n") - announce("You do not have kernel PPS available.") - # Don't turn off PPS here, we might be using the non-kernel version + if env['bluez'] and config.CheckPKG('bluez'): + confdefs.append("#define HAVE_BLUEZ 1\n") + bluezlibs = pkg_config('bluez') + else: + confdefs.append("/* #undef HAVE_BLUEZ */\n") + bluezlibs = [] + env["bluez"] = False + + # ntpshm is required for pps support + if env['pps'] and env['ntpshm'] and config.CheckHeader("sys/timepps.h"): + confdefs.append("#define HAVE_SYS_TIMEPPS_H 1\n") + announce("You have kernel PPS available.") + else: + confdefs.append("/* #undef HAVE_SYS_TIMEPPS_H */\n") + announce("You do not have kernel PPS available.") + # Don't turn off PPS here, we might be using the non-kernel version -if config.CheckHeader(["bits/sockaddr.h", "linux/can.h"]): - confdefs.append("#define HAVE_LINUX_CAN_H 1\n") - announce("You have kernel CANbus available.") -else: - confdefs.append("/* #undef HAVE_LINUX_CAN_H */\n") - announce("You do not have kernel CANbus available.") - env["nmea2000"] = False - -# endian.h is required for rtcm104v2 unless the compiler defines -# __ORDER_BIG_ENDIAN__, __ORDER_LITTLE_ENDIAN__ and __BYTE_ORDER__ -if config.CheckCompilerDefines("__ORDER_BIG_ENDIAN__") \ -and config.CheckCompilerDefines("__ORDER_LITTLE_ENDIAN__") \ -and config.CheckCompilerDefines("__BYTE_ORDER__"): - confdefs.append("#define HAVE_BUILTIN_ENDIANNESS 1\n") - confdefs.append("/* #undef HAVE_ENDIAN_H */\n") - confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n") - announce("Your compiler has built-in endianness support.") -else: - confdefs.append("/* #undef HAVE_BUILTIN_ENDIANNESS\n */") - if config.CheckHeader("endian.h"): - confdefs.append("#define HAVE_ENDIAN_H 1\n") - confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n") - confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n") - elif config.CheckHeader("sys/endian.h"): - confdefs.append("/* #undef HAVE_ENDIAN_H */\n") - confdefs.append("#define HAVE_SYS_ENDIAN_H 1\n") - confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n") - elif config.CheckHeader("machine/endian.h"): - confdefs.append("/* #undef HAVE_ENDIAN_H */\n") - confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n") - confdefs.append("#define HAVE_MACHINE_ENDIAN_H 1\n") + if config.CheckHeader(["bits/sockaddr.h", "linux/can.h"]): + confdefs.append("#define HAVE_LINUX_CAN_H 1\n") + announce("You have kernel CANbus available.") else: + confdefs.append("/* #undef HAVE_LINUX_CAN_H */\n") + announce("You do not have kernel CANbus available.") + env["nmea2000"] = False + + # endian.h is required for rtcm104v2 unless the compiler defines + # __ORDER_BIG_ENDIAN__, __ORDER_LITTLE_ENDIAN__ and __BYTE_ORDER__ + if config.CheckCompilerDefines("__ORDER_BIG_ENDIAN__") \ + and config.CheckCompilerDefines("__ORDER_LITTLE_ENDIAN__") \ + and config.CheckCompilerDefines("__BYTE_ORDER__"): + confdefs.append("#define HAVE_BUILTIN_ENDIANNESS 1\n") confdefs.append("/* #undef HAVE_ENDIAN_H */\n") confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n") - confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n") - announce("You do not have the endian.h header file. RTCM V2 support disabled.") - env["rtcm104v2"] = False - -# check function after libraries, because some function require library -# for example clock_gettime() require librt on Linux -for f in ("daemon", "strlcpy", "strlcat", "clock_gettime"): - if config.CheckFunc(f): - confdefs.append("#define HAVE_%s 1\n" % f.upper()) + announce("Your compiler has built-in endianness support.") else: - confdefs.append("/* #undef HAVE_%s */\n" % f.upper()) + confdefs.append("/* #undef HAVE_BUILTIN_ENDIANNESS\n */") + if config.CheckHeader("endian.h"): + confdefs.append("#define HAVE_ENDIAN_H 1\n") + confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n") + confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n") + elif config.CheckHeader("sys/endian.h"): + confdefs.append("/* #undef HAVE_ENDIAN_H */\n") + confdefs.append("#define HAVE_SYS_ENDIAN_H 1\n") + confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n") + elif config.CheckHeader("machine/endian.h"): + confdefs.append("/* #undef HAVE_ENDIAN_H */\n") + confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n") + confdefs.append("#define HAVE_MACHINE_ENDIAN_H 1\n") + else: + confdefs.append("/* #undef HAVE_ENDIAN_H */\n") + confdefs.append("/* #undef HAVE_SYS_ENDIAN_H */\n") + confdefs.append("/* #undef HAVE_MACHINE_ENDIAN_H */\n") + announce("You do not have the endian.h header file. RTCM V2 support disabled.") + env["rtcm104v2"] = False + + # check function after libraries, because some function require library + # for example clock_gettime() require librt on Linux + for f in ("daemon", "strlcpy", "strlcat", "clock_gettime"): + if config.CheckFunc(f): + confdefs.append("#define HAVE_%s 1\n" % f.upper()) + else: + confdefs.append("/* #undef HAVE_%s */\n" % f.upper()) -# Map options to libraries required to support them that might be absent. -optionrequires = { - "bluez": ["libbluetooth"], - "dbus_export" : ["libdbus-1"], - } + # Map options to libraries required to support them that might be absent. + optionrequires = { + "bluez": ["libbluetooth"], + "dbus_export" : ["libdbus-1"], + } -keys = map(lambda x: (x[0],x[2]), boolopts) + map(lambda x: (x[0],x[2]), nonboolopts) + map(lambda x: (x[0],x[2]), pathopts) -keys.sort() -for (key,help) in keys: - value = env[key] - if value and key in optionrequires: - for required in optionrequires[key]: - if not config.CheckLib(required): - announce("%s not found, %s cannot be enabled." % (required,key)) - value = False - break - - confdefs.append("/* %s */" % help) - if type(value) == type(True): - if value: - confdefs.append("#define %s_ENABLE 1\n" % key.upper()) - else: - confdefs.append("/* #undef %s_ENABLE */\n" % key.upper()) - elif value in (0, "", "(undefined)"): - confdefs.append("/* #undef %s */\n" % key.upper()) - else: - if value.isdigit(): - confdefs.append("#define %s %s\n" % (key.upper(), value)) + keys = map(lambda x: (x[0],x[2]), boolopts) + map(lambda x: (x[0],x[2]), nonboolopts) + map(lambda x: (x[0],x[2]), pathopts) + keys.sort() + for (key,help) in keys: + value = env[key] + if value and key in optionrequires: + for required in optionrequires[key]: + if not config.CheckLib(required): + announce("%s not found, %s cannot be enabled." % (required,key)) + value = False + break + + confdefs.append("/* %s */" % help) + if type(value) == type(True): + if value: + confdefs.append("#define %s_ENABLE 1\n" % key.upper()) + else: + confdefs.append("/* #undef %s_ENABLE */\n" % key.upper()) + elif value in (0, "", "(undefined)"): + confdefs.append("/* #undef %s */\n" % key.upper()) else: - confdefs.append("#define %s \"%s\"\n" % (key.upper(), value)) + if value.isdigit(): + confdefs.append("#define %s %s\n" % (key.upper(), value)) + else: + confdefs.append("#define %s \"%s\"\n" % (key.upper(), value)) -if config.CheckFunc("pselect"): - confdefs.append("/* #undef COMPAT_SELECT */\n") -else: - confdefs.append("#define COMPAT_SELECT\n") + if config.CheckFunc("pselect"): + confdefs.append("/* #undef COMPAT_SELECT */\n") + else: + confdefs.append("#define COMPAT_SELECT\n") -if not config.CheckHeaderDefines("sys/ioctl.h", "TIOCMIWAIT"): - announce("Forcing pps=no (TIOCMIWAIT not available)") - env["pps"] = False + if not config.CheckHeaderDefines("sys/ioctl.h", "TIOCMIWAIT"): + announce("Forcing pps=no (TIOCMIWAIT not available)") + env["pps"] = False -confdefs.append('''\ + confdefs.append('''\ /* Some libcs do not have strlcat/strlcpy. Local copies are provided */ #ifndef HAVE_STRLCAT # ifdef __cplusplus @@ -692,44 +705,44 @@ size_t strlcpy(/*@out@*/char *dst, /*@in@*/const char *src, size_t size); ''') -manbuilder = mangenerator = htmlbuilder = None -if env['manbuild']: - if config.CheckXsltproc(): - mangenerator = 'xsltproc' - build = "xsltproc --nonet %s $SOURCE >$TARGET" - htmlbuilder = build % docbook_html_uri - manbuilder = build % docbook_man_uri - elif WhereIs("xmlto"): - mangenerator = 'xmlto' - xmlto = "xmlto %s $SOURCE || mv `basename $TARGET` `dirname $TARGET`" - htmlbuilder = xmlto % "html-nochunks" - manbuilder = xmlto % "man" + manbuilder = mangenerator = htmlbuilder = None + if env['manbuild']: + if config.CheckXsltproc(): + mangenerator = 'xsltproc' + build = "xsltproc --nonet %s $SOURCE >$TARGET" + htmlbuilder = build % docbook_html_uri + manbuilder = build % docbook_man_uri + elif WhereIs("xmlto"): + mangenerator = 'xmlto' + xmlto = "xmlto %s $SOURCE || mv `basename $TARGET` `dirname $TARGET`" + htmlbuilder = xmlto % "html-nochunks" + manbuilder = xmlto % "man" + else: + announce("Neither xsltproc nor xmlto found, documentation cannot be built.") else: - announce("Neither xsltproc nor xmlto found, documentation cannot be built.") -else: - announce("Build of man and HTML documentation is disabled.") -if manbuilder: - env['BUILDERS']["Man"] = Builder(action=manbuilder) - env['BUILDERS']["HTML"] = Builder(action=htmlbuilder, - src_suffix=".xml", suffix=".html") - -qt_network = env['libQgpsmm'] and config.CheckPKG('QtNetwork') - - -# check if ptys are available for regression tests -regress_driver_options = '' -try: - import pty - pty.openpty() -except Exception: - pty_available = False -else: - pty_available = True + announce("Build of man and HTML documentation is disabled.") + if manbuilder: + env['BUILDERS']["Man"] = Builder(action=manbuilder) + env['BUILDERS']["HTML"] = Builder(action=htmlbuilder, + src_suffix=".xml", suffix=".html") + + qt_network = env['libQgpsmm'] and config.CheckPKG('QtNetwork') + + + # check if ptys are available for regression tests + regress_driver_options = '' + try: + import pty + pty.openpty() + except Exception: + pty_available = False + else: + pty_available = True -if not pty_available: - regress_driver_options = '-u' + if not pty_available: + regress_driver_options = '-u' -env = config.Finish() + env = config.Finish() # Be explicit about what we're doing. changelatch = False |