docs/README-porting.md
author Ryan C. Gordon <icculus@icculus.org>
Mon, 29 Oct 2018 20:00:03 -0400
changeset 12369 68c87b40b434
parent 11005 5f5bd41b1fc6
child 12674 e2d1f4e9c323
permissions -rw-r--r--
winmain: Don't use SDL_malloc (or SDL_stack_alloc, which might be malloc).

Otherwise, we are using the allocator before the app can set up its own hooks.

Now we use VirtualAlloc, and WideCharToMultiByte (because SDL_iconv uses
SDL_malloc, too!) to get ready to call into SDL_main.

This also makes console_wmain() call into the same routines as everything
else, so we don't have to deal with those allocations, too. Hopefully we
end up with the same results from GetCommandLine() as we do in wargv.

Fixes Bugzilla #4340.
philipp@10153
     1
Porting
philipp@10153
     2
=======
gabomdq@9023
     3
gabomdq@9023
     4
* Porting To A New Platform
gabomdq@9023
     5
gabomdq@9023
     6
  The first thing you have to do when porting to a new platform, is look at
gabomdq@9023
     7
include/SDL_platform.h and create an entry there for your operating system.
philipp@10153
     8
The standard format is "__PLATFORM__", where PLATFORM is the name of the OS.
gabomdq@9023
     9
Ideally SDL_platform.h will be able to auto-detect the system it's building
gabomdq@9023
    10
on based on C preprocessor symbols.
gabomdq@9023
    11
gabomdq@9023
    12
There are two basic ways of building SDL at the moment:
gabomdq@9023
    13
gabomdq@9023
    14
1. The "UNIX" way:  ./configure; make; make install
gabomdq@9023
    15
gabomdq@9023
    16
   If you have a GNUish system, then you might try this.  Edit configure.in,
gabomdq@9023
    17
   take a look at the large section labelled:
philipp@10153
    18
philipp@9316
    19
	"Set up the configuration based on the host platform!"
philipp@10153
    20
gabomdq@9023
    21
   Add a section for your platform, and then re-run autogen.sh and build!
gabomdq@9023
    22
gabomdq@9023
    23
2. Using an IDE:
gabomdq@9023
    24
gabomdq@9023
    25
   If you're using an IDE or other non-configure build system, you'll probably
gabomdq@9023
    26
   want to create a custom SDL_config.h for your platform.  Edit SDL_config.h,
gabomdq@9023
    27
   add a section for your platform, and create a custom SDL_config_{platform}.h,
philipp@10941
    28
   based on SDL_config_minimal.h and SDL_config.h.in
gabomdq@9023
    29
gabomdq@9023
    30
   Add the top level include directory to the header search path, and then add
gabomdq@9023
    31
   the following sources to the project:
philipp@10153
    32
gabomdq@9023
    33
	src/*.c
gabomdq@9023
    34
	src/atomic/*.c
gabomdq@9023
    35
	src/audio/*.c
gabomdq@9023
    36
	src/cpuinfo/*.c
gabomdq@9023
    37
	src/events/*.c
gabomdq@9023
    38
	src/file/*.c
gabomdq@9023
    39
	src/haptic/*.c
gabomdq@9023
    40
	src/joystick/*.c
gabomdq@9023
    41
	src/power/*.c
gabomdq@9023
    42
	src/render/*.c
philipp@11005
    43
	src/render/software/*.c
gabomdq@9023
    44
	src/stdlib/*.c
gabomdq@9023
    45
	src/thread/*.c
gabomdq@9023
    46
	src/timer/*.c
gabomdq@9023
    47
	src/video/*.c
gabomdq@9023
    48
	src/audio/disk/*.c
gabomdq@9023
    49
	src/audio/dummy/*.c
philipp@9824
    50
	src/filesystem/dummy/*.c
gabomdq@9023
    51
	src/video/dummy/*.c
gabomdq@9023
    52
	src/haptic/dummy/*.c
gabomdq@9023
    53
	src/joystick/dummy/*.c
gabomdq@9023
    54
	src/main/dummy/*.c
gabomdq@9023
    55
	src/thread/generic/*.c
gabomdq@9023
    56
	src/timer/dummy/*.c
gabomdq@9023
    57
	src/loadso/dummy/*.c
gabomdq@9023
    58
gabomdq@9023
    59
gabomdq@9023
    60
Once you have a working library without any drivers, you can go back to each
gabomdq@9023
    61
of the major subsystems and start implementing drivers for your platform.
gabomdq@9023
    62
gabomdq@9023
    63
If you have any questions, don't hesitate to ask on the SDL mailing list:
gabomdq@9023
    64
	http://www.libsdl.org/mailing-list.php
gabomdq@9023
    65
gabomdq@9023
    66
Enjoy!
gabomdq@9023
    67
	Sam Lantinga				(slouken@libsdl.org)
gabomdq@9023
    68