#!/usr/bin/env python

import os

programs = """
wayrad.c
""".split()

includedirs = """
../../lib/krad_compositor/
../../lib/krad_chronometer/
../../lib/krad_xmms2/
../../lib/krad_y4m/
../../lib/krad_framepool/
../../lib/krad_web/
../../lib/krad_web/ext/
../../lib/krad_web/ext/libwebsockets/
../../lib/krad_web/res/
../../lib/krad_vhs/
../../lib/krad_sfx/
../../lib/krad_tone/
../../lib/krad_ipc/
../../lib/krad_tags/
../../lib/krad_audio/
../../lib/krad_theora/
../../lib/krad_jack/
../../lib/krad_alsa/
../../lib/krad_mixer/
../../lib/krad_osc/
../../lib/krad_xmms2/
../../lib/krad_wayland/
../../lib/krad_vpx/
../../lib/krad_v4l2/
../../lib/krad_flac/
../../lib/krad_vorbis/
../../lib/krad_opus/
../../lib/krad_radio/
../../lib/krad_ring/
../../lib/krad_ogg/
../../lib/krad_io/
../../lib/krad_transponder/
../../lib/krad_transmitter/
../../lib/krad_container/
../../lib/krad_x11/
../../lib/krad_udp/
../../lib/krad_system/
../../lib/krad_decklink/
../../lib/krad_ebml/
../../lib/krad_legacy/
/usr/local/include
/usr/include
""".split()

shlibs = ["cairo", "wayland-client"]
depsources = ["hex.c", "../../lib/krad_wayland/krad_wayland.c"]

stlibs = []
syslibs = ['m', 'dl', 'z']
syslibs2 = ['rt']

def configure(conf):

  global programs
  global shlibs
  global shlibs2  
  global syslibs

  if conf.env['KRAD_USE_WAYLAND']:
    for l in syslibs:
      conf.check(lib = l, cflags='-Wall', uselib_store = l)

    for l in shlibs:
      conf.check_cfg(package = l, uselib_store = l, args='--cflags --libs')

    for l in stlibs:
      conf.check_cfg(package = l, uselib_store = l, args='--cflags --libs --static')

def build(bld):

  global programs
  global shlibs
  global shlibs2  
  global syslibs
  global syslibs2

  if bld.env['KRAD_USE_WAYLAND']:
    for p in programs:
      bld(features = 'c cprogram', 
      source = [p] + depsources, 
      includes = includedirs, 
      target = p.replace(".c", ""),
      use = ["kradradio_client"],
      uselib = shlibs + stlibs + syslibs)

