#!/usr/bin/env python

import glob, os, sys
from distutils.core import setup, Extension

dnet_srcs = [ '@srcdir@/dnet.c' ]
dnet_incdirs = [ '@top_srcdir@/include' ]
dnet_libdirs = []
dnet_libs = []
dnet_extargs = []
dnet_extobj = []

if sys.platform == 'win32':
    winpcap_dir = '../../WPdpack'
    dnet_srcs.extend(['../src/addr-util.c', '../src/addr.c', '../src/blob.c', '../src/ip-util.c', '../src/ip6.c', '../src/rand.c', '../src/err.c', '../src/strlcat.c', '../src/strlcpy.c', '../src/err.c', '../src/strlcat.c', '../src/strlcpy.c', '../src/strsep.c', '../src/arp-win32.c', '../src/eth-win32.c', '../src/fw-pktfilter.c', '../src/intf-win32.c', '../src/ip-win32.c', '../src/route-win32.c', '../src/tun-none.c'])
    dnet_incdirs.append(winpcap_dir + '/Include')
    dnet_libdirs.append(winpcap_dir + '/Lib')
    dnet_libs.extend([ 'advapi32', 'iphlpapi', 'ws2_32', 'packet' ])
else:
    # XXX - can't build on Cygwin+MinGW yet.
    #if sys.platform == 'cygwin':
    #    dnet_extargs.append('-mno-cygwin')
    dnet_extobj.extend(glob.glob('@top_builddir@/src/.libs/*.o'))

dnet = Extension('dnet',
                 dnet_srcs,
                 include_dirs=dnet_incdirs,
                 library_dirs=dnet_libdirs,
                 libraries=dnet_libs,
                 extra_compile_args=dnet_extargs,
                 extra_objects=dnet_extobj)

setup(name='dnet',
      version='@VERSION@',
      description='low-level networking library',
      author='Dug Song',
      author_email='dugsong@monkey.org',
      url='http://libdnet.sourceforge.net/',
      ext_modules = [ dnet ])
