premake/projects/SDL2.lua
author Ryan C. Gordon
Mon, 09 Dec 2013 16:03:18 -0500
changeset 8094 9efaae827924
parent 7925 f090a47eb7f7
child 8149 681eb46b8ac4
permissions -rwxr-xr-x
Implemented the Dynamic API magic.
     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 		"/dynapi/",
    73 		"/events/",
    74 		"/file/",
    75 		"/haptic/",
    76 		"/joystick/",
    77 		"/power/",
    78 		"/render/",
    79 		"/render/software/",
    80 		"/stdlib/",
    81 		"/thread/",
    82 		"/timer/",
    83 		"/video/",
    84 		"/video/dummy/"
    85 	}
    86 
    87 	-- SDL2 on Windows
    88 	SDL_dependency "windows"
    89 		SDL_os "windows|mingw"
    90 		SDL_links { "imm32", "oleaut32", "winmm", "version" }
    91 		-- these are the links that Visual Studio includes by default
    92 		SDL_links { "kernel32", "user32", "gdi32", "winspool",
    93 			"comdlg32", "advapi32", "shell32", "ole32",
    94 			"oleaut32", "uuid", "odbc32", "odbccp32" }
    95 		SDL_config
    96 		{
    97 			["SDL_LOADSO_WINDOWS"] = 1,
    98 			["SDL_THREAD_WINDOWS"] = 1,
    99 			["SDL_TIMER_WINDOWS"] = 1,
   100 			["SDL_VIDEO_DRIVER_WINDOWS"] = 1,
   101 			["SDL_POWER_WINDOWS"] = 1,
   102 			["SDL_AUDIO_DRIVER_WINMM"] = 1,
   103 			["SDL_FILESYSTEM_WINDOWS"] = 1
   104 		}
   105 		SDL_paths
   106 		{
   107 			"/audio/winmm/",
   108 			"/core/windows/",
   109 			"/libm/",
   110 			"/loadso/windows/",
   111 			"/power/windows/",
   112 			"/thread/windows/",
   113 			"/timer/windows/",
   114 			"/video/windows/",
   115 			"/filesystem/windows/"
   116 		}
   117 		SDL_files
   118 		{
   119 			-- these files have to be specified uniquely to avoid double
   120 			-- and incorrect linking
   121 			"/thread/generic/SDL_syscond.c",
   122 			"/thread/generic/SDL_sysmutex_c.h"
   123 		}
   124 
   125 	-- DirectX dependency
   126 	SDL_dependency "directx"
   127 		SDL_os "windows|mingw"
   128 		SDL_depfunc "DirectX"
   129 		SDL_config
   130 		{
   131 			["SDL_AUDIO_DRIVER_DSOUND"] = 1,
   132 			["SDL_AUDIO_DRIVER_XAUDIO2"] = 1,
   133 			["SDL_JOYSTICK_DINPUT"] = 1,
   134 			["SDL_HAPTIC_DINPUT"] = 1,
   135 			["SDL_VIDEO_RENDER_D3D"] = 1
   136 		}
   137 		SDL_paths
   138 		{
   139 			"/audio/directsound/",
   140 			"/audio/xaudio2/",
   141 			"/render/direct3d/",
   142 			-- these two depend on Xinput
   143 			"/haptic/windows/",
   144 			"/joystick/windows/",
   145 		}
   146 	-- in case DirectX was not found
   147 	SDL_dependency "notdirectx"
   148 		SDL_os "windows|mingw"
   149 		SDL_notdepfunc "DirectX"
   150 		SDL_config
   151 		{
   152 			-- enable dummy systems (same as disabling them)
   153 			["SDL_HAPTIC_DUMMY"] = 1,
   154 			["SDL_JOYSTICK_DUMMY"] = 1
   155 		}
   156 		SDL_paths
   157 		{
   158 			-- since we don't have Xinput
   159 			"/haptic/dummy/",
   160 			"/joystick/dummy/",
   161 		}
   162 
   163 	-- OpenGL dependency
   164 	SDL_dependency "opengl"
   165 		SDL_depfunc "OpenGL"
   166 		SDL_config
   167 		{
   168 			["SDL_VIDEO_OPENGL"] = 1,
   169 			["SDL_VIDEO_RENDER_OGL"] = 1
   170 		}
   171 		SDL_paths { "/render/opengl/" }
   172 	-- WGL dependency for OpenGL on Windows
   173 	SDL_dependency "opengl-windows"
   174 		SDL_os "windows|mingw"
   175 		SDL_depfunc "OpenGL"
   176 		SDL_config { ["SDL_VIDEO_OPENGL_WGL"] = 1 }
   177 	-- GLX dependency for OpenGL on Linux
   178 	SDL_dependency "opengl-linux"
   179 		SDL_os "linux"
   180 		SDL_depfunc "OpenGL"
   181 		SDL_config { ["SDL_VIDEO_OPENGL_GLX"] = 1 }
   182 
   183 	-- SDL2 on Mac OS X
   184 	SDL_dependency "macosx"
   185 		SDL_os "macosx"
   186 		SDL_config
   187 		{
   188 			["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
   189 			["SDL_JOYSTICK_IOKIT"] = 1,
   190 			["SDL_HAPTIC_IOKIT"] = 1,
   191 			["SDL_LOADSO_DLOPEN"] = 1,
   192 			["SDL_THREAD_PTHREAD"] = 1,
   193 			["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
   194 			["SDL_TIMER_UNIX"] = 1,
   195 			["SDL_VIDEO_DRIVER_COCOA"] = 1,
   196 			["SDL_POWER_MACOSX"] = 1,
   197 			["SDL_FILESYSTEM_COCOA"] = 1
   198 		}
   199 		SDL_paths
   200 		{
   201 			"/audio/coreaudio/",
   202 			"/file/cocoa/",
   203 			"/haptic/darwin/",
   204 			"/joystick/darwin/",
   205 			"/loadso/dlopen/",
   206 			"/power/macosx/",
   207 			"/render/opengl/",
   208 			"/thread/pthread/",
   209 			"/timer/unix/",
   210 			"/video/cocoa/",
   211 			"/video/x11/",
   212 			"/filesystem/cocoa/"
   213 		}
   214 		SDL_links
   215 		{
   216 			"AudioToolbox.framework",
   217 			"AudioUnit.framework",
   218 			"Cocoa.framework",
   219 			"CoreAudio.framework",
   220 			"IOKit.framework",
   221 			"Carbon.framework",
   222 			"ForceFeedback.framework",
   223 			"CoreFoundation.framework"
   224 		}
   225 
   226 	-- Linux dependency: DLOpen
   227 	SDL_dependency "linux-dlopen"
   228 		SDL_os "linux"
   229 		SDL_depfunc "DLOpen"
   230 		SDL_paths { "/loadso/dlopen/" }
   231 		SDL_config { ["SDL_LOADSO_DLOPEN"] = 1 }
   232 	-- Linux dependency: ALSA
   233 	SDL_dependency "linux-alsa"
   234 		SDL_os "linux"
   235 		SDL_depfunc "ALSA"
   236 		SDL_paths { "/audio/alsa/" }
   237 		SDL_config
   238 		{
   239 			["SDL_AUDIO_DRIVER_ALSA"] = 1,
   240 			["SDL_AUDIO_DRIVER_ALSA_DYNAMIC"] = '"libasound.so"'
   241 		}
   242 	-- Linux dependency: PulseAudio
   243 	SDL_dependency "linux-pulseaudio"
   244 		SDL_os "linux"
   245 		SDL_depfunc "PulseAudio"
   246 		SDL_paths { "/audio/pulseaudio/" }
   247 		SDL_config
   248 		{
   249 			["SDL_AUDIO_DRIVER_PULSEAUDIO"] = 1,
   250 			["SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC"] = '"libpulse-simple.so"'
   251 		}
   252 	-- Linux dependency: ESD
   253 	SDL_dependency "linux-esd"
   254 		SDL_os "linux"
   255 		SDL_depfunc "ESD"
   256 		SDL_paths { "/audio/esd/" }
   257 		SDL_config
   258 		{
   259 			["SDL_AUDIO_DRIVER_ESD"] = 1,
   260 			["SDL_AUDIO_DRIVER_ESD_DYNAMIC"] = '"libesd.so"'
   261 		}
   262 	-- Linux dependency: NAS
   263 	SDL_dependency "linux-nas"
   264 		SDL_os "linux"
   265 		SDL_depfunc "NAS"
   266 		SDL_paths { "/audio/nas/" }
   267 		SDL_config
   268 		{
   269 			["SDL_AUDIO_DRIVER_NAS"] = 1,
   270 			["SDL_AUDIO_DRIVER_NAS_DYNAMIC"] = '"libaudio.so"'
   271 		}
   272 	-- Linux dependency: OSS
   273 	SDL_dependency "linux-oss"
   274 		SDL_os "linux"
   275 		SDL_depfunc "OSS"
   276 		SDL_paths { "/audio/dsp/" }
   277 		SDL_config { ["SDL_AUDIO_DRIVER_OSS"] = 1 }
   278 	-- Linux dependency: X11
   279 	SDL_dependency "linux-x11"
   280 		SDL_os "linux"
   281 		SDL_depfunc "X11"
   282 		SDL_paths { "/video/x11/" }
   283 		SDL_config
   284 		{
   285 			["SDL_VIDEO_DRIVER_X11"] = 1,
   286 			["SDL_VIDEO_DRIVER_X11_DYNAMIC"] = '"libX11.so"',
   287 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT"] = '"libXext.so"',
   288 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR"] = '"libXcursor.so"',
   289 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA"] = '"libXinerama.so"',
   290 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2"] = '"libXi.so"',
   291 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR"] = '"libXrandr.so"',
   292 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS"] = '"libXss.so"',
   293 			["SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE"] = '"libXxf86vm.so"',
   294 			["SDL_VIDEO_DRIVER_X11_XCURSOR"] = 1,
   295 			["SDL_VIDEO_DRIVER_X11_XINERAMA"] = 1,
   296 			["SDL_VIDEO_DRIVER_X11_XINPUT2"] = 1,
   297 			["SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH"] = 1,
   298 			["SDL_VIDEO_DRIVER_X11_XRANDR"] = 1,
   299 			["SDL_VIDEO_DRIVER_X11_XSCRNSAVER"] = 1,
   300 			["SDL_VIDEO_DRIVER_X11_XSHAPE"] = 1,
   301 			["SDL_VIDEO_DRIVER_X11_XVIDMODE"] = 1,
   302 			["SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS"] = 1,
   303 			["SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY"] = 1,
   304 			["SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM"] = 1
   305 		}
   306 	-- SDL2 on Linux
   307 	SDL_dependency "linux"
   308 		SDL_os "linux"
   309 		SDL_depfunc "DBus"
   310 		SDL_config
   311 		{
   312 			["SDL_INPUT_LINUXEV"] = 1,
   313 			["SDL_JOYSTICK_LINUX"] = 1,
   314 			["SDL_HAPTIC_LINUX"] = 1,
   315 			["SDL_THREAD_PTHREAD"] = 1,
   316 			["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
   317 			["SDL_TIMER_UNIX"] = 1,
   318 			["SDL_POWER_LINUX"] = 1,
   319 			["SDL_FILESYSTEM_UNIX"] = 1,
   320 		}
   321 		SDL_paths
   322 		{
   323 			"/haptic/linux/",
   324 			"/joystick/linux/",
   325 			"/power/linux/",
   326 			"/thread/pthread/",
   327 			"/timer/unix/",
   328 			"/filesystem/unix/"
   329 		}
   330 		SDL_links
   331 		{
   332 			"m",
   333 			"pthread",
   334 			"rt"
   335 		}
   336 
   337 	-- SDL2 on Cygwin (not quite working yet)
   338 	SDL_dependency "cygwin"
   339 		SDL_os "cygwin"
   340 		SDL_config
   341 		{
   342 			['SDL_JOYSTICK_DISABLED'] = 1,
   343 			['SDL_HAPTIC_DISABLED'] = 1,
   344 			['SDL_LOADSO_DLOPEN'] = 1,
   345 			['SDL_THREAD_PTHREAD'] = 1,
   346 			['SDL_THREAD_PTHREAD_RECURSIVE_MUTEX'] = 1,
   347 			['SDL_TIMER_UNIX'] = 1,
   348 			['SDL_FILESYSTEM_UNIX'] = 1,
   349 			['SDL_POWER_LINUX'] = 1
   350 		}
   351 		SDL_paths
   352 		{
   353 			"/loadso/dlopen/",
   354 			"/power/linux/",
   355 			"/render/opengl/",
   356 			"/thread/pthread/",
   357 			"/timer/unix/",
   358 			"/filesystem/unix/",
   359 			"/libm/"
   360 		}
   361 
   362 	-- SDL2 on iOS
   363 	SDL_dependency "iphoneos"
   364 		SDL_os "ios"
   365 		SDL_config
   366 		{
   367 			["SDL_AUDIO_DRIVER_COREAUDIO"] = 1,
   368 			["SDL_JOYSTICK_DISABLED"] = 0,
   369 			["SDL_HAPTIC_DISABLED"] = 1,
   370 			["SDL_LOADSO_DISABLED"] = 1,
   371 			["SDL_THREAD_PTHREAD"] = 1,
   372 			["SDL_THREAD_PTHREAD_RECURSIVE_MUTEX"] = 1,
   373 			["SDL_TIMER_UNIX"] = 1,
   374 			["SDL_VIDEO_DRIVER_UIKIT"] = 1,
   375 			["SDL_VIDEO_OPENGL_ES"] = 1,
   376 			["SDL_VIDEO_RENDER_OGL_ES"] = 1,
   377 			["SDL_VIDEO_RENDER_OGL_ES2"] = 1,
   378 			["SDL_POWER_UIKIT"] = 1,
   379 			["SDL_IPHONE_KEYBOARD"] = 1,
   380 			["SDL_FILESYSTEM_COCOA"] = 1
   381 		}
   382 		SDL_paths
   383 		{
   384 			"/audio/coreaudio/",
   385 			"/file/cocoa/",
   386 			"/joystick/iphoneos/",
   387 			"/loadso/dlopen/",
   388 			"/power/uikit/",
   389 			"/render/opengles/",
   390 			"/render/opengles2/",
   391 			"/thread/pthread/",
   392 			"/timer/unix/",
   393 			"/video/uikit/",
   394 			"/filesystem/cocoa/"
   395 		}
   396 		SDL_links
   397 		{
   398 			"$(SDKROOT)/AudioToolbox.framework",
   399 			"$(SDKROOT)/QuartzCore.framework",
   400 			"$(SDKROOT)/OpenGLES.framework",
   401 			"$(SDKROOT)/CoreGraphics.framework",
   402 			"$(SDKROOT)/UIKit.framework",
   403 			"$(SDKROOT)/Foundation.framework",
   404 			"$(SDKROOT)/CoreAudio.framework"
   405 		}