Commit b5e3d264f294013c4ce3dd49e9b55ed22a897f49

Sam Lantinga 2020-01-23T01:00:52

Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds Protected more code with #ifdefs to reduce the size of minimal shared library builds

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
diff --git a/src/SDL_internal.h b/src/SDL_internal.h
index 4ce31ad..21cfc3d 100644
--- a/src/SDL_internal.h
+++ b/src/SDL_internal.h
@@ -54,46 +54,67 @@
 /* A few #defines to reduce SDL2 footprint.
    Only effective when library is statically linked.
    You have to manually edit this file. */
+#ifndef SDL_LEAN_AND_MEAN
+#define SDL_LEAN_AND_MEAN               1
+#endif
 
 /* Optimized functions from 'SDL_blit_0.c'
    - blit with source BitsPerPixel < 8, palette */
-#define SDL_HAVE_BLIT_0                 1
+#ifndef SDL_HAVE_BLIT_0
+#define SDL_HAVE_BLIT_0                 !SDL_LEAN_AND_MEAN
+#endif
 
 /* Optimized functions from 'SDL_blit_1.c'
    - blit with source BytesPerPixel == 1, palette */
-#define SDL_HAVE_BLIT_1                 1
+#ifndef SDL_HAVE_BLIT_1
+#define SDL_HAVE_BLIT_1                 !SDL_LEAN_AND_MEAN
+#endif
 
 /* Optimized functions from 'SDL_blit_A.c'
    - blit with 'SDL_BLENDMODE_BLEND' blending mode */
-#define SDL_HAVE_BLIT_A                 1
+#ifndef SDL_HAVE_BLIT_A
+#define SDL_HAVE_BLIT_A                 !SDL_LEAN_AND_MEAN
+#endif
 
 /* Optimized functions from 'SDL_blit_N.c'
    - blit with COLORKEY mode, or nothing */
-#define SDL_HAVE_BLIT_N                 1
+#ifndef SDL_HAVE_BLIT_N
+#define SDL_HAVE_BLIT_N                 !SDL_LEAN_AND_MEAN
+#endif
 
 /* Optimized functions from 'SDL_blit_N.c'
    - RGB565 conversion with Lookup tables */
-#define SDL_HAVE_BLIT_N_RGB565          1
+#ifndef SDL_HAVE_BLIT_N_RGB565
+#define SDL_HAVE_BLIT_N_RGB565          !SDL_LEAN_AND_MEAN
+#endif
 
 /* Optimized functions from 'SDL_blit_AUTO.c'
    - blit with modulate color, modulate alpha, any blending mode
    - scaling or not */
-#define SDL_HAVE_BLIT_AUTO              1
+#ifndef SDL_HAVE_BLIT_AUTO
+#define SDL_HAVE_BLIT_AUTO              !SDL_LEAN_AND_MEAN
+#endif
 
 /* Run-Length-Encoding
    - SDL_SetColorKey() called with SDL_RLEACCEL flag */
-#define SDL_HAVE_RLE                    1
+#ifndef SDL_HAVE_RLE
+#define SDL_HAVE_RLE                    !SDL_LEAN_AND_MEAN
+#endif
 
 /* Software SDL_Renderer
    - creation of software renderer
    - *not* general blitting functions
    - {blend,draw}{fillrect,line,point} internal functions */
-#define SDL_VIDEO_RENDER_SW             1
+#ifndef SDL_VIDEO_RENDER_SW
+#define SDL_VIDEO_RENDER_SW             !SDL_LEAN_AND_MEAN
+#endif
 
 /* YUV formats
    - handling of YUV surfaces
    - blitting and conversion functions */
-#define SDL_HAVE_YUV                    1
+#ifndef SDL_HAVE_YUV
+#define SDL_HAVE_YUV                    !SDL_LEAN_AND_MEAN
+#endif
 
 #endif /* SDL_internal_h_ */
 
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 6a03cc5..ff7d247 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1426,6 +1426,7 @@ SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode)
     return 0;
 }
 
+#if SDL_HAVE_YUV
 static int
 SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
                      const void *pixels, int pitch)
@@ -1471,6 +1472,7 @@ SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
     }
     return 0;
 }
+#endif /* SDL_HAVE_YUV */
 
 static int
 SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
@@ -1553,6 +1555,7 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
     }
 }
 
