diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 44 | ||||
-rwxr-xr-x | configure | 6 | ||||
-rw-r--r-- | src/libgamma-method.h | 24 | ||||
-rw-r--r-- | test/test.c | 60 |
4 files changed, 104 insertions, 30 deletions
@@ -54,11 +54,13 @@ ifeq ($(DEBUG),y) DEBUG_FLAGS += -D'DEBUG' endif -# Options for the C compiler. -C_FLAGS = $(OPTIMISE) $(WARN) -std=$(STD) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \ - -ftree-vrp -fstrict-aliasing -fipa-pure-const -fstack-usage \ - -fstrict-overflow -funsafe-loop-optimizations -fno-builtin \ - $(DEBUG_FLAGS) $(DEFINITIONS) -DLIBGAMMA_CONFIG_H +# Options for the C compiler for the test. +TEST_FLAGS = $(OPTIMISE) $(WARN) -std=$(STD) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \ + -ftree-vrp -fstrict-aliasing -fipa-pure-const -fstack-usage \ + -fstrict-overflow -funsafe-loop-optimizations -fno-builtin + +# Options for the C compiler for the library. +LIB_FLAGS = $(TEST_FLAGS) $(DEBUG_FLAGS) $(DEFINITIONS) -DLIBGAMMA_CONFIG_H # Library linking flags for the linker. LIBS_LD = @@ -68,6 +70,14 @@ LIBS_C = # Object files for the library. LIBOBJ = libgamma-facade libgamma-method libgamma-error gamma-helper edid +# Object files for the test. +TESTOBJ = test + +# The version of the library. +LIB_MAJOR = 1 +LIB_MINOR = 0 +LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR) + # Include configurations from `./configure`. include config.mk @@ -77,16 +87,32 @@ include config.mk # Build rules. .PHONY: all -all: bin/libgamma.so +all: bin/libgamma.so.$(LIB_VERSION) bin/libgamma.so.$(LIB_MAJOR) bin/libgamma.so bin/test -bin/libgamma.so: $(foreach O,$(LIBOBJ),obj/$(O).o) +bin/libgamma.so.$(LIB_VERSION): $(foreach O,$(LIBOBJ),obj/$(O).o) mkdir -p $(shell dirname $@) - $(CC) $(C_FLAGS) $(LIBS_LD) -shared -o $@ $^ + $(CC) $(LIB_FLAGS) $(LIBS_LD) -shared -Wl,-soname,libgamma.so.$(LIB_MAJOR) -o $@ $^ + +bin/libgamma.so.$(LIB_MAJOR): + mkdir -p $(shell dirname $@) + ln -s libgamma.so.$(LIB_VERSION) $@ + +bin/libgamma.so: + mkdir -p $(shell dirname $@) + ln -s libgamma.so.$(LIB_VERSION) $@ obj/%.o: src/%.c src/*.h mkdir -p $(shell dirname $@) - $(CC) $(C_FLAGS) $(LIBS_C) -fPIC -c -o $@ $< + $(CC) $(LIB_FLAGS) $(LIBS_C) -fPIC -c -o $@ $< + +bin/test: $(foreach O,$(TESTOBJ),obj/$(O).o) bin/libgamma.so.$(LIB_VERSION) bin/libgamma.so + mkdir -p $(shell dirname $@) + $(CC) $(TEST_FLAGS) $(LIBS_LD) -Lbin -lgamma -o $@ $(foreach O,$(TESTOBJ),obj/$(O).o) + +obj/%.o: test/%.c + mkdir -p $(shell dirname $@) + $(CC) $(TEST_FLAGS) -Isrc -c -o $@ $< # Clean rules. @@ -110,7 +110,7 @@ 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_LD += $$(pkg-config --libs 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' @@ -118,7 +118,7 @@ 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_LD += $$(pkg-config --libs x11 xxf86vm)' >&3 echo 'LIBS_C += $$(pkg-config --cflags x11 xxf86vm)' >&3 echo '#define HAVE_GAMMA_METHOD_X_VIDMODE' >&4 have_vidmode='Yes' @@ -126,7 +126,7 @@ 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_LD += $$(pkg-config --libs libdrm)' >&3 echo 'LIBS_C += $$(pkg-config --cflags libdrm)' >&3 echo '#define HAVE_GAMMA_METHOD_LINUX_DRM' >&4 have_drm='Yes' diff --git a/src/libgamma-method.h b/src/libgamma-method.h index 6d2cb33..260ec60 100644 --- a/src/libgamma-method.h +++ b/src/libgamma-method.h @@ -33,17 +33,13 @@ * This method can be configured and is useful for * testing your program's ability to handle errors. */ -#ifdef HAVE_GAMMA_METHOD_DUMMY -# define GAMMA_METHOD_DUMMY 0 -#endif +#define GAMMA_METHOD_DUMMY 0 /** * The identifier for the adjustment method with * uses the RandR protocol under the X display server. */ -#ifdef HAVE_GAMMA_METHOD_X_RANDR -# define GAMMA_METHOD_X_RANDR 1 -#endif +#define GAMMA_METHOD_X_RANDR 1 /** * The identifier for the adjustment method with @@ -53,9 +49,7 @@ * supported by RandR, however it can only control the * primary CRTC per screen (partition). */ -#ifdef HAVE_GAMMA_METHOD_X_VIDMODE -# define GAMMA_METHOD_X_VIDMODE 2 -#endif +#define GAMMA_METHOD_X_VIDMODE 2 /** * The identifier for the Direct Rendering Manager @@ -68,9 +62,7 @@ * started while this is running, but it can be * started while a display server is running. */ -#ifdef HAVE_GAMMA_METHOD_LINUX_DRM -# define GAMMA_METHOD_LINUX_DRM 3 -#endif +#define GAMMA_METHOD_LINUX_DRM 3 /** * The identifier for the Graphics Device Interface @@ -78,9 +70,7 @@ * This method is not well tested; it can be compiled * to be available under X.org using a translation layer. */ -#ifdef HAVE_GAMMA_METHOD_W32_GDI -# define GAMMA_METHOD_W32_GDI 4 -#endif +#define GAMMA_METHOD_W32_GDI 4 /** * The identifier for the Core Graphics adjustment @@ -89,9 +79,7 @@ * This method is not well tested; it can be compiled * to be available under X.org using a translation layer. */ -#ifdef HAVE_GAMMA_METHOD_QUARTZ_CORE_GRAPHICS -# define GAMMA_METHOD_QUARTZ_CORE_GRAPHICS 5 -#endif +#define GAMMA_METHOD_QUARTZ_CORE_GRAPHICS 5 /** diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..9dc3b1b --- /dev/null +++ b/test/test.c @@ -0,0 +1,60 @@ +/** + * libgamma — Display server abstraction layer for gamma ramp adjustments + * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org) + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. + */ +#include <libgamma.h> + +#include <stdio.h> + + +int main(void) +{ + int methods[GAMMA_METHOD_COUNT]; + size_t n = libgamma_list_methods(methods, 0); + size_t i; + + for (i = 0; i < n; i++) + switch (methods[i]) + { + case GAMMA_METHOD_DUMMY: + printf("dummy\n"); + break; + case GAMMA_METHOD_X_RANDR: + printf("RandR X extension\n"); + break; + case GAMMA_METHOD_X_VIDMODE: + printf("VidMode X extension\n"); + break; + case GAMMA_METHOD_LINUX_DRM: + printf("Linux DRM\n"); + break; + case GAMMA_METHOD_W32_GDI: + printf("Windows GDI\n"); + break; + case GAMMA_METHOD_QUARTZ_CORE_GRAPHICS: + printf("Quartz using Core Graphics\n"); + break; + default: +#if GAMMA_METHOD_COUNT != 6 +# warning List of adjustment methods is out of date +#endif + printf("(unknown)\n"); + break; + } + + return 0; +} + |