#
# 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

SUBDIRS =
ifeq (1,$(CONFIG_SND_PCM1))
SUBDIRS += pcm1
endif
ifeq (1,$(CONFIG_SND_SEQUENCER))
SUBDIRS += seq
endif
TARGETS = $(SNDVERSIONS)
SYMFILES =
ifeq (1,$(CONFIG_PERSIST))
TARGETS += $(TOPDIR)/modules/persist.o
SYMFILES += persist_export.c
endif
ifeq (1,$(CONFIG_SND))
TARGETS += $(TOPDIR)/modules/snd.o
SYMFILES += snd_export.c
endif
ifeq (1,$(CONFIG_SND_MIXER))
TARGETS += $(TOPDIR)/modules/snd-mixer.o
SYMFILES += mixer_export.c
endif
ifeq (1,$(CONFIG_SND_PCM))
TARGETS += $(TOPDIR)/modules/snd-pcm.o
SYMFILES += pcm_export.c
endif
ifeq (1,$(CONFIG_SND_MIDI))
TARGETS += $(TOPDIR)/modules/snd-midi.o
SYMFILES += midi_export.c
endif
ifeq (1,$(CONFIG_SND_TIMER))
TARGETS += $(TOPDIR)/modules/snd-timer.o
SYMFILES += timer_export.c
endif
ifeq (1,$(CONFIG_SND_SYNTH))
TARGETS += $(TOPDIR)/modules/snd-synth.o
SYMFILES += synth_export.c
endif
ifeq (1,$(CONFIG_SND_OSSEMUL))
TARGETS += $(TOPDIR)/modules/snd-mixer-oss.o
endif

PERSIST = persist.o persist_export.o
OBJECTS = sound.o init.o isadma.o memory.o \
          info.o switch.o control.o pci.o misc.o sthread.o snd_export.o
ifeq (1,$(CONFIG_SND_OSSEMUL))
OBJECTS += sound_oss.o info_oss.o
endif
MIXER   = mixer.o mixer_lib.o mixer_export.o
OMIXER	= mixer_oss.o
PCM	= pcm.o pcm_proc.o ulaw.o pcm_export.o
MIDI    = midi.o rawmidi.o midi_export.o
TIMER	= timer.o timer_export.o
SYNTH   = synth.o synth_export.o

include $(TOPDIR)/Rules.make

all: $(TARGETS)
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d; then exit 1; fi; done
	@echo
	@echo "ALSA kernel were sucessfully compiled."
	@echo

include $(TOPDIR)/Rules1.make

$(TOPDIR)/modules/persist.o: .depend $(SNDVERSIONS) $(PERSIST)
	$(LINKER) -o $@ $(PERSIST)

$(TOPDIR)/modules/snd.o: .depend $(SNDVERSIONS) $(OBJECTS)
	$(LINKER) -o $@ $(OBJECTS)

$(TOPDIR)/modules/snd-control.o: .depend $(SNDVERSIONS) $(CONTROL)
	$(LINKER) -o $@ $(CONTROL)

$(TOPDIR)/modules/snd-mixer.o: .depend $(SNDVERSIONS) $(MIXER)
	$(LINKER) -o $@ $(MIXER)

$(TOPDIR)/modules/snd-mixer-oss.o: .depend $(SNDVERSIONS) $(OMIXER)
	$(LINKER) -o $@ $(OMIXER)

$(TOPDIR)/modules/snd-pcm.o: .depend $(SNDVERSIONS) $(PCM)
	$(LINKER) -o $@ $(PCM)

$(TOPDIR)/modules/snd-midi.o: .depend $(SNDVERSIONS) $(MIDI)
	$(LINKER) -o $@ $(MIDI)

$(TOPDIR)/modules/snd-timer.o: .depend $(SNDVERSIONS) $(TIMER)
	$(LINKER) -o $@ $(TIMER)

$(TOPDIR)/modules/snd-synth.o: .depend $(SNDVERSIONS) $(SYNTH)
	$(LINKER) -o $@ $(SYNTH)

gcompile: $(TARGETS)

clean:
	$(MAKE) -C seq clean
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d clean; then exit 1; fi; done
	rm -f .depend *.o *.orig snd.map snd.map? *.old *~
	rm -f core $(SNDVERSIONS) $(SYMFILES)

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

dep:	.depend

dummy:

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