DEBUG=1
COVERAGE=0
INSTALL=install
-PREFIX=/usr
-ifeq ($(PREFIX),/usr)
-SYSCONFDIR=/etc
-else
-SYSCONFDIR=$(PREFIX)/etc
+ifndef PREFIX
+ PREFIX=/usr
+endif
+ifndef SYSCONFDIR
+ ifeq ($(PREFIX),/usr)
+ SYSCONFDIR=/etc
+ else
+ SYSCONFDIR=$(PREFIX)/etc
+ endif
endif
TERM_EMU=xterm
# The escaping is absurd, but we need to escape for shell, sed, make, define
CFLAGS += $(call cflags_for_lib, x11)
CFLAGS += $(call cflags_for_lib, yajl)
CFLAGS += $(call cflags_for_lib, libev)
+CFLAGS += $(call cflags_for_lib, libpcre)
CPPFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
CPPFLAGS += -DTERM_EMU=\"$(TERM_EMU)\"
LIBS += $(call ldflags_for_lib, x11, X11)
LIBS += $(call ldflags_for_lib, yajl, yajl)
LIBS += $(call ldflags_for_lib, libev, ev)
+LIBS += $(call ldflags_for_lib, libpcre, pcre)
+
+# Please test if -Wl,--as-needed works on your platform and send me a patch.
+# it is known not to work on Darwin (Mac OS X)
+ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
+LDFLAGS += -Wl,--as-needed
+endif
ifeq ($(UNAME),NetBSD)
# We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
# Fallback for libyajl 1 which did not include yajl_version.h. We need
# YAJL_MAJOR from that file to decide which code path should be used.
-CFLAGS += -idirafter yajl-fallback
+CFLAGS += -idirafter $(TOPDIR)/yajl-fallback
ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
CPPFLAGS += -D_GNU_SOURCE