git: acbf6fa6cb42 - main - games/gracer: fix build with -fno-common

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Fri, 14 Apr 2023 14:17:55 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=acbf6fa6cb42a609fec8fcaf5f0a5a3f8810817b

commit acbf6fa6cb42a609fec8fcaf5f0a5a3f8810817b
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-04-13 00:41:49 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-04-14 14:16:07 +0000

    games/gracer: fix build with -fno-common
    
    Move a variable definition from header to source file.
    This fixes the build on FreeBSD 13+.
    While we are at it, rename patches in accordance with makepatch
    conventions and add missing dependencies.
---
 games/gracer/Makefile                                | 10 ++++------
 .../{patch-ac2scene.c => patch-ac2scene_ac2scene.c}  | 12 ++++++------
 games/gracer/files/patch-common_gr__memory.h         | 20 ++++++++++++++++++++
 ...patch-gr_texture.c => patch-common_gr__texture.c} |  6 +++---
 games/gracer/files/patch-gr_memory.h                 | 11 -----------
 games/gracer/files/patch-gr_world.c                  | 11 -----------
 games/gracer/files/{patch-ab => patch-src_glhash.h}  |  5 +++--
 .../{patch-glutwidgets.c => patch-src_glutwidgets.c} | 16 ++++++++--------
 games/gracer/files/patch-src_gr__world.c             | 11 +++++++++++
 games/gracer/files/patch-src_vehicle.c               | 11 +++++++++++
 games/gracer/files/patch-src_vehicle.h               | 11 +++++++++++
 11 files changed, 77 insertions(+), 47 deletions(-)

diff --git a/games/gracer/Makefile b/games/gracer/Makefile
index 74870773c53f..3f1aab30ff3a 100644
--- a/games/gracer/Makefile
+++ b/games/gracer/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	gracer
 PORTVERSION=	0.1.5
-PORTREVISION=	23
+PORTREVISION=	24
 CATEGORIES=	games
 MASTER_SITES=	SF
 
@@ -11,16 +11,14 @@ WWW=		http://gracer.sourceforge.net/
 LICENSE=	GPLv2+
 LICENSE_FILE=	${WRKSRC}/COPYING
 
-BROKEN_FreeBSD_13=	ld: error: duplicate symbol: GrBreak
-BROKEN_FreeBSD_14=	ld: error: duplicate symbol: GrBreak
-
 BUILD_DEPENDS=	${LOCALBASE}/lib/libplibsl.a:x11-toolkits/plib
 LIB_DEPENDS=	libgif.so:graphics/giflib \
 		libpng.so:graphics/png
 
-USES=		gl gmake jpeg localbase perl5 tcl
-USE_GL=		glut
+USES=		gl gmake jpeg localbase perl5 tcl xorg
+USE_GL=		gl glu glut
 USE_PERL5=	build
+USE_XORG=	ice sm x11 xext xi xmu xt
 GNU_CONFIGURE=	yes
 CONFIGURE_ARGS=	--with-plib=${LOCALBASE}
 CPPFLAGS+=	-I${TCL_INCLUDEDIR}
diff --git a/games/gracer/files/patch-ac2scene.c b/games/gracer/files/patch-ac2scene_ac2scene.c
similarity index 51%
rename from games/gracer/files/patch-ac2scene.c
rename to games/gracer/files/patch-ac2scene_ac2scene.c
index 66e5d009cbbd..627e63430c7c 100644
--- a/games/gracer/files/patch-ac2scene.c
+++ b/games/gracer/files/patch-ac2scene_ac2scene.c
@@ -1,6 +1,6 @@
---- ac2scene/ac2scene.c.orig	Fri Apr  1 18:36:19 2005
-+++ ac2scene/ac2scene.c	Fri Apr  1 18:36:48 2005
-@@ -160,8 +160,6 @@
+--- ac2scene/ac2scene.c.orig	2000-03-01 04:26:42 UTC
++++ ac2scene/ac2scene.c
+@@ -160,8 +160,6 @@ check_triangle_strip (GrSceneOptHint *hint, GrSurface 
        return 1;
      }
      break;
@@ -9,7 +9,7 @@
    }
  
    return 0;
-@@ -232,8 +230,6 @@
+@@ -232,8 +230,6 @@ check_triangle_fan (GrSceneOptHint *hint, GrSurface *s
        return 1;
      }
      break;
@@ -18,7 +18,7 @@
    }
  
    return 0;
-@@ -315,7 +311,6 @@
+@@ -315,7 +311,6 @@ check_quad_strip (GrSceneOptHint *hint, GrSurface *sur
        return 1;
      }
      break;
@@ -26,7 +26,7 @@
    }
  
    return 0;
