# vim: set noexpandtab:
#
# GNU Solfege - eartraining for GNOME
# Copyright (C) 2000, 2001, 2002  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 $(python-installfiles) $(filter-out solfege_c_midi_wrap.c, $(wildcard *.c *.i *.h)) winmidi.dsp winmidi.dsw winmidi.def

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

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

OBJECTS = macro_to_function.o \
	solfege_c_midi.o \
	solfege_c_midi_wrap.o

ifeq ($(ENABLE_TUNER),yes)
OBJECTS += fft.o dsp.o gate.o calc.o xmalloc.o
endif

solfege_c_midimodule.so: $(OBJECTS)
	$(CC) -fPIC -shared $(OBJECTS) -o solfege_c_midimodule.so -lc $(LIBS)

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
	$(SWIG) -python solfege_c_midi.i

# win32
# This section is still just a hack and will be completed in a later
# release. At the moment I (tca) use this section to cross-compile
# the win32 sound module 'winmidi.py'

W32CFLAGS=-I/home/tom/X/wp -I/usr/i586-mingw32msvc/include 
W32GCC=i586-mingw32msvc-gcc

PYDLL=/home/tom/X/python/python21.dll
DLLWRAP=i586-mingw32msvc-dllwrap

winmidi.pyd: winmidi.o
	$(DLLWRAP) --dllname=winmidi.pyd --def=winmidi.def winmidi.o -s --entry=_DllMain@12 -L/usr/i586-mingw32msvc/lib/ -lwinmm $(PYDLL)

winmidi.o: winmidi.c
	$(W32GCC) $(W32CFLAGS) -c winmidi.c

# end win32

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 *~
	rm -f solfege_c_midi_wrap.*
	rm -f winmidi.pyd winmidi.o

distclean: clean

