#Uncomment the next line for a debug build
#DEBUG=1

CC=gcc

ifdef DEBUG
CFLAGS=-c -g -W -Wall -O -pedantic
LDFLAGS=-g -mwindows
else
CFLAGS=-c -march=i586 -O3 -ffast-math -fomit-frame-pointer -funroll-loops
LDFLAGS=-s -mwindows
endif

OBJS=in_ym.o ym2612.o sn76496.o ym2151.o resource.o
EXENAME=in_ym.dll

all: $(EXENAME)

$(EXENAME): $(OBJS)
	dllwrap $(LDFLAGS) -o in_ym.dll $(OBJS) -lz

in_ym.o: in_ym.c ym2612.h sn76496.h in_ym.h
	$(CC) $(CFLAGS) in_ym.c

ym2612.o: ym2612.h ym2612.c
	$(CC) $(CFLAGS) ym2612.c

sn76496.o: sn76496.h sn76496.c
	$(CC) $(CFLAGS) sn76496.c

ym2151.o: ym2151.c ym2151.h
	$(CC) $(CFLAGS) ym2151.c

resource.o: resource.h resource.rc afxres.h
	windres -i resource.rc -o resource.o

clean:
	rm -f $(OBJS)

veryclean:
	rm -f $(EXENAME) $(OBJS)