-@@ -397,8 +392,6 @@
+@@ -397,8 +392,6 @@ optimize_object (GrObject *obj,
        hints[i]->state = GR_SCENE_OPT_QUAD_STRIP_START;
        hints[i]->surf->elements = gr_new (GrSElement, num_quads * 2 + 2);
        break;
diff --git a/games/gracer/files/patch-common_gr__memory.h b/games/gracer/files/patch-common_gr__memory.h
new file mode 100644
index 000000000000..41d8b96cfc71
--- /dev/null
+++ b/games/gracer/files/patch-common_gr__memory.h
@@ -0,0 +1,20 @@
+--- common/gr_memory.h.orig	2000-03-01 04:27:04 UTC
++++ common/gr_memory.h
+@@ -29,7 +29,7 @@ extern "C" {
+ }
+ #endif
+ 
+-#include <malloc.h>
++#include <stdlib.h>
+ 
+ #define gr_new(type,num)	(type *) malloc (sizeof(type) * (num))
+ #define gr_new0(type,num)	(type *) __malloc0 (sizeof(type) * (num))
+@@ -64,7 +64,7 @@ void	gr_slist_free			(GrSList *list);
+ void	gr_dlist_free			(GrDList *list);
+ 
+ #define gr_FOREACH(l,p) \
+-  for (; (l) != NULL && ((void *)(p) = (l)->data, 1); (l) = (l)->next) 
++  for (; (l) != NULL && ((p) = (l)->data, 1); (l) = (l)->next) 
+ 
+ void	gr_ref_incr			(GrRef *ref);
+ void	gr_ref_decr			(GrRef *ref);
diff --git a/games/gracer/files/patch-gr_texture.c b/games/gracer/files/patch-common_gr__texture.c
similarity index 75%
rename from games/gracer/files/patch-gr_texture.c
rename to games/gracer/files/patch-common_gr__texture.c
index 9ea5e054f72e..059abc94b08d 100644
--- a/games/gracer/files/patch-gr_texture.c
+++ b/games/gracer/files/patch-common_gr__texture.c
@@ -1,6 +1,6 @@
 --- common/gr_texture.c.orig	2000-03-01 04:27:18 UTC
 +++ common/gr_texture.c
-@@ -274,7 +274,11 @@ read_gif_file (GrTexture *texture, char 
+@@ -274,7 +274,11 @@ read_gif_file (GrTexture *texture, char *filename)
    int index;
    int width, height;
  
@@ -12,7 +12,7 @@
    if (!file)
      return -1;
  
-@@ -419,7 +423,7 @@ read_png_file (GrTexture *texture, char 
+@@ -419,7 +423,7 @@ read_png_file (GrTexture *texture, char *filename)
    if (fread (header, 1, PNG_BYTES_TO_CHECK, file) != PNG_BYTES_TO_CHECK) {
      goto ERROR;
    }
@@ -21,7 +21,7 @@
      goto ERROR;
    }
  
-@@ -431,7 +435,7 @@ read_png_file (GrTexture *texture, char 
+@@ -431,7 +435,7 @@ read_png_file (GrTexture *texture, char *filename)
    if (!info_ptr) {
      goto ERROR;
    }
diff --git a/games/gracer/files/patch-gr_memory.h b/games/gracer/files/patch-gr_memory.h
deleted file mode 100644
index 218a2b368ddc..000000000000
--- a/games/gracer/files/patch-gr_memory.h
+++ /dev/null
@@ -1,11 +0,0 @@
---- common/gr_memory.h.orig	Wed May  4 18:49:43 2005
-+++ common/gr_memory.h	Wed May  4 18:49:45 2005
-@@ -64,7 +64,7 @@
- void	gr_dlist_free			(GrDList *list);
- 
- #define gr_FOREACH(l,p) \
--  for (; (l) != NULL && ((void *)(p) = (l)->data, 1); (l) = (l)->next) 
-+  for (; (l) != NULL && ((p) = (l)->data, 1); (l) = (l)->next) 
- 
- void	gr_ref_incr			(GrRef *ref);
- void	gr_ref_decr			(GrRef *ref);
diff --git a/games/gracer/files/patch-gr_world.c b/games/gracer/files/patch-gr_world.c
deleted file mode 100644
index 0c0401bb33b2..000000000000
--- a/games/gracer/files/patch-gr_world.c
+++ /dev/null
@@ -1,11 +0,0 @@
---- src/gr_world.c.orig	Wed May  4 18:49:13 2005
-+++ src/gr_world.c	Wed May  4 18:49:24 2005
-@@ -167,8 +167,6 @@
-     case GR_CLINE_B_TO_A:
-       vehicle->lap_count --;
-       break;
--
--    default:
-     }
- 
-     tlist = entry->triggers;
diff --git a/games/gracer/files/patch-ab b/games/gracer/files/patch-src_glhash.h
similarity index 71%
rename from games/gracer/files/patch-ab
rename to games/gracer/files/patch-src_glhash.h
index c3b805f5796d..624a4844ee30 100644
--- a/games/gracer/files/patch-ab
+++ b/games/gracer/files/patch-src_glhash.h
@@ -1,5 +1,6 @@
-Index: src/glhash.h
-@@ -709,6 +709,8 @@
+--- src/glhash.h.orig	2000-03-01 04:09:04 UTC
++++ src/glhash.h
+@@ -709,6 +709,8 @@ glWordList glwordlist[] = {
  	{"all_attrib_bits",	GL_ALL_ATTRIB_BITS},
  	{"client_pixel_store_bit",	GL_CLIENT_PIXEL_STORE_BIT},
  	{"client_vertex_array_bit",	GL_CLIENT_VERTEX_ARRAY_BIT},
diff --git a/games/gracer/files/patch-glutwidgets.c b/games/gracer/files/patch-src_glutwidgets.c
similarity index 62%
rename from games/gracer/files/patch-glutwidgets.c
rename to games/gracer/files/patch-src_glutwidgets.c
index b1fc3ec264b4..37f6e23654c9 100644
--- a/games/gracer/files/patch-glutwidgets.c
+++ b/games/gracer/files/patch-src_glutwidgets.c
@@ -1,6 +1,6 @@
---- src/glutwidgets.c.orig	Wed May  4 18:47:07 2005
-+++ src/glutwidgets.c	Wed May  4 18:48:56 2005
-@@ -254,7 +254,6 @@
+--- src/glutwidgets.c.orig	2000-03-01 04:28:21 UTC
++++ src/glutwidgets.c
+@@ -254,7 +254,6 @@ glut_reshape_func (int width, int height)
  	widget->x -= (width - screen_width) / 2;
  	widget->width += (width - screen_width);
  	break;
@@ -8,7 +8,7 @@
        }
        switch (widget->anchor & GR_VERTICAL_MASK) {
        case GR_BOTTOM:
-@@ -267,7 +266,6 @@
+@@ -267,7 +266,6 @@ glut_reshape_func (int width, int height)
  	widget->y -= (height - screen_height) / 2;
  	widget->height += (width - screen_height);
  	break;
@@ -16,7 +16,7 @@
        }
        glut_widget_calc_bbox (widget);
      }
-@@ -325,8 +323,6 @@
+@@ -325,8 +323,6 @@ glut_keyboard_func (unsigned char key, int x, int y)
  	glut_widget_set_focus (glut_next_focus_widget (NULL));
        }
        break;
