# Makefile for Vortex au88xx driver
#
# Copyright (c) 1999 Aureal Inc.
# Copyright (c) 2000 Warren Chartier
# Modified to adapt the new source tree by Nikos Kalogridis
#
# Environment:
#	AUCHIP		- AU8830 (default), AU8820, or AU8810
#	AUSMP		- empty (default) or -D__SMP__
#
# 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
# 
# Contact: http://aureal.sourceforge.net

ifndef AUCHIP
AUCHIP = AU8830
endif

ifeq ($(AUCHIP),AU8830)
NAME = au8830
ASP_OBJ = asp30.o
endif

ifeq ($(AUCHIP),AU8810)
NAME = au8810
ASP_OBJ = asp10.o
endif

ifeq ($(AUCHIP),AU8820)
NAME = au8820
ASP_OBJ = asp20.o
endif

VER    = $(shell uname -r)
MODDIR = /lib/modules/$(VER)/misc
CONF   = $(wildcard /etc/modules.conf)
ifeq ($(strip $(CONF)),)
CONF   = /etc/conf.modules
endif

INCLUDEDIRS = -I/usr/src/linux/include

#
# CPU types, Uncomment one only!
#
#CFCPU = 486
CFCPU = pentium
#CFCPU = pentiumpro

#
# If you have an SMP system uncomment the following (experimental)
# 
#AUSMP = -D__SMP__

#
# Debug/Optimization
#
#CFDEBUG = -g -DDEBUG=1 -DDEBUG_AU -D__VerboseMode
CFOPT = -O6 -fomit-frame-pointer

# Do Not Modify Anything Below This Line!

CFLAGS	= -D__KERNEL__ $(AUSMP) -DMODULE -D$(AUCHIP) -m$(CFCPU) $(CFDEBUG) $(CFOPT) -Wall -pipe $(INCLUDEDIRS)

CFILES = au_audio.c au_midi.c au_core.c au_sndstat.c au_mixer.c au_utils.c au_vortex.c
OFILES = $(CFILES:.c=.o)

$(NAME).o: $(OFILES) $(ASP_OBJ)
	$(LD) -m elf_i386 -r $^ -o $@

compile: $(NAME).o

install: compile
	 mv -f $(CONF) $(CONF).old
	 gawk -f mod_conf $(CONF).old > $(CONF)
	 echo "alias sound $(NAME)" >> $(CONF)
	 echo "alias midi $(NAME)" >> $(CONF)
	 mkdir -p $(MODDIR)
	 cp -f $(NAME).o $(MODDIR)
	 -/sbin/depmod -a
	 -/sbin/rmmod $(NAME)
	 -/sbin/modprobe $(NAME)

install10:
	$(MAKE) install AUCHIP=AU8810

install20:
	$(MAKE) install AUCHIP=AU8820

rebuild10:
	$(MAKE) rebuild AUCHIP=AU8810

rebuild20:
	$(MAKE) rebuild AUCHIP=AU8820

rebuild: clean install

clean:
	rm -f $(NAME).o $(OFILES)

drebuild:
	$(MAKE) rebuild VERBOSE=YES
	
drebuild10:
	$(MAKE) rebuild10 VERBOSE=YES

drebuild20:
	$(MAKE) rebuild20 VERBOSE=YES
