From d783cc81db44cf09c635d5a4155fbba7fe64eae3 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 22 May 2014 21:36:04 +0200 Subject: library linking and some of gamma-linux-drm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 8 ++++++-- configure | 11 +++++++++++ src/gamma-linux-drm.c | 44 +++++++++++++++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index ae8db5f..540b219 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,10 @@ C_FLAGS = $(OPTIMISE) $(WARN) -std=$(STD) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \ -fstrict-overflow -funsafe-loop-optimizations -fno-builtin \ $(DEBUG_FLAGS) $(DEFINITIONS) -DLIBGAMMA_CONFIG_H +# Library linking flags for the linker. +LIBS_LD = +# Library linking flags for the C compiler. +LIBS_C = # Object files for the library. LIBOBJ = libgamma-facade libgamma-method gamma-helper @@ -78,11 +82,11 @@ all: bin/libgamma.so bin/libgamma.so: $(foreach O,$(LIBOBJ),obj/$(O).o) mkdir -p $(shell dirname $@) - $(CC) $(C_FLAGS) -shared -o $@ $^ + $(CC) $(C_FLAGS) $(LIBS_LD) -shared -o $@ $^ obj/%.o: src/%.c src/*.h mkdir -p $(shell dirname $@) - $(CC) $(C_FLAGS) -fPIC -c -o $@ $< + $(CC) $(C_FLAGS) $(LIBS_C) -fPIC -c -o $@ $< # Clean rules. diff --git a/configure b/configure index 3fd389f..8a79c28 100755 --- a/configure +++ b/configure @@ -110,18 +110,24 @@ fi if [ ${enable_randr} = 1 ]; then echo 'LIBOBJ += gamma-x-randr' >&3 echo 'DEFINITIONS += -DHAVE_GAMMA_METHOD_X_RANDR' >&3 + echo 'LIBS_LD += $$(pkg-config --cflags xcb xcb-randr)' >&3 + echo 'LIBS_C += $$(pkg-config --cflags xcb xcb-randr)' >&3 echo '#define HAVE_GAMMA_METHOD_X_RANDR' >&4 have_randr='Yes' fi if [ ${enable_vidmode} = 1 ]; then echo 'LIBOBJ += gamma-x-vidmode' >&3 echo 'DEFINITIONS += -DHAVE_GAMMA_METHOD_X_VIDMODE' >&3 + echo 'LIBS_LD += $$(pkg-config --cflags x11 xxf86vm)' >&3 + echo 'LIBS_C += $$(pkg-config --cflags x11 xxf86vm)' >&3 echo '#define HAVE_GAMMA_METHOD_X_VIDMODE' >&4 have_vidmode='Yes' fi if [ ${enable_drm} = 1 ]; then echo 'LIBOBJ += gamma-linux-drm' >&3 echo 'DEFINITIONS += -DHAVE_GAMMA_METHOD_LINUX_DRM' >&3 + echo 'LIBS_LD += $$(pkg-config --cflags libdrm)' >&3 + echo 'LIBS_C += $$(pkg-config --cflags libdrm)' >&3 echo '#define HAVE_GAMMA_METHOD_LINUX_DRM' >&4 have_drm='Yes' fi @@ -134,6 +140,11 @@ fi if [ ${enable_quartz} = 1 ]; then echo 'LIBOBJ += gamma-quartz-cg' >&3 echo 'DEFINITIONS += -DHAVE_GAMMA_METHOD_QUARTZ_CORE_GRAPHICS' >&3 + if [ ${fake_w32gdi} = 0 ]; then + F_ApplicationServices="/System/Library/Frameworks/ApplicationServices.framework" + I_ApplicationServices="${F_ApplicationServices}/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers" + echo "LIBS_LD += -I${I_ApplicationServices} -F${F_ApplicationServices} -framework ApplicationServices" >&3 + fi echo '#define HAVE_GAMMA_METHOD_QUARTZ_CORE_GRAPHICS' >&4 have_quartz='Yes' fi diff --git a/src/gamma-linux-drm.c b/src/gamma-linux-drm.c index dbe01b5..fa0b517 100644 --- a/src/gamma-linux-drm.c +++ b/src/gamma-linux-drm.c @@ -24,6 +24,18 @@ #include "libgamma-error.h" #include +#include +#include + +#include +#include + +#ifndef O_CLOEXEC +# define O_CLOEXEC 02000000 +#endif +#ifndef PATH_MAX +# define PATH_MAX 4096 +#endif /** @@ -76,6 +88,25 @@ void libgamma_linux_drm_method_capabilities(libgamma_method_capabilities_t* rest int libgamma_linux_drm_site_initialise(libgamma_site_state_t* restrict this, char* restrict site) { + char pathname[PATH_MAX]; + struct stat _attr; + + if (site != NULL) + return LIBGAMMA_NO_SUCH_SITE; + + /* Count the number of available graphics cards by + * stat:ing there existence in an API filesystem. */ + this->partitions_available = 0; + for (;;) + { + snprintf(pathname, sizeof(pathname) / sizeof(char), + DRM_DEV_NAME, DRM_DIR_NAME, (int)(this->partitions_available)); + if (stat(pathname, &_attr)) + break; + if (this->partitions_available++ > INT_MAX) + return LIBGAMMA_IMPOSSIBLE_AMOUNT; + } + return 0; } @@ -86,6 +117,7 @@ int libgamma_linux_drm_site_initialise(libgamma_site_state_t* restrict this, */ void libgamma_linux_drm_site_destroy(libgamma_site_state_t* restrict this) { + (void) this; } @@ -166,17 +198,7 @@ int libgamma_linux_drm_crtc_initialise(libgamma_crtc_state_t* restrict this, */ void libgamma_linux_drm_crtc_destroy(libgamma_crtc_state_t* restrict this) { -} - - -/** - * Release all resources held by a CRTC state - * and free the CRTC state pointer - * - * @param this The CRTC state - */ -void libgamma_linux_drm_crtc_free(libgamma_crtc_state_t* restrict this) -{ + (void) this; } -- cgit v1.2.3-70-g09d2