# vim: set noexpandtab:
#
# GNU Solfege - eartraining for GNOME
# Copyright (C) 2000-2001  Tom Cato Amundsen
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


depth = ..
name = soundcard

include $(depth)/Makefile.inc

python-installfiles = $(wildcard *.py)
dist_files = Makefile config.h.in $(python-installfiles) $(wildcard *.c *.i)

CFLAGS:=$(CFLAGS) -I/usr/src/linux/include -Wall -pedantic -fPIC
CC=gcc $(CFLAGS)

ifeq ($(ENABLE_OSS_SOUND),yes)
all: solfege_c_midimodule.so
else
all:
endif


solfege_c_midimodule.so: macro_to_function.o solfege_c_midi.o \
                         solfege_c_midi_wrap.o
	$(CC) -fPIC -shared macro_to_function.o solfege_c_midi.o \
                  solfege_c_midi_wrap.o -o solfege_c_midimodule.so -lc 

solfege_c_midi_wrap.o: solfege_c_midi_wrap.c solfege_c_midi.i
	$(CC) $(CFLAGS) -c solfege_c_midi_wrap.c -I$(PYTHON_PREFIX)/include/python$(PYTHON_VERSION)

solfege_c_midi_wrap.c: solfege_c_midi.c macro_to_function.c solfege_c_midi.i
ifeq ($(HAVE_LINUX_AWE_VOICE_H),yes)
	swig -python -DHAVE_LINUX_AWE_VOICE_H solfege_c_midi.i 
else
	swig -python solfege_c_midi.i
endif

install: python-install
ifeq ($(ENABLE_OSS_SOUND),yes)
	mkdir -p $(libdir)/$(PACKAGE)/$(VERSION)
	$(INSTALL_DATA) solfege_c_midimodule.so $(libdir)/$(PACKAGE)/$(VERSION)/
endif

uninstall: python-uninstall
	rm -f $(libdir)/$(PACKAGE)/$(VERSION)/solfege_c_midimodule.so
	rmdir $(libdir)/$(PACKAGE)/$(VERSION) || true
	rmdir $(libdir)/$(PACKAGE) || true

clean:
	rm -f *.pyc *.pyo *.o *.so *~

distclean: clean
	rm -f config.h
	rm -f solfege_c_midi_wrap.*