+#if SDL_HAVE_YUV
 static int
 SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
                            const Uint8 *Yplane, int Ypitch,
@@ -1604,6 +1607,7 @@ SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
     }
     return 0;
 }
+#endif /* SDL_HAVE_YUV */
 
 int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
                          const Uint8 *Yplane, int Ypitch,
@@ -1672,12 +1676,14 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
 #endif
 }
 
+#if SDL_HAVE_YUV
 static int
 SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
                    void **pixels, int *pitch)
 {
     return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch);
 }
+#endif /* SDL_HAVE_YUV */
 
 static int
 SDL_LockTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
@@ -1767,6 +1773,7 @@ SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect,
     return 0;
 }
 
+#if SDL_HAVE_YUV
 static void
 SDL_UnlockTextureYUV(SDL_Texture * texture)
 {
@@ -1787,6 +1794,7 @@ SDL_UnlockTextureYUV(SDL_Texture * texture)
                         rect.w, rect.h, native_pixels, native_pitch);
     SDL_UnlockTexture(native);
 }
+#endif /* SDL_HAVE_YUV */
 
 static void
 SDL_UnlockTextureNative(SDL_Texture * texture)
diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c
index 2713995..c0cae26 100644
--- a/src/render/SDL_yuv_sw.c
+++ b/src/render/SDL_yuv_sw.c
@@ -22,6 +22,8 @@
 
 /* This is the software implementation of the YUV texture support */
 
+#if SDL_HAVE_YUV
+
 #include "SDL_assert.h"
 
 #include "SDL_yuv_sw_c.h"
@@ -411,4 +413,6 @@ SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
     }
 }
 
+#endif /* SDL_HAVE_YUV */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/software/SDL_blendfillrect.c b/src/render/software/SDL_blendfillrect.c
index 5e3db41..9ab5476 100644
--- a/src/render/software/SDL_blendfillrect.c
+++ b/src/render/software/SDL_blendfillrect.c
@@ -20,7 +20,7 @@
 */
 #include "../../SDL_internal.h"
 
-#if !SDL_RENDER_DISABLED
+#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
 
 #include "SDL_draw.h"
 #include "SDL_blendfillrect.h"
@@ -352,6 +352,6 @@ SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
     return status;
 }
 
-#endif /* !SDL_RENDER_DISABLED */
+#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c
index e8702e4..38b2d04 100644
--- a/src/render/software/SDL_blendline.c
+++ b/src/render/software/SDL_blendline.c
@@ -20,7 +20,7 @@
 */
 #include "../../SDL_internal.h"
 
-#if !SDL_RENDER_DISABLED
+#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
 
 #include "SDL_draw.h"
 #include "SDL_blendline.h"
@@ -870,6 +870,6 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
     return 0;
 }
 
-#endif /* !SDL_RENDER_DISABLED */
+#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/software/SDL_blendpoint.c b/src/render/software/SDL_blendpoint.c
index fde84c4..b6a406e 100644
--- a/src/render/software/SDL_blendpoint.c
+++ b/src/render/software/SDL_blendpoint.c
@@ -20,7 +20,7 @@
 */
 #include "../../SDL_internal.h"
 
-#if !SDL_RENDER_DISABLED
+#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
 
 #include "SDL_draw.h"
 #include "SDL_blendpoint.h"
@@ -357,6 +357,6 @@ SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
     return status;
 }
 
-#endif /* !SDL_RENDER_DISABLED */
+#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c
index e66627c..0faeb4f 100644
--- a/src/render/software/SDL_drawline.c
+++ b/src/render/software/SDL_drawline.c
@@ -20,7 +20,7 @@
 */
 #include "../../SDL_internal.h"
 
-#if !SDL_RENDER_DISABLED
+#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
 
 #include "SDL_draw.h"
 #include "SDL_drawline.h"
@@ -204,6 +204,6 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
     return 0;
 }
 
-#endif /* !SDL_RENDER_DISABLED */
+#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/software/SDL_drawpoint.c b/src/render/software/SDL_drawpoint.c
index 8d35320..0e78744 100644
--- a/src/render/software/SDL_drawpoint.c
+++ b/src/render/software/SDL_drawpoint.c
@@ -20,7 +20,7 @@
 */
 #include "../../SDL_internal.h"
 
-#if !SDL_RENDER_DISABLED
+#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
 
 #include "SDL_draw.h"
 #include "SDL_drawpoint.h"
