#
# Copyright (c) 2001 Conexant Systems, Inc.
# 
# 1.   Permitted use. Redistribution and use in source and binary forms,
# with or without modification, are permitted under the terms set forth
# herein.
# 
# 2.   Disclaimer of Warranties. CONEXANT AND OTHER CONTRIBUTORS MAKE NO
# REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.
# IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTIES OF ANY KIND.
# CONEXANT AND OTHER CONTRIBUTORS DISCLAIMS ALL WARRANTIES WITH REGARD TO
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE, GOOD TITLE AND AGAINST INFRINGEMENT.
# 
# This software has not been formally tested, and there is no guarantee that
# it is free of errors including, but not limited to, bugs, defects,
# interrupted operation, or unexpected results. Any use of this software is
# at user's own risk.
# 
# 3.   No Liability.
# 
# (a) Conexant or contributors shall not be responsible for any loss or
# damage to Company, its customers, or any third parties for any reason
# whatsoever, and CONEXANT OR CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY
# ACTUAL, DIRECT, INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED, WHETHER IN CONTRACT, STRICT OR OTHER LEGAL THEORY OF
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
# WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
# 
# (b) User agrees to hold Conexant and contributors harmless from any
# liability, loss, cost, damage or expense, including attorney's fees,
# as a result of any claims which may be made by any person, including
# but not limited to User, its agents and employees, its customers, or
# any third parties that arise out of or result from the manufacture,
# delivery, actual or alleged ownership, performance, use, operation
# or possession of the software furnished hereunder, whether such claims
# are based on negligence, breach of contract, absolute liability or any
# other legal theory.
# 
# 4.   Notices. User hereby agrees not to remove, alter or destroy any
# copyright, trademark, credits, other proprietary notices or confidential
# legends placed upon, contained within or associated with the Software,
# and shall include all such unaltered copyright, trademark, credits,
# other proprietary notices or confidential legends on or in every copy of
# the Software.
#
TOP = ..

SUBDIRS= osspec

include common.mak

ALL_MODS= hsfosspec.o hsfbasic2.o hsfich.o hsfyukon.o hsfengine.o hsfserial.o

# Build hsfscrdmp debug module?
ifeq ($(IMPORTED_SCR_SUPPORT),yes)
ifeq ($(IMPORTED_DMP_SUPPORT),yes)
ALL_MODS+= hsfscrdmp.o
endif
endif

all: $(ALL_MODS)

mod_basic2.o mod_engine.o mod_ich.o mod_yukon.o mod_osspec.o mod_scrdmp.o: CFLAGS += -DEXPORT_SYMTAB

# Remove the following if your OS already has the new serial core
# (expected to be merged one day in linux 2.5)
serial_hsf.o: CFLAGS += -DHSFSERIAL_INCLUDE_CORE

serial_hsf.o: serial_core.c serial_core.h

hsfserial.o: serial_hsf.o
	@echo "> Linking kernel module $@"
	@$(LD) -r -o $@ $^
	@echo ""

hsfengine.o hsfbasic2.o hsfich.o hsfyukon.o: hsf%.o: mod_%.o $(IMPORTED)/hsf%.O
	@echo "> Linking kernel module $@"
	@$(LD) -r -o $@ $^
	@echo ""

OSSPEC_T_OBJS = $(patsubst %.c, %.o, $(wildcard osspec/*.c))

ifneq ($(IMPORTED_SCR_SUPPORT),yes)
OSSPEC_OBJS = $(subst osspec/cdbgscr.o,,$(OSSPEC_T_OBJS))
else
OSSPEC_OBJS = $(OSSPEC_T_OBJS)
endif

hsfosspec.o:: $(SUBDIRS)

hsfosspec.o:: mod_osspec.o $(OSSPEC_OBJS)
	@echo "> Linking kernel module $@"
	@$(LD) -r -o $@ $^
	@echo ""

hsfscrdmp.o:: mod_scrdmp.o $(IMPORTED)/hsfdbgscr.O
	@echo "> Linking kernel module $@"
	@$(LD) -r -o $@ $^
	@echo ""

HSF_MODS_DIR= $(KMODS_DIR)/misc

.PHONY: check_kernelver modules_install minstall
check_kernelver:
	@if [ -z "$(KERNELVER)" ]; then \
		echo 1>&2 "Unable to determine version of kernel source directory $(KERNELSRC)"; false; \
	else \
		true; \
	fi

modules_install: check_kernelver all $(HSF_MODS_DIR)
	rm -f "$(HSF_MODS_DIR)/hsf"*.o
	$(INSTALL) -m 644 $(ALL_MODS) $(HSF_MODS_DIR)

minstall: modules_install

.PHONY: install uninstall
install: uninstall $(HSFMODDIR)
	(cd $(TOP) && find config.mak imported -depth -print | cpio -pdm $(HSFLIBDIR))
	find . \( -name '*.[ch]' -o -name '*.mak' -o -name '[Mm]akefile' \) -print | cpio -pdm $(HSFMODDIR)
	find binaries -depth -print | cpio -pdm $(HSFMODDIR)

$(HSF_MODS_DIR) $(HSFMODDIR):
	$(MKDIR) -p $@

uninstall:
	rm -rf "$(HSFLIBDIR)/config.mak" "$(HSFLIBDIR)/imported" "$(HSFMODDIR)"

