#
# Makefile for YAE
# (C) 1997-2007 Doug Kwan.
#

# usual stuff

# C compiler
CC=gcc

CFLAGS=-g -O2
LDFLAGS=

# FIXME: need to figure out right way of doing this
LIBS= -lXext -lX11

X_CFLAGS= -I/usr/X11R6/include
X_LIBS= -L/usr/X11R6/lib
X_EXTRA_LIBS=
X_PRE_LIBS= -lSM -lICE

DEFS=-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_FCNTL_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DTIME_WITH_SYS_TIME=1 -DRETSIGTYPE=void -DHAVE_GETTIMEOFDAY=1 -DHAVE_SELECT=1 -DHAVE_STRDUP=1 -DHAVE_SNPRINTF=1 

OBJS= main.o 6502.o x_window.o memory.o mm.o loadrom.o \
   disk2.o gcr.o sound.o vbl.o fonts.o mousetext.o ucron.o \
   keyboard.o paddle.o speed.o iou.o memmap.o \
   screen.o scanline8.o scanline16.o scanline32.o \
   colour.o shm.o mouse.o emutrap.o confile.o

TAR_FILES= 6502.c 6502.h ChangeLog Makefile.in Readme.wkt colour.c \
	config.guess config.status config.sub configure configure.in \
	confile.c disk2.c emutrap.c fonts fonts.c gcr.c hardware.h install-sh \
	iou.c iou.h keyboard.c loadrom.c main.c memmap.c memory.c memory.h \
	mm.c mouse.c mousetext mousetext.c paddle.c scanline16.c scanline32.c \
	scanline8.c screen.c shm.c sound.c speed.c ucron.c vbl.c video.h \
	x_window.c x_window.h yae.h

COMPILE=$(CC) $(X_CFLAGS) $(CFLAGS) $(DEFS)

apple2: $(OBJS) 
	$(COMPILE) -o apple2 $(OBJS) $(LDFLAGS) $(X_LIBS) $(X_PRE_LIBS) \
		$(LIBS) $(X_EXTRA_LIBS)

clean:
	rm -f apple2 core $(OBJS)

#Building modules from source:

.c.o:
	$(COMPILE) -c $<

yae.tar:
	tar -cf yae.tar $(TAR_FILES)

#
# FIXME: need to add a make depend rule
# instead of this
#

6502.o: 6502.c hardware.h 6502.h memory.h
colour.o: colour.c
disk2.o: disk2.c hardware.h yae.h
emutrap.o: emutrap.c hardware.h 6502.h
fonts.o: fonts.c hardware.h x_window.h fonts/char00.bmp \
 fonts/char01.bmp fonts/char02.bmp fonts/char03.bmp fonts/char04.bmp \
 fonts/char05.bmp fonts/char06.bmp fonts/char07.bmp fonts/char08.bmp \
 fonts/char09.bmp fonts/char0a.bmp fonts/char0b.bmp fonts/char0c.bmp \
 fonts/char0d.bmp fonts/char0e.bmp fonts/char0f.bmp fonts/char10.bmp \
 fonts/char11.bmp fonts/char12.bmp fonts/char13.bmp fonts/char14.bmp \
 fonts/char15.bmp fonts/char16.bmp fonts/char17.bmp fonts/char18.bmp \
 fonts/char19.bmp fonts/char1a.bmp fonts/char1b.bmp fonts/char1c.bmp \
 fonts/char1d.bmp fonts/char1e.bmp fonts/char1f.bmp fonts/char20.bmp \
 fonts/char21.bmp fonts/char22.bmp fonts/char23.bmp fonts/char24.bmp \
 fonts/char25.bmp fonts/char26.bmp fonts/char27.bmp fonts/char28.bmp \
 fonts/char29.bmp fonts/char2a.bmp fonts/char2b.bmp fonts/char2c.bmp \
 fonts/char2d.bmp fonts/char2e.bmp fonts/char2f.bmp fonts/char30.bmp \
 fonts/char31.bmp fonts/char32.bmp fonts/char33.bmp fonts/char34.bmp \
 fonts/char35.bmp fonts/char36.bmp fonts/char37.bmp fonts/char38.bmp \
 fonts/char39.bmp fonts/char3a.bmp fonts/char3b.bmp fonts/char3c.bmp \
 fonts/char3d.bmp fonts/char3e.bmp fonts/char3f.bmp fonts/char40.bmp \
 fonts/char41.bmp fonts/char42.bmp fonts/char43.bmp fonts/char44.bmp \
 fonts/char45.bmp fonts/char46.bmp fonts/char47.bmp fonts/char48.bmp \
 fonts/char49.bmp fonts/char4a.bmp fonts/char4b.bmp fonts/char4c.bmp \
 fonts/char4d.bmp fonts/char4e.bmp fonts/char4f.bmp fonts/char50.bmp \
 fonts/char51.bmp fonts/char52.bmp fonts/char53.bmp fonts/char54.bmp \
 fonts/char55.bmp fonts/char56.bmp fonts/char57.bmp fonts/char58.bmp \
 fonts/char59.bmp fonts/char5a.bmp fonts/char5b.bmp fonts/char5c.bmp \
 fonts/char5d.bmp fonts/char5e.bmp fonts/char5f.bmp
