#
# Makefile for ALSA low level driver (Linux version)
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@suse.cz>
#

TOPDIR	= ..

include $(TOPDIR)/Makefile.conf
include $(TOPDIR)/cards.config

ifeq (1,$(CONFIG_SND_INTERWAVE))
TARGETS += $(TOPDIR)/modules/snd-interwave.o
endif
ifeq (1,$(CONFIG_SND_INTERWAVE_STB))
TARGETS += $(TOPDIR)/modules/snd-interwave-stb.o
endif
ifeq (1,$(CONFIG_SND_GUSMAX))
TARGETS += $(TOPDIR)/modules/snd-gusmax.o
endif
ifeq (1,$(CONFIG_SND_GUSEXTREME))
TARGETS += $(TOPDIR)/modules/snd-gusextreme.o
endif
ifeq (1,$(CONFIG_SND_GUSCLASSIC))
TARGETS += $(TOPDIR)/modules/snd-gusclassic.o
endif
ifeq (1,$(CONFIG_SND_AUDIODRIVE1688))
TARGETS += $(TOPDIR)/modules/snd-audiodrive1688.o
endif
ifeq (1,$(CONFIG_SND_AUDIODRIVE18XX))
TARGETS += $(TOPDIR)/modules/snd-audiodrive18xx.o
endif
ifeq (1,$(CONFIG_SND_SB8))
TARGETS += $(TOPDIR)/modules/snd-sb8.o
endif
ifeq (1,$(CONFIG_SND_SB16))
TARGETS += $(TOPDIR)/modules/snd-sb16.o
endif
ifeq (1,$(CONFIG_SND_SBAWE))
TARGETS += $(TOPDIR)/modules/snd-sbawe.o
endif
ifeq (1,$(CONFIG_SND_OPL3SA))
TARGETS += $(TOPDIR)/modules/snd-opl3sa.o
endif
ifeq (1,$(CONFIG_SND_MOZART))
TARGETS += $(TOPDIR)/modules/snd-mozart.o
endif
ifeq (1,$(CONFIG_SND_OPTI9XX))
TARGETS += $(TOPDIR)/modules/snd-opti9xx.o
endif
ifeq (1,$(CONFIG_SND_CARD_AD1848))
TARGETS += $(TOPDIR)/modules/snd-card-ad1848.o
endif
ifeq (1,$(CONFIG_SND_CARD_CS4231))
TARGETS += $(TOPDIR)/modules/snd-card-cs4231.o
endif
ifeq (1,$(CONFIG_SND_CARD_CS4232))
TARGETS += $(TOPDIR)/modules/snd-card-cs4232.o
endif
ifeq (1,$(CONFIG_SND_CARD_CS4236))
TARGETS += $(TOPDIR)/modules/snd-card-cs4236.o
endif
ifeq (1,$(CONFIG_SND_SERIAL))
TARGETS += $(TOPDIR)/modules/snd-serial.o
endif
ifeq (1,$(CONFIG_SND_SGALAXY))
TARGETS += $(TOPDIR)/modules/snd-sgalaxy.o
endif
  
ifeq (1,$(CONFIG_SND_PCI))
ifeq (1,$(CONFIG_SND_SONICVIBES))
TARGETS += $(TOPDIR)/modules/snd-sonicvibes.o
endif
ifeq (1,$(CONFIG_SND_AUDIOPCI1370))
TARGETS += $(TOPDIR)/modules/snd-audiopci1370.o
endif
ifeq (1,$(CONFIG_SND_AUDIOPCI1371))
TARGETS += $(TOPDIR)/modules/snd-audiopci1371.o
endif
ifeq (1,$(CONFIG_SND_ESSSOLO1))
TARGETS += $(TOPDIR)/modules/snd-esssolo1.o	   
endif
ifeq (1,$(CONFIG_SND_TRID4DWAVE))
TARGETS += $(TOPDIR)/modules/snd-trid4dwave.o	   
endif
ifeq (1,$(CONFIG_SND_CARD_CS461X))
TARGETS += $(TOPDIR)/modules/snd-card-cs461x.o
endif
ifeq (1,$(CONFIG_SND_CARD_FM801))
TARGETS += $(TOPDIR)/modules/snd-card-fm801.o
endif
endif

INTERWAVE        = interwave.o
INTERWAVE_STB	 = interwave-stb.o
GUSMAX           = gusmax.o
GUSEXTREME       = gusextreme.o
GUSCLASSIC       = gusclassic.o
AUDIODRIVE1688   = audiodrive1688.o
AUDIODRIVE18XX   = audiodrive18xx.o
SB8              = sb8.o
SB16             = sb16.o
SBAWE		 = sbawe.o
OPL3SA           = opl3-sa.o
MOZART		 = mozart.o
OPTI9XX		 = opti9xx.o
SONICVIBES	 = sonicvibes.o
AUDIOPCI1370	 = audiopci1370.o
AUDIOPCI1371	 = audiopci1371.o
CARD_AD1848	 = card-ad1848.o
CARD_CS4231	 = card-cs4231.o
CARD_CS4232	 = card-cs4232.o
CARD_CS4236	 = card-cs4236.o
CARD_CS461X	 = card-cs461x.o
CARD_FM801	 = card-fm801.o
ESSSOLO1	 = esssolo1.o
SERIAL		 = serial.o
TRID4DWAVE	 = trid4dwave.o
SGALAXY		 = sgalaxy.o

include $(TOPDIR)/Rules.make

all: $(TARGETS)
	@if [ "$(CONFIG_SND_SGI)" = "1" ]; then if ! $(MAKE) -C hal2; then exit 1; fi; fi
	@echo
	@echo "ALSA soundcard specific modules were sucessfully compiled."
	@echo

