# This is a makefile for the Unix/X version of VGB, the portable
# GameBoy emulator. Following #defines can be customized:
#
# UNIX      - Should always be present in the Unix 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.

# These are the compiler name, #defines, and the flags used to  
# build VGB. Always set flags for the highest possible speed   
# optimization. For GCC compiler, it will be
#
#        -O3 -fomit-frame-pointer -funroll-loops
#
# 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	= -DUNIX -DLSB_FIRST -DDEBUG -DMITSHM
CFLAGS	= -O2 -I/usr/X11/include  -L/usr/X11/lib/ ${DEFINES}
OBJECTS	= VGB.o GB.o Z80.o Debug.o Unix.o

# Make the standard distribution: VGB, DASM, and utilities.
all:	vgb dasm gblist contrib

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

# DASM is a little disassembler allowing to do a quick analysis
# of GameBoy binaries.
dasm:	dasm.c
	${CC} -o dasm ${CFLAGS} dasm.c

# GBLIST lists and checks the cartridge files making a nice
# table of them.
gblist:	gblist.c
	${CC} -o gblist ${CFLAGS} gblist.c

# LISTALL and TESTALL are contributed by Pascal Felber
contrib: listall testall
listall: listall.c
	${CC} -o listall ${CFLAGS} listall.c
testall: testall.c
	${CC} -o testall ${CFLAGS} testall.c

# Clean up.
clean:
	rm -f *.o vgb dasm gblist testall listall

# Dependencies for the object files.
VGB.o:  VGB.c GB.h Z80.h Help.h
GB.o:   GB.c GB.h Z80.h
Z80.o:  Z80.c Z80.h Tables.h Codes.h CodesCB.h
Unix.o: Unix.c GB.h Z80.h Common.h
Debug.o: Debug.c GB.h Z80.h
