Skip to content

Commit 5efd3f1

Browse files
committed
makefiles: remove MUSIC, introduce SIMPLE_SDL2
when defined, sdl_gfx and sdl_music are omitted when linking
1 parent ea18a57 commit 5efd3f1

6 files changed

Lines changed: 26 additions & 203 deletions

File tree

helpers/Makefile.3ds

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ BUILD := build_3ds
1919
NO_SMDH := 1 # idk how this broke
2020

2121
# remove some libs/flags not used yet on 3DS
22-
LIBS := $(filter-out -lSDL2_gfx -lSDL2_mixer,$(LIBS))
23-
CFLAGS := $(filter-out -DMUSIC,$(CFLAGS))
22+
SIMPLE_SDL2 := 1
2423

2524
#---------------------------------------------------------------------------------
2625
ifneq ($(BUILD),$(notdir $(CURDIR)))

helpers/Makefile.sdl2

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ ifeq (pc,$(MAKECMDGOALS))
55
endif
66
endif
77

8-
LIBS += -lSDL2_ttf -lSDL2_image -lSDL2_gfx -lSDL2_mixer -lmpg123 -lSDL2 -lSDL2main -lfreetype -lpng -lbz2 -ljpeg -lz
8+
ADV_LIBS := -lSDL2_gfx -lSDL2_mixer
9+
10+
# check if SIMPLE_SDL2 is defined
11+
ifeq ($(SIMPLE_SDL2),1)
12+
ADV_LIBS :=
13+
CFLAGS += -DSIMPLE_SDL2
14+
endif
15+
16+
LIBS += -lSDL2_ttf -lSDL2_image $(ADV_LIBS) -lmpg123 -lSDL2 -lSDL2main -lfreetype -lpng -lbz2 -ljpeg -lz
917
CFLAGS += -DSDL2 -DMUSIC
1018

1119
$(info MAKECMDGOALS: $(MAKECMDGOALS))

src/DrawUtils.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void CST_DrawExit()
7373
SDL_DestroyWindow(RootDisplay::mainDisplay->window);
7474
SDL_QuitSubSystem(SDL_INIT_VIDEO);
7575

76-
#ifdef MUSIC
76+
#ifndef SIMPLE_SDL2
7777
auto root = RootDisplay::mainDisplay;
7878
if (root->music != NULL)
7979
{
@@ -92,7 +92,7 @@ void CST_DrawExit()
9292

9393
void CST_MixerInit(RootDisplay* root)
9494
{
95-
#if defined(MUSIC)
95+
#if !defined(SIMPLE_SDL2)
9696
Mix_Init(MIX_INIT_MP3);
9797
if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 4096) != 0) {
9898
printf("Failed to initialize SDL2 mixer: %s\n", Mix_GetError());
@@ -149,7 +149,7 @@ bool CST_SavePNG(CST_Texture* texture, const char* file_name)
149149

150150
void CST_FadeInMusic(RootDisplay* root)
151151
{
152-
#if defined(MUSIC)
152+
#if !defined(SIMPLE_SDL2)
153153
if (root->music)
154154
{
155155
Mix_VolumeMusic(0.85 * MIX_MAX_VOLUME);
@@ -238,8 +238,8 @@ void CST_SetQualityHint(const char* quality)
238238

239239
void CST_filledCircleRGBA(CST_Renderer* renderer, uint32_t x, uint32_t y, uint32_t radius, uint32_t r, uint32_t g, uint32_t b, uint32_t a)
240240
{
241-
#if !defined(_3DS) && !defined(_3DS_MOCK)
242-
// TODO: filledCircleRGBA needs to take a surface on 3DS
241+
#if !defined(SIMPLE_SDL2)
242+
// TODO: filledCircleRGBA needs to take a surface in SIMPLE_SDL2
243243
filledCircleRGBA(renderer, x, y, radius, r, g, b, a);
244244
#endif
245245
}
@@ -323,8 +323,8 @@ void CST_roundedBoxRGBA (
323323
Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
324324
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a
325325
) {
326-
#if !defined(_3DS) && !defined(_3DS_MOCK)
327-
// TODO: roundedBoxRGBA needs to take a surface on 3DS
326+
#if !defined(SIMPLE_SDL2)
327+
// TODO: roundedBoxRGBA needs to take a surface in SIMPLE_SDL2
328328
roundedBoxRGBA(renderer, x1, y1, x2, y2, rad, r, g, b, a);
329329
#endif
330330
}
@@ -334,8 +334,8 @@ void CST_roundedRectangleRGBA (
334334
Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
335335
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a
336336
) {
337-
#if !defined(_3DS) && !defined(_3DS_MOCK)
338-
// TODO: roundedRectangleRGBA needs to take a surface on 3DS
337+
#if !defined(SIMPLE_SDL2)
338+
// TODO: roundedRectangleRGBA needs to take a surface in SIMPLE_SDL2
339339
roundedRectangleRGBA(renderer, x1, y1, x2, y2, rad, r, g, b, a);
340340
#endif
341341
}
@@ -345,13 +345,13 @@ void CST_rectangleRGBA (
345345
Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
346346
Uint8 r, Uint8 g, Uint8 b, Uint8 a
347347
) {
348-
#if !defined(_3DS) && !defined(_3DS_MOCK)
349-
// TODO: rectangleRGBA needs to take a surface on 3DS
348+
#if !defined(SIMPLE_SDL2)
349+
// TODO: rectangleRGBA needs to take a surface in SIMPLE_SDL2
350350
rectangleRGBA(renderer, x1, y1, x2, y2, r, g, b, a);
351351
#endif
352352
}
353353

354-
#ifdef MUSIC
354+
#ifndef SIMPLE_SDL2
355355

356356
// returns a size-3 vector of: (title, artist, album)
357357
std::vector<std::string> CST_GetMusicInfo(CST_Music* music) {

src/DrawUtils.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
#include <SDL2/SDL_image.h>
55
#include <SDL2/SDL_ttf.h>
66

7-
#if !defined(_3DS)
7+
#if !defined(SIMPLE_SDL2)
88
#include <SDL2/SDL2_gfxPrimitives.h> // 3ds has no gfx library
99
#endif
1010

1111
#include "../libs/SDL_FontCache/SDL_FontCache.h"
1212

1313
#include <string>
1414

15-
#if defined(MUSIC)
15+
#if !defined(SIMPLE_SDL2)
1616
#include <SDL2/SDL_mixer.h>
1717
#include <mpg123.h>
1818
typedef Mix_Music CST_Music;
@@ -88,7 +88,7 @@ void CST_SetWindowTitle(const char* title);
8888
void CST_SetCursor(int cursor);
8989
void CST_LowRumble(InputEvents* event, int ms);
9090

91-
#ifdef MUSIC
91+
#ifndef SIMPLE_SDL2
9292
std::vector<std::string> CST_GetMusicInfo(CST_Music* music);
9393
#endif
9494

src/Element.hpp.orig

Lines changed: 0 additions & 184 deletions
This file was deleted.

src/RootDisplay.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class RootDisplay : public Element
6464

6565
void requestQuit();
6666

67-
#if defined(MUSIC)
67+
#if !defined(SIMPLE_SDL2)
6868
Mix_Music* music = NULL;
6969
#endif
7070

0 commit comments

Comments
 (0)