games/freeblocks: -fno-common fixes or -fcommon?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

games/freeblocks: -fno-common fixes or -fcommon?

Christian Weisgerber
games/freeblocks fails to build with -fno-common.  Upstream has not
yet addressed this problem.

The patches below fix dozens of multiple variable definitions.
Some need an extern, some need to be defined in a source module in
the first place.  One had a wrong enum type.

Alternatively, this may be a case where -fcommon is warranted.

Opinions?


Index: Makefile
===================================================================
RCS file: /cvs/ports/games/freeblocks/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- Makefile 14 Feb 2020 11:11:33 -0000 1.6
+++ Makefile 17 Feb 2021 20:33:08 -0000
@@ -6,7 +6,7 @@ CATEGORIES = games x11
 GH_ACCOUNT = dorkster
 GH_PROJECT = freeblocks
 GH_TAGNAME = v0.5
-REVISION = 2
+REVISION = 3
 
 HOMEPAGE = https://github.com/dorkster/freeblocks
 
Index: patches/patch-src_block_c
===================================================================
RCS file: patches/patch-src_block_c
diff -N patches/patch-src_block_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_block_c 17 Feb 2021 20:33:08 -0000
@@ -0,0 +1,35 @@
+$OpenBSD$
+
+Index: src/block.c
+--- src/block.c.orig
++++ src/block.c
+@@ -23,8 +23,28 @@ const int POINTS_PER_BLOCK = 10;
+ const int POINTS_PER_BUMP = 5;
+ const int POINTS_PER_COMBO_BLOCK = 15;
+
+-int speed_init = 1;
++int ROWS;
++int COLS;
++int NUM_BLOCKS;
++int START_ROWS;
++int DISABLED_ROWS;
++int CURSOR_MAX_X;
++int CURSOR_MIN_Y;
++int CURSOR_MAX_Y;
++int BLOCK_MOVE_SPEED;
++int DRAW_OFFSET_X;
++int DRAW_OFFSET_Y;
++
+ Block **blocks = NULL;
++int speed_init = 1;
++
++bool animating;
++int bump_timer;
++int bump_pixels;
++int speed;
++int speed_timer;
++int game_over_timer;
++bool jewels_cursor_select;
+
+ int blockRand(void) {
+     return rand() % NUM_BLOCKS;
Index: patches/patch-src_block_h
===================================================================
RCS file: patches/patch-src_block_h
diff -N patches/patch-src_block_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_block_h 17 Feb 2021 20:33:08 -0000
@@ -0,0 +1,66 @@
+$OpenBSD$
+
+Index: src/block.h
+--- src/block.h.orig
++++ src/block.h
+@@ -33,21 +33,21 @@
+ #define SPEED_TIME 1800 / (60/FPS)
+ #define MAX_SPEED 25
+
+-const int POINTS_PER_BLOCK;
+-const int POINTS_PER_BUMP;
+-const int POINTS_PER_COMBO_BLOCK;
++extern const int POINTS_PER_BLOCK;
++extern const int POINTS_PER_BUMP;
++extern const int POINTS_PER_COMBO_BLOCK;
+
+-int ROWS;
+-int COLS;
+-int NUM_BLOCKS;
+-int START_ROWS;
+-int DISABLED_ROWS;
+-int CURSOR_MAX_X;
+-int CURSOR_MIN_Y;
+-int CURSOR_MAX_Y;
+-int BLOCK_MOVE_SPEED;
+-int DRAW_OFFSET_X;
+-int DRAW_OFFSET_Y;
++extern int ROWS;
++extern int COLS;
++extern int NUM_BLOCKS;
++extern int START_ROWS;
++extern int DISABLED_ROWS;
++extern int CURSOR_MAX_X;
++extern int CURSOR_MIN_Y;
++extern int CURSOR_MAX_Y;
++extern int BLOCK_MOVE_SPEED;
++extern int DRAW_OFFSET_X;
++extern int DRAW_OFFSET_Y;
+
+ typedef struct Block{
+     int x,y;
+@@ -62,15 +62,15 @@ typedef struct Block{
+     bool sound_after_move;
+ }Block;
+
+-Block **blocks;
+-bool animating;
+-int bump_timer;
+-int bump_pixels;
+-int speed;
+-int speed_init;
+-int speed_timer;
+-int game_over_timer;
+-bool jewels_cursor_select;
++extern Block **blocks;
++extern bool animating;
++extern int bump_timer;
++extern int bump_pixels;
++extern int speed;
++extern int speed_init;
++extern int speed_timer;
++extern int game_over_timer;
++extern bool jewels_cursor_select;
+
+ void blockSet(int i, int j, bool alive, int color);
+ void blockClear(int i, int j);
Index: patches/patch-src_game_c
===================================================================
RCS file: patches/patch-src_game_c
diff -N patches/patch-src_game_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_game_c 17 Feb 2021 20:33:08 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Index: src/game.c
+--- src/game.c.orig
++++ src/game.c
+@@ -23,6 +23,10 @@
+ #include "menu.h"
+ #include "sys.h"
+
++bool cursor_moving;
++int cursor_timer;
++int rebind_index;
++
+ void gameTitle() {
+     title_screen = true;
+     high_scores_screen = false;
Index: patches/patch-src_game_h
===================================================================
RCS file: patches/patch-src_game_h
diff -N patches/patch-src_game_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_game_h 17 Feb 2021 20:33:08 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+Index: src/game.h
+--- src/game.h.orig
++++ src/game.h
+@@ -21,9 +21,9 @@
+
+ #include "sys.h"
+
+-bool cursor_moving;
+-int cursor_timer;
+-int rebind_index;
++extern bool cursor_moving;
++extern int cursor_timer;
++extern int rebind_index;
+
+ void gameTitle();
+ void gameHighScores();
Index: patches/patch-src_menu_h
===================================================================
RCS file: patches/patch-src_menu_h
diff -N patches/patch-src_menu_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_menu_h 17 Feb 2021 20:33:08 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+Index: src/menu.h
+--- src/menu.h.orig
++++ src/menu.h
+@@ -37,9 +37,9 @@ typedef struct {
+     bool has_action;
+ }MenuItem;
+
+-MenuItem** menu_items;
+-int menu_option;
+-int menu_size;
++extern MenuItem** menu_items;
++extern int menu_option;
++extern int menu_size;
+
+ void menuItemUpdate(int i);
+ char* menuItemGetText(int i);
Index: patches/patch-src_sys_c
===================================================================
RCS file: patches/patch-src_sys_c
diff -N patches/patch-src_sys_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_sys_c 17 Feb 2021 20:33:08 -0000
@@ -0,0 +1,66 @@
+$OpenBSD$
+
+Index: src/sys.c
+--- src/sys.c.orig
++++ src/sys.c
+@@ -52,6 +52,7 @@ TTF_Font* font = NULL;
+ SDL_Surface* surface_blocks = NULL;
+ SDL_Surface* surface_clear = NULL;
+ SDL_Surface* surface_cursor = NULL;
++SDL_Surface* surface_cursor_highlight = NULL;
+ SDL_Surface* surface_cursor_single = NULL;
+ SDL_Surface* surface_bar = NULL;
+ SDL_Surface* surface_bar_inactive = NULL;
+@@ -68,6 +69,7 @@ Mix_Chunk* sound_drop = NULL;
+ SDL_Joystick* joy = NULL;
+
+ int score = 0;
++int high_scores[10];
+ bool title_screen = true;
+ bool high_scores_screen = false;
+ int options_screen = -1;
+@@ -77,15 +79,22 @@ bool quit = false;
+
+ int game_mode = GAME_MODE_DEFAULT;
+
++struct Cursor cursor;
++
+ int action_cooldown = 0;
+ ActionMove action_move = ACTION_NONE;
+ ActionMove action_last_move = ACTION_NONE;
+-ActionMove action_switch = ACTION_NONE;
++bool action_switch = false;
+ bool action_bump = false;
+ bool action_accept = false;
+ bool action_pause = false;
+ bool action_exit = false;
+
++Dork_String path_dir_config;
++Dork_String path_file_config;
++Dork_String path_file_highscores;
++Dork_String path_file_highscores_jewels;
++
+ int option_joystick = -1;
+ int option_sound = 8;
+ int option_music = 8;
+@@ -96,8 +105,20 @@ int option_fullscreen = 1;
+ int option_fullscreen = 0;
+ #endif
+
++SDLKey option_key[9];
++int option_joy_button[5];
++int option_joy_axis_x;
++int option_joy_axis_y;
++
+ SDLKey last_key = SDLK_UNKNOWN;
+ int last_joy_button = -1;
++
++SDL_Event event;
++
++// Timers
++unsigned int startTimer;
++unsigned int endTimer;
++unsigned int deltaTimer;
+
+ bool sysInit() {
+     if(SDL_Init(SDL_INIT_EVERYTHING) == -1) return false;
Index: patches/patch-src_sys_h
===================================================================
RCS file: patches/patch-src_sys_h
diff -N patches/patch-src_sys_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_sys_h 17 Feb 2021 20:33:08 -0000
@@ -0,0 +1,151 @@
+$OpenBSD$
+
+Index: src/sys.h
+--- src/sys.h.orig
++++ src/sys.h
+@@ -99,62 +99,63 @@ enum KEYBINDS {
+
+ extern const char* const key_desc[];
+
+-SDL_Surface* screen;
+-TTF_Font* font;
++extern SDL_Surface* screen;
++extern TTF_Font* font;
+
+-int score;
+-int high_scores[10];
+-bool title_screen;
+-bool high_scores_screen;
+-int options_screen;
+-bool game_over;
+-bool paused;
+-bool quit;
+-int game_mode;
++extern int score;
++extern int high_scores[10];
++extern bool title_screen;
++extern bool high_scores_screen;
++extern int options_screen;
++extern bool game_over;
++extern bool paused;
++extern bool quit;
++extern int game_mode;
+
+ struct Cursor {
+     int x1;
+     int y1;
+     int x2;
+     int y2;
+-}cursor;
++};
++extern struct Cursor cursor;
+
+-int action_cooldown;
++extern int action_cooldown;
+ typedef enum {
+     ACTION_NONE, ACTION_LEFT, ACTION_RIGHT, ACTION_UP, ACTION_DOWN
+ }ActionMove;
+-ActionMove action_move;
+-ActionMove action_last_move;
+-ActionMove action_switch;
+-bool action_bump;
+-bool action_accept;
+-bool action_pause;
+-bool action_exit;
++extern ActionMove action_move;
++extern ActionMove action_last_move;
++extern bool action_switch;
++extern bool action_bump;
++extern bool action_accept;
++extern bool action_pause;
++extern bool action_exit;
+
+-Dork_String path_dir_config;
+-Dork_String path_file_config;
+-Dork_String path_file_highscores;
+-Dork_String path_file_highscores_jewels;
++extern Dork_String path_dir_config;
++extern Dork_String path_file_config;
++extern Dork_String path_file_highscores;
++extern Dork_String path_file_highscores_jewels;
+
+-int option_joystick;
+-int option_sound;
+-int option_music;
+-int option_fullscreen;
++extern int option_joystick;
++extern int option_sound;
++extern int option_music;
++extern int option_fullscreen;
+
+-SDLKey option_key[9];
+-int option_joy_button[5];
+-int option_joy_axis_x;
+-int option_joy_axis_y;
++extern SDLKey option_key[9];
++extern int option_joy_button[5];
++extern int option_joy_axis_x;
++extern int option_joy_axis_y;
+
+-SDLKey last_key;
+-int last_joy_button;
++extern SDLKey last_key;
++extern int last_joy_button;
+
+-SDL_Event event;
++extern SDL_Event event;
+
+ // Timers
+-unsigned int startTimer;
+-unsigned int endTimer;
+-unsigned int deltaTimer;
++extern unsigned int startTimer;
++extern unsigned int endTimer;
++extern unsigned int deltaTimer;
+
+ // Functions
+ bool sysInit();
+@@ -176,26 +177,26 @@ void sysHighScoresSave();
+ void sysHighScoresClear();
+
+ // Images
+-SDL_Surface* surface_blocks;
+-SDL_Surface* surface_clear;
+-SDL_Surface* surface_cursor;
+-SDL_Surface* surface_cursor_highlight;
+-SDL_Surface* surface_bar;
+-SDL_Surface* surface_bar_inactive;
+-SDL_Surface* surface_background;
+-SDL_Surface* surface_background_jewels;
+-SDL_Surface* surface_title;
+-SDL_Surface* surface_highscores;
++extern SDL_Surface* surface_blocks;
++extern SDL_Surface* surface_clear;
++extern SDL_Surface* surface_cursor;
++extern SDL_Surface* surface_cursor_highlight;
++extern SDL_Surface* surface_bar;
++extern SDL_Surface* surface_bar_inactive;
++extern SDL_Surface* surface_background;
++extern SDL_Surface* surface_background_jewels;
++extern SDL_Surface* surface_title;
++extern SDL_Surface* surface_highscores;
+
+ // Music and Sounds
+-Mix_Music* music;
+-Mix_Music* music_jewels;
+-Mix_Chunk* sound_menu;
+-Mix_Chunk* sound_switch;
+-Mix_Chunk* sound_match;
+-Mix_Chunk* sound_drop;
++extern Mix_Music* music;
++extern Mix_Music* music_jewels;
++extern Mix_Chunk* sound_menu;
++extern Mix_Chunk* sound_switch;
++extern Mix_Chunk* sound_match;
++extern Mix_Chunk* sound_drop;
+
+ // Joystick
+-SDL_Joystick* joy;
++extern SDL_Joystick* joy;
+
+ #endif
--
Christian "naddy" Weisgerber                          [hidden email]