summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile28
-rw-r--r--libnsfb.pc.in2
-rw-r--r--src/surface/Makefile10
-rw-r--r--src/surface/x.c1
4 files changed, 36 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index bb29314..4239425 100644
--- a/Makefile
+++ b/Makefile
@@ -18,8 +18,32 @@ WARNFLAGS := -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align \
CFLAGS := -g -std=c99 -D_BSD_SOURCE -I$(CURDIR)/include/ \
-I$(CURDIR)/src $(WARNFLAGS) $(CFLAGS)
-# TODO: probably want to retrieve SDL from pkg-config
-TESTLDFLAGS = -Wl,--whole-archive -l$(COMPONENT) -Wl,--no-whole-archive -lSDL -lxcb-icccm -lxcb -lxcb-image -lxcb-keysyms
+NSFB_XCB_PKG_NAMES := xcb xcb-icccm xcb-image xcb-keysyms
+
+$(eval $(call pkg_config_package_available,NSFB_SDL_AVAILABLE,sdl))
+$(eval $(call pkg_config_package_available,NSFB_XCB_AVAILABLE,$(NSFB_XCB_PKG_NAMES)))
+
+ifeq ($(NSFB_SDL_AVAILABLE),yes)
+ $(eval $(call pkg_config_package_add_flags,sdl,CFLAGS))
+ $(eval $(call pkg_config_package_add_flags,sdl,TESTCFLAGS,TESTLDFLAGS))
+
+ REQUIRED_PKGS := $(REQUIRED_PKGS) sdl
+endif
+
+ifeq ($(NSFB_XCB_AVAILABLE),yes)
+ $(eval $(call pkg_config_package_min_version,NSFB_XCB_NEW_API,xcb,0.23))
+
+ ifeq ($(NSFB_XCB_NEW_API),yes)
+ CFLAGS := $(CFLAGS) -DNEED_HINTS_ALLOC
+ endif
+
+ $(eval $(call pkg_config_package_add_flags,$(NSFB_XCB_PKG_NAMES),CFLAGS))
+ $(eval $(call pkg_config_package_add_flags,$(NSFB_XCB_PKG_NAMES),TESTCFLAGS,TESTLDFLAGS))
+
+ REQUIRED_PKGS := $(REQUIRED_PKGS) $(NSFB_XCB_PKG_NAMES)
+endif
+
+TESTLDFLAGS := -Wl,--whole-archive -l$(COMPONENT) -Wl,--no-whole-archive $(TESTLDFLAGS)
include build/makefiles/Makefile.top
diff --git a/libnsfb.pc.in b/libnsfb.pc.in
index e9d942e..64e8270 100644
--- a/libnsfb.pc.in
+++ b/libnsfb.pc.in
@@ -6,6 +6,6 @@ includedir=${prefix}/include
Name: libnsfb
Description: Provides framebuffer access for netsurf.
Version: VERSION
-Requires: sdl xcb xcb-icccm xcb-image xcb-keysyms
+REQUIRED
Libs: -L${libdir} -lnsfb
Cflags: -I${includedir}
diff --git a/src/surface/Makefile b/src/surface/Makefile
index 3abbfb6..6eddcb6 100644
--- a/src/surface/Makefile
+++ b/src/surface/Makefile
@@ -1,4 +1,12 @@
# Sources
-DIR_SOURCES := surface.c sdl.c vnc.c able.c ram.c linux.c x.c
+DIR_SOURCES := surface.c vnc.c able.c ram.c linux.c
+
+ifeq ($(NSFB_SDL_AVAILABLE),yes)
+ DIR_SOURCES := $(DIR_SOURCES) sdl.c
+endif
+
+ifeq ($(NSFB_XCB_AVAILABLE),yes)
+ DIR_SOURCES := $(DIR_SOURCES) x.c
+endif
include build/makefiles/Makefile.subdir
diff --git a/src/surface/x.c b/src/surface/x.c
index 2b8d3bf..a8c06ee 100644
--- a/src/surface/x.c
+++ b/src/surface/x.c
@@ -7,7 +7,6 @@
*/
#define _XOPEN_SOURCE 500
-#define NEED_HINTS_ALLOC
#include <stdbool.h>
#include <stdlib.h>