@@ -25,7 +25,7 @@
      }
    }
  
-@@ -502,8 +498,6 @@
+@@ -502,8 +498,6 @@ glut_special_func (int key, int x, int y)
  	glut_widget_set_focus (widget);
        }
        break;
@@ -34,7 +34,7 @@
      }
    }
  
-@@ -1297,8 +1291,6 @@
+@@ -1297,8 +1291,6 @@ default_button_keyboard (GlutObject obj, unsigned char
      }
      glut_post_redisplay ();
      break;
@@ -43,7 +43,7 @@
    }
  }
  
-@@ -1569,8 +1561,6 @@
+@@ -1569,8 +1561,6 @@ default_label_display (GlutObject obj)
      case GR_RIGHT:
        width = glut_label_width (obj) / 2;
        break;
diff --git a/games/gracer/files/patch-src_gr__world.c b/games/gracer/files/patch-src_gr__world.c
new file mode 100644
index 000000000000..893f573fca9d
--- /dev/null
+++ b/games/gracer/files/patch-src_gr__world.c
@@ -0,0 +1,11 @@
+--- src/gr_world.c.orig	2000-03-01 04:28:24 UTC
++++ src/gr_world.c
+@@ -167,8 +167,6 @@ gr_world_check_trigger (GrWorld *world, int side)
+     case GR_CLINE_B_TO_A:
+       vehicle->lap_count --;
+       break;
+-
+-    default:
+     }
+ 
+     tlist = entry->triggers;
diff --git a/games/gracer/files/patch-src_vehicle.c b/games/gracer/files/patch-src_vehicle.c
new file mode 100644
index 000000000000..988aa44a077b
--- /dev/null
+++ b/games/gracer/files/patch-src_vehicle.c
@@ -0,0 +1,11 @@
+--- src/vehicle.c.orig	2023-04-13 00:36:40 UTC
++++ src/vehicle.c
+@@ -58,6 +58,8 @@
+ 
+ #define SIGN(d)  ((d)>=0.0? 1.0:-1.0)
+ 
++extern struct _GrBreakData GrBreak;
++
+ static void
+ next_word (char *str, int *index)
+ {
diff --git a/games/gracer/files/patch-src_vehicle.h b/games/gracer/files/patch-src_vehicle.h
new file mode 100644
index 000000000000..b220dc4f21a0
--- /dev/null
+++ b/games/gracer/files/patch-src_vehicle.h
@@ -0,0 +1,11 @@
+--- src/vehicle.h.orig	2023-04-13 00:36:07 UTC
++++ src/vehicle.h
+@@ -65,7 +65,7 @@ typedef struct _GrEngineData	GrEngineData;
+ typedef struct _GrLapHistory	GrLapHistory;
+ typedef struct _GrVehicleData	GrVehicleData;
+ 
+-struct _GrBreakData {
++extern struct _GrBreakData {
+   GrRef ref;
+ 
+   /* constants */