#
# Makefile.in for UAE
#


CC        = arm-linux-gnueabi-gcc
WRC       = not-found
CPP       = arm-linux-gnueabi-gcc -E
LDFLAGS   = -Wl,-z,defs -L.
CFLAGS    = -O2 -fomit-frame-pointer  -Wall -Wno-unused -Wno-format -W -Wmissing-prototypes -Wstrict-prototypes   -DUSING_GTK_GUI -I/home/smoku/Projects/uae-m/src/gui-gtk -DREGPARAM= -DUSE_ZFILE -DSUPPORT_THREADS -D_REENTRANT -D__inline__=inline \
		-DSYSTEM_ROMDIR=\"$(datadir)/uae/roms\" \
		-DSYSTEM_CFGDIR=\"$(datadir)/uae/configs\"
X_CFLAGS  =  -DMAEMO_CHANGES -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12   -DSHM_SUPPORT_LINKS=1
TARGET    = x11
LIBRARIES =   -lSM -lICE -lXext -lX11   -lasound -lpthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0  
MATHLIB   = -lm
RESOBJS   = 

NO_SCHED_CFLAGS = 

INSTALL         = /scratchbox/tools/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA    = ${INSTALL} -m 644
prefix          = /usr
datarootdir     = ${prefix}/share
datadir         = ${datarootdir}
exec_prefix     = ${prefix}
bindir          = ${exec_prefix}/bin
libdir          = ${exec_prefix}/lib
sysconfdir      = ${prefix}/etc

VPATH = ../src

.SUFFIXES: .o .c .h .m .i .S .rc .res

#.SECONDARY: cpuemu.c cpustbl.c cputbl.h

INCLUDES=-I. -I../src/include/

OBJS =  main.o newcpu.o memory.o cpuemu.o custom.o cia.o serial.o blitter.o \
	autoconf.o ersatz.o filesys.o hardfile.o keybuf.o expansion.o zfile.o \
	fpp.o readcpu.o cpudefs.o gfxutil.o traps.o blitfunc.o blittable.o \
	gayle.o rommgr.o disk.o audio.o drawing.o cpustbl.o inputdevice.o \
	uaelib.o picasso96.o uaeexe.o bsdsocket.o bsdsocket-posix-new.o \
	missing.o \
	sd-sound.o od-joy.o md-support.o \
	fsusage.o cfgfile.o native2amiga.o fsdb.o identify.o timemgr.o crc32.o \
	savestate.o writelog.o \
	hotkeys.o keymap/keymap.o keymap/x11pc_rawkeys.o \
	sinctable.o \
	 xwin.o x11keys.o  guidep/gtkui.o guidep/util.o debug.o scsi-none.o fsdb_unix.o


all: $(TARGET)

x11: progs

svgalib: progs

win32: progs $(RESOBJS)
	$(WRC) $(RESOBJS) uae.exe

ggilib: progs

asciiart: progs

amigaos: progs

p_os: progs

beos: progs

next: progs
	cp uae ../Uae.app/Uae

progs: uae readdisk

install:

readdisk: readdisk.o missing.o
	$(CC) readdisk.o missing.o -o readdisk $(LDFLAGS) $(DEBUGFLAGS)

uae: $(OBJS)
	$(CC) $(OBJS) -o uae $(GFXLDFLAGS) $(LDFLAGS) $(DEBUGFLAGS) $(LIBRARIES) $(MATHLIB)

clean:
	$(MAKE) -C tools clean
	-rm -f $(OBJS) *.o uae readdisk
	-rm -f blit.h cpudefs.c
	-rm -f cpuemu.c build68k cputmp.s cpustbl.c cputbl.h
	-rm -f blitfunc.c blitfunc.h blittable.c

halfclean:
	-rm -f $(OBJS)

streifenfrei: clean
	$(MAKE) -C tools streifenfrei
	-rm -f Makefile sysconfig.h
	-rm -f od-joy.c md-X86.S sd-sound.c md-support.c
	-rm -f machdep osdep threaddep sounddep target.h
	-rm -f md-fpp.h

blit.h: tools/genblitter
	./tools/genblitter i >blit.h
blitfunc.c: tools/genblitter blitfunc.h
	./tools/genblitter f >blitfunc.c
blitfunc.h: tools/genblitter
	./tools/genblitter h >blitfunc.h
blittable.c: tools/genblitter blitfunc.h
	./tools/genblitter t >blittable.c

tools/genblitter:
	$(MAKE) -C tools genblitter
tools/build68k:
	$(MAKE) -C tools build68kc
tools/gencpu: 
	$(MAKE) -C tools gencpu

custom.o: blit.h
drawing.o: linetoscr.c

cpudefs.c: tools/build68k ../src/table68k
	./tools/build68k <../src/table68k >cpudefs.c

cpuemu.c: tools/gencpu
	./tools/gencpu

# gencpu also creates cpustbl.c and cputbl.h
cpustbl.c: cpuemu.c
cputbl.h: cpuemu.c

console_missing.o: missing.c
	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $(CFLAGS_$@) $< -o $@

osdep/beos.o: osdep/beos.cpp
	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) osdep/beos.cpp -o osdep/beos.o

.rc.res:
	$(WRC) $(INCLUDES) $<
.m.o:
	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $<
.c.o:
	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $(CFLAGS_$@) $< -o $@
.c.s:
	$(CC) $(INCLUDES) -S $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
.c.i:
	$(CC) $(INCLUDES) -E $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< > $@
.S.o:
	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
.s.o:
	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@

# Saves recompiling...
touch:
	touch *.o; touch build68k; touch cpudefs.c; touch cpudefs.o; touch gencpu; touch cpuemu.c; touch cpuemu.o

build68k.o: include/readcpu.h
readcpu.o: include/readcpu.h

cia.o: include/events.h
custom.o: include/events.h blit.h
newcpu.o: include/events.h
audio.o: include/events.h
disk.o: include/events.h
blitter.o: include/events.h blit.h

# sam: this is for people with low memory. (is there a way do do this with a single rule ?)
cpuemu1.o: cpuemu.c
	$(CC) -DPART_1 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
cpuemu2.o: cpuemu.c
	$(CC) -DPART_2 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
cpuemu3.o: cpuemu.c
	$(CC) -DPART_3 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
cpuemu4.o: cpuemu.c
	$(CC) -DPART_4 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
cpuemu5.o: cpuemu.c
	$(CC) -DPART_5 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
cpuemu6.o: cpuemu.c
	$(CC) -DPART_6 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
cpuemu7.o: cpuemu.c
	$(CC) -DPART_7 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
cpuemu8.o: cpuemu.c
	$(CC) -DPART_8 $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $< -o $@