$(TOPDIR)/modules/snd-interwave.o: .depend $(INTERWAVE)
	$(LINKER) -o $@ $(INTERWAVE)

$(INTERWAVE_STB): .depend $(INTERWAVE)
	$(CC) $(COPTS) $(INCLUDE) -DSND_STB -c -o $(INTERWAVE_STB) interwave.c

$(TOPDIR)/modules/snd-interwave-stb.o: .depend $(INTERWAVE_STB)
	$(LINKER) -o $@ $(INTERWAVE_STB)

$(TOPDIR)/modules/snd-gusmax.o: .depend $(GUSMAX)
	$(LINKER) -o $@ $(GUSMAX)

$(TOPDIR)/modules/snd-gusextreme.o: .depend $(GUSEXTREME)
	$(LINKER) -o $@ $(GUSEXTREME)

$(TOPDIR)/modules/snd-gusclassic.o: .depend $(GUSCLASSIC)
	$(LINKER) -o $@ $(GUSCLASSIC)

$(TOPDIR)/modules/snd-audiodrive1688.o: .depend $(AUDIODRIVE1688)
	$(LINKER) -o $@ $(AUDIODRIVE1688)

$(TOPDIR)/modules/snd-audiodrive18xx.o: .depend $(AUDIODRIVE18XX)
	$(LINKER) -o $@ $(AUDIODRIVE18XX)

$(TOPDIR)/modules/snd-sb8.o: .depend $(SB8)
	$(LINKER) -o $@ $(SB8)

$(TOPDIR)/modules/snd-sb16.o: .depend $(SB16)
	$(LINKER) -o $@ $(SB16)

$(SBAWE): .depend $(SB16)
	$(CC) $(COPTS) $(INCLUDE) -DSND_SBAWE -c -o $(SBAWE) sb16.c

$(TOPDIR)/modules/snd-sbawe.o: .depend $(SBAWE)
	$(LINKER) -o $@ $(SBAWE)

$(TOPDIR)/modules/snd-opl3sa.o: .depend $(OPL3SA)
	$(LINKER) -o $@ $(OPL3SA)

$(TOPDIR)/modules/snd-mozart.o: .depend $(MOZART)
	$(LINKER) -o $@ $(MOZART)

$(TOPDIR)/modules/snd-opti9xx.o: .depend $(OPTI9XX)
	$(LINKER) -o $@ $(OPTI9XX)

$(TOPDIR)/modules/snd-sonicvibes.o: .depend $(SONICVIBES)
	$(LINKER) -o $@ $(SONICVIBES)

$(AUDIOPCI1370): .depend audiopci.c
	$(CC) $(COPTS) $(INCLUDE) -DCHIP1370 -c -o $(AUDIOPCI1370) audiopci.c

$(TOPDIR)/modules/snd-audiopci1370.o: .depend $(AUDIOPCI1370)
	$(LINKER) -o $@ $(AUDIOPCI1370)

$(AUDIOPCI1371): .depend audiopci.c
	$(CC) $(COPTS) $(INCLUDE) -DCHIP1371 -c -o $(AUDIOPCI1371) audiopci.c

$(TOPDIR)/modules/snd-audiopci1371.o: .depend $(AUDIOPCI1371)
	$(LINKER) -o $@ $(AUDIOPCI1371)

$(TOPDIR)/modules/snd-card-ad1848.o: .depend $(CARD_AD1848)
	$(LINKER) -o $@ $(CARD_AD1848)

$(TOPDIR)/modules/snd-card-cs4231.o: .depend $(CARD_CS4231)
	$(LINKER) -o $@ $(CARD_CS4231)

$(TOPDIR)/modules/snd-card-cs4232.o: .depend $(CARD_CS4232)
	$(LINKER) -o $@ $(CARD_CS4232)

$(TOPDIR)/modules/snd-card-cs4236.o: .depend $(CARD_CS4236)
	$(LINKER) -o $@ $(CARD_CS4236)

$(TOPDIR)/modules/snd-card-cs461x.o: .depend $(CARD_CS461X)
	$(LINKER) -o $@ $(CARD_CS461X)

$(TOPDIR)/modules/snd-card-fm801.o: .depend $(CARD_FM801)
	$(LINKER) -o $@ $(CARD_FM801)

$(TOPDIR)/modules/snd-esssolo1.o: .depend $(ESSSOLO1)
	$(LINKER) -o $@ $(ESSSOLO1)

$(TOPDIR)/modules/snd-serial.o: .depend $(SERIAL)
	$(LINKER) -o $@ $(SERIAL)

$(TOPDIR)/modules/snd-trid4dwave.o: .depend $(TRID4DWAVE)
	$(LINKER) -o $@ $(TRID4DWAVE)

$(TOPDIR)/modules/snd-sgalaxy.o: .depend $(SGALAXY)
	$(LINKER) -o $@ $(SGALAXY)

gcompile: $(TARGETS)

insert: $(TARGETS) remove
	sync		# for sure - debug versions may hang
	/sbin/insmod snd-interwave.o

remove:
	sync		# for sure - debug versions may hang
	- /sbin/rmmod snd-interwave

clean:
	@if [ "$(CONFIG_SND_SGI)" = "1" ]; then if ! $(MAKE) -C hal2 clean; then exit 1; fi; fi
	rm -f core .depend *.o *.orig snd.map snd.map? *~

.depend:
	$(CPP) $(COPTS) $(INCLUDE) *.c > .depend

dep:	.depend

dummy:

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
