sdlconf.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/sh
  2. [ ! -f src/SDL.c ] && exit
  3. ./configure --enable-static --disable-shared --enable-assertions=release --enable-video --disable-render \
  4. --disable-audio --disable-joystick --disable-haptic --disable-sensor --disable-power --disable-filesystem \
  5. --disable-threads --disable-file --disable-jack --disable-diskaudio --disable-dummyaudio --disable-libsamplerate \
  6. --disable-video-opengl --disable-video-opengles --disable-video-opengles1 --disable-video-opengles2 --disable-video-vulkan \
  7. --disable-pthreads --disable-directx --disable-wasapi --disable-sdl-dlopen --disable-dbus --disable-ime --disable-ibus \
  8. --disable-oss --disable-alsa --disable-pulseaudio --disable-esd --disable-arts --disable-nas --disable-sndio \
  9. --disable-fusionsound --disable-libudev --disable-video-x11-xdbe --disable-video-x11-xinerama --disable-video-x11-xrandr \
  10. --disable-video-x11-xinput --disable-video-x11-scrnsaver --disable-video-x11-xshape --disable-video-x11-vm \
  11. --disable-video-vivante --disable-video-directfb --disable-video-dummy --disable-video-kmsdrm --disable-hidapi
  12. # we must overwrite a header file in the source, there's no other way to compile a static SDL library
  13. cat >src/dynapi/SDL_dynapi.h <<EOF
  14. #ifndef SDL_dynapi_h_
  15. #define SDL_dynapi_h_
  16. #define SDL_DYNAMIC_API 0
  17. #endif
  18. EOF
  19. # Makefile header, common part. Configure generated one that includes everything, even disabled subsystems...
  20. cat >Makefile <<EOF
  21. # Makefile to build the SDL library
  22. INCLUDE = -I./include
  23. CFLAGS = -O2 \$(INCLUDE)
  24. AR = ar
  25. RANLIB = ranlib
  26. TARGET = libSDL.a
  27. SOURCES = \\
  28. src/*.c \\
  29. src/atomic/*.c \\
  30. src/cpuinfo/*.c \\
  31. src/events/*.c \\
  32. src/file/*.c \\
  33. src/stdlib/*.c \\
  34. src/thread/*.c \\
  35. src/thread/generic/*.c \\
  36. src/timer/*.c \\
  37. src/render/*.c \\
  38. src/video/*.c \\
  39. src/video/yuv2rgb/*.c \\
  40. EOF
  41. # check in the newly generated SDL_config.h, which drivers we have and only include those
  42. [ "`grep 'define SDL_VIDEO_DRIVER_X11 1' include/SDL_config.h`" != "" ] && cat >>Makefile <<EOF
  43. src/core/unix/*.c \\
  44. src/timer/unix/*.c \\
  45. src/video/x11/*.c \\
  46. EOF
  47. [ "`grep 'define SDL_VIDEO_DRIVER_WAYLAND 1' include/SDL_config.h`" != "" ] && cat >>Makefile <<EOF
  48. src/core/unix/*.c \\
  49. src/timer/unix/*.c \\
  50. src/video/wayland/*.c \\
  51. EOF
  52. [ "`grep 'define SDL_VIDEO_DRIVER_WINDOWS 1' include/SDL_config.h`" != "" ] && cat >>Makefile <<EOF
  53. src/core/windows/*.c \\
  54. src/loadso/windows/*.c \\
  55. src/timer/windows/*.c \\
  56. src/video/windows/*.c \\
  57. EOF
  58. [ "`grep 'define SDL_VIDEO_DRIVER_COCOA 1' include/SDL_config.h`" != "" ] && cat >>Makefile <<EOF
  59. src/core/unix/*.c \\
  60. src/timer/unix/*.c \\
  61. src/file/cocoa/*.m \\
  62. src/video/cocoa/*.m \\
  63. EOF
  64. # Makefile footer, common part
  65. cat >>Makefile <<EOF
  66. OBJECTS = \$(shell echo \$(SOURCES) | sed -e 's,\\.c,\\.o,g' | sed -e 's,\\.m,\\.o,g')
  67. all: \$(TARGET)
  68. \$(TARGET): \$(OBJECTS)
  69. \$(AR) crv \$@ \$^
  70. \$(RANLIB) \$@
  71. clean:
  72. rm -f \$(TARGET) \$(OBJECTS)
  73. EOF