# Makefile for TNZS-EMU
#
# Note: TOUCH is used here to make header files have their time-stamps
#       updated. This allows a header to depend on another header.

# Compiler flags
#CFLAGS  = -O3 -m486 -Wall -Iinclude
CFLAGS  = -O6 -mpentium -Wall -Iinclude
#CFLAGS  = -g -Iinclude

# Assembler flags
AFLAGS  = -f coff

# Comment this out if you don't want profiling
#PROFILE = -pg

CC      = gcc
MAIN_OBJS = main.o gamelist.o help.o options.o
GUI_OBJS  = gui/gui.o gui/desktop.o gui/gadgets.o gui/log.o
EMU_OBJS  = emu/emu.o emu/cpu.o emu/dip.o emu/palette.o emu/clock.o emu/raze.o
UTIL_OBJS = utils/memdump.o utils/palview.o utils/perfmon.o
SND_OBJS  = audio/ym2203.o audio/fm.o audio/psg.o
DRV_OBJS  = drivers/tnzs.o
OBJS    = $(MAIN_OBJS) $(GUI_OBJS) $(EMU_OBJS) $(UTIL_OBJS) $(DRV_OBJS) $(SND_OBJS)
LIBS    = -lalleg
PROG    = main.exe

all: $(PROG)

####### Main section #######

$(PROG): $(OBJS) 
	$(CC) $(OBJS) $(PROFILE) -o $(PROG) $(LIBS)

$(MAIN_OBJS): include/nz.h include/gui.h include/emu.h

include/nz.h: include/gui.h include/emu.h
	touch $@

####### GUI section #######

$(GUI_OBJS): include/gui.h

include/gui.h: include/data.h
	touch $@

####### EMU section #######

emu/emu.o: include/gui.h include/emu.h include/cpu.h
emu/cpu.o: include/gui.h include/emu.h include/cpu.h
emu/dip.o: include/gui.h include/emu.h include/dip.h

include/emu.h: include/gui.h include/cpu.h
	touch $@

include/cpu.h: include/raze.h
	touch $@

####### UTIL section #######

$(GUI_OBJS): include/gui.h include/emu.h

####### Drivers section #######

$(DRV_OBJS): include/gui.h include/emu.h include/data.h include/soundhw.h

####### Audio section #######

$(SND_OBJS): include/gui.h include/emu.h include/soundhw.h
audio/fm.c:  include/emu.h include/fm.h
audio/psg.c: include/emu.h include/psg.h