gcr.o: gcr.c hardware.h yae.h
iou.o: iou.c hardware.h memory.h iou.h yae.h
keyboard.o: keyboard.c hardware.h yae.h
loadrom.o: loadrom.c hardware.h memory.h yae.h
main.o: main.c hardware.h memory.h 6502.h yae.h
memmap.o: memmap.c hardware.h memory.h iou.h
memory.o: memory.c hardware.h memory.h iou.h yae.h
mm.o: mm.c hardware.h memory.h 6502.h
mouse.o: mouse.c hardware.h memory.h yae.h 6502.h
mousetext.o: mousetext.c mousetext/mtchar40.bmp mousetext/mtchar41.bmp \
 mousetext/mtchar42.bmp mousetext/mtchar43.bmp mousetext/mtchar44.bmp \
 mousetext/mtchar45.bmp mousetext/mtchar46.bmp mousetext/mtchar47.bmp \
 mousetext/mtchar48.bmp mousetext/mtchar49.bmp mousetext/mtchar4A.bmp \
 mousetext/mtchar4B.bmp mousetext/mtchar4C.bmp mousetext/mtchar4D.bmp \
 mousetext/mtchar4E.bmp mousetext/mtchar4F.bmp mousetext/mtchar50.bmp \
 mousetext/mtchar51.bmp mousetext/mtchar52.bmp mousetext/mtchar53.bmp \
 mousetext/mtchar54.bmp mousetext/mtchar55.bmp mousetext/mtchar56.bmp \
 mousetext/mtchar57.bmp mousetext/mtchar58.bmp mousetext/mtchar59.bmp \
 mousetext/mtchar5A.bmp mousetext/mtchar5B.bmp mousetext/mtchar5C.bmp \
 mousetext/mtchar5D.bmp mousetext/mtchar5E.bmp mousetext/mtchar5F.bmp \
 mousetext/runningman0.bmp mousetext/runningman1.bmp
paddle.o: paddle.c hardware.h yae.h
scanline8.o: scanline8.c memory.h hardware.h video.h
scanline16.o: scanline16.c memory.h hardware.h video.h
scanline32.o: scanline32.c memory.h hardware.h video.h
screen.o: screen.c hardware.h memory.h video.h iou.h yae.h
shm.o: shm.c hardware.h
sound.o: sound.c hardware.h yae.h
speed.o: speed.c hardware.h yae.h
ucron.o: ucron.c hardware.h 6502.h yae.h
vbl.o: vbl.c hardware.h yae.h
x_window.o: x_window.c hardware.h x_window.h 6502.h yae.h
