From 1cb60e0dd75e1204c030c116359aeb31d13f9aa8 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 02:53:13 +0200 Subject: [PATCH 1/7] Treat warnings in travis as fatal --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a4340c8..37ce3c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ addons: dist: trusty sudo: false language: c -script: make && make test +script: CFLAGS=-Werror make && make test compiler: - gcc - clang From 37d76ab0d1438f20c5214142cd64d35fbdc07356 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 03:06:40 +0200 Subject: [PATCH 2/7] Simplify dunstify flags --- Makefile | 2 +- config.mk | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bd1d4bb..551b924 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,6 @@ test-clean: rm -f test/test test/*.o dunstify: dunstify.o - ${CC} ${CFLAGS} -o $@ dunstify.o $(shell pkg-config --libs --cflags glib-2.0 libnotify gdk-3.0) + ${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS} .PHONY: all clean dist install uninstall diff --git a/config.mk b/config.mk index dddff01..c50a4ea 100644 --- a/config.mk +++ b/config.mk @@ -32,6 +32,11 @@ else $(warning STATIC_CONFIG is deprecated behavior. It will get removed in future releases) endif +# dunstify also needs libnotify +ifneq (,$(findstring dunstify,${MAKECMDGOALS})) + pkg_config_packs += libnotify +endif + # includes and libs INCS := $(shell ${PKG_CONFIG} --cflags ${pkg_config_packs}) CFLAGS += ${INCS} From e8900524316df9df6d128844b6d3b4346eeab535 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 03:11:19 +0200 Subject: [PATCH 3/7] Restructure the Makefile (refactor) --- Makefile | 54 +++++++++++++++++++++++++++++------------------------- config.mk | 5 ----- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 551b924..7f7108c 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,18 @@ include config.mk +VERSION := "1.2.0-non-git" +ifneq ($(wildcard ./.git/.),) +VERSION := $(shell git describe --tags) +endif + CFLAGS += -I. LDFLAGS += -L. SRC := $(sort $(shell find src/ -name '*.c')) OBJ := ${SRC:.c=.o} +TEST_SRC := $(sort $(shell find test/ -name '*.c')) +TEST_OBJ := $(TEST_SRC:.c=.o) all: doc dunst service @@ -19,6 +26,25 @@ ${OBJ}: config.mk dunst: ${OBJ} main.o ${CC} ${CFLAGS} -o $@ ${OBJ} main.o ${LDFLAGS} +dunstify: dunstify.o + ${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS} + +test: test/test + cd test && ./test + +test/test: ${OBJ} ${TEST_OBJ} + ${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS} + +doc: docs/dunst.1 +docs/dunst.1: docs/dunst.pod + pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ + +service: + @sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service + @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service + +clean: clean-dunst clean-dunstify clean-doc clean-tests + clean-dunst: rm -f dunst ${OBJ} main.o rm -f org.knopwob.dunst.service @@ -31,15 +57,10 @@ clean-dunstify: clean-doc: rm -f docs/dunst.1 -clean: clean-dunst clean-dunstify clean-doc test-clean +clean-tests: + rm -f test/test test/*.o -doc: docs/dunst.1 -docs/dunst.1: docs/dunst.pod - pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ - -service: - @sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service - @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service +install: install-dunst install-doc install-service install-dunst: dunst doc mkdir -p ${DESTDIR}${PREFIX}/bin @@ -56,8 +77,6 @@ install-service: service install -m644 org.knopwob.dunst.service ${DESTDIR}${PREFIX}/share/dbus-1/services install -Dm644 dunst.systemd.service ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service -install: install-dunst install-doc install-service - uninstall: rm -f ${DESTDIR}${PREFIX}/bin/dunst rm -f ${DESTDIR}${MANPREFIX}/man1/dunst.1 @@ -65,19 +84,4 @@ uninstall: rm -f ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service rm -rf ${DESTDIR}${PREFIX}/share/dunst -test: test/test - cd test && ./test - -TEST_SRC := $(shell find test/ -name '*.c') -TEST_OBJ := $(TEST_SRC:.c=.o) - -test/test: ${OBJ} ${TEST_OBJ} - ${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS} - -test-clean: - rm -f test/test test/*.o - -dunstify: dunstify.o - ${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS} - .PHONY: all clean dist install uninstall diff --git a/config.mk b/config.mk index c50a4ea..96613a7 100644 --- a/config.mk +++ b/config.mk @@ -2,11 +2,6 @@ PREFIX ?= /usr/local MANPREFIX = ${PREFIX}/share/man -VERSION := "1.2.0-non-git" -ifneq ($(wildcard ./.git/.),) -VERSION := $(shell git describe --tags) -endif - # Warning: This is deprecated behavior # uncomment to disable parsing of dunstrc # or use "CFLAGS=-DSTATIC_CONFIG make" to build From 1091a976f2a59d5b67cd83e5d94c45799a5ec63b Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 03:11:56 +0200 Subject: [PATCH 4/7] travis: also build dunstify --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 37ce3c5..ba198d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ addons: dist: trusty sudo: false language: c -script: CFLAGS=-Werror make && make test +script: CFLAGS=-Werror make all dunstify test compiler: - gcc - clang From bfc8b17c27532e0e69549e640bf1e14dddd58d25 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 03:55:19 +0200 Subject: [PATCH 5/7] 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 From d07bdacab919cde0bf8668995045642067558fa3 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 22 Oct 2017 04:03:43 +0200 Subject: [PATCH 6/7] Introduce debug target --- Makefile | 5 +++++ config.mk | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 58c8370..316e9d6 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,11 @@ TEST_OBJ := $(TEST_SRC:.c=.o) all: doc dunst service +debug: CFLAGS += ${CFLAGS_DEBUG} +debug: LDFLAGS += ${LDFLAGS_DEBUG} +debug: CPPFLAGS += ${CPPFLAGS_DEBUG} +debug: all + .c.o: ${CC} -o $@ -c $< ${CFLAGS} diff --git a/config.mk b/config.mk index 12a85f7..2484df3 100644 --- a/config.mk +++ b/config.mk @@ -11,6 +11,10 @@ CPPFLAGS += -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" CFLAGS += -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} ${CPPFLAGS} LDFLAGS += -lm -L${X11LIB} +CPPFLAGS_DEBUG := -DDEBUG_BUILD +CFLAGS_DEBUG := -O0 +LDFLAGS_DEBUG := + pkg_config_packs := dbus-1 \ gio-2.0 \ gdk-3.0 \ From b5a48ea13505a926a26e6587d8774c3f6b720332 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 26 Oct 2017 17:21:33 +0200 Subject: [PATCH 7/7] Sync phony targets with .PHONY and organise in sections --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 316e9d6..e37a978 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ OBJ := ${SRC:.c=.o} TEST_SRC := $(sort $(shell find test/ -name '*.c')) TEST_OBJ := $(TEST_SRC:.c=.o) +.PHONY: all debug all: doc dunst service debug: CFLAGS += ${CFLAGS_DEBUG} @@ -43,20 +44,24 @@ dunst: ${OBJ} main.o dunstify: dunstify.o ${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS} +.PHONY: test test: test/test cd test && ./test test/test: ${OBJ} ${TEST_OBJ} ${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS} +.PHONY: doc doc: docs/dunst.1 docs/dunst.1: docs/dunst.pod pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ +.PHONY: service service: @sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service +.PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests clean: clean-dunst clean-dunstify clean-doc clean-tests clean-dunst: @@ -74,6 +79,7 @@ clean-doc: clean-tests: rm -f test/test test/*.o +.PHONY: install install-dunst install-doc install-service uninstall install: install-dunst install-doc install-service install-dunst: dunst doc @@ -97,5 +103,3 @@ uninstall: rm -f ${DESTDIR}${PREFIX}/share/dbus-1/services/org.knopwob.dunst.service rm -f ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service rm -rf ${DESTDIR}${PREFIX}/share/dunst - -.PHONY: all clean dist install uninstall