Index: src/CodeBlocks-unix.cbp
===================================================================
--- src/CodeBlocks-unix.cbp	(revision 9677)
+++ src/CodeBlocks-unix.cbp	(working copy)
@@ -2145,6 +2145,9 @@
 		<Unit filename="plugins/scriptedwizard/resources/qt4/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
+		<Unit filename="plugins/scriptedwizard/resources/sdl2/wizard.script">
+			<Option target="Scripted wizard" />
+		</Unit>
 		<Unit filename="plugins/scriptedwizard/resources/sdl/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
Index: src/CodeBlocks.cbp
===================================================================
--- src/CodeBlocks.cbp	(revision 9677)
+++ src/CodeBlocks.cbp	(working copy)
@@ -2388,6 +2388,9 @@
 		<Unit filename="plugins/scriptedwizard/resources/qt4/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
+		<Unit filename="plugins/scriptedwizard/resources/sdl2/wizard.script">
+			<Option target="Scripted wizard" />
+		</Unit>
 		<Unit filename="plugins/scriptedwizard/resources/sdl/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
Index: src/CodeBlocks_wx30-unix.cbp
===================================================================
--- src/CodeBlocks_wx30-unix.cbp	(revision 9677)
+++ src/CodeBlocks_wx30-unix.cbp	(working copy)
@@ -2189,6 +2189,9 @@
 		<Unit filename="plugins/scriptedwizard/resources/qt4/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
+		<Unit filename="plugins/scriptedwizard/resources/sdl2/wizard.script">
+			<Option target="Scripted wizard" />
+		</Unit>
 		<Unit filename="plugins/scriptedwizard/resources/sdl/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
Index: src/CodeBlocks_wx30.cbp
===================================================================
--- src/CodeBlocks_wx30.cbp	(revision 9677)
+++ src/CodeBlocks_wx30.cbp	(working copy)
@@ -2383,6 +2383,9 @@
 		<Unit filename="plugins/scriptedwizard/resources/qt4/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
+		<Unit filename="plugins/scriptedwizard/resources/sdl2/wizard.script">
+			<Option target="Scripted wizard" />
+		</Unit>
 		<Unit filename="plugins/scriptedwizard/resources/sdl/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
Index: src/CodeBlocks_wx30_64.cbp
===================================================================
--- src/CodeBlocks_wx30_64.cbp	(revision 9677)
+++ src/CodeBlocks_wx30_64.cbp	(working copy)
@@ -2386,6 +2386,9 @@
 		<Unit filename="plugins/scriptedwizard/resources/qt4/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
+		<Unit filename="plugins/scriptedwizard/resources/sdl2/wizard.script">
+			<Option target="Scripted wizard" />
+		</Unit>
 		<Unit filename="plugins/scriptedwizard/resources/sdl/wizard.script">
 			<Option target="Scripted wizard" />
 		</Unit>
Index: src/plugins/scriptedwizard/resources/config.script
===================================================================
--- src/plugins/scriptedwizard/resources/config.script	(revision 9677)
+++ src/plugins/scriptedwizard/resources/config.script	(working copy)
@@ -42,6 +42,7 @@
     RegisterWizard(wizProject,     _T("plugins"),      _T("Code::Blocks plugin"),   _T("Code::Blocks"));
     RegisterWizard(wizProject,     _T("qt4"),          _T("QT4 project"),           _T("GUI"));
     RegisterWizard(wizProject,     _T("sdl"),          _T("SDL project"),           _T("2D/3D Graphics"));
+    RegisterWizard(wizProject,     _T("sdl2"),         _T("SDL2 project"),          _T("2D/3D Graphics"));
     RegisterWizard(wizProject,     _T("sfml"),         _T("SFML project"),          _T("2D/3D Graphics"));
     if (PLATFORM == PLATFORM_MSW)
         RegisterWizard(wizProject, _T("smartwin"),     _T("SmartWin project"),      _T("GUI"));
