# $Id: vstsdk2.3.patch,v 1.2 2012-10-24 03:56:58 otu Exp $
# Original file is on http://otu.sakura.ne.jp/gallery/
#
# This is for
#   vstsdk2.3.zip (md5sum: b81470739c1d056b391071bc7a33b7b6)
#   in
#   vst_sdk2_3.zip (md5sum: c91d3be58ad4e9c695d0a90b2198be0d)
#
#
# Execute
#   patch -p0 <vstsdk2.3.patch
#   cd vstsdk2.3/cygwin
#   make
#
--- vstsdk2.3/resource/controlsgui/controlsgui.rc	2003-05-14 17:49:00.000000000 +0900
+++ vstsdk2.3/resource/controlsgui/controlsgui.rc	2012-10-23 14:01:15.984375000 +0900
@@ -14,16 +14,16 @@
-10001                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10001.bmp"
-10002                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10002.bmp"
-10003                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10003.bmp"
-10004                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10004.bmp"
-10005                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10005.bmp"
-10006                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10006.bmp"
-10007                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10007.bmp"
-10008                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10008.bmp"
-10009                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10009.bmp"
-10010                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10010.bmp"
-10011                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10011.bmp"
-10012                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10012.bmp"
-10013                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10013.bmp"
-10014                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10014.bmp"
-10015                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10015.bmp"
-10016                     BITMAP  DISCARDABLE     "..\controlsgui\bmp10016.bmp"
+10001                     BITMAP  DISCARDABLE     "bmp10001.bmp"
+10002                     BITMAP  DISCARDABLE     "bmp10002.bmp"
+10003                     BITMAP  DISCARDABLE     "bmp10003.bmp"
+10004                     BITMAP  DISCARDABLE     "bmp10004.bmp"
+10005                     BITMAP  DISCARDABLE     "bmp10005.bmp"
+10006                     BITMAP  DISCARDABLE     "bmp10006.bmp"
+10007                     BITMAP  DISCARDABLE     "bmp10007.bmp"
+10008                     BITMAP  DISCARDABLE     "bmp10008.bmp"
+10009                     BITMAP  DISCARDABLE     "bmp10009.bmp"
+10010                     BITMAP  DISCARDABLE     "bmp10010.bmp"
+10011                     BITMAP  DISCARDABLE     "bmp10011.bmp"
+10012                     BITMAP  DISCARDABLE     "bmp10012.bmp"
+10013                     BITMAP  DISCARDABLE     "bmp10013.bmp"
+10014                     BITMAP  DISCARDABLE     "bmp10014.bmp"
+10015                     BITMAP  DISCARDABLE     "bmp10015.bmp"
+10016                     BITMAP  DISCARDABLE     "bmp10016.bmp"
--- vstsdk2.3/source/ADelay/ADelayMain.cpp	2003-05-13 17:53:00.000000000 +0900
+++ vstsdk2.3/source/ADelay/ADelayMain.cpp	2012-05-24 12:32:13.141125000 +0900
@@ -32 +32 @@
-AEffect *main (audioMasterCallback audioMaster);
+int main (audioMasterCallback audioMaster);
@@ -36 +36 @@
-AEffect *main (audioMasterCallback audioMaster)
+int main (audioMasterCallback audioMaster)
@@ -53 +53 @@
-	return effect->getAeffect ();
+	return (int) effect->getAeffect ();
@@ -63,0 +64 @@
+extern "C"
--- vstsdk2.3/source/ADelayEditGUI/ADelayEditMain.cpp	2003-05-13 17:57:00.000000000 +0900
+++ vstsdk2.3/source/ADelayEditGUI/ADelayEditMain.cpp	2012-05-24 12:37:56.922375000 +0900
@@ -34 +34 @@
-AEffect *main (audioMasterCallback audioMaster);
+int main (audioMasterCallback audioMaster);
@@ -38 +38 @@
-AEffect *main (audioMasterCallback audioMaster)
+int main (audioMasterCallback audioMaster)
@@ -60 +60 @@
-	return effect->getAeffect ();
+	return (int) effect->getAeffect ();
@@ -71,0 +72 @@
+extern "C"
--- vstsdk2.3/source/common/vstgui.cpp	2003-05-14 17:08:00.000000000 +0900
+++ vstsdk2.3/source/common/vstgui.cpp	2012-05-24 12:24:58.156750000 +0900
@@ -7326 +7326 @@
-		WORD wsz[2048];
+		WCHAR wsz[2048];
--- vstsdk2.3/source/controlsgui/controlsguimain.cpp	2003-05-13 17:14:00.000000000 +0900
+++ vstsdk2.3/source/controlsgui/controlsguimain.cpp	2012-05-24 12:34:19.391125000 +0900
@@ -29 +29 @@
-AEffect *main (audioMasterCallback audioMaster);
+int main (audioMasterCallback audioMaster);
@@ -33 +33 @@
-AEffect *main (audioMasterCallback audioMaster)
+int main (audioMasterCallback audioMaster)
@@ -50 +50 @@
-	return effect->getAeffect ();
+	return (int) effect->getAeffect ();
@@ -60,0 +61 @@
+extern "C"
--- vstsdk2.3/source/offline/OfflineMain.cpp	2003-05-13 17:23:00.000000000 +0900
+++ vstsdk2.3/source/offline/OfflineMain.cpp	2012-05-24 13:04:20.781750000 +0900
@@ -30 +30 @@
-AEffect *main (audioMasterCallback audioMaster);
+int main (audioMasterCallback audioMaster);
@@ -34 +34 @@
-AEffect *main (audioMasterCallback audioMaster)
+int main (audioMasterCallback audioMaster)
@@ -41 +41 @@
-	return effect->getAeffect ();
+	return (int) effect->getAeffect ();
@@ -52,0 +53 @@
+extern "C"
--- vstsdk2.3/source/surrounddelay/surrounddelaymain.cpp	2003-05-13 18:26:00.000000000 +0900
+++ vstsdk2.3/source/surrounddelay/surrounddelaymain.cpp	2012-05-24 13:01:48.938000000 +0900
@@ -34 +34 @@
-AEffect *main (audioMasterCallback audioMaster);
+int main (audioMasterCallback audioMaster);
@@ -38 +38 @@
-AEffect *main (audioMasterCallback audioMaster)
+int main (audioMasterCallback audioMaster)
@@ -60 +60 @@
-	return effect->getAeffect ();
+	return (int) effect->getAeffect ();
@@ -70,0 +71 @@
+extern "C"
--- vstsdk2.3/source/vstxsynth/vstxsynthmain.cpp	2003-05-15 17:34:00.000000000 +0900
+++ vstsdk2.3/source/vstxsynth/vstxsynthmain.cpp	2012-05-24 12:22:36.281750000 +0900
@@ -41 +41 @@
-AEffect *main (audioMasterCallback audioMaster);
+int main (audioMasterCallback audioMaster);
@@ -45 +45 @@
-AEffect *main (audioMasterCallback audioMaster)
+int main (audioMasterCallback audioMaster)
@@ -62 +62 @@
-	return effect->getAeffect ();
+	return (int) effect->getAeffect ();
@@ -72,0 +73 @@
+extern "C"
--- vstsdk2.3/cygwin/Makefile	1970-01-01 09:00:00.000000000 +0900
+++ vstsdk2.3/cygwin/Makefile	2012-10-23 14:51:37.265625000 +0900
@@ -0,0 +1,61 @@
+#! /usr/bin/make -f
+## A Makefile to build contents of VST SDK 2.3 on Cygwin.
+## Make "cygwin" subdirectory in the top directory (vstsdk2.3).
+## and put this Makefile in it.
+##
+
+VPATH = ../source/common:../source/vstxsynth:../source/controlsgui:../source/ADelayEditGUI:../source/ADelay:../resource/delayeditgui:../source/offline:../source/surrounddelay
+
+CC      = g++
+CFLAGS  = -mno-cygwin -mwindows -g -DWINDOWS
+INCLUDE = -I../source -I../source/common -I../source/ADelay -I../source/ADelayEditGUI
+LIB     = -L. -lvst
+GUILIB  = -lole32 -luuid
+
+all : Vstxsynth.dll ADelay.dll ControlsGui.dll ADelayEditGUI.dll SurroundDelay.dll Offline.dll
+
+libvst.a : $(subst .cpp,.o,$(notdir $(wildcard ../source/common/*.cpp)))
+	ar rv $@ $?
+
+clean :
+	rm -f *.o *.dll *.a *.coff
+
+.cpp.o :
+	$(CC) $(CFLAGS) $(INCLUDE) -c $?
+
+Vstxsynth.dll : $(subst .cpp,.o,$(notdir $(wildcard ../source/vstxsynth/*.cpp))) libvst.a
+	$(CC) $(CFLAGS) -shared -o $@ $^ $(LIB)
+
+ADelay.dll : $(subst .cpp,.o,$(notdir $(wildcard ../source/ADelay/*.cpp))) libvst.a
+	$(CC) $(CFLAGS) -shared -o $@ $^ $(LIB)
+
+ControlsGui.dll : $(subst .cpp,.o,$(notdir $(wildcard ../source/controlsgui/*.cpp))) controlsgui.coff libvst.a
+	$(CC) $(CFLAGS) -shared -o $@ $^ $(LIB) $(GUILIB)
+
+ADelayEditGUI.dll : $(subst .cpp,.o,$(notdir $(wildcard ../source/ADelayEditGUI/*.cpp))) ADelay.o DelayEditGUI.coff libvst.a
+	$(CC) $(CFLAGS) -shared -o $@ $^ $(LIB) $(GUILIB)
+
+SurroundDelay.dll : $(subst .cpp,.o,$(notdir $(wildcard ../source/surrounddelay/*.cpp))) ADelay.o ADEditor.o surrounddelay.coff libvst.a
+	$(CC) $(CFLAGS) -shared -o $@ $^ $(LIB) $(GUILIB)
+
+Offline.dll : $(subst .cpp,.o,$(notdir $(wildcard ../source/offline/*.cpp))) surrounddelay.coff libvst.a
+	$(CC) $(CFLAGS) -shared -o $@ $^ $(LIB) $(GUILIB) -lcomctl32
+
+controlsgui.coff : $(wildcard ../resource/controlsgui/*.*)
+	cd ../resource/controlsgui && windres --input-format=rc --output-format=coff controlsgui.rc ../../cygwin/controlsgui.coff
+
+DelayEditGUI.coff : $(wildcard ../resource/delayeditgui/*.*)
+	cd ../resource/delayeditgui && windres --input-format=rc --output-format=coff DelayEditGUI.rc ../../cygwin/DelayEditGUI.coff
+
+surrounddelay.coff : $(wildcard ../resource/delayeditgui/*.*)
+	cd ../resource/delayeditgui && windres --input-format=rc --output-format=coff surrounddelay.rc ../../cygwin/surrounddelay.coff
+
+installlib : libvst.a
+	cp libvst.a /usr/local/lib
+	mkdir -p /usr/local/include/vst
+	cd ../source/common && cp AEffEditor.hpp AEffect.h AudioEffect.hpp aeffectx.h aeffguieditor.h audioeffectx.h vstcontrols.h vstgui.h /usr/local/include/vst/.
+
+uninstalllib :
+	rm -f /usr/local/lib/libvst.a
+	rm -rf /usr/local/include/vst
+