@@ -109,6 +109,6 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
     return 0;
 }
 
-#endif /* !SDL_RENDER_DISABLED */
+#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index 03d40b1..b21fa2e 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -20,7 +20,7 @@
 */
 #include "../../SDL_internal.h"
 
-#if !SDL_RENDER_DISABLED
+#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
 
 #include "../SDL_sysrender.h"
 #include "SDL_render_sw_c.h"
@@ -889,6 +889,6 @@ SDL_RenderDriver SW_RenderDriver = {
      0}
 };
 
-#endif /* !SDL_RENDER_DISABLED */
+#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c
index 50f8bb6..a903d1d 100644
--- a/src/render/software/SDL_rotate.c
+++ b/src/render/software/SDL_rotate.c
@@ -30,6 +30,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
 */
 #include "../../SDL_internal.h"
 
+#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
+
 #if defined(__WIN32__)
 #include "../../core/windows/SDL_windows.h"
 #endif
@@ -532,3 +534,5 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, 
     /* Return rotated surface */
     return rz_dst;
 }
+
+#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c
index 9807694..c9b84e3 100644
--- a/src/video/SDL_RLEaccel.c
+++ b/src/video/SDL_RLEaccel.c
@@ -20,6 +20,8 @@
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_RLE
+
 /*
  * RLE encoding for software colorkey and alpha-channel acceleration
  *
@@ -1584,4 +1586,6 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode)
     }
 }
 
+#endif /* SDL_HAVE_RLE */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c
index dc0d4df..a5df0b9 100644
--- a/src/video/SDL_blit.c
+++ b/src/video/SDL_blit.c
@@ -99,6 +99,8 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect,
     return (okay ? 0 : -1);
 }
 
+#if SDL_HAVE_BLIT_AUTO
+
 #ifdef __MACOSX__
 #include <sys/sysctl.h>
 
@@ -187,6 +189,7 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
     }
     return NULL;
 }
+#endif /* SDL_HAVE_BLIT_AUTO */
 
 /* Figure out which of many blit routines to set up on a surface */
 int
diff --git a/src/video/SDL_blit_0.c b/src/video/SDL_blit_0.c
index bd949ef..1e4ebbe 100644
--- a/src/video/SDL_blit_0.c
+++ b/src/video/SDL_blit_0.c
@@ -20,6 +20,8 @@
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_BLIT_0
+
 #include "SDL_video.h"
 #include "SDL_blit.h"
 
@@ -480,4 +482,6 @@ SDL_CalculateBlit0(SDL_Surface * surface)
     return (SDL_BlitFunc) NULL;
 }
 
+#endif /* SDL_HAVE_BLIT_0 */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_blit_1.c b/src/video/SDL_blit_1.c
index 36e3d89..d75caff 100644
--- a/src/video/SDL_blit_1.c
+++ b/src/video/SDL_blit_1.c
@@ -20,6 +20,8 @@
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_BLIT_1
+
 #include "SDL_video.h"
 #include "SDL_blit.h"
 #include "SDL_sysvideo.h"
@@ -549,4 +551,6 @@ SDL_CalculateBlit1(SDL_Surface * surface)
     return (SDL_BlitFunc) NULL;
 }
 
+#endif /* SDL_HAVE_BLIT_1 */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c
index 0db5780..c9c37f0 100644
--- a/src/video/SDL_blit_A.c
+++ b/src/video/SDL_blit_A.c
@@ -20,6 +20,8 @@
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_BLIT_A
+
 #include "SDL_video.h"
 #include "SDL_blit.h"
 
@@ -1489,4 +1491,6 @@ SDL_CalculateBlitA(SDL_Surface * surface)
     return NULL;
 }
 
+#endif /* SDL_HAVE_BLIT_A */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c
index 419dc67..39c08f6 100644
--- a/src/video/SDL_blit_N.c
+++ b/src/video/SDL_blit_N.c
@@ -20,6 +20,8 @@
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_BLIT_N
+
 #include "SDL_video.h"
 #include "SDL_endian.h"
 #include "SDL_cpuinfo.h"
@@ -1450,6 +1452,8 @@ Blit_RGB888_RGB565(SDL_BlitInfo * info)
 }
 
 
+#if SDL_HAVE_BLIT_N_RGB565
+
 /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */
 #define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1])
 static void
