# NOTE: chuck_win32.h and chuck_win32.c come from the output of
# chuck.lex and chuck.y
#
# > flex -ochuck.yy.c chuck.lex
# > bison -dv -b chuck chuck.y
#
# to create the chuck_win32 files:
#
# > cat chuck.tab.c chuck.yy.c > chuck_win32.c
# > cp chuck.tab.h chuck_win32.h
#
# ALSO: we are actually now building in 64-bit, but yeah.

MSBUILD=msbuild.exe
RTAUDIODIR=rtaudio

ifneq (,$(CHUCK_DEBUG))
CONFIG=Debug
CHUCK_BIN=Debug/chuck.exe
else
CONFIG=Release
CHUCK_BIN=Release/chuck.exe
endif

CSRCS+= chuck_win32.c util_math.c util_network.c util_raw.c \
	util_xforms.c
CXXSRCS+= chuck_absyn.cpp chuck_parse.cpp chuck_errmsg.cpp \
	chuck_frame.cpp chuck_symbol.cpp chuck_table.cpp chuck_utils.cpp \
	chuck_vm.cpp chuck_instr.cpp chuck_scan.cpp chuck_type.cpp chuck_emit.cpp \
	chuck_compile.cpp chuck_dl.cpp chuck_oo.cpp chuck_lang.cpp chuck_ugen.cpp \
	chuck_otf.cpp chuck_stats.cpp chuck_shell.cpp \
	chuck_io.cpp chuck_carrier.cpp chuck.cpp \
    hidio_sdl.cpp \
	midiio_rtmidi.cpp rtmidi.cpp ugen_osc.cpp ugen_filter.cpp \
	ugen_stk.cpp ugen_xxx.cpp ulib_machine.cpp ulib_math.cpp ulib_std.cpp \
	ulib_opsc.cpp util_buffers.cpp util_console.cpp \
	util_string.cpp util_thread.cpp util_opsc.cpp util_serial.cpp \
	util_hid.cpp uana_xform.cpp uana_extract.cpp
CXXINC_HOST+= -I${RTAUDIODIR} -I${RTAUDIODIR}/include
CXXSRCS_HOST+= chuck_main.cpp chuck_audio.cpp chuck_console.cpp ../${RTAUDIODIR}/RtAudio.cpp
LO_CSRCS+= lo/address.c lo/blob.c lo/bundle.c lo/message.c lo/method.c \
    lo/pattern_match.c lo/send.c lo/server.c lo/server_thread.c lo/timetag.c

CSRCS:=$(addprefix core/,$(CSRCS))
CXXSRCS:=$(addprefix core/,$(CXXSRCS))
CXXSRCS_HOST:=$(addprefix host/,$(CXXSRCS_HOST))
LO_CSRCS:=$(addprefix core/,$(LO_CSRCS))

CXXOBJS_HOST=$(addprefix $(HOSTDIR)/,$(CXXSRCS_HOST:.cpp=.o))

COBJS=$(COBJS_HOST) $(addprefix $(COREDIR)/,$(COBJS_CORE))
CXXOBJS=$(CXXOBJS_HOST) $(addprefix $(COREDIR)/,$(CXXOBJS_CORE))
LO_COBJS=$(addprefix $(COREDIR)/,$(LO_COBJS_CORE))
SF_COBJS=$(addprefix $(COREDIR)/,$(SF_CSRCS:.c=.o))
OBJS=$(COBJS) $(CXXOBJS) $(LO_COBJS) $(SF_COBJS)
SRCS=$(CSRCS) $(CXXSRCS) $(CXXSRCS_HOST) $(LO_CSRCS)

$(CHUCK_BIN): $(SRCS)
	$(MSBUILD) visual-studio/chuck.sln /p:Configuration=$(CONFIG) 

clean:
	$(MSBUILD) visual-studio/chuck.sln /p:Configuration=$(CONFIG) /t:Clean

