def build(ctx):
    srcnode = ctx.srcnode.abspath()

    libntp_source = [
        "atolfp.c",
        "authkeys.c",
        "authreadkeys.c",
        "clocktime.c",
        "decodenetnum.c",
        "dofptoa.c",
        "dolfptoa.c",
        "getopt.c",
        "initnetwork.c",
        "macencrypt.c",
        "mstolfp.c",
        "netof.c",
        "ntp_endian.c",
        "ntp_intres.c",
        "ntp_random.c",
        "ntp_worker.c",
        "numtoa.c",
        "recvbuff.c",
        "refidsmear.c",
        "socket.c",
        "socktoa.c",
        "ssl_init.c",
        "syssignal.c",
        "work_thread.c",
        "ymd2yd.c",
    ]

    libntp_source_sharable = [
        "clockwork.c",
        "emalloc.c",
        "hextolfp.c",
        "humandate.c",
        "lib_strbuf.c",
        "msyslog.c",
        "ntp_calendar.c",
        "prettydate.c",
        "statestr.c",
        "systime.c",
        "timetoa.c",
    ]

    if not ctx.env.HAVE_STRLCAT or not ctx.env.HAVE_STRLCPY:
        libntp_source_sharable += ["strl_obsd.c"]

    includes = [
        "%s/libisc/include/" % srcnode,
        ] + ctx.env.PLATFORM_INCLUDES

    # C library
    ctx(
        features="c cstlib bld_include src_include",
        includes=includes,
        source=libntp_source + libntp_source_sharable,
        target="ntp",
    )

    # Loadable Python extension
    ctx(
        features="c cshlib bld_include src_include pyext",
        install_path='${PYTHONDIR}/ntp',
        includes=includes,
        source=["pymodule.c"] + libntp_source_sharable,
        target="ntpc",
        use="M RT CRYPTO",
    )
