# This is a makefile for the Unix/X version of fMSX, the portable
# MSX/MSX2/MSX2+ emulator. Following #defines can be customized:
#
# UNIX      - Should always be present in the Unix version.
# MSDOS     - Should always be present in the MSDOS version.
# WINDOWS   - Should always be present in the Windows version.
# LSB_FIRST - Use this if your CPU has least-significant-byte-first
#             architecture (Intel 80x86, Alpha, etc.).
# DEBUG     - Define this option if you have a little runtime
#             debugger to be compiled into the emulator. It
#             slows down the emulation though.
# MITSHM    - Put this if you are going to use MIT Shared Memory
#             Extensions for XWindows. Using them greatly speeds
#             up screen updates, although they can't be used on
#             remote X-terminals. Note that MITSHM can always
#             be disabled from the command line using -noshm
#             option. 
# BPP8      - Compile for 8bit X-terminals.
# BPP16     - Compile for 16bit X-terminals.
# BPP32     - Compile for 32bit X-terminals.
# DISK      - Use this option to enable builtin disk drive emulation
#             using disk image files.
# NARROW    - Use this option to enable standard SCREEN 6,7,TXT80
#             drivers shrinking picture to fit 256x212 window. When this
#             option is absent, you have to write drivers for these
#             screens yourself. fMSX will not compile without them.
# SOUND     - Use this option if you have /dev/dsp [present in
#             Linux and FreeBSD] or /dev/audio [SunOS and Solaris]
#             and would like to have sound.
# SUN_AUDIO - Define this if you are compiling sound support via
#             SunOS-compatible /dev/audio.
# ZLIB      - Use this when compiling emulator with ZLib, a library
#             for transparent access to GZIPped files. When compiled
#             with ZLib, emulator will be able to load ROM images
#             compressed with GZIP or PKZIP. It will also save and
#             load GZIPped state files.
# GIFLIB    - Use this under MSDOS, when compiling emulator with
#             GIFLib, a library for reading/writing .GIF files.
#             When compiled with GIFLib, emulator will be able
#             to make screen snapshots.

# These are the compiler name, #defines, and the flags used to
# build fMSX. Always set flags for the highest possible speed
# optimization. For GCC compiler, it will be
#
#        -O3 -fomit-frame-pointer
#
# If you are getting errors about not found X11 header files,
# change the -I/usr/X11R6/include to the directory where X11
# headers are located on your system.
# If you are getting linker errors about not found X11 functions,
# change the -L/usr/X11R6/lib to the directory where X11
# libraries libX11.* and libXext.* are located on your system.
CC      = gcc
DEFINES = -DFMSX -DUNIX -DLSB_FIRST -DDEBUG -DMITSHM \
          -DDISK -DNARROW -DSOUND -DBPP16 -DZLIB
CFLAGS  = -O3 -Wall -I/usr/X11R6/include -L/usr/X11R6/lib ${DEFINES}
OBJECTS = fMSX.o MSX.o Patch.o Debug.o Disk.o Floppy.o Sound.o \
	  Z80.o I8255.o AY8910.o YM2413.o SCC.o V9938.o I8251.o \
	  Unix.o LibUnix.o SndUnix.o 

# Make the standard distribution: fMSX and contributed utilities.
all:	fmsx contrib

# Two little utilities to export/import files from .DSK disk images,
# written by Arnold Metselaar.
contrib:rddsk.c wrdsk.c DiskUtil.h Boot.h
	${CC} -o rddsk rddsk.c
	${CC} -o wrdsk wrdsk.c

# fMSX Unix/X requires X11 libraries. See note above if you are
# experiencing any problems.
fmsx:	${OBJECTS}
	${CC} ${CFLAGS} -o fmsx ${OBJECTS} -lXext -lX11 -lz

# Clean up.
clean:
	rm -f *.o fmsx rddsk wrdsk

# Dependencies for the object files.
fMSX.o:		fMSX.c MSX.h Z80.h Help.h
MSX.o:		MSX.c MSX.h Z80.h V9938.h I8255.h AY8910.h YM2413.h I8251.h SCC.h Sound.h
Z80.o:		Z80.c Z80.h Codes.h CodesED.h CodesCB.h CodesXX.h Tables.h CodesXCB.h
V9938.o:	V9938.c V9938.h MSX.h Z80.h
I8255.o:	I8255.c I8255.h
AY8910.o:	AY8910.c AY8910.h Sound.h
YM2413.o:	YM2413.c YM2413.h Sound.h
SCC.o:		SCC.c SCC.h Sound.h
I8251.o:	I8251.c I8251.h
Disk.o:		Disk.c Floppy.h MSX.h Z80.h
Patch.o:	Patch.c Boot.h MSX.h Z80.h
Floppy.o:	Floppy.c Floppy.h
Debug.o:	Debug.c Z80.h
Unix.o:		Unix.c LibUnix.h Sound.h MSX.h Z80.h Common.h
LibUnix.o:	LibUnix.c LibUnix.h
SndUnix.o:	SndUnix.c Sound.h
Sound.o:	Sound.c Sound.h MIDIFreq.h
