
CC=gcc-3.3
OBJS=synthlib.o
SYNTHDOBJS=synthd.o emu_opl2.o
LIBS=-lm -lpthread
BINARY=synthd

INCDIR=$(PWD)/inc
INCDIRS=-I$(INCDIR)
LIBDIRS=-L.

CFLAGS=-g -Wall $(INCDIRS)
PWD=$(shell pwd)

EMUINCLUDEFILES=$(INCDIR)/fmopl.h

CFLAGS+=-DDEBUG=1 -DUSE_ALSA=1

default: libsynth.a test synthd

synthd: $(SYNTHDOBJS)
	$(CC) $(SYNTHDOBJS) -o $(BINARY) $(LIBS)

emu_opl2.o: emu_opl2.c $(INCDIR)/fmopl.h
	$(CC) $(CFLAGS) emu_opl2.c -c -o emu_opl2.o

synthd.o: synthd_main.c $(EMUINCLUDEFILES)
	$(CC) $(CFLAGS) synthd_main.c -c -o synthd.o

libsynth.a: synthlib.o
	ar cruv libsynth.a synthlib.o
	ranlib libsynth.a

synthlib.o: synthlib.c $(INCDIR)/synthlib.h
	$(CC) synthlib.c -c -o synthlib.o $(INCDIRS)

test: test.o libsynth.a
	$(CC) test.o -o test $(LIBDIRS) -lsynth

test.o: test.c $(INCDIR)/synthlib.h
	$(CC) test.c -c -o test.o $(INCDIRS)

clean:
	rm -f *.o libsynth.a $(OBJS) $(BINARY) test

.PHONY: clean
