]> git.sur5r.net Git - i3/i3/blobdiff - common.mk
Merge branch 'master' into next
[i3/i3] / common.mk
index 76813264275bea07768181949b320d647bf401bd..62eb99586e4ddbb9d799b3009319fac5f7b711ec 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -2,11 +2,15 @@ UNAME=$(shell uname)
 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
@@ -45,6 +49,7 @@ CFLAGS += $(call cflags_for_lib, xcursor)
 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)\"
@@ -66,6 +71,13 @@ LIBS += $(call ldflags_for_lib, xcursor, Xcursor)
 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
@@ -83,9 +95,13 @@ ifeq ($(UNAME),FreeBSD)
 LIBS += -liconv
 endif
 
+ifeq ($(UNAME),Darwin)
+LIBS += -liconv
+endif
+
 # 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