## Process this file with autoconf to produce Makefile

objects = main.o tools.o screen.o files.o changehw.o menus.o commands.o linkset.o core.o x7_subcore.o xp_subcore.o xs_subcore.o x4_subcore.o xz_subcore.o x2_subcore.o x3_subcore.o x5_subcore.o x6_subcore.o link.o io.o inter.o outils.o debug.o dasm.o symbols.o keypad.o

CC = @CC@
INSTALL = @INSTALL@
CFLAGS = @CFLAGS@ @TICABLES_CFLAGS@ @GLIB_CFLAGS@ @GTK_CFLAGS@
CPPFLAGS = @CPPFLAGS@ -I..
LDFLAGS = @LDFLAGS@ @TICABLES_LIBS@ @GLIB_LIBS@ @GTK_LIBS@

prefix = $(DESTDIR)@prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@

elinklib = @TICABLES_LIBS@
elink = @TICABLES_CFLAGS@

# debug = true

# ifdef debug
extraflags = $(CFLAGS) $(CPPFLAGS) -g -pedantic
coreflags = $(CFLAGS) $(CPPFLAGS) -g -O2 -DTRACE -pedantic
# else
# extraflags = $(CFLAGS) $(CPPFLAGS) -O2
# coreflags = $(CFLAGS) $(CPPFLAGS) -O3 -DTRACE
# endif

gtkc = @GTK_CFLAGS@ @GLIB_CFLAGS@ @GTHREAD_CFLAGS@
gtklib = @GTK_LIBS@ @GLIB_LIBS@ @GTHREAD_LIBS@ @IMLIB_LIBS@
imc = @IMLIB_CFLAGS@

all: tilem

tilem:	$(objects)
	$(CC) $(extraflags) $(LDFLAGS) $(objects) -o tilem $(gtklib) $(elinklib) 

inter.o: core/dep/inter.c core/dep/inter.h core/dep/shared.c core/dep/rom.c
	$(CC) $(extraflags) -c core/dep/inter.c $(gtkc)

io.o: io.c io.h
	$(CC) $(extraflags) -c io.c $(gtkc)

main.o:	main.c main.h
	$(CC) $(extraflags) -c main.c $(gtkc) $(imc) $(elink)

tools.o: tools.c tools.h
	$(CC) $(extraflags) -c tools.c -DSHARE_DIR=\"$(datadir)\" $(gtkc) $(imc)

screen.o: gui/screen.c gui/screen.h gui/files.h gui/commands.h gui/changehw.h gui/linkset.h
	$(CC) $(extraflags) -c gui/screen.c $(gtkc) $(elink)

files.o: gui/files.c gui/files.h
	$(CC) $(extraflags) -c gui/files.c $(gtkc)

changehw.o: gui/changehw.c gui/changehw.h main.h
	$(CC) $(extraflags) -c gui/changehw.c $(gtkc)

commands.o: gui/commands.c gui/commands.h
	$(CC) $(extraflags) -c gui/commands.c $(gtkc)

menus.o: gui/menus.c gui/menus.h
	$(CC) $(extraflags) -c gui/menus.c $(gtkc)

linkset.o: gui/linkset.c gui/linkset.h main.h
	$(CC) $(extraflags) -c gui/linkset.c $(gtkc) $(elink)

debug.o: gui/debug.c
	$(CC) $(extraflags) -c gui/debug.c $(gtkc)

dasm.o: dasm.c
	$(CC) $(extraflags) -c dasm.c $(gtkc)

symbols.o: symbols.c symbols.h
	$(CC) $(extraflags) -c symbols.c $(gtkc)

keypad.o: keypad.c keypad.h
	$(CC) $(extraflags) -c keypad.c $(gtkc)

outils.o: gui/outils.c gui/outils.h
	$(CC) $(extraflags) -c gui/outils.c $(gtkc) $(imc)

core.o: core/core.c core/core.h core/Z80.c core/Z80.h core/Z80CDx86.h core/Z80Codes.h core/Z80Debug.c core/Z80IO.h core/zints.c core/dep/inter.h symbols.h
	$(CC) $(coreflags) -c core/core.c $(gtkc)

xp_subcore.o:	core/dep/xp/init.c core/dep/xp/internal.c core/dep/xp/io.c core/dep/x3/lcd.c core/dep/xp/loadapp.c core/dep/xp/memory.c core/dep/xp/xp_subcore.c
	$(CC) $(extraflags) -c core/dep/xp/xp_subcore.c $(elink) $(gtkc)

xs_subcore.o:	core/dep/xs/init.c core/dep/xs/internal.c core/dep/xs/io.c core/dep/x3/lcd.c core/dep/xs/loadapp.c core/dep/xs/memory.c core/dep/xs/xs_subcore.c
	$(CC) $(extraflags) -c core/dep/xs/xs_subcore.c $(elink) $(gtkc)

x4_subcore.o:	core/dep/x4/init.c core/dep/x4/internal.c core/dep/x4/io.c core/dep/x3/lcd.c core/dep/x4/loadapp.c core/dep/x4/memory.c core/dep/x4/x4_subcore.c
	$(CC) $(extraflags) -c core/dep/x4/x4_subcore.c $(elink) $(gtkc)

xz_subcore.o:	core/dep/xz/init.c core/dep/xz/internal.c core/dep/xz/io.c core/dep/x3/lcd.c core/dep/xz/loadapp.c core/dep/xz/memory.c core/dep/xz/xz_subcore.c
	$(CC) $(extraflags) -c core/dep/xz/xz_subcore.c $(elink) $(gtkc)

x7_subcore.o:	core/dep/x7/init.c core/dep/x7/internal.c core/dep/x7/io.c core/dep/x3/lcd.c core/dep/x7/loadapp.c core/dep/x7/memory.c core/dep/x7/x7_subcore.c
	$(CC) $(extraflags) -c core/dep/x7/x7_subcore.c $(elink) $(gtkc)

x3_subcore.o:	core/dep/x3/init.c core/dep/x3/internal.c core/dep/x3/io.c core/dep/x3/lcd.c core/dep/x3/memory.c core/dep/x3/x3_subcore.c
	$(CC) $(extraflags) -c core/dep/x3/x3_subcore.c $(elink) $(gtkc)

x2_subcore.o:	core/dep/x2/init.c core/dep/x2/internal.c core/dep/x2/io.c core/dep/x3/lcd.c core/dep/x2/memory.c core/dep/x2/x2_subcore.c
	$(CC) $(extraflags) -c core/dep/x2/x2_subcore.c $(elink) $(gtkc)

x5_subcore.o:	core/dep/x5/init.c core/dep/x5/internal.c core/dep/x5/io.c core/dep/x5/memory.c core/dep/x5/x5_subcore.c
	$(CC) $(extraflags) -c core/dep/x5/x5_subcore.c $(elink) $(gtkc)

x6_subcore.o:	core/dep/x6/init.c core/dep/x6/internal.c core/dep/x6/io.c core/dep/x6/memory.c core/dep/x6/x6_subcore.c
	$(CC) $(extraflags) -c core/dep/x6/x6_subcore.c $(elink) $(gtkc)

link.o:	core/dep/link.c
	$(CC) $(extraflags) -c core/dep/link.c $(elink) $(gtkc)

clean:
	rm -f $(objects)

install:
	$(INSTALL) -o 0 -g 0 -m 755 -d $(bindir)
	$(INSTALL) -o 0 -g 0 -m 711 tilem $(bindir)/

distclean: clean
	@rm -Rf .libs

distdir: clean
	cp -rl core gui ../@PACKAGE@-@VERSION@/src
	find ../@PACKAGE@-@VERSION@/src -name .svn -exec rm -rf "{}" \\; 2>/dev/nul\l