@@ -2068,6 +2072,8 @@ Blit_RGB565_BGRA8888(SDL_BlitInfo * info)
     Blit_RGB565_32(info, RGB565_BGRA8888_LUT);
 }
 
+#endif /* SDL_HAVE_BLIT_N_RGB565 */
+
 static void
 BlitNto1(SDL_BlitInfo * info)
 {
@@ -3461,4 +3467,6 @@ SDL_CalculateBlitN(SDL_Surface * surface)
     return NULL;
 }
 
+#endif /* SDL_HAVE_BLIT_N */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_blit_auto.c b/src/video/SDL_blit_auto.c
index 7edcdd1..7aff395 100644
--- a/src/video/SDL_blit_auto.c
+++ b/src/video/SDL_blit_auto.c
@@ -21,6 +21,8 @@
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_BLIT_AUTO
+
 /* *INDENT-OFF* */
 
 #include "SDL_video.h"
@@ -7674,4 +7676,6 @@ SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
 
 /* *INDENT-ON* */
 
+#endif /* SDL_HAVE_BLIT_AUTO */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_blit_auto.h b/src/video/SDL_blit_auto.h
index a93cefd..53deacb 100644
--- a/src/video/SDL_blit_auto.h
+++ b/src/video/SDL_blit_auto.h
@@ -21,10 +21,14 @@
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_BLIT_AUTO
+
 /* *INDENT-OFF* */
 
 extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[];
 
 /* *INDENT-ON* */
 
+#endif /* SDL_HAVE_BLIT_AUTO */
+
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c
index 7e1cc70..4b9755d 100644
--- a/src/video/SDL_yuv.c
+++ b/src/video/SDL_yuv.c
@@ -56,6 +56,8 @@ SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionModeForResolution(int width, int hei
     return mode;
 }
 
+#if SDL_HAVE_YUV
+
 static int GetYUVConversionType(int width, int height, YCbCrType *yuv_type)
 {
     switch (SDL_GetYUVConversionModeForResolution(width, height)) {
@@ -1809,11 +1811,14 @@ SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height,
     return 0;
 }
 
+#endif /* SDL_HAVE_YUV */
+
 int
 SDL_ConvertPixels_YUV_to_YUV(int width, int height,
          Uint32 src_format, const void *src, int src_pitch,
          Uint32 dst_format, void *dst, int dst_pitch)
 {
+#if SDL_HAVE_YUV
     if (src_format == dst_format) {
         if (src == dst) {
             /* Nothing to do */
@@ -1833,6 +1838,9 @@ SDL_ConvertPixels_YUV_to_YUV(int width, int height,
     } else {
         return SDL_SetError("SDL_ConvertPixels_YUV_to_YUV: Unsupported YUV conversion: %s -> %s", SDL_GetPixelFormatName(src_format), SDL_GetPixelFormatName(dst_format));
     }
+#else
+	return SDL_SetError("SDL not built with YUV support");
+#endif
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/sdlgenblit.pl b/src/video/sdlgenblit.pl
index eca8f89..6206ec2 100755
--- a/src/video/sdlgenblit.pl
+++ b/src/video/sdlgenblit.pl
@@ -112,6 +112,8 @@ sub open_file {
 */
 #include "../SDL_internal.h"
 
+#if SDL_HAVE_BLIT_AUTO
+
 /* *INDENT-OFF* */
 
 __EOF__
@@ -122,6 +124,8 @@ sub close_file {
     print FILE <<__EOF__;
 /* *INDENT-ON* */
 
+#endif /* SDL_HAVE_BLIT_AUTO */
+
 /* vi: set ts=4 sw=4 expandtab: */
 __EOF__
     close FILE;
diff --git a/src/video/yuv2rgb/yuv_rgb.c b/src/video/yuv2rgb/yuv_rgb.c
index 891dae2..6e821a8 100644
--- a/src/video/yuv2rgb/yuv_rgb.c
+++ b/src/video/yuv2rgb/yuv_rgb.c
@@ -2,6 +2,8 @@
 // Distributed under BSD 3-Clause License
 #include "../../SDL_internal.h"
 
+#if SDL_HAVE_YUV
+
 #include "yuv_rgb.h"
 
 #include "SDL_cpuinfo.h"
@@ -685,3 +687,4 @@ void rgb24_yuv420_sseu(uint32_t width, uint32_t height,
 
 #endif //__SSE2__
 
+#endif /* SDL_HAVE_YUV */