# To compile this with Cygwin on Windows box,
# uncomment line 28 (#define WINDOWS) in h-config.h

# This is a makefile for the Cygwin tools which may
# be downloaded by following the links from the URL:
# http://sources.redhat.com/cygwin/

#
# Standard defines
#

CC = gcc
WRES = windres
# pern
LIBS = -s -mwindows -e _mainCRTStartup -lwinmm
CFLAGS = -Wall -O2 -fno-strength-reduce -DUSE_TRANSPARENCY -DWINDOWS
# ey
# LIBS = -s -mwindows -e _mainCRTStartup -lwinmm
# CFLAGS = -Wall -pedantic -O2 -fno-strength-reduce


SRCS = \
	angband.rc \
	birth.c \
	cave.c \
	cmd-attk.c \
	cmd-book.c \
	cmd-item.c \
	cmd-know.c \
	cmd-misc.c \
	cmd-util.c \
	dungeon.c \
	effects.c \
	files.c \
	generate.c \
	init1.c \
	init2.c \
	info.c \
	load.c \
	main-win.c \
	melee1.c \
	melee2.c \
	monster1.c \
	monster2.c \
	monster3.c \
	object1.c \
	object2.c \
	object3.c \
	powers.c \
	quest.c \
	save.c \
	spells1.c \
	spells2.c \
	squelch.c \
	store.c \
	tables.c \
	traps.c \
	util.c \
	variable.c \
	wizard.c \
	xtra1.c \
	xtra2.c \
	z-form.c \
	z-rand.c \
	z-term.c \
	z-util.c \
	z-virt.c 


EXOBJS = \
	angband.res \
	birth.o \
	cave.o \
	cmd-attk.o \
	cmd-book.o \
	cmd-item.o \
	cmd-know.o \
	cmd-misc.o \
	cmd-util.o \
	dungeon.o \
	effects.o \
	files.o \
	generate.o \
	init1.o \
	init2.o \
	info.o \
	load.o \
	main-win.o \
	melee1.o \
	melee2.o \
	monster1.o \
	monster2.o \
	monster3.o \
	object1.o \
	object2.o \
	object3.o \
	powers.o \
	quest.o \
	save.o \
	spells1.o \
	spells2.o \
	squelch.o \
	store.o \
	tables.o \
	traps.o \
	util.o \
	variable.o \
	wizard.o \
	xtra1.o \
	xtra2.o \
	z-form.o \
	z-rand.o \
	z-term.o \
	z-util.o \
	z-virt.o 


HDRS = \
	h-basic.h \
	h-define.h h-type.h \
	h-system.h h-config.h


INCS = \
	angband.h \
	config.h defines.h \
	types.h externs.h \
	z-term.h z-rand.h \
	z-util.h z-virt.h \
	z-form.h $(HDRS)


#
# Targets
#


default:	mist

install:	mist movebin cleanobjs

# movebin:
#		copy mist.exe ..
#		del mist.exe

movebin:
		mv -f mist.exe ../mist.exe

cleanobjs:
		rm -f $(EXOBJS)

cleanbin:
		rm -f mist.exe

clean:	cleanobjs cleanbin


#
# Dependency rules
#

mist: $(EXOBJS)
	$(CC) -o mist $(EXOBJS) $(LIBS)


#
# Compiling angband.rc
#
# Note: this format seems to work but the alternative actually used
# is the one recommended by Cygnus
#
# angband.res : angband.rc
#	$(WRES) angband.rc angband.res
#

angband.res : angband.rc
	$(WRES) $< -O coff -o $@


#
# Compiling objects
#

birth.o: birth.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

cave.o: cave.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

cmd-attk.o: cmd-attk.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

cmd-book.o: cmd-book.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

cmd-item.o: cmd-item.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

cmd-know.o: cmd-know.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

cmd-misc.o: cmd-misc.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

cmd-util.o: cmd-util.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

dungeon.o: dungeon.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

effects.o: effects.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

files.o: files.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

generate.o: generate.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

init1.o: init1.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

init2.o: init2.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

info.o: info.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

load.o: load.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

main.o: main.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

melee1.o: melee1.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

main-win.o: main-win.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

melee2.o: melee2.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

monster1.o: monster1.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

monster2.o: monster2.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

monster3.o: monster3.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

object1.o: object1.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

object2.o: object2.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

object3.o: object3.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

powers.o: powers.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

quest.o: quest.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

save.o: save.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

spells1.o: spells1.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

spells2.o: spells2.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

squelch.o: squelch.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

store.o: store.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

tables.o: tables.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

traps.o: traps.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

util.o: util.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

variable.o: variable.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

wizard.o: wizard.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

xtra1.o: xtra1.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

xtra2.o: xtra2.c $(INCS)
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

z-form.o: z-form.c $(HDRS) z-form.h z-util.h z-virt.h
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

z-rand.o: z-rand.c $(HDRS) z-rand.h
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

z-term.o: z-term.c $(HDRS) z-term.h z-virt.h
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

z-util.o: z-util.c $(HDRS) z-util.h
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

z-virt.o: z-virt.c $(HDRS) z-virt.h z-util.h
	$(CC) $(CFLAGS) $(INCDIRS) -c -o $@ $<

