Bug fix: #48: Compilation failure with old libconfig/libpcre

- Fix compilation failure with <libpcre-8.20 and <libconfig-1.4. Tested
  with libpcre-8.12 and libconfig-1.3.2, but not extensively tested.
  libconfig-1.3* probably has more limitations on configuration file
  syntax (enforces comma at the end of a setting?) and does not support
  @include.

- Make it possible to turn off PCRE and libconfig support using
  environment variable "CFG". Not well tested. CMake might provide a
  better solution.
This commit is contained in:
Richard Grenville
2012-09-28 09:10:34 +08:00
parent 69513d6231
commit 9139d038c2
4 changed files with 50 additions and 21 deletions

View File

@ -12,6 +12,12 @@ INCS += $(shell pcre-config --cflags)
CFLAGS += -Wall -std=c99
OBJS = compton.o
CFG ?= -DCONFIG_LIBCONFIG -DCONFIG_REGEX_PCRE -DCONFIG_REGEX_PCRE_JIT
# libconfig-1.3* does not define LIBCONFIG_VER* macros, so we use pkg-config
# to determine its version here
CFG += $(shell pkg-config --atleast-version=1.4 libconfig || echo '-DCONFIG_LIBCONFIG_LEGACY')
CFLAGS += $(CFG)
%.o: src/%.c src/%.h
$(CC) $(CFLAGS) $(INCS) -c src/$*.c