Commits

ecsv committed 4fff815

Allow to statically set *_(CFLAGS|LIBS) without pkg-config

n.pepinpe requested in #540 to allow overwriting the automatically searched
CFLAGS and LIBS for used libraries. This should allow distributors to set the
build configuration without patching the makefile. This is important for
systems were pkg-config or sdl-config aren't normally used.

Comments (0)

Files changed (1)

projects/unix/Makefile

 CXXFLAGS += -fvisibility-inlines-hidden
 LDFLAGS += $(SHARED)
 
-# default configuration programs
-PKG_CONFIG = $(CROSS_COMPILE)pkg-config
-
 ifeq ($(CPU), X86)
   CFLAGS += -msse
 endif
 endif
 
 # search for OpenGL libraries
-GL_LIBS=
 ifeq ($(OS), OSX)
-  GL_LIBS = -framework OpenGL
+  GL_LDLIBS = -framework OpenGL
 endif
 ifeq ($(OS), MINGW)
-  GL_LIBS = -lopengl32
+  GL_LDLIBS = -lopengl32
 endif
-ifeq ("$(GL_LIBS)", "")
-  ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),)
-    $(error $(PKG_CONFIG) not found)
+ifeq ($(origin GL_CFLAGS) $(origin GL_LDLIBS), undefined undefined)
+  ifeq ($(origin PKG_CONFIG), undefined)
+    PKG_CONFIG = $(CROSS_COMPILE)pkg-config
+    ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),)
+      $(error $(PKG_CONFIG) not found)
+    endif
   endif
+
   ifeq ($(shell $(PKG_CONFIG) --modversion gl 2>/dev/null),)
     $(error No OpenGL development libraries found!)
   endif
-  CFLAGS += $(shell $(PKG_CONFIG) --cflags gl)
-  GL_LIBS = $(shell $(PKG_CONFIG) --libs gl)
+  GL_CFLAGS += $(shell $(PKG_CONFIG) --cflags gl)
+  GL_LDLIBS +=  $(shell $(PKG_CONFIG) --libs gl)
 endif
-LDLIBS += $(GL_LIBS)
+CFLAGS += $(GL_CFLAGS)
+LDLIBS += $(GL_LDLIBS)
 
 # test for presence of SDL
 ifeq ($(origin SDL_CFLAGS) $(origin SDL_LDLIBS), undefined undefined)