From d2ce1df87a93debcf68e61e92617974b8d61dcdc Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sat, 10 Apr 2021 23:07:53 +0100 Subject: [PATCH] Fix compilation with MinGW --- Makefile | 3 +++ auto/src/glew_head.c | 2 +- build/cmake/CMakeLists.txt | 2 +- config/Makefile.mingw | 6 ++++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e5222f9..8347c59 100644 --- a/Makefile +++ b/Makefile @@ -48,8 +48,11 @@ INCDIR ?= $(GLEW_DEST)/include/GL PKGDIR ?= $(GLEW_DEST)/lib/pkgconfig ifneq ($(GLEW_NO_GLU), -DGLEW_NO_GLU) +# MinGW does not provide a .pc file for glu +ifeq ($(filter mingw%,$(SYSTEM)),) LIBGLU = glu endif +endif DIST_NAME ?= glew-$(GLEW_VERSION) DIST_SRC_ZIP ?= $(shell pwd)/$(DIST_NAME).zip diff --git a/auto/src/glew_head.c b/auto/src/glew_head.c index 832ded7..3a4de48 100644 --- a/auto/src/glew_head.c +++ b/auto/src/glew_head.c @@ -133,7 +133,7 @@ void* NSGLGetProcAddress (const GLubyte *name) #elif defined(GLEW_EGL) # define glewGetProcAddress(name) eglGetProcAddress((const char *)name) #elif defined(_WIN32) -# define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name) +# define glewGetProcAddress(name) (void *)wglGetProcAddress((LPCSTR)name) #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) # define glewGetProcAddress(name) NSGLGetProcAddress(name) #elif defined(__sgi) || defined(__sun) || defined(__HAIKU__) diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index 5565f92..e6c67fd 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -239,7 +239,7 @@ set (cflags) set (requireslib glu) # Mac OSX has no glu.pc unless optional X11/GLX is installed -if (APPLE) +if (WIN32 OR APPLE) set (requireslib) endif () diff --git a/config/Makefile.mingw b/config/Makefile.mingw index 3f413ee..933b1d2 100644 --- a/config/Makefile.mingw +++ b/config/Makefile.mingw @@ -4,9 +4,11 @@ CC := gcc -fno-builtin LD := gcc LN := LDFLAGS.GL = -lopengl32 -lgdi32 -luser32 -lkernel32 +ifneq ($(GLEW_NO_GLU), -DGLEW_NO_GLU) +LDFLAGS.GL := -lglu32 $(LDFLAGS.GL) +endif LDFLAGS.EXTRA = -L/mingw/lib CFLAGS.EXTRA += -fno-builtin -fno-stack-protector -LDFLAGS.EXTRA += -nostdlib WARN = -Wall -W POPT = -O2 BIN.SUFFIX = .exe @@ -14,4 +16,4 @@ LIB.SONAME = lib$(NAME).dll LIB.DEVLNK = lib$(NAME).dll.a # for mingw this is the dll import lib LIB.SHARED = $(NAME).dll LIB.STATIC = lib$(NAME).a # the static lib will be broken -LDFLAGS.SO = -shared -Wl,-soname,$(LIB.SONAME) -Wl,--out-implib,lib/$(LIB.DEVLNK) +LDFLAGS.SO = -nostdlib -shared -Wl,-soname,$(LIB.SONAME) -Wl,--out-implib,lib/$(LIB.DEVLNK)