# Makefile for Agere Soft Modem Driver for Linux
#
# Copyright (c) 2002, 2003 Agere Systems, Inc.  All rights reserved.
#
# Description:
# Makes the following modules
#   - Agere Soft Modem Controller driver module 
#   - Modem Serail Interface driver module
#
# Usage:
#   make install: to make and install the driver modules
#   make uninstall: to uninstall the driver modules
#
# Revision History:
#   Name                   Date          Change
#   Soumyendu Sarkar       12/03/2002    Initial
#

KERNEL_DIR = /lib/modules/`uname -r`/build/
#KERNEL_DIR = /usr/src/linux-`uname -r | sed -e 's,\-default,,'`/
#KERNEL_DIR = /usr/src/linux-`uname -r | sed -e 's,\-.*,,'`/
KERNEL_DIR1 = /usr/src/linux-`uname -r`/include
KERNEL_DIR2 = /usr/src/linux-`uname -r | sed -e 's,\-.*,,'`/include
KERNEL_DIR5 = /usr/src/linux-`uname -r | sed -e 's,\-.*,,'`/include/asm/mach-default
KERNEL_DIR3 = /usr/src/linux-`uname -r | sed -e 's,\..*,,'`.`uname -r | sed -e 's,[^\.]*\.,,' -e 's,\..*,,'`/include
KERNEL_DIR4 = /usr/src/linux-`uname -r | sed -e 's,\-.*,,'`.SuSE/include

I_FLAGS =  -I$(KERNEL_DIR1) -I$(KERNEL_DIR2) -I$(KERNEL_DIR5) -I$(KERNEL_DIR3) -I$(KERNEL_DIR4)/include

#C_FLAGS = -Wall -Wno-unused -O2 -fomit-frame-pointer -fno-strength-reduce  -pipe\
#		-mcpu=i486 -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
#		-DMODULE -D__KERNEL__ -DLT_KER_24 -DLT_KER_26 -DKERNEL_DIR -DNO_EEPROM

C_FLAGS = -Wall	-Wno-unused -O1 -fomit-frame-pointer -fno-strength-reduce -pipe \
		-fno-gcse-after-reload \
		-falign-loops=2 -falign-jumps=2 -falign-functions=2 \
		-DMODULE -D__KERNEL__ -DLT_KER_24 -DLT_KER_26 -DNO_EEPROM $(I_FLAGS)

EXTRA_CFLAGS += -Wall -DLT_KER_24 -DLT_KER_26 -DNO_EEPROM 

EXTRA_LDFLAGS := -d
    
help :
	@echo ''
	@echo 'Run "make install" to install Agere Systems Soft Modem on your system.'
	@echo 'Run "make uninstall" to remove a previously installed modem.'
	@echo ''

agrmodem-objs := \
        agrsoftmodem.o agrmodemlib.o HDA.o

agrserial-objs := \
	serial26.o

obj-m += agrmodem.o agrserial.o

module:
#	cp ../../build/Linux/dbg-agr-linux-fedora-6-0/bin/AGRSMDM_lib.o agrmodemlib.o

	make -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules

$(obj)/agrmodemlib.o:
	cp $(src)/agrmodemlib.o $(obj)/agrmodemlib.o

clean:
	rm -f *.a
	rm -f *~
	rm -f agrmodem.o
	rm -f agrmodem.ko
	rm -f agrmodem.mod.o
	rm -f agrmodem.mod.c
	rm -f agrserial.o
	rm -f agrserial.ko
	rm -f agrserial.mod.o
	rm -f agrserial.mod.c
	rm -f agrsoftmodem.o
	rm -f serial26.o
	rm -f HDA.o

install:
	./agrinst
  
uninstall :
	./agruninst


	
