#
# Pablo System: Visual/Src/Audio/Build/SPARCServer/Makefile
#
.PHONY : Makefile ../Makefile.common

# my_port is the unique port name which identifies this particular server
MY_PORT := \"sparcaudio\"

# SAMPLE_LIBRARY is the directory of the sample library which holds
# instrument samples, voices, etc.
SAMPLE_LIBRARY = \"$(SOUNDDIR)/Sample-Libraries\"

EXECUTABLE := sparcaudiod

DEVICEDEFAULTS := SparcDeviceDefaults.config
DEVICEPARAMS   := SparcDeviceParameters.tab
MESSAGECONFIG  := SPARCMessageConfiguration.config
SERVERDEVICECLASS := SPARCSoundDevice

AUDIO_TOP := ../..
#
# In setting the local definitions, be careful to use the recursive form
# (VAR = VALUE) for all variables that depend on information from the 
# confguration file Makefile.defines in their definition because that isn't
# include until later (by ../Makefile.common).
#

INCLUDES     = -I. \
	       -I$(AUDIO_TOP)/Includes \
	       -I$(AUDIO_TOP)/SPARCServer \
	       -I$(SPARC_DEMO_SOUND)

SRCDIRS     := . \
	       $(AUDIO_TOP)/Shared \
	       $(AUDIO_TOP)/CommonClasses \
	       $(AUDIO_TOP)/SPARCServer

LOCAL_FLAGS  = -DMY_PORT=$(MY_PORT) \
	       -DROOT=\"$(SOUNDLIBDIR)\" \
	       -DSAMPLE_LIBRARY=$(SAMPLE_LIBRARY)

COMMON_OBJS := $(addprefix ../CommonObjs/,$(shell cat ../CommonObjs/CommonObjs))

OBJECTS     := SparcAudioHardware.o \
	       Oscil.o \
	       Samples.o \
	       WaveTable.o \
	       conversion.o \
	       SPARCSoundDevice.o \
	       Message.o \
	       MessageList.o \
	       HardwareServer.o \
	       InitMessageList.o	

TARGET	    := $(EXECUTABLE)

include ../Makefile.common

#
# Targets
#
.PHONY : install

$(EXECUTABLE): $(OBJECTS) $(COMMON_OBJS)
	$(C++) $(C++FLAGS) $(CNFG_C++LDFLAGS) -o $@ $(OBJECTS) $(COMMON_OBJS) \
		-L$(SPARC_DEMO_SOUND) -laudio -lm

$(COMMON_OBJS):
	$(MAKE) -C ../CommonObjs

install:  $(EXECUTABLE)
	$(MAKEDIRHIER) $(SOUNDLIBDIR)
	install -s -m 0755 $(EXECUTABLE) $(SOUNDLIBDIR)
	install -m 0644 $(DEVICEPARAMS) $(SOUNDLIBDIR)
	install -m 0644 $(DEVICEDEFAULTS).tab $(SOUNDLIBDIR)
	install -m 0644 $(MESSAGECONFIG) $(SOUNDLIBDIR)
	install -m 0644 SparcInstruments $(SOUNDLIBDIR)
	install -m 0644 SparcOutputs $(SOUNDLIBDIR)
	install -m 0644 Voices $(SOUNDLIBDIR)
	install -m 0644 SampleFileMenu $(SOUNDLIBDIR)
	@echo "**** NOTE!! You must install the sample library "
	@echo "**** ../../Sample-Libraries someplace with 15M free, and "
	@echo "**** make sure that " $(SAMPLE_LIBRARY) "is a link to it."

InitMessageList.C: $(DEVICEPARAMS) $(DEVICEDEFAULTS) $(MESSAGECONFIG) 
	rm -f DeviceSpecificDefs.h
	$(PERL) $(AUDIO_TOP)/ConfigureDeviceServer.perl \
	   	$(DEVICEPARAMS) $(DEVICEDEFAULTS) \
		$(MESSAGECONFIG) $(SERVERDEVICECLASS)

