# Makefile.am - Copyright 2005, 2006, University
#               of Padova, dept. of Pure and Applied
#               Mathematics
#
# This file is part of SGPEMv2.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# SGPEMv2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SGPEMv2. If not, see http://www.gnu.org/licenses/.



# extra calls
.PHONY : apidox

# this should be the only recursive call
SUBDIRS = po

# directories definition
datarootdir = @datarootdir@
localedir = @datadir@/locale
plugindir = $(SGPEMV2_PLUGINS_DIR)
sharedir = $(plugindir)/extras/pyloader
policiesdir = $(SGPEMV2_POLICIES_DIR)

#define empty global variables
plugin_LTLIBRARIES =
noinst_HEADERS =
noinst_PYTHON =
EXTRA_DIST =
MAINTAINERCLEANFILES =
MOSTLYCLEANFILES =
CLEANFILES =

# ############################################################
#
# extra dist, cleanup and automake/aclocal flags
#
# ############################################################

ACLOCAL_AMFLAGS = -I m4 --install

macros = m4/compilerflags.m4 \
	m4/linkingflags.m4 \
	m4/sgpemv2-dirs.m4

EXTRA_DIST += \
	gettext.h \
	$(macros)

# ############################################################
#
# source : libpyloader.la
#
# ############################################################

plugin_LTLIBRARIES += libpyloader.la

libpyloader_la_CPPFLAGS = \
               -I@top_srcdir@ \
               -DSHAREDIR="\"$(sharedir)\"" \
               -DLOCALEDIR="\"$(localedir)\"" \
               $(PYTHON_CPPFLAGS) \
               $(GLIBMM_CFLAGS) \
               $(SGPEMV2_CFLAGS)
libpyloader_la_CXXFLAGS = \
               $(VISIB_HIDDEN)
libpyloader_la_LIBADD = \
               $(PYTHON_EXTRA_LIBS) \
               $(GLIBMM_LIBS) \
               $(SGPEMV2_LIBS)
libpyloader_la_LDFLAGS = \
               $(PYTHON_LDFLAGS) \
               $(PYTHON_EXTRA_LDFLAGS) \
               -version-info 0:0:0 \
               -module

# Please keep this in sorted order:
libpyloader_la_SOURCES = \
               src/plugin.cc \
               src/python_cpu_policy.cc \
               src/python_cpu_policy_manager.cc 

noinst_HEADERS += \
               src/python_cpu_policy.hh \
               src/python_cpu_policy_manager.hh

share_PYTHON = \
               src/CPUPolicy.py \
               src/ScriptAdapter.py

# ############################################################
#
# C++ modules -> Python loadable modules
#
# ############################################################

proxies = src/sgpem.py
wrappers = src/sgpem_wrap.cc

share_LTLIBRARIES = _sgpem.la
share_PYTHON += $(proxies)

# static pattern rule
$(proxies) $(wrappers) : src/sgpem.i
	test -d "$(@D)" || mkdir -p -- "$(@D)"
	$(SWIG) $(SWIG_PYTHON_OPT) -o $@  $<

_sgpem_la_INTERFACES = src/sgpem.i

_sgpem_la_CPPFLAGS = \
               -I@top_srcdir@ \
               $(SWIG_PYTHON_CPPFLAGS) \
               $(GLIBMM_CFLAGS) \
      	       $(SGPEMV2_CFLAGS)
_sgpem_la_LDFLAGS = -module -export-dynamic \
               $(GLIBMM_LDFLAGS)
_sgpem_la_LIBADD = $(SGPEMV2_LIBS) \
               $(GLIBMM_LIBS)
_sgpem_la_SOURCES = $(wrappers)

EXTRA_DIST += $(_sgpem_la_INTERFACES)
MOSTLYCLEANFILES += $(proxies) $(wrappers)

# ############################################################
#
# source : builtin-policies
#
# ############################################################

# built-in policies
policies_PYTHON = \
       src/builtin-policies/fcfs.py \
       src/builtin-policies/lottery.py \
       src/builtin-policies/rr.py \
       src/builtin-policies/rr_priority.py \
       src/builtin-policies/sjf.py


# ############################################################
#
# check : testsuite
#
# ############################################################

if COND_TESTS

# DEJATOOL = src/testsuite/example-test.exp

noinst_PROGRAMS = \
	src/testsuite/test-pyloader

src_testsuite_test_pyloader_CPPFLAGS = \
               -I@top_srcdir@ \
	       -DSHAREDIR="\"$(sharedir)\"" \
               $(PYTHON_CPPFLAGS) \
               $(GLIBMM_CFLAGS) \
               $(GTHREAD_CFLAGS) \
	       $(SGPEMV2_CFLAGS)
src_testsuite_test_pyloader_DEPENDENCIES = \
               libpyloader.la
src_testsuite_test_pyloader_LDFLAGS = \
               $(SGPEMV2_LIBS) \
               $(GLIBMM_LIBS) \
	       $(GTHREAD_LIBS) \
               $(PYTHON_LDFLAGS) \
               $(PYTHON_EXTRA_LIBS) \
               $(PYTHON_EXTRA_LDFLAGS)
src_testsuite_test_pyloader_SOURCES = \
               src/testsuite/test-python_loader.cc \
               src/python_cpu_policy.cc \
               src/python_cpu_policy_manager.cc

noinst_PYTHON += src/testsuite/python_loader_configure.py \
               src/testsuite/python_loader_sort_queue.py \
               src/testsuite/python_loader_is_preemptive.py \
               src/testsuite/python_loader_get_time_slice.py


# Workaround an automake bug that leaves behind some files 
# while it's finishing the distcheck target
CLEANFILES += \
	src/testsuite/.libs/test-pyloader

endif #~ if COND_TESTS

