SDKDIR                = `find . | grep 'vstsdk[^/]*\$$'`
VSTDIR                = $(SDKDIR)/source/common

### Generated by Winemaker


SRCDIR                = .
SUBDIRS               =
DLLS                  =
EXES                  = fst.exe



### Common settings

CEXTRA                = `pkg-config --cflags gtk+-2.0` `pkg-config --cflags jack` `pkg-config --cflags jack` `pkg-config --cflags lash-1.0` -DHAVE_LASH
CXXEXTRA              = -mno-cygwin
RCEXTRA               =
INCLUDE_PATH          = -I.
DLL_PATH              =
LIBRARY_PATH          =
LIBRARIES             = `pkg-config --libs gtk+-2.0` `pkg-config --libs jack` `pkg-config --libs alsa` `pkg-config --libs lash-1.0`  -L/usr/X11R6/lib -lX11



### fst.exe sources and settings

fst_exe_MODULE       = fst.exe
fst_exe_C_SRCS       = audiomaster.c \
			fst.c \
			fstinfofile.c \
			gtk.c \
			jfst.c \
			vsti.c \
			vstwin.c
fst_exe_CXX_SRCS     =
fst_exe_RC_SRCS      =
fst_exe_LDFLAGS      = -mwindows
fst_exe_DLL_PATH     =
fst_exe_DLLS         = 
fst_exe_LIBRARY_PATH =
fst_exe_LIBRARIES    = uuid

fst_exe_OBJS         = $(fst_exe_C_SRCS:.c=.o) \
			$(fst_exe_CXX_SRCS:.cpp=.o) \
			$(fst_exe_RC_SRCS:.rc=.res)



### Global source lists

C_SRCS                = $(fst_exe_C_SRCS)
CXX_SRCS              = $(fst_exe_CXX_SRCS)
RC_SRCS               = $(fst_exe_RC_SRCS)


### Tools

CC = winegcc
CXX = wineg++
RC = wrc
WINEBUILD = winebuild


### Generic targets

all: hackheaders $(SUBDIRS) $(DLLS:%=%.so) $(EXES:%=%)

### Build rules

hackheaders:
	cp -a $(VSTDIR) ./vst
	sed -i '/struct VstFileType\|struct VstFileSelect/,/};/d' vst/aeffectx.h

distclean:clean
	test -n $(SDKDIR) && $(RM) -rf $(SDKDIR)

.PHONY: all clean dummy

$(SUBDIRS): dummy
	@cd $@ && $(MAKE)

# Implicit rules

.SUFFIXES: .cpp .rc .res
DEFINCL = $(INCLUDE_PATH) $(DEFINES) $(OPTIONS)

.c.o:
	$(CC) -c $(CFLAGS) $(CEXTRA) $(DEFINCL) -o $@ $<

.cpp.o:
	$(CXX) -c $(CXXFLAGS) $(CXXEXTRA) $(DEFINCL) -o $@ $<

.cxx.o:
	$(CXX) -c $(CXXFLAGS) $(CXXEXTRA) $(DEFINCL) -o $@ $<

.rc.res:
	$(RC) $(RCFLAGS) $(RCEXTRA) $(DEFINCL) -fo$@ $<

# Rules for cleaning

CLEAN_FILES     = *.dbg.c y.tab.c y.tab.h lex.yy.c \
                  core *.orig *.rej \
                  \\\#*\\\# *~ *% .\\\#*

clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
	$(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(C_SRCS:.c=.o) $(CXX_SRCS:.cpp=.o)
	$(RM) $(DLLS:%=%.dbg.o) $(DLLS:%=%.so)
	$(RM) $(EXES:%=%.dbg.o) $(EXES:%=%.so) $(EXES:%.exe=%)
	$(RM) -rf ./vst

$(SUBDIRS:%=%/__clean__): dummy
	cd `dirname $@` && $(MAKE) clean

$(EXTRASUBDIRS:%=%/__clean__): dummy
	-cd `dirname $@` && $(RM) $(CLEAN_FILES)

### Target specific build rules
DEFLIB = $(LIBRARY_PATH) $(LIBRARIES) $(DLL_PATH)

# $(xfst_exe_MODULE).dbg.c: $(xfst_exe_C_SRCS) $(xfst_exe_CXX_SRCS)
#	$(WINEBUILD) -o $@ --debug -C$(SRCDIR) $(xfst_exe_C_SRCS) $(xfst_exe_CXX_SRCS)

$(fst_exe_MODULE): $(fst_exe_OBJS)
	$(CC) $(fst_exe_LDFLAGS) -o $@ $(fst_exe_OBJS) $(fst_exe_LIBRARY_PATH) $(DEFLIB) $(fst_exe_DLLS:%=-l%) $(fst_exe_LIBRARIES:%=-l%)


