$NetBSD: patch-ab,v 1.28 2023/09/07 14:36:54 vins Exp $

- Handle the various operating systems in the same way avoiding hardcoding
- Avoid to use objcopy by setting HAVE_OBJCOPY to no (if `yes', and with
  `USE_TOOLS+= objcopy' the objcopy-ing fails as follow:
    OBJCOPY build/release/resources/fonts/urw/Dingbats.cff.o
    build/release/resources/fonts/urw/Dingbats.cff.o:1: warning: NUL character seen; rest of line ignored
    build/release/resources/fonts/urw/Dingbats.cff.o:1: *** missing separator.  Stop.
  (also for other fonts)).  This needs to be investigated further.
- Avoid internal version of freeglut and try to pick it up via pkg-config and
  set SYS_GLUT_{CFLAGS,LIBS} accordingly.

--- Makerules.orig	2023-09-05 11:51:19.000000000 +0000
+++ Makerules
@@ -42,30 +42,6 @@ endif
 
 # System specific features
 
-ifeq ($(findstring -fembed-bitcode,$(XCFLAGS)),)
-  # clang does not support these in combination with -fembed-bitcode
-  CFLAGS += -ffunction-sections -fdata-sections
-endif
-
-ifeq ($(OS),MACOS)
-  LDREMOVEUNREACH := -Wl,-dead_strip
-  SO := dylib
-else
-  LDREMOVEUNREACH := -Wl,--gc-sections
-  ifeq ($(OS),MINGW)
-    SO := dll
-    EXE := .exe
-  else
-    SO := so
-  endif
-endif
-
-ifeq "$(OS)" "ios"
-  NEONFLAGS =
-else
-  NEONFLAGS = -mneon
-endif
-
 SANITIZE_FLAGS += -fsanitize=address
 SANITIZE_FLAGS += -fsanitize=leak
 
@@ -154,41 +130,7 @@ ifneq "$(CLUSTER)" ""
   CFLAGS += -DCLUSTER
 endif
 
-ifeq ($(OS),MINGW)
-  WINDRES := windres
-  HAVE_WIN32 := yes
-
-else ifeq ($(OS),MACOS)
-  HAVE_GLUT := yes
-  SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
-  SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
-  CC = xcrun cc
-  AR = xcrun ar
-  LD = xcrun ld
-  RANLIB = xcrun ranlib
-
-  ifneq ($(ARCHFLAGS),)
-    $(warning "MacOS with ARCHFLAGS set. Assuming we are building for arm64, and setting HAVE_LIBCRYPTO to no.")
-    HAVE_LIBCRYPTO := no
-  else ifeq (, $(shell which pkg-config))
-    $(warning "No pkg-config found, install it for proper integration of libcrypto")
-  else
-    HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
-    ifeq ($(HAVE_LIBCRYPTO),yes)
-	  LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
-	  LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
-    endif
-  endif
-
-else ifeq ($(OS),Linux)
-  ifeq ($(PYODIDE_ROOT),)
-    HAVE_OBJCOPY := yes
-  else
-    # Pyodide's ld does not support -b so we cannot use it to create object
-    # files containing font data, so leave HAVE_OBJCOPY unset. And we need
-    # extra memory when linking.
-    LDFLAGS += -sTOTAL_MEMORY=48MB
-  endif
+HAVE_OBJCOPY := no
 
   ifeq ($(shell pkg-config --exists freetype2 && echo yes),yes)
 	SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2)
@@ -237,10 +179,10 @@ else ifeq ($(OS),Linux)
 	SYS_CURL_LIBS := $(shell pkg-config --libs libcurl)
   endif
 
-  HAVE_GLUT := yes
-  ifeq ($(HAVE_GLUT),yes)
-	SYS_GLUT_CFLAGS :=
-	SYS_GLUT_LIBS := -lglut -lGL
+  HAVE_GLUT := $(shell pkg-config --exists glut && echo yes)
+  ifeq ($(shell pkg-config --exists glut && echo yes),yes)
+	SYS_GLUT_CFLAGS := $(shell pkg-config --cflags glut)
+	SYS_GLUT_LIBS := $(shell pkg-config --libs glut)
   endif
 
   HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
@@ -263,8 +205,6 @@ else ifeq ($(OS),Linux)
 	PTHREAD_LIBS := -lpthread
   endif
 
-endif
-
 # The following section has various cross compilation configurations.
 #
 # Invoke these as:
