VERSION              = 0.1.1
#see gentoo Makefile patches in ebuild
VSTDIR                = /usr/include/vst
SDKDIR                = `find . | grep 'vstsdk[^/]*\$$'`
#PICSDIR               = /usr/share/easyfst
BINDIR                = /usr/bin/

### Generated by Winemaker


SRCDIR                = .
SUBDIRS               =
DLLS                  =
EXES                  = easyfst.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 -DIMAGES_DIR=\"pics\"
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

easyfst_exe_MODULE       = easyfst.exe
easyfst_exe_C_SRCS       = audiomaster.c \
			fst.c \
			fstinfofile.c \
			gtk.c \
			easyfst.c \
			vsti.c \
			vstwin.c \
			model_plugin.c \
			ayyi_utils.c \
			support.c \
			window.c
easyfst_exe_CXX_SRCS     =
easyfst_exe_RC_SRCS      =
easyeasyfst_exe_LDFLAGS      = -mwindows
easyfst_exe_DLL_PATH     =
easyfst_exe_DLLS         = 
easyfst_exe_LIBRARY_PATH =
easyfst_exe_LIBRARIES    = uuid

easyfst_exe_OBJS         = $(easyfst_exe_C_SRCS:.c=.o) \
			$(easyfst_exe_CXX_SRCS:.cpp=.o) \
			$(easyfst_exe_RC_SRCS:.rc=.res)



### Global source lists

C_SRCS                = $(easyfst_exe_C_SRCS)
CXX_SRCS              = $(easyfst_exe_CXX_SRCS)
RC_SRCS               = $(easyfst_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)

dir="../easyfst/"
tarball="easyfst-"$(VERSION)".tar.bz2"
dist_dir="../easyfst-"$(VERSION)"/"

dist:
	echo "making distribution tarball...";
	mkdir ${dist_dir};
	cp -pR ${dir}*.[ch] ${dir}Makefile ${dir}README ${dir}pics ${dist_dir}
	tar cjvvf ${tarball} ${dist_dir} --exclude *.svn
	mv ${tarball} ..
	rm -rf ${dist_dir}

shared_dir = "/usr/share/"

install:
	if [ ! -d ${shared_dir}easyfst ]; then mkdir ${shared_dir}easyfst; fi
	if [ ! -d ${shared_dir}easyfst/pics ]; then mkdir ${shared_dir}easyfst/pics; fi
	cp -pR pics/*.png /usr/share/easyfst/pics;
	cp -p easyfst easyfst.exe.so ${BINDIR}

.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)

$(easyfst_exe_MODULE): $(easyfst_exe_OBJS)
	$(CC) $(easyfst_exe_LDFLAGS) -o $@ $(easyfst_exe_OBJS) $(easyfst_exe_LIBRARY_PATH) $(DEFLIB) $(easyfst_exe_DLLS:%=-l%) $(easyfst_exe_LIBRARIES:%=-l%)


