# PyEPL: hardware/eeg/scalp/Makefile
#
# Copyright (C) 2003-2005 Michael J. Kahana
# Authors: Ian Schleifer, Per Sederberg, Aaron Geller, Josh Jacobs
# URL: http://memory.psych.upenn.edu/programming/pyepl
#
# Distributed under the terms of the GNU Lesser General Public License
# (LGPL). See the license.txt that came with this file.

all: scalp.so


INCLUDEPY=$(shell python -c "import distutils.sysconfig;print distutils.sysconfig.get_config_var('INCLUDEPY')")

PLATFORM = $(shell uname)

ifeq ($(PLATFORM), Linux)

scalp.so: scalp.o epleeg.o epleeg_wrapper.o
	c++ -shared scalp.o epleeg.o epleeg_wrapper.o -o scalp.so

epleeg.o: epleeg.cpp
	g++ -c -fPIC epleeg.cpp

epleeg_wrapper.o: epleeg_wrapper.cpp
	g++ -c -fPIC epleeg_wrapper.cpp

scalp.o: scalp.c
	gcc -c -fPIC -I$(INCLUDEPY) scalp.c

scalp.c: scalp.pyx
	pyrexc scalp.pyx

endif

ifeq ($(PLATFORM), Darwin)

scalp.so: scalp.o epleeg.o epleeg_wrapper.o
	c++ -bundle -flat_namespace -undefined suppress scalp.o epleeg.o epleeg_wrapper.o -o scalp.so

epleeg.o: epleeg.cpp
	g++ -fPIC -c epleeg.cpp

epleeg_wrapper.o: epleeg_wrapper.cpp
	g++ -fPIC -c epleeg_wrapper.cpp

scalp.o: scalp.c
	gcc -fPIC -c scalp.c -I$(INCLUDEPY)
scalp.c: scalp.pyx
	pyrexc scalp.pyx

endif
