# Makefile for Vortex au88xx driver
#
# Copyright (c) 1999 Aureal Inc.
#
# Environment:
#	AUCHIP		- AU8830 (default), AU8820, or AU8810
#
# 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://linux.aureal.com

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

STD_CFLAGS = -D__KERNEL__ -DMODULE -D$(AUCHIP) -O -Wall -pipe -m486 $(INCLUDEDIRS)
#CFLAGS = $(STD_CFLAGS) -g -DDEBUG=1 -DDEBUG_AU
CFLAGS = $(STD_CFLAGS) -O2 -fomit-frame-pointer

CFILES = vortex.c
OFILES = $(CFILES:.c=.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/modprobe $(NAME)

install10:
	$(MAKE) install AUCHIP=AU8810

install20:
	$(MAKE) install AUCHIP=AU8820

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

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