MODULE_DIR=/lib/modules/`uname -r`/kernel/drivers/usb
INCLUDE_DIR=-I/lib/modules/`uname -r`/build/include -I/lib/modules/`uname -r`/build/include/asm/mach-default
MOTIF=-I/usr/X11R6/include -L/usr/X11R6/lib -lXm 
EXECUTABLE_DIR=/usr/local/bin
EXECUTABLES=mmusbplay mmusbrecord

obj-m := mmusbaudio.o
	
# make -C /usr/src/linux-`uname -r` SUBDIRS=`pwd` modules

all: mmusbaudio.ko $(EXECUTABLES)
	@echo Done

mmusbaudio.ko: mmusbaudio.c
	make -C /lib/modules/`uname -r`/build SUBDIRS=`pwd` modules

ua100mix : ua100mix.cpp
	g++ -O0 -g3 -Wall $(MOTIF) -o $@ $<
	cp *.xpm /usr/share/icons
	cp $@ $(EXECUTABLE_DIR)
	
mmusbplay : mmusbplay.cpp mmusbaudio.h mmuwave_file_header.h
	g++ -O0 -g3 -Wall -o $@ $<

mmusbrecord : mmusbrecord.cpp mmusbaudio.h mmuwave_file_header.h
	g++ -O0 -g3 -Wall -o $@ $<

clean:
	rm -rf core *.o *.ko *.mod.* .cmd .tmp_versions .mmnull* .mmusb* .mmfakealsa* $(EXECUTABLES)
	rm -f Module.markers modules.order Module.symvers

install: all
	cp mmusbaudio.ko $(MODULE_DIR)
	cp $(EXECUTABLES) $(EXECUTABLE_DIR)
	/sbin/depmod
	sync

uninstall:
	-rm $(MODULE_DIR)/mmusbaudio.ko
	cd $(EXECUTABLE_DIR)
	rm $(EXECUTABLES)
	-/sbin/rmmod mmusbaudio

load: mmusbaudio.ko
	/sbin/modprobe mmusbaudio
	sync

unload:
	/sbin/rmmod mmusbaudio

null: mmnullaudio.ko
	-/sbin/rmmod mmnullaudio
	cp $< $(MODULE_DIR)
	/sbin/depmod
	/sbin/modprobe mmnullaudio
	sync