Index: src/plugins/scriptedwizard/resources/sdl2/Makefile.am
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/Makefile.am	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/Makefile.am	(working copy)
@@ -0,0 +1,7 @@
+SUBDIRS = files
+
+pkgdatadir = $(datadir)/@PACKAGE@/templates/wizard/sdl2
+
+dist_pkgdata_DATA = logo.png \
+					wizard.png \
+					wizard.script
\ No newline at end of file
Index: src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am	(working copy)
@@ -0,0 +1,4 @@
+pkgdatadir = $(datadir)/@PACKAGE@/templates/wizard/sdl2/files
+
+dist_pkgdata_DATA = main.cpp \
+					hello.bmp
\ No newline at end of file
Index: src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp	(working copy)

Property changes on: src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/plugins/scriptedwizard/resources/sdl2/files/main.cpp
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/main.cpp	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/main.cpp	(working copy)
@@ -0,0 +1,82 @@
+
+#include <stdio.h>
+#include <SDL2/SDL.h>
+
+int main (int argc, char** argv)
+{
+    // Initialize SDL video
+    if (SDL_Init(SDL_INIT_VIDEO) < 0)
+    {
+        printf("Unable to init SDL: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create SDL window
+    SDL_Window* window = SDL_CreateWindow("SDL2 window", 100, 100, 800, 600, SDL_WINDOW_SHOWN);
+    if (window == NULL)
+    {
+        printf("Unable to create window: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create SDL renderer
+    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+    if (renderer == NULL) {
+        printf("Unable to create renderer: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Load an image
+    SDL_Surface* hello_bmp = SDL_LoadBMP("hello.bmp");
+    if (hello_bmp == NULL)
+    {
+        printf("Unable to load image: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create texture to hold the image
+    SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, hello_bmp);
+    if (texture == NULL)
+    {
+        printf("Unable to create texture: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // The texture has a copy of the image so we don't need it any more.
+    SDL_FreeSurface(hello_bmp);
+
+    // Main loop
+    bool quit = false;
+    while (!quit)
+    {
+        // Event processing
+        SDL_Event e;
+        while (SDL_PollEvent(&e)){
+            // If user closes the window
+            if (e.type == SDL_QUIT)
+                quit = true;
+            // If user presses any key
+            if (e.type == SDL_KEYDOWN)
+                quit = true;
+        }
+
+        // Clear renderer
+        SDL_RenderClear(renderer);
+
+        // Copy texture to renderer
+        SDL_RenderCopy(renderer, texture, NULL, NULL);
+
+        // Show renderer on screen
+        SDL_RenderPresent(renderer);
+    }
+
+    // Destroy the image, renderer and window
+    SDL_DestroyTexture(texture);
+    SDL_DestroyRenderer(renderer);
+    SDL_DestroyWindow(window);
+
+    // Clean up
+    SDL_Quit();
+
+    return 0;
+}
Index: src/plugins/scriptedwizard/resources/sdl2/logo.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/plugins/scriptedwizard/resources/sdl2/logo.png
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/logo.png	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/logo.png	(working copy)

Property changes on: src/plugins/scriptedwizard/resources/sdl2/logo.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/plugins/scriptedwizard/resources/sdl2/wizard.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/plugins/scriptedwizard/resources/sdl2/wizard.png
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/wizard.png	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/wizard.png	(working copy)

Property changes on: src/plugins/scriptedwizard/resources/sdl2/wizard.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/plugins/scriptedwizard/resources/sdl2/wizard.script
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/wizard.script	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/wizard.script	(working copy)
@@ -0,0 +1,161 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// SDL2 project wizard
+//
+////////////////////////////////////////////////////////////////////////////////
+
+// globals (used under windows only)
+SDL2PathDefault    <- _T("");
+SDL2PathDefaultInc <- _T("");
+SDL2PathDefaultLib <- _T("");
+SDL2Path           <- _T("");
+
+function BeginWizard()
+{
+    local intro_msg = _T("Welcome to the SDL2 project wizard!\n\n" +
+                         "This wizard will guide you to create a new\n" +
+                         "project using the SDL2 graphics library.\n\n")
+    if (PLATFORM == PLATFORM_MSW)
+    {
+        intro_msg += _T("When you have completed this setup remember\n" +
+                        "to copy SDL2.dll to your executable folder.\n\n")
+    }
+    intro_msg += _T("When you're ready to proceed, please click \"Next\"...");
+
+    local sdl2path_descr = _T("Please select the location of SDL2 on your computer.\n" +
+                             "This is the top-level folder where SDL2 was installed (unpacked).\n" +
+                             "To help you, this folder must contain the subfolders\n" +
+                             "\"include\" and \"lib\".");
+
+    Wizard.AddInfoPage(_T("SDL2Intro"), intro_msg);
+    Wizard.AddProjectPathPage();
+    if (PLATFORM == PLATFORM_MSW)
+        Wizard.AddGenericSelectPathPage(_T("SDL2Path"), sdl2path_descr, _T("Please select SDL2's location:"), SDL2PathDefault);
+    Wizard.AddCompilerPage(_T(""), _T("*"), true, true);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// SDL2's path page
+////////////////////////////////////////////////////////////////////////////////
+
+function OnLeave_SDL2Path(fwd)
+{
+    if (fwd)
+    {
+        local dir         = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
+        local dir_nomacro = VerifyDirectory(dir);
+
+        if (dir_nomacro.IsEmpty())
+            return false;
+
+        // verify include dependencies
+        local dir_nomacro_inc = GetCompilerIncludeDir(dir, SDL2PathDefault, SDL2PathDefaultInc);
+        if (dir_nomacro_inc.IsEmpty())
+            return false;
+
+        if (!IO.FileExists(dir_nomacro_inc + wxFILE_SEP_PATH + _T("SDL.h")))
+        {
+            if (VerifyFile(dir_nomacro_inc, _T("SDL2/SDL.h"), _T("SDL2's include")))
+                SDL2PathDefaultInc = SDL2PathDefaultInc + _T("/SDL2");
+            else
+                return false;
+        }
+
+        // verify library dependencies
+        local dir_nomacro_lib = GetCompilerLibDir(dir, SDL2PathDefault, SDL2PathDefaultLib);
+        if (dir_nomacro_lib.IsEmpty())
+            return false;
+
+        if (!VerifyLibFile(dir_nomacro_lib, _T("SDL2main"), _T("SDL2's")))
+            return false;
+
+        if (!VerifyLibFile(dir_nomacro_lib, _T("SDL2"), _T("SDL2's")))
+            return false;
+
+        SDL2Path = dir; // Remember the original selection.
+
+        local is_macro = _T("");
+
+        // try to resolve the include directory as macro
+        is_macro = GetCompilerIncludeMacro(dir, SDL2PathDefault, SDL2PathDefaultInc);
+        if (is_macro.IsEmpty())
+        {
+            // not possible -> use the real inc path we had computed instead
+            SDL2PathDefaultInc = dir_nomacro_inc;
+        }
+
+        // try to resolve the library directory as macro
+        is_macro = GetCompilerLibMacro(dir, SDL2PathDefault, SDL2PathDefaultLib);
+        if (is_macro.IsEmpty())
+        {
+            // not possible -> use the real lib path we had computed instead
+            SDL2PathDefaultLib = dir_nomacro_lib;
+        }
+    }
+    return true;
+}
+
+// return the files this project contains
+function GetFilesDir()
+{
+    return _T("sdl2/files");
+}
+
+// setup the already created project
+function SetupProject(project)
+{
+    if (PLATFORM == PLATFORM_MSW)
+    {
+        project.AddIncludeDir(SDL2PathDefaultInc);
+        project.AddLibDir(SDL2PathDefaultLib);
+
+        // add link libraries
+        project.AddLinkLib(_T("mingw32"));
+        project.AddLinkLib(_T("SDL2main"));
+        project.AddLinkLib(_T("SDL2"));
+        project.AddLinkLib(_T("user32"));
+        project.AddLinkLib(_T("gdi32"));
+        project.AddLinkLib(_T("winmm"));
+        project.AddLinkLib(_T("dxguid"));
+    }
+    else if (PLATFORM == PLATFORM_MAC)
+    {
+        //project.AddCompilerOption(_T("-D_GNU_SOURCE=1 -D_THREAD_SAFE"));
+        project.AddLinkerOption(_T("-framework SDL2"));
+        // libSDL2main.a does not exist by default, needs to be built from SDL2Main.m:
+        project.AddLinkLib(_T("SDL2main"));
+
+        project.AddLinkerOption(_T("-framework Cocoa")); // SDL2 dependency
+    }
+    else
+    {
+        // unix way
+        project.AddCompilerOption(_T("`sdl2-config --cflags`"));
+        project.AddLinkerOption(_T("`sdl2-config --libs`"));
+    }
+
+    // enable compiler warnings (project-wide)
+    WarningsOn(project, Wizard.GetCompilerID());
+
+    // Debug
+    local target = project.GetBuildTarget(Wizard.GetDebugName());
+    if (!IsNull(target))
+    {
+        target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
+        target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
+        // enable generation of debugging symbols for target
+        DebugSymbolsOn(target, Wizard.GetCompilerID());
+    }
+
+    // Release
+    target = project.GetBuildTarget(Wizard.GetReleaseName());
+    if (!IsNull(target))
+    {
+        target.SetTargetType(ttExecutable); // ttExecutable: no console
+        target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
+        // enable optimizations for target
+        OptimizationsOn(target, Wizard.GetCompilerID());
+    }
+
+    return true;
+}
Index: src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am	(working copy)
@@ -0,0 +1,4 @@
+pkgdatadir = $(datadir)/@PACKAGE@/templates/wizard/sdl2/files
+
+dist_pkgdata_DATA = main.cpp \
+					hello.bmp
\ No newline at end of file
Index: src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp	(working copy)

Property changes on: src/plugins/scriptedwizard/resources/sdl2/files/hello.bmp
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: src/plugins/scriptedwizard/resources/sdl2/files/main.cpp
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/main.cpp	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/main.cpp	(working copy)
@@ -0,0 +1,82 @@
+
+#include <stdio.h>
+#include <SDL2/SDL.h>
+
+int main (int argc, char** argv)
+{
+    // Initialize SDL video
+    if (SDL_Init(SDL_INIT_VIDEO) < 0)
+    {
+        printf("Unable to init SDL: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create SDL window
+    SDL_Window* window = SDL_CreateWindow("SDL2 window", 100, 100, 800, 600, SDL_WINDOW_SHOWN);
+    if (window == NULL)
+    {
+        printf("Unable to create window: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create SDL renderer
+    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+    if (renderer == NULL) {
+        printf("Unable to create renderer: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Load an image
+    SDL_Surface* hello_bmp = SDL_LoadBMP("hello.bmp");
+    if (hello_bmp == NULL)
+    {
+        printf("Unable to load image: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create texture to hold the image
+    SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, hello_bmp);
+    if (texture == NULL)
+    {
+        printf("Unable to create texture: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // The texture has a copy of the image so we don't need it any more.
+    SDL_FreeSurface(hello_bmp);
+
+    // Main loop
+    bool quit = false;
+    while (!quit)
+    {
+        // Event processing
+        SDL_Event e;
+        while (SDL_PollEvent(&e)){
+            // If user closes the window
+            if (e.type == SDL_QUIT)
+                quit = true;
+            // If user presses any key
+            if (e.type == SDL_KEYDOWN)
+                quit = true;
+        }
+
+        // Clear renderer
+        SDL_RenderClear(renderer);
+
+        // Copy texture to renderer
+        SDL_RenderCopy(renderer, texture, NULL, NULL);
+
+        // Show renderer on screen
+        SDL_RenderPresent(renderer);
+    }
+
+    // Destroy the image, renderer and window
+    SDL_DestroyTexture(texture);
+    SDL_DestroyRenderer(renderer);
+    SDL_DestroyWindow(window);
+
+    // Clean up
+    SDL_Quit();
+
+    return 0;
+}
Index: src/plugins/scriptedwizard/resources/sdl2/files/main.cpp
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/main.cpp	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/main.cpp	(working copy)
@@ -0,0 +1,82 @@
+
+#include <stdio.h>
+#include <SDL2/SDL.h>
+
+int main (int argc, char** argv)
+{
+    // Initialize SDL video
+    if (SDL_Init(SDL_INIT_VIDEO) < 0)
+    {
+        printf("Unable to init SDL: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create SDL window
+    SDL_Window* window = SDL_CreateWindow("SDL2 window", 100, 100, 800, 600, SDL_WINDOW_SHOWN);
+    if (window == NULL)
+    {
+        printf("Unable to create window: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create SDL renderer
+    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+    if (renderer == NULL) {
+        printf("Unable to create renderer: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Load an image
+    SDL_Surface* hello_bmp = SDL_LoadBMP("hello.bmp");
+    if (hello_bmp == NULL)
+    {
+        printf("Unable to load image: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // Create texture to hold the image
+    SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, hello_bmp);
+    if (texture == NULL)
+    {
+        printf("Unable to create texture: %s\n", SDL_GetError());
+        return 1;
+    }
+
+    // The texture has a copy of the image so we don't need it any more.
+    SDL_FreeSurface(hello_bmp);
+
+    // Main loop
+    bool quit = false;
+    while (!quit)
+    {
+        // Event processing
+        SDL_Event e;
+        while (SDL_PollEvent(&e)){
+            // If user closes the window
+            if (e.type == SDL_QUIT)
+                quit = true;
+            // If user presses any key
+            if (e.type == SDL_KEYDOWN)
+                quit = true;
+        }
+
+        // Clear renderer
+        SDL_RenderClear(renderer);
+
+        // Copy texture to renderer
+        SDL_RenderCopy(renderer, texture, NULL, NULL);
+
+        // Show renderer on screen
+        SDL_RenderPresent(renderer);
+    }
+
+    // Destroy the image, renderer and window
+    SDL_DestroyTexture(texture);
+    SDL_DestroyRenderer(renderer);
+    SDL_DestroyWindow(window);
+
+    // Clean up
+    SDL_Quit();
+
+    return 0;
+}
Index: src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/files/Makefile.am	(working copy)
@@ -0,0 +1,4 @@
+pkgdatadir = $(datadir)/@PACKAGE@/templates/wizard/sdl2/files
+
+dist_pkgdata_DATA = main.cpp \
+					hello.bmp
\ No newline at end of file
Index: src/plugins/scriptedwizard/resources/sdl2/Makefile.am
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/Makefile.am	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/Makefile.am	(working copy)
@@ -0,0 +1,7 @@
+SUBDIRS = files
+
+pkgdatadir = $(datadir)/@PACKAGE@/templates/wizard/sdl2
+
+dist_pkgdata_DATA = logo.png \
+					wizard.png \
+					wizard.script
\ No newline at end of file
Index: src/plugins/scriptedwizard/resources/sdl2/wizard.script
===================================================================
--- src/plugins/scriptedwizard/resources/sdl2/wizard.script	(revision 0)
+++ src/plugins/scriptedwizard/resources/sdl2/wizard.script	(working copy)
@@ -0,0 +1,161 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// SDL2 project wizard
+//
+////////////////////////////////////////////////////////////////////////////////
+
+// globals (used under windows only)
+SDL2PathDefault    <- _T("");
+SDL2PathDefaultInc <- _T("");
+SDL2PathDefaultLib <- _T("");
+SDL2Path           <- _T("");
+
+function BeginWizard()
+{
+    local intro_msg = _T("Welcome to the SDL2 project wizard!\n\n" +
+                         "This wizard will guide you to create a new\n" +
+                         "project using the SDL2 graphics library.\n\n")
+    if (PLATFORM == PLATFORM_MSW)
+    {
+        intro_msg += _T("When you have completed this setup remember\n" +
+                        "to copy SDL2.dll to your executable folder.\n\n")
+    }
+    intro_msg += _T("When you're ready to proceed, please click \"Next\"...");
+
+    local sdl2path_descr = _T("Please select the location of SDL2 on your computer.\n" +
+                             "This is the top-level folder where SDL2 was installed (unpacked).\n" +
+                             "To help you, this folder must contain the subfolders\n" +
+                             "\"include\" and \"lib\".");
+
+    Wizard.AddInfoPage(_T("SDL2Intro"), intro_msg);
+    Wizard.AddProjectPathPage();
+    if (PLATFORM == PLATFORM_MSW)
+        Wizard.AddGenericSelectPathPage(_T("SDL2Path"), sdl2path_descr, _T("Please select SDL2's location:"), SDL2PathDefault);
+    Wizard.AddCompilerPage(_T(""), _T("*"), true, true);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// SDL2's path page
+////////////////////////////////////////////////////////////////////////////////
+
+function OnLeave_SDL2Path(fwd)
+{
+    if (fwd)
+    {
+        local dir         = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
+        local dir_nomacro = VerifyDirectory(dir);
+
+        if (dir_nomacro.IsEmpty())
+            return false;
+
+        // verify include dependencies
+        local dir_nomacro_inc = GetCompilerIncludeDir(dir, SDL2PathDefault, SDL2PathDefaultInc);
+        if (dir_nomacro_inc.IsEmpty())
+            return false;
+
+        if (!IO.FileExists(dir_nomacro_inc + wxFILE_SEP_PATH + _T("SDL.h")))
+        {
+            if (VerifyFile(dir_nomacro_inc, _T("SDL2/SDL.h"), _T("SDL2's include")))
+                SDL2PathDefaultInc = SDL2PathDefaultInc + _T("/SDL2");
+            else
+                return false;
+        }
+
+        // verify library dependencies
+        local dir_nomacro_lib = GetCompilerLibDir(dir, SDL2PathDefault, SDL2PathDefaultLib);
+        if (dir_nomacro_lib.IsEmpty())
+            return false;
+
+        if (!VerifyLibFile(dir_nomacro_lib, _T("SDL2main"), _T("SDL2's")))
+            return false;
+
+        if (!VerifyLibFile(dir_nomacro_lib, _T("SDL2"), _T("SDL2's")))
+            return false;
+
+        SDL2Path = dir; // Remember the original selection.
+
+        local is_macro = _T("");
+
+        // try to resolve the include directory as macro
+        is_macro = GetCompilerIncludeMacro(dir, SDL2PathDefault, SDL2PathDefaultInc);
+        if (is_macro.IsEmpty())
+        {
+            // not possible -> use the real inc path we had computed instead
+            SDL2PathDefaultInc = dir_nomacro_inc;
+        }
+
+        // try to resolve the library directory as macro
+        is_macro = GetCompilerLibMacro(dir, SDL2PathDefault, SDL2PathDefaultLib);
+        if (is_macro.IsEmpty())
+        {
+            // not possible -> use the real lib path we had computed instead
+            SDL2PathDefaultLib = dir_nomacro_lib;
+        }
+    }
+    return true;
+}
+
+// return the files this project contains
+function GetFilesDir()
+{
+    return _T("sdl2/files");
+}
+
+// setup the already created project
+function SetupProject(project)
+{
+    if (PLATFORM == PLATFORM_MSW)
+    {
+        project.AddIncludeDir(SDL2PathDefaultInc);
+        project.AddLibDir(SDL2PathDefaultLib);
+
+        // add link libraries
+        project.AddLinkLib(_T("mingw32"));
+        project.AddLinkLib(_T("SDL2main"));
+        project.AddLinkLib(_T("SDL2"));
+        project.AddLinkLib(_T("user32"));
+        project.AddLinkLib(_T("gdi32"));
+        project.AddLinkLib(_T("winmm"));
+        project.AddLinkLib(_T("dxguid"));
+    }
+    else if (PLATFORM == PLATFORM_MAC)
+    {
+        //project.AddCompilerOption(_T("-D_GNU_SOURCE=1 -D_THREAD_SAFE"));
+        project.AddLinkerOption(_T("-framework SDL2"));
+        // libSDL2main.a does not exist by default, needs to be built from SDL2Main.m:
+        project.AddLinkLib(_T("SDL2main"));
+
+        project.AddLinkerOption(_T("-framework Cocoa")); // SDL2 dependency
+    }
+    else
+    {
+        // unix way
+        project.AddCompilerOption(_T("`sdl2-config --cflags`"));
+        project.AddLinkerOption(_T("`sdl2-config --libs`"));
+    }
+
+    // enable compiler warnings (project-wide)
+    WarningsOn(project, Wizard.GetCompilerID());
+
+    // Debug
+    local target = project.GetBuildTarget(Wizard.GetDebugName());
+    if (!IsNull(target))
+    {
+        target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
+        target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
+        // enable generation of debugging symbols for target
+        DebugSymbolsOn(target, Wizard.GetCompilerID());
+    }
+
+    // Release
+    target = project.GetBuildTarget(Wizard.GetReleaseName());
+    if (!IsNull(target))
+    {
+        target.SetTargetType(ttExecutable); // ttExecutable: no console
+        target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
+        // enable optimizations for target
+        OptimizationsOn(target, Wizard.GetCompilerID());
+    }
+
+    return true;
+}
