From bfc8b17c27532e0e69549e640bf1e14dddd58d25 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 03:55:19 +0200 Subject: [PATCH] Reorganise CLFAGS/LDFLAGS handling --- Makefile | 13 +++++++++++-- config.mk | 33 +++++++++++---------------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 7f7108c..58c8370 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,17 @@ ifneq ($(wildcard ./.git/.),) VERSION := $(shell git describe --tags) endif -CFLAGS += -I. -LDFLAGS += -L. +LIBS := $(shell pkg-config --libs ${pkg_config_packs}) +INCS := $(shell pkg-config --cflags ${pkg_config_packs}) + +ifneq (clean, $(MAKECMDGOALS)) +ifeq ($(and $(INCS),$(LIBS)),) +$(error "pkg-config failed!") +endif +endif + +CFLAGS += -I. ${INCS} +LDFLAGS+= -L. ${LIBS} SRC := $(sort $(shell find src/ -name '*.c')) OBJ := ${SRC:.c=.o} diff --git a/config.mk b/config.mk index 96613a7..12a85f7 100644 --- a/config.mk +++ b/config.mk @@ -2,23 +2,24 @@ PREFIX ?= /usr/local MANPREFIX = ${PREFIX}/share/man -# Warning: This is deprecated behavior # uncomment to disable parsing of dunstrc # or use "CFLAGS=-DSTATIC_CONFIG make" to build -#STATIC= -DSTATIC_CONFIG - -PKG_CONFIG:=$(shell which pkg-config) -ifeq (${PKG_CONFIG}, ${EMPTY}) -$(error "Failed to find pkg-config, please make sure it is installed") -endif +#STATIC= -DSTATIC_CONFIG # Warning: This is deprecated behavior # flags CPPFLAGS += -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" CFLAGS += -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} ${CPPFLAGS} +LDFLAGS += -lm -L${X11LIB} -pkg_config_packs := dbus-1 x11 xscrnsaver \ - "glib-2.0 >= 2.36" gio-2.0 \ - pangocairo gdk-3.0 xrandr xinerama +pkg_config_packs := dbus-1 \ + gio-2.0 \ + gdk-3.0 \ + "glib-2.0 >= 2.36" \ + pangocairo \ + x11 \ + xinerama \ + xrandr \ + xscrnsaver # check if we need libxdg-basedir ifeq (,$(findstring STATIC_CONFIG,$(CFLAGS))) @@ -31,15 +32,3 @@ endif ifneq (,$(findstring dunstify,${MAKECMDGOALS})) pkg_config_packs += libnotify endif - -# includes and libs -INCS := $(shell ${PKG_CONFIG} --cflags ${pkg_config_packs}) -CFLAGS += ${INCS} -LDFLAGS += -lm -L${X11LIB} -lXss $(shell ${PKG_CONFIG} --libs ${pkg_config_packs}) - -# only make this an fatal error when where not cleaning -ifneq (clean, $(MAKECMDGOALS)) -ifeq (${INCS}, ${EMPTY}) -$(error "pkg-config failed, see errors above") -endif -endif