########################################################################
# AtariSIO Makefile
# (c) 2002-2004 by Matthias Reichl <hias@horus.com>
# http://www.horus.com/~hias/atari/
########################################################################

########################################################################
# use kernel 2.6 build system (un-comment if you use kernel 2.6.x)
########################################################################

#USE_KBUILD_26 = 1

########################################################################
# location of your kernel source (header) files
########################################################################

KDIR = /lib/modules/$(shell uname -r)/build
#KDIR = /usr/src/linux
#KDIR = /data/hias/laptop/linux-2.2.19

########################################################################
# installation directory for the kernel module atarisio.o/atarisio.ko
# (lib/modules/$KERNELVERSION/misc)
# please note: some RedHat versions ship with a nonstandard version.h
# file which causes grep to fail in getting the version information.
# In this case, uncomment either the 'uname' line below or set the
# version directory by hand.
########################################################################

VERSION = $(shell grep UTS_RELEASE $(KDIR)/include/linux/version.h | cut -d '"' -f2)
#VERSION = $(shell uname -r)
#VERSION = 2.4.25

MDIR = /lib/modules/$(VERSION)/misc

########################################################################
# installation directory
# The executables will be installed in INST_DIR/bin,
# the header file atarisio.h will be installed in INST_DIR/include,
########################################################################

INST_DIR = /usr/local
#INST_DIR = /usr/local/atarisio
#INST_DIR = /opt/hias

########################################################################
# if you don't have zlib installed on your system, please comment out
# the following two lines. With zlib enabled you will be able to
# directly load and save gzip-compressed image files (eg file.atr.gz)
########################################################################

ZLIB_CXX_FLAGS=-DUSE_ZLIB
ZLIB_LD_FLAGS=-lz

########################################################################
# gcc version to use for compiling the kernel module
# The (major) version number must match the version that was used
# when compiling the linux kernel, otherwise your system may crash!
# To find out which gcc version was used to compile the kernel
# just do a "cat /proc/version"
########################################################################

KERNEL_CC = gcc
#KERNEL_CC = gcc-2.95
#KERNEL_CC = kgcc

########################################################################
# gcc version for compiling the user space apps
# Usually you don't need to change this
########################################################################

CC = gcc
CXX = g++
#CC = gcc-3.0
#CXX = g++-3.0
#CC = /usr/local/gcc-3.2.2/bin/gcc
#CXX = /usr/local/gcc-3.2.2/bin/g++

########################################################################
# don't change anything below here
########################################################################

MODFLAGS = -Wstrict-prototypes -Wall -O2 -DMODULE -D__KERNEL__ -I$(KERNEL_INCLUDES)

CXXFLAGS = -g -W -Wall -DATARISIO_DEBUG $(ZLIB_CXX_FLAGS)
CFLAGS = -g -W -Wall -DATARISIO_DEBUG 
#CXXFLAGS = -O3 -W -Wall $(ZLIB_CXX_FLAGS)
#CFLAGS = -O3 -W -Wall

LDFLAGS =
#LDFLAGS = -static

COMMON_LIBS = $(ZLIB_LD_FLAGS)

export KERNEL_CC MODFLAGS KDIR MDIR USE_KBUILD_26
export CC CXX CFLAGS CXXFLAGS LDFLAGS
export COMMON_LIBS
export INST_DIR

all:
	$(MAKE) -C driver
	$(MAKE) -C tools

clean:
	$(MAKE) -C driver clean
	$(MAKE) -C tools clean

backup:
	tar zcf bak/SIO-`date '+%y%m%d-%H%M'`.tgz \
	driver/*.c driver/*.h driver/Makefile \
	tools/*.c tools/*.h tools/*.cpp tools/*.src tools/Makefile tools/.depend \
	Makefile modutils* Changelog README* INSTALL* LICENSE

install:
	$(MAKE) -C driver install
	$(MAKE) -C tools install

/dev/atarisio:
	mknod -m 660 /dev/atarisio c 10 240

uninstall:
	$(MAKE) -C driver uninstall
	$(MAKE) -C tools uninstall
	rm -f /dev/atarisio

dep:
	$(MAKE) -C driver dep
	$(MAKE) -C tools dep

