premake/projects/SDL2.lua
author Ryan C. Gordon
Sun, 10 Nov 2013 00:38:37 -0500
changeset 7925 f090a47eb7f7
child 8094 9efaae827924
permissions -rwxr-xr-x
Added Ben Henning's GSoC2013 work: premake build system.
     1 -- Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     2 --
     3 -- This software is provided 'as-is', without any express or implied
     4 -- warranty.  In no event will the authors be held liable for any damages
     5 -- arising from the use of this software.
     6 --
     7 -- Permission is granted to anyone to use this software for any purpose,
     8 -- including commercial applications, and to alter it and redistribute it
     9 -- freely.
    10 --
    11 -- Meta-build system using premake created and maintained by
    12 -- Benjamin Henning <b.henning@digipen.edu>
    13 
    14 --[[
    15 SDL2.lua
    16 
    17 	This file provides the project definition for the entire SDL2 library, on all
    18 	platforms supported by the meta-build system. That includes Windows, MinGW,
    19 	Cygwin, Mac OS X, iOS, and Linux. This project is responsible for setting up
    20 	the source trees and the complicated dependencies required to build the
    21 	final SDL2 library. In order to simplify this process, the library is split
    22 	into several different segments. Each segment focuses on a different
    23 	dependency and series of configurations which are thrown into the generated
    24 	config header file, used to build this project.
    25 ]]
    26 
    27 SDL_project "SDL2"
    28 	 SDL_isos "windows|mingw" -- all other bindings should be a shared library
    29 		SDL_kind "SharedLib"
    30 	SDL_isos "macosx|ios" -- macosx employs a static linking
    31 		SDL_kind "StaticLib"
    32 	-- the way premake generates project dependencies and how that affects linkage
    33 	-- makes it difficult to use shared libraries on Linux. Cygwin has issues
    34 	-- binding to GetProcAddress, so a static library is an easy fix.
    35 	SDL_isos "linux|cygwin"
    36 		SDL_kind "StaticLib"
    37 
    38 	SDL_language "C++"
    39 	SDL_sourcedir "../src"
    40 	-- primary platforms
    41 	SDL_isos "ios"
    42 		SDL_platforms { "iOS" }
    43 	SDL_isnotos "ios"
    44 		SDL_platforms { "native" }
    45 	-- additional platforms
    46 	SDL_isos "macosx"
    47 		SDL_platforms { "universal" }
    48 	SDL_isos "windows|mingw"
    49 		SDL_defines { "_WINDOWS" }
    50 
    51 	-- Following is the dependency tree for SDL2
    52 	-- (no SDL_os call means platform-independent)
    53 
    54 	-- The core and minimal of the SDL2 library. This will not quite build
    55 	-- standalone, but it's doable with a bit of tweaking to build this using the
    56 	-- minimal configuration header. This is a good start to adding SDL support to
    57 	-- new platforms.
    58 	SDL_config
    59 	{
    60 		["SDL_AUDIO_DRIVER_DISK"] = 1,
    61 		["SDL_AUDIO_DRIVER_DUMMY"] = 1,
    62 		["SDL_VIDEO_DRIVER_DUMMY"] = 1
    63 	}
    64 	SDL_paths
    65 	{
    66 		"/",
    67 		"/atomic/",
    68 		"/audio/",
    69 		"/audio/disk/",
    70 		"/audio/dummy/",
    71 		"/cpuinfo/",
    72 		"/events/",
    73 		"/file/",
    74 		"/haptic/",
    75 		"/joystick/",
    76 		"/power/",
    77 		"/render/",
    78 		"/render/software/",
    79 		"/stdlib/",
    80 		"/thread/",
    81 		"/timer/",
    82 		"/video/",
    83 		"/video/dummy/"
    84 	}
    85 
    86 	-- SDL2 on Windows
    87 	SDL_dependency "windows"
    88 		SDL_os "windows|mingw"
    89 		SDL_links { "imm32", "oleaut32", "winmm", "version" }
    90 		-- these are the links that Visual Studio includes by default
    91 		SDL_links { "kernel32", "user32", "gdi32", "winspool",
    92 			"comdlg32", "advapi32", "shell32", "ole32",
    93 			"oleaut32", "uuid", "odbc32", "odbccp32" }
    94 		SDL_config
    95 		{
    96 			["SDL_LOADSO_WINDOWS"] = 1,
    97 			["SDL_THREAD_WINDOWS"] = 1,
    98 			["SDL_TIMER_WINDOWS"] = 1,
    99 			["SDL_VIDEO_DRIVER_WINDOWS"] = 1,
   100 			["SDL_POWER_WINDOWS"] = 1,
   101 			["SDL_AUDIO_DRIVER_WINMM"] = 1,
   102 			["SDL_FILESYSTEM_WINDOWS"] = 1
   103 		}
   104 		SDL_paths
   105 		{
   106 			"/audio/winmm/",
   107 			"/core/windows/",
   108 			"/libm/",
   109 			"/loadso/windows/",
   110 			"/power/windows/",
   111 			"/thread/windows/",
   112 			"/timer/windows/",
   113 			"/video/windows/",
   114 			"/filesystem/windows/"
   115 		}
   116 		SDL_files
   117 		{
   118 			-- these files have to be specified uniquely to avoid double
   119 			-- and incorrect linking
   120 			"/thread/generic/SDL_syscond.c",
   121 			"/thread/generic/SDL_sysmutex_c.h"
   122 		}
   123 
   124 	-- DirectX dependency
   125 	SDL_dependency "directx"
   126 		SDL_os "windows|mingw"
   127 		SDL_depfunc "DirectX"
   128 		SDL_config
   129 		{
   130 			["SDL_AUDIO_DRIVER_DSOUND"] = 1,
   131 			["SDL_AUDIO_DRIVER_XAUDIO2"] = 1,
   132 			["SDL_JOYSTICK_DINPUT"] = 1,
   133 			["SDL_HAPTIC_DINPUT"] = 1,
   134 			["SDL_VIDEO_RENDER_D3D"] = 1
   135 		}
   136 		SDL_paths
   137 		{
   138 			"/audio/directsound/",
   139 			"/audio/xaudio2/",
   140 			"/render/direct3d/",
   141 			-- these two depend on Xinput
   142 			"/haptic/windows/",
   143 			"/joystick/windows/",
   144 		}
   145 	-- in case DirectX was not found
   146 	SDL_dependency "notdirectx"
   147 		SDL_os "windows|mingw"
   148 		SDL_notdepfunc "DirectX"
   149 		SDL_config
   150 		{
   151 			-- enable dummy systems (same as disabling them)
   152 			["SDL_HAPTIC_DUMMY"] = 1,
   153 			["SDL_JOYSTICK_DUMMY"] = 1
   154 		}
   155 		SDL_paths
   156 		{
   157 			-- since we don't have Xinput
   158 			"/haptic/dummy/",
   159 			"/joystick/dummy/",
   160 		}
   161 
   162 	-- OpenGL dependency
   163 	SDL_dependency "opengl"
   164 		SDL_depfunc "OpenGL"
   165 		SDL_config
   166 		{
   167 			["SDL_VIDEO_OPENGL"] = 1,
   168 			["SDL_VIDEO_RENDER_OGL"] = 1
   169 		}
   170 		SDL_paths { "/render/opengl/" }
   171 	-- WGL dependency for OpenGL on Windows
   172 	SDL_dependency "opengl-windows"
   173 		SDL_os "windows|mingw"
   174 		SDL_depfunc "OpenGL"
   175 		SDL_config { ["SDL_VIDEO_OPENGL_WGL"] = 1 }
   176 	-- GLX dependency for OpenGL on Linux
   177 	SDL_dependency "opengl-linux"
   178 		SDL_os "linux"
   179 		SDL_depfunc "OpenGL"
   180 		SDL_config { ["SDL_VIDEO_OPENGL_GLX"] = 1 }
   181 
   182 	-- SDL2 on Mac OS X
   183 	SDL_dependency "macosx"
   184 		SDL_os "macosx"
   185 		SDL_config
   186 		{
   187 			["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
   188 			["SDL_JOYSTICK_IOKIT"] = 1,
   189 			["SDL_HAPTIC_IOKIT"] = 1,
   190 			["SDL_LOADSO_DLOPEN"] = 1,
   191 			["SDL_THREAD_PTHREAD"] = 1,
   192 			["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
   193 			["SDL_TIMER_UNIX"] = 1,
   194 			["SDL_VIDEO_DRIVER_COCOA"] = 1,
   195 			["SDL_POWER_MACOSX"] = 1,
   196 			["SDL_FILESYSTEM_COCOA"] = 1
   197 		}
   198 		SDL_paths
   199 		{
   200 			"/audio/coreaudio/",
   201 			"/file/cocoa/",
   202 			"/haptic/darwin/",
   203 			"/joystick/darwin/",
   204 			"/loadso/dlopen/",
   205 			"/power/macosx/",
   206 			"/render/opengl/",
   207 			"/thread/pthread/",
   208 			"/timer/unix/",
   209 			"/video/cocoa/",
   210 			"/video/x11/",
   211 			"/filesystem/cocoa/"
   212 		}
   213 		SDL_links
   214 		{
   215 			"AudioToolbox.framework",
   216 			"AudioUnit.framework",
   217 			"Cocoa.framework",
   218 			"CoreAudio.framework",
   219 			"IOKit.framework",
   220 			"Carbon.framework",
   221 			"ForceFeedback.framework",
   222 			"CoreFoundation.framework"
   223 		}
   224 
   225 	-- Linux dependency: DLOpen
   226 	SDL_dependency "linux-dlopen"
   227 		SDL_os "linux"
   228 		SDL_depfunc "DLOpen"
   229 		SDL_paths { "/loadso/dlopen/" }
   230 		SDL_config { ["SDL_LOADSO_DLOPEN"] = 1 }
   231 	-- Linux dependency: ALSA
   232 	SDL_dependency "linux-alsa"
   233 		SDL_os "linux"
   234 		SDL_depfunc "ALSA"
   235 		SDL_paths { "/audio/alsa/" }
   236 		SDL_config
   237 		{
   238 			["SDL_AUDIO_DRIVER_ALSA"] = 1,
   239 			["SDL_AUDIO_DRIVER_ALSA_DYNAMIC"] = '"libasound.so"'
   240 		}
   241 	-- Linux dependency: PulseAudio
   242 	SDL_dependency "linux-pulseaudio"
   243 		SDL_os "linux"
   244 		SDL_depfunc "PulseAudio"
   245 		SDL_paths { "/audio/pulseaudio/" }
   246 		SDL_config
   247 		{
   248 			["SDL_AUDIO_DRIVER_PULSEAUDIO"] = 1,
   249 			["SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC"] = '"libpulse-simple.so"'
   250 		}
   251 	-- Linux dependency: ESD
   252 	SDL_dependency "linux-esd"
   253 		SDL_os "linux"
   254 		SDL_depfunc "ESD"
   255 		SDL_paths { "/audio/esd/" }
   256 		SDL_config
   257 		{
   258 			["SDL_AUDIO_DRIVER_ESD"] = 1,
   259 			["SDL_AUDIO_DRIVER_ESD_DYNAMIC"] = '"libesd.so"'
   260 		}
   261 	-- Linux dependency: NAS
   262 	SDL_dependency "linux-nas"
   263 		SDL_os "linux"
   264 		SDL_depfunc "NAS"
   265 		SDL_paths { "/audio/nas/" }
   266 		SDL_config
   267 		{
   268 			["SDL_AUDIO_DRIVER_NAS"] = 1,
   269 			["SDL_AUDIO_DRIVER_NAS_DYNAMIC"] = '"libaudio.so"'
   270 		}
   271 	-- Linux dependency: OSS
   272 	SDL_dependency "linux-oss"
   273 		SDL_os "linux"
   274 		SDL_depfunc "OSS"
   275 		SDL_paths { "/audio/dsp/" }
   276 		SDL_config { ["SDL_AUDIO_DRIVER_OSS"] = 1 }
   277 	-- Linux dependency: X11
   278 	SDL_dependency "linux-x11"
   279 		SDL_os "linux"
   280 		SDL_depfunc "X11"
   281 		SDL_paths { "/video/x11/" }
   282 		SDL_config
   283 		{
   284 			["SDL_VIDEO_DRIVER_X11"] = 1,
   285 			["SDL_VIDEO_DRIVER_X11_DYNAMIC"] = '"libX11.so"',
   286 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT"] = '"libXext.so"',
   287 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR"] = '"libXcursor.so"',
   288 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA"] = '"libXinerama.so"',
   289 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2"] = '"libXi.so"',
   290 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR"] = '"libXrandr.so"',
   291 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS"] = '"libXss.so"',
   292 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE"] = '"libXxf86vm.so"',
   293 			["SDL_VIDEO_DRIVER_X11_XCURSOR"] = 1,
   294 			["SDL_VIDEO_DRIVER_X11_XINERAMA"] = 1,
   295 			["SDL_VIDEO_DRIVER_X11_XINPUT2"] = 1,
   296 			["SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH"] = 1,
   297 			["SDL_VIDEO_DRIVER_X11_XRANDR"] = 1,
   298 			["SDL_VIDEO_DRIVER_X11_XSCRNSAVER"] = 1,
   299 			["SDL_VIDEO_DRIVER_X11_XSHAPE"] = 1,
   300 			["SDL_VIDEO_DRIVER_X11_XVIDMODE"] = 1,
   301 			["SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS"] = 1,
   302 			["SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY"] = 1,
   303 			["SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM"] = 1
   304 		}
   305 	-- SDL2 on Linux
   306 	SDL_dependency "linux"
   307 		SDL_os "linux"
   308 		SDL_depfunc "DBus"
   309 		SDL_config
   310 		{
   311 			["SDL_INPUT_LINUXEV"] = 1,
   312 			["SDL_JOYSTICK_LINUX"] = 1,
   313 			["SDL_HAPTIC_LINUX"] = 1,
   314 			["SDL_THREAD_PTHREAD"] = 1,
   315 			["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
   316 			["SDL_TIMER_UNIX"] = 1,
   317 			["SDL_POWER_LINUX"] = 1,
   318 			["SDL_FILESYSTEM_UNIX"] = 1,
   319 		}
   320 		SDL_paths
   321 		{
   322 			"/haptic/linux/",
   323 			"/joystick/linux/",
   324 			"/power/linux/",
   325 			"/thread/pthread/",
   326 			"/timer/unix/",
   327 			"/filesystem/unix/"
   328 		}
   329 		SDL_links
   330 		{
   331 			"m",
   332 			"pthread",
   333 			"rt"
   334 		}
   335 
   336 	-- SDL2 on Cygwin (not quite working yet)
   337 	SDL_dependency "cygwin"
   338 		SDL_os "cygwin"
   339 		SDL_config
   340 		{
   341 			['SDL_JOYSTICK_DISABLED'] = 1,
   342 			['SDL_HAPTIC_DISABLED'] = 1,
   343 			['SDL_LOADSO_DLOPEN'] = 1,
   344 			['SDL_THREAD_PTHREAD'] = 1,
   345 			['SDL_THREAD_PTHREAD_RECURSIVE_MUTEX'] = 1,
   346 			['SDL_TIMER_UNIX'] = 1,
   347 			['SDL_FILESYSTEM_UNIX'] = 1,
   348 			['SDL_POWER_LINUX'] = 1
   349 		}
   350 		SDL_paths
   351 		{
   352 			"/loadso/dlopen/",
   353 			"/power/linux/",
   354 			"/render/opengl/",
   355 			"/thread/pthread/",
   356 			"/timer/unix/",
   357 			"/filesystem/unix/",
   358 			"/libm/"
   359 		}
   360 
   361 	-- SDL2 on iOS
   362 	SDL_dependency "iphoneos"
   363 		SDL_os "ios"
   364 		SDL_config
   365 		{
   366 			["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
   367 			["SDL_JOYSTICK_DISABLED"] = 0,
   368 			["SDL_HAPTIC_DISABLED"] = 1,
   369 			["SDL_LOADSO_DISABLED"] = 1,
   370 			["SDL_THREAD_PTHREAD"] = 1,
   371 			["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
   372 			["SDL_TIMER_UNIX"] = 1,
   373 			["SDL_VIDEO_DRIVER_UIKIT"] = 1,
   374 			["SDL_VIDEO_OPENGL_ES"] = 1,
   375 			["SDL_VIDEO_RENDER_OGL_ES"] = 1,
   376 			["SDL_VIDEO_RENDER_OGL_ES2"] = 1,
   377 			["SDL_POWER_UIKIT"] = 1,
   378 			["SDL_IPHONE_KEYBOARD"] = 1,
   379 			["SDL_FILESYSTEM_COCOA"] = 1
   380 		}
   381 		SDL_paths
   382 		{
   383 			"/audio/coreaudio/",
   384 			"/file/cocoa/",
   385 			"/joystick/iphoneos/",
   386 			"/loadso/dlopen/",
   387 			"/power/uikit/",
   388 			"/render/opengles/",
   389 			"/render/opengles2/",
   390 			"/thread/pthread/",
   391 			"/timer/unix/",
   392 			"/video/uikit/",
   393 			"/filesystem/cocoa/"
   394 		}
   395 		SDL_links
   396 		{
   397 			"$(SDKROOT)/AudioToolbox.framework",
   398 			"$(SDKROOT)/QuartzCore.framework",
   399 			"$(SDKROOT)/OpenGLES.framework",
   400 			"$(SDKROOT)/CoreGraphics.framework",
   401 			"$(SDKROOT)/UIKit.framework",
   402 			"$(SDKROOT)/Foundation.framework",
   403 			"$(SDKROOT)/CoreAudio.framework"
   404 		}