CC := gcc
CFLAGS= -W -Wall
DEBUG=n

ifeq ($(DEBUG),y)
  CFLAGS := $(CFLAGS) -DDEBUG
endif

ifndef ($(BIN_INSTALL_PATH))
	BIN_INSTALL_PATH=/usr/local/bin
endif

ifndef ($(DSP_INSTALL_PATH))
	DSP_INSTALL_PATH=/usr/local/shared/emu10k1
endif

ifndef ($(MAN_INSTALL_PATH))
        MAN_INSTALL_PATH=/usr/local/man/man1
endif


all: dep as10k1 dsp

dep:
	$(CC) -M *.c $(CFLAGS) > .depend

-include .depend

as10k1: as10k1.o parse.o assemble.o macro.o


install: all
	mkdir -p $(DSP_INSTALL_PATH)
	install -m 664 *.bin $(DSP_INSTALL_PATH)
	install -m 755 as10k1 $(BIN_INSTALL_PATH)
	install -m 664 as10k1.1 $(MAN_INSTALL_PATH)
clean:
	rm -f *.o *~ as10k1 core .depend
	rm -f *.o *~ as10k1 core .depend *.bin

dsp: as10k1 chorus.bin delay.bin eq2.bin eq5.bin flanger.bin tremolo.bin vibrato.bin vol_ctrl.bin 

chorus.bin: chorus.asm emu_constants.asm
	./as10k1  chorus.asm
flanger.bin: flanger.asm emu_constants.asm
	./as10k1  flanger.asm
delay.bin: delay.asm  emu_constants.asm
	./as10k1  delay.asm 
eq2.bin: eq2.asm  emu_constants.asm
	./as10k1  eq2.asm
eq5.bin: eq5.asm  emu_constants.asm
	./as10k1  eq5.asm
tremolo.bin:tremolo.asm emu_constants.asm
	./as10k1  tremolo.asm
vibrato.bin:vibrato.asm emu_constants.asm
	./as10k1  vibrato.asm
vol_ctrl.bin: vol_ctrl.asm emu_constants.asm
	./as10k1  vol_ctrl.asm